Salome HOME
SMH: Add forgotten files
[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)
29   {
30     myFunction = theFunction;
31     myCounter++;
32   }
33
34   TPythonDump::~TPythonDump()
35   {
36     if (--myCounter == 0) {
37       myFunction->SetDescription((char *)myStream.str().c_str());
38     }
39   }
40
41 //  TPythonDump::operator TCollection_AsciiString () const
42 //  {
43 //    if (myCounter == 1) {
44 //      return TCollection_AsciiString ((char *)myStream.str().c_str());
45 //    }
46 //    return TCollection_AsciiString ();
47 //  }
48
49   TPythonDump& TPythonDump::operator<< (long int theArg)
50   {
51     myStream<<theArg;
52     return *this;
53   }
54
55   TPythonDump& TPythonDump::operator<< (int theArg)
56   {
57     myStream<<theArg;
58     return *this;
59   }
60
61   TPythonDump& TPythonDump::operator<< (double theArg)
62   {
63     myStream.precision(16);
64     myStream<<theArg;
65     return *this;
66   }
67
68   TPythonDump& TPythonDump::operator<< (float theArg)
69   {
70     myStream.precision(8);
71     myStream<<theArg;
72     return *this;
73   }
74
75   TPythonDump& TPythonDump::operator<< (const void* theArg)
76   {
77     myStream<<theArg;
78     return *this;
79   }
80
81   TPythonDump& TPythonDump::operator<< (const char* theArg)
82   {
83     myStream<<theArg;
84     return *this;
85   }
86
87   TPythonDump& TPythonDump::operator<< (const Handle(GEOM_Object)& theObject)
88   {
89     TCollection_AsciiString anEntry;
90     TDF_Tool::Entry(theObject->GetEntry(), anEntry);
91     myStream << anEntry.ToCString();
92     return *this;
93   }
94 }