]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOM/GEOM_PythonDump.cxx
Salome HOME
86c576c643e8349d9776498b51122467207b55fc
[modules/geom.git] / src / GEOM / GEOM_PythonDump.cxx
1 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
3 // 
4 //  This library is free software; you can redistribute it and/or 
5 //  modify it under the terms of the GNU Lesser General Public 
6 //  License as published by the Free Software Foundation; either 
7 //  version 2.1 of the License. 
8 // 
9 //  This library is distributed in the hope that it will be useful, 
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 //  Lesser General Public License for more details. 
13 // 
14 //  You should have received a copy of the GNU Lesser General Public 
15 //  License along with this library; if not, write to the Free Software 
16 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
17 // 
18 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
19
20 #include "GEOM_PythonDump.hxx"
21
22 #include <TDF_Tool.hxx>
23
24 namespace GEOM
25 {
26   size_t TPythonDump::myCounter = 0;
27
28   TPythonDump::TPythonDump (Handle(GEOM_Function)& theFunction, bool theAppend)
29   {
30     myFunction = theFunction;
31     myCounter++;
32     myAppend = theAppend;
33   }
34
35   TPythonDump::~TPythonDump()
36   {
37     if (--myCounter == 0) {
38       TCollection_AsciiString aDescr;
39       if ( myAppend )
40         aDescr = myFunction->GetDescription() + "\n\t";
41       aDescr += (char *)myStream.str().c_str();
42       myFunction->SetDescription( aDescr );
43     }
44   }
45
46 //  TPythonDump::operator TCollection_AsciiString () const
47 //  {
48 //    if (myCounter == 1) {
49 //      return TCollection_AsciiString ((char *)myStream.str().c_str());
50 //    }
51 //    return TCollection_AsciiString ();
52 //  }
53
54   TPythonDump& TPythonDump::operator<< (long int theArg)
55   {
56     myStream<<theArg;
57     return *this;
58   }
59
60   TPythonDump& TPythonDump::operator<< (int theArg)
61   {
62     myStream<<theArg;
63     return *this;
64   }
65
66   TPythonDump& TPythonDump::operator<< (double theArg)
67   {
68     myStream.precision(16);
69     myStream<<theArg;
70     return *this;
71   }
72
73   TPythonDump& TPythonDump::operator<< (float theArg)
74   {
75     myStream.precision(8);
76     myStream<<theArg;
77     return *this;
78   }
79
80   TPythonDump& TPythonDump::operator<< (const void* theArg)
81   {
82     myStream<<theArg;
83     return *this;
84   }
85
86   TPythonDump& TPythonDump::operator<< (const char* theArg)
87   {
88     myStream<<theArg;
89     return *this;
90   }
91
92   TPythonDump& TPythonDump::operator<< (const Handle(GEOM_Object)& theObject)
93   {
94     TCollection_AsciiString anEntry;
95     TDF_Tool::Entry(theObject->GetEntry(), anEntry);
96     myStream << anEntry.ToCString();
97     return *this;
98   }
99 }