Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
XAO_XaoUtils.hxx
Go to the documentation of this file.
1 // Copyright (C) 2013-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Frederic Pons (OpenCascade)
20 
21 #ifndef __XAO_UTILS_HXX__
22 #define __XAO_UTILS_HXX__
23 
24 #include <sstream>
25 #include <string>
26 #include <exception>
27 
28 #include "XAO.hxx"
29 #include "XAO_Exception.hxx"
30 
31 #ifdef WIN32
32 #pragma warning(disable:4290) // Warning Exception ...
33 #endif
34 
35 namespace XAO
36 {
40  enum Format
41  {
44  };
45 
49  enum Dimension
50  {
51  VERTEX = 0,
52  EDGE = 1,
53  FACE = 2,
54  SOLID = 3,
55  WHOLE = -1
56  };
57 
61  enum Type
62  {
63  BOOLEAN = 0,
64  INTEGER = 1,
65  DOUBLE = 2,
66  STRING = 3
67  };
68 
74  {
75  public:
81  static const std::string intToString(const int& value);
82 
89  static const int stringToInt(const std::string& value) throw(XAO_Exception);
90 
96  static const std::string doubleToString(const double& value);
103  static const double stringToDouble(const std::string& value) throw(XAO_Exception);
104 
110  static const std::string booleanToString(const bool& value);
118  static const bool stringToBoolean(const std::string& value) throw(XAO_Exception);
119 
126  static const std::string dimensionToString(const XAO::Dimension& dimension) throw(XAO_Exception);
127 
134  static const XAO::Dimension stringToDimension(const std::string& dimension) throw(XAO_Exception);
135 
142  static const std::string fieldTypeToString(const XAO::Type& type) throw(XAO_Exception);
143 
150  static const XAO::Type stringToFieldType(const std::string& type) throw(XAO_Exception);
151 
158  static const std::string shapeFormatToString(const XAO::Format& format) throw(XAO_Exception);
159 
166  static const XAO::Format stringToShapeFormat(const std::string& format) throw(XAO_Exception);
167  };
168 
174  {
175  public:
180 
181 #ifndef SWIG
182 
183  template <typename T>
184  MsgBuilder& operator <<(const T& t)
185  {
186  m_stream << t;
187  return *this;
188  }
189 
193  operator const char*() const { return m_stream.str().c_str(); }
194 #endif
195 
196  private :
197  std::stringstream m_stream;
198  };
199 
200 }
201 
202 
203 
204 #endif /* __XAO_UTILS_HXX__ */