printable_object.cpp
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 #include "printable_object.hpp"
24 #include <typeinfo>
25 #include <sstream>
26 
27 
28 using namespace std;
29 namespace CasADi{
30 
31 ostream& operator<<(ostream &stream, const PrintableObject& obj){
32  obj.repr(stream);
33  return stream;
34 }
35 
36 void PrintableObject::repr(std::ostream &stream) const{
37  // Print description by default
38  print(stream);
39 }
40 
41 void PrintableObject::print(std::ostream &stream) const{
42  // Print name by default
43  stream << typeid(this).name();
44 }
45 
46 string PrintableObject::getRepresentation() const{
47  stringstream ss;
48  repr(ss);
49  return ss.str();
50 }
51 
52 string PrintableObject::getDescription() const{
53  stringstream ss;
54  print(ss);
55  return ss.str();
56 }
57 
58 
59 } // namespace CasADi
60 
61 
62 
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.
BEGIN_NAMESPACE_QPOASES returnValue print(const real_t *const v, int n)
ostream & operator<<(ostream &stream, vector< T > &array)


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