2013-04-09 12:00:09 +00:00
|
|
|
// Copyright (C) 2013 CEA/DEN, EDF R&D
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2.1 of the License.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
//
|
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
|
|
|
//
|
|
|
|
// Author : Frederic Pons (OpenCascade)
|
|
|
|
|
|
|
|
#ifndef __XAO_UTILS_HXX__
|
|
|
|
#define __XAO_UTILS_HXX__
|
|
|
|
|
2013-09-03 15:56:58 +00:00
|
|
|
#include <sstream>
|
|
|
|
#include <string>
|
|
|
|
|
2013-04-25 14:46:57 +00:00
|
|
|
#include "Xao.hxx"
|
2013-08-27 11:27:42 +00:00
|
|
|
#include "Field.hxx"
|
2013-04-25 14:46:57 +00:00
|
|
|
|
2013-04-09 12:00:09 +00:00
|
|
|
namespace XAO
|
|
|
|
{
|
2013-04-25 14:46:57 +00:00
|
|
|
/**
|
|
|
|
* \class XaoUtils
|
|
|
|
* Utilities class to convert types.
|
|
|
|
*/
|
2013-04-09 12:00:09 +00:00
|
|
|
class XaoUtils
|
|
|
|
{
|
|
|
|
public:
|
2013-04-25 14:46:57 +00:00
|
|
|
/**
|
|
|
|
* Converts an integer into a string.
|
|
|
|
* \param value the integer to convert.
|
|
|
|
* \return the string.
|
|
|
|
*/
|
2013-08-28 15:22:43 +00:00
|
|
|
static const std::string intToString(const int& value);
|
|
|
|
static const int stringToInt(const std::string& value);
|
2013-08-27 11:27:42 +00:00
|
|
|
|
2013-08-28 15:22:43 +00:00
|
|
|
static const std::string doubleToString(const double& value);
|
|
|
|
static const double stringToDouble(const std::string& value);
|
2013-04-25 14:46:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts a Dimension to string.
|
|
|
|
* \param dimension the Dimension to convert.
|
|
|
|
* \return the dimension as a string.
|
|
|
|
* \throw SALOME_Exception
|
|
|
|
*/
|
2013-08-28 15:22:43 +00:00
|
|
|
static const std::string dimensionToString(const XAO::Dimension& dimension);
|
2013-04-25 14:46:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts a string into a Dimension.
|
|
|
|
* \param dimension the dimension as a string.
|
|
|
|
* \return the converted Dimension.
|
2013-08-27 11:27:42 +00:00
|
|
|
* \throw SALOME_Exception
|
|
|
|
*/
|
2013-08-28 15:22:43 +00:00
|
|
|
static const XAO::Dimension stringToDimension(const std::string& dimension);
|
2013-08-27 11:27:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts a Type to string.
|
|
|
|
* \param type the Type to convert.
|
|
|
|
* \return the Type as a string.
|
|
|
|
* \throw SALOME_Exception
|
|
|
|
*/
|
2013-08-28 15:22:43 +00:00
|
|
|
static const std::string fieldTypeToString(const XAO::Type& type);
|
2013-08-27 11:27:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts a string into a Type.
|
|
|
|
* \param type the Type as a string.
|
|
|
|
* \return the converted Type.
|
|
|
|
* \throw SALOME_Exception
|
2013-04-25 14:46:57 +00:00
|
|
|
*/
|
2013-08-28 15:22:43 +00:00
|
|
|
static const XAO::Type stringToFieldType(const std::string& type);
|
2013-08-30 14:13:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts a Format to string.
|
|
|
|
* \param format the Format to convert.
|
|
|
|
* \return the Format as a string.
|
|
|
|
* \throw SALOME_Exception
|
|
|
|
*/
|
|
|
|
static const std::string shapeFormatToString(const XAO::Format& format);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts a string into a Format.
|
|
|
|
* \param format the Format as a string.
|
|
|
|
* \return the converted Format.
|
|
|
|
* \throw SALOME_Exception
|
|
|
|
*/
|
|
|
|
static const XAO::Format stringToShapeFormat(const std::string& format);
|
2013-09-03 15:56:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class MsgBuilder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MsgBuilder() {};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
MsgBuilder& operator <<(const T& t)
|
|
|
|
{
|
|
|
|
m_stream << t;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
operator const char*() const { return m_stream.str().c_str(); }
|
|
|
|
|
|
|
|
private :
|
|
|
|
std::stringstream m_stream;
|
|
|
|
};
|
|
|
|
|
2013-04-09 12:00:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* __XAO_UTILS_HXX__ */
|