printable_object.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of CasADi.
3  *
4  * CasADi -- A symbolic framework for dynamic optimization.
5  * Copyright (C) 2010 by Joel Andersson, Moritz Diehl, K.U.Leuven. All rights reserved.
6  *
7  * CasADi is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 3 of the License, or (at your option) any later version.
11  *
12  * CasADi is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with CasADi; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  *
21  */
22 
23 #ifndef PRINTABLE_OBJECT_HPP
24 #define PRINTABLE_OBJECT_HPP
25 
26 #include <iostream>
27 #include <string>
28 #include <sstream>
29 #include <streambuf>
30 #include <vector>
31 
32 namespace CasADi{
33 
39  public:
40 
41 #ifndef SWIG
42  virtual void print(std::ostream &stream=std::cout) const;
44 
46  virtual void repr(std::ostream &stream=std::cout) const;
47 
49  friend std::ostream& operator<<(std::ostream &stream, const PrintableObject& obj);
50 #endif // SWIG
51 
53  std::string getRepresentation() const;
54 
56  std::string getDescription() const;
57 
58 };
59 
60 #ifdef SWIG
61 %extend PrintableObject{
62  std::string __str__() { return $self->getDescription(); }
63  std::string __repr__() { return $self->getRepresentation(); }
64 }
65 #endif // SWIG
66 
67 } // namespace CasADi
68 
69 
70 #endif // PRINTABLE_OBJECT_HPP
71 
friend std::ostream & operator<<(std::ostream &stream, const PrintableObject &obj)
Print a representation of the object to a stream.
std::string getDescription() const
Return a string with a destription (for SWIG)
std::string getRepresentation() const
Return a string with a representation (for SWIG)
Base class for objects that have a natural string representation.
virtual void repr(std::ostream &stream=std::cout) const
Print a representation of the object.
virtual void print(std::ostream &stream=std::cout) const
Print a destription of the object.


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:59