1 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef _SMESH_PYTHONDUMP_HXX_
21 #define _SMESH_PYTHONDUMP_HXX_
25 #include <SALOMEconfig.h>
26 #include CORBA_SERVER_HEADER(SMESH_Mesh)
27 #include CORBA_SERVER_HEADER(SALOMEDS)
32 class SMESH_MeshEditor_i;
33 class TCollection_AsciiString;
34 class Resource_DataMapOfAsciiStringAsciiString;
36 // ===========================================================================================
38 * \brief Tool converting SMESH engine calls into commands defined in smesh.py
40 * Implementation is in SMESH_2smeshpy.cxx
42 // ===========================================================================================
48 * \brief Convert a python script using commands of smesh.py
49 * \param theScript - Input script
50 * \param theEntry2AccessorMethod - The returning method names to access to
51 * objects wrapped with python class
52 * \retval TCollection_AsciiString - Convertion result
54 static TCollection_AsciiString
55 ConvertScript(const TCollection_AsciiString& theScript,
56 Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod);
59 * \brief Return the name of the python file wrapping IDL API
60 * \retval TCollection_AsciiString - The file name
62 static char* SmeshpyName() { return "smesh"; }
63 static char* GenName() { return "smesh.smesh"; }
68 class FilterLibrary_i;
69 class FilterManager_i;
73 // ===========================================================================================
75 * \brief Utility helping in storing SMESH engine calls as python commands
77 // ===========================================================================================
79 class SMESH_I_EXPORT TPythonDump
81 std::ostringstream myStream;
82 static size_t myCounter;
85 virtual ~TPythonDump();
88 operator<<(long int theArg);
91 operator<<(int theArg);
94 operator<<(double theArg);
97 operator<<(float theArg);
100 operator<<(const void* theArg);
103 operator<<(const char* theArg);
106 operator<<(const SMESH::ElementType& theArg);
109 operator<<(const SMESH::long_array& theArg);
112 operator<<(const SMESH::double_array& theArg);
115 operator<<(SALOMEDS::SObject_ptr theArg);
118 operator<<(CORBA::Object_ptr theArg);
121 operator<<(SMESH::FilterLibrary_i* theArg);
124 operator<<(SMESH::FilterManager_i* theArg);
127 operator<<(SMESH::Filter_i* theArg);
130 operator<<(SMESH::Functor_i* theArg);
133 operator<<(SMESH_Gen_i* theArg);
136 operator<<(SMESH_MeshEditor_i* theArg);
139 operator<<(SMESH::MED_VERSION theArg);
142 operator<<(const SMESH::AxisStruct & theAxis);
145 operator<<(const SMESH::DirStruct & theDir);
148 operator<<(const TCollection_AsciiString & theArg);
150 static char* SMESHGenName() { return "smeshgen"; }
151 static char* MeshEditorName() { return "mesh_editor"; }
154 * \brief Return marker of long string literal beginning
155 * \param type - a name of functionality producing the string literal
156 * \retval TCollection_AsciiString - the marker string to be written into
157 * a raw python script
159 static TCollection_AsciiString LongStringStart(const char* type);
161 * \brief Return marker of long string literal end
162 * \retval TCollection_AsciiString - the marker string to be written into
163 * a raw python script
165 static TCollection_AsciiString LongStringEnd();
167 * \brief Cut out a long string literal from a string
168 * \param theText - text possibly containing string literals
169 * \param theFrom - position in the text to search from
170 * \param theLongString - the retrieved literal
171 * \param theStringType - a name of functionality produced the literal
172 * \retval bool - true if a string literal found
174 * The literal is removed from theText; theFrom points position right after
175 * the removed literal
177 static bool CutoutLongString( TCollection_AsciiString & theText,
179 TCollection_AsciiString & theLongString,
180 TCollection_AsciiString & theStringType);