StringUtilitiesMacros.h File Reference

#include "StringUtilities.h"
#include <algorithm>
#include <boost/tuple/tuple.hpp>
#include <limits>
#include <string>
#include <vector>

Go to the source code of this file.

Classes

class  FindTupleValue< tupleIndex, CompareType >

Defines

#define ENUM_MAPPING_TO_DISPLAY_STRING(eName__, eAlias__)
#define ENUM_MAPPING_TO_DISPLAY_STRING_VEC(eName__)
#define ENUM_MAPPING_TO_XML_STRING(eName__, eAlias__)
#define ENUM_MAPPING_TO_XML_STRING_VEC(eName__)
#define ENUM_MAPPING_FROM_DISPLAY_STRING(eName__, eAlias__)
#define ENUM_MAPPING_FROM_DISPLAY_STRING_VEC(eName__)
#define ENUM_MAPPING_FROM_XML_STRING(eName__, eAlias__)
#define ENUM_MAPPING_FROM_XML_STRING_VEC(eName__)
#define ENUM_MAPPING_PRE_DEFINITIONS(eName__, eAlias__)
#define ENUM_MAPPING_FUNCTION(eAlias__)
#define ENUM_GET_ALL_VALUES(eName__, eAlias__)
#define ENUM_GET_ALL_VALUES_DISPLAY_STRING(eName__, eAlias__)
#define ENUM_GET_ALL_VALUES_XML_STRING(eName__, eAlias__)
#define BEGIN_ENUM_MAPPING_ALIAS(eName__, eAlias__)
#define BEGIN_ENUM_MAPPING(eName__)   BEGIN_ENUM_MAPPING_ALIAS(eName__, eName__)
#define ADD_ENUM_MAPPING(enumVal, displayValue, xmlValue)   values.push_back(boost::make_tuple(enumVal, displayValue, xmlValue));
#define END_ENUM_MAPPING()
#define STRINGSTREAM_MAPPING_TO_XML_STRING(type__, __precision)
#define STRINGSTREAM_MAPPING_TO_XML_STRING_CAST(type__, cast__, precision__)
#define STRINGSTREAM_MAPPING_TO_XML_STRING_VEC(type__)
#define STRINGSTREAM_MAPPING_TO_DISPLAY_STRING(type__, __precision)
#define STRINGSTREAM_MAPPING_TO_DISPLAY_STRING_CAST(type__, cast__, precision__)
#define STRINGSTREAM_MAPPING_TO_DISPLAY_STRING_VEC(type__)
#define STRINGSTREAM_MAPPING_FROM_XML_STRING(type__)
#define STRINGSTREAM_MAPPING_FROM_XML_STRING_CAST(type__, cast__)
#define STRINGSTREAM_MAPPING_FROM_XML_STRING_VEC(type__)
#define STRINGSTREAM_MAPPING_FROM_DISPLAY_STRING(type__)
#define STRINGSTREAM_MAPPING_FROM_DISPLAY_STRING_CAST(type__, cast__)
#define STRINGSTREAM_MAPPING_FROM_DISPLAY_STRING_VEC(type__)
#define STRINGSTREAM_MAPPING_PRECISION(type__, precision__)
#define STRINGSTREAM_MAPPING(__type)   STRINGSTREAM_MAPPING_PRECISION(__type, -1) \
#define STRINGSTREAM_MAPPING_PRECISION_CAST(type__, cast__, precision__)
#define STRINGSTREAM_MAPPING_CAST(__type, __cast)   STRINGSTREAM_MAPPING_PRECISION_CAST(__type, __cast, -1)
#define TO_DISPLAY_POINTER_VARIATIONS(interface__)
#define TO_XML_POINTER_VARIATIONS(interface__)

Functions

template<typename T>
std::string convertVectorToString (const std::vector< T > &vec, bool *pError, std::string sep, bool forDisplay)
template<class T>
std::vector< T > convertStringToVector (string value, bool *pError, std::string sep, bool forDisplay)


Define Documentation

#define ADD_ENUM_MAPPING ( enumVal,
displayValue,
xmlValue   )     values.push_back(boost::make_tuple(enumVal, displayValue, xmlValue));

Definition at line 355 of file StringUtilitiesMacros.h.

#define BEGIN_ENUM_MAPPING ( eName__   )     BEGIN_ENUM_MAPPING_ALIAS(eName__, eName__)

Definition at line 352 of file StringUtilitiesMacros.h.

#define BEGIN_ENUM_MAPPING_ALIAS ( eName__,
eAlias__   ) 

Value:

Definition at line 337 of file StringUtilitiesMacros.h.

 
#define END_ENUM_MAPPING (  ) 

Value:

} \
   return values; \
}

Definition at line 357 of file StringUtilitiesMacros.h.

#define ENUM_GET_ALL_VALUES ( eName__,
eAlias__   ) 

Value:

template<>\
vector<eName__> getAllEnumValues<eName__>()\
{\
   vector<eName__> retValues;\
   eAlias__##Mapping values = get##eAlias__##Mapping();\
   eAlias__##Mapping::iterator iter;\
   for (iter = values.begin(); iter != values.end(); ++iter)\
   {\
      retValues.push_back(iter->get<0>());\
   }\
   return retValues;\
}\

Definition at line 295 of file StringUtilitiesMacros.h.

#define ENUM_GET_ALL_VALUES_DISPLAY_STRING ( eName__,
eAlias__   ) 

Value:

template<>\
vector<string> getAllEnumValuesAsDisplayString<eName__>()\
{\
   vector<string> retValues;\
   eAlias__##Mapping values = get##eAlias__##Mapping();\
   eAlias__##Mapping::iterator iter;\
   for (iter = values.begin(); iter != values.end(); ++iter)\
   {\
      retValues.push_back(iter->get<1>());\
   }\
   return retValues;\
}\

Definition at line 309 of file StringUtilitiesMacros.h.

#define ENUM_GET_ALL_VALUES_XML_STRING ( eName__,
eAlias__   ) 

Value:

template<>\
vector<string> getAllEnumValuesAsXmlString<eName__>()\
{\
   vector<string> retValues;\
   eAlias__##Mapping values = get##eAlias__##Mapping();\
   eAlias__##Mapping::iterator iter;\
   for (iter = values.begin(); iter != values.end(); ++iter)\
   {\
      retValues.push_back(iter->get<2>());\
   }\
   return retValues;\
}\

Definition at line 323 of file StringUtilitiesMacros.h.

#define ENUM_MAPPING_FROM_DISPLAY_STRING ( eName__,
eAlias__   ) 

Value:

template<>\
eName__ fromDisplayString<eName__>(std::string value, bool* pError)\
{\
   eAlias__##Mapping values = get##eAlias__##Mapping();\
   eAlias__##Mapping::iterator foundValue;\
   foundValue = std::find_if(values.begin(), values.end(), FindTupleValue<1, string>(value));\
   if (foundValue != values.end())\
   {\
      if (pError != NULL)\
      {\
         *pError = false;\
      }\
      return foundValue->get<0>();\
   }\
   if (pError != NULL)\
   {\
      *pError = true;\
   }\
   return eName__();\
}\

Definition at line 226 of file StringUtilitiesMacros.h.

#define ENUM_MAPPING_FROM_DISPLAY_STRING_VEC ( eName__   ) 

Value:

template<>\
vector<eName__> fromDisplayString<vector<eName__> >(std::string value, bool* pError)\
{\
   return convertStringToVector<eName__>(value, pError, ", ", true);\
}\

Definition at line 248 of file StringUtilitiesMacros.h.

#define ENUM_MAPPING_FROM_XML_STRING ( eName__,
eAlias__   ) 

Value:

template<>\
eName__ fromXmlString<eName__>(std::string value, bool* pError)\
{\
   eAlias__##Mapping values = get##eAlias__##Mapping();\
   eAlias__##Mapping::iterator foundValue;\
   foundValue = std::find_if(values.begin(), values.end(), FindTupleValue<2, string>(value));\
   if (foundValue != values.end())\
   {\
      if (pError != NULL)\
      {\
         *pError = false;\
      }\
      return foundValue->get<0>();\
   }\
   if (pError != NULL)\
   {\
      *pError = true;\
   }\
   return eName__();\
}\

Definition at line 255 of file StringUtilitiesMacros.h.

#define ENUM_MAPPING_FROM_XML_STRING_VEC ( eName__   ) 

Value:

template<>\
vector<eName__> fromXmlString<vector<eName__> >(std::string value, bool* pError)\
{\
   return convertStringToVector<eName__>(value, pError, ", ", false);\
}\

Definition at line 277 of file StringUtilitiesMacros.h.

#define ENUM_MAPPING_FUNCTION ( eAlias__   ) 

Value:

const eAlias__##Mapping& get##eAlias__##Mapping()\
{\
   static eAlias__##Mapping values;\
   if (values.empty())\
   {\

Definition at line 288 of file StringUtilitiesMacros.h.

#define ENUM_MAPPING_PRE_DEFINITIONS ( eName__,
eAlias__   ) 

Value:

typedef vector<boost::tuple<eName__, string, string> > eAlias__##Mapping;\
const eAlias__##Mapping & get##eAlias__##Mapping();\

Definition at line 284 of file StringUtilitiesMacros.h.

#define ENUM_MAPPING_TO_DISPLAY_STRING ( eName__,
eAlias__   ) 

Value:

template<>\
std::string toDisplayString(const eName__& val, bool* pError)\
{\
   eAlias__##Mapping values = get##eAlias__##Mapping();\
   eAlias__##Mapping::iterator foundValue;\
   foundValue = std::find_if(values.begin(), values.end(), FindTupleValue<0, eName__>(val));\
   if (foundValue != values.end())\
   {\
      if (pError != NULL)\
      {\
         *pError = false;\
      }\
      return foundValue->get<1>();\
   }\
   if (pError != NULL)\
   {\
      *pError = true;\
   }\
   return "";\
}\
template<>\
std::string toDisplayString(const eName__::EnumType& val, bool* pError)\
{\
   return toDisplayString(EnumWrapper<eName__::EnumType>(val), pError);\
}\

Definition at line 158 of file StringUtilitiesMacros.h.

#define ENUM_MAPPING_TO_DISPLAY_STRING_VEC ( eName__   ) 

Value:

template<>\
std::string toDisplayString(const vector<eName__>& vec, bool* pError)\
{\
   return convertVectorToString(vec, pError, ", ", true);\
}\

Definition at line 185 of file StringUtilitiesMacros.h.

#define ENUM_MAPPING_TO_XML_STRING ( eName__,
eAlias__   ) 

Value:

template<>\
std::string toXmlString(const eName__& val, bool* pError)\
{\
   eAlias__##Mapping values = get##eAlias__##Mapping();\
   eAlias__##Mapping::iterator foundValue;\
   foundValue = std::find_if(values.begin(), values.end(), FindTupleValue<0, eName__>(val));\
   if (foundValue != values.end())\
   {\
      if (pError != NULL)\
      {\
         *pError = false;\
      }\
      return foundValue->get<2>();\
   }\
   if (pError != NULL)\
   {\
      *pError = true;\
   }\
   return "";\
}\
template<>\
std::string toXmlString(const eName__::EnumType& val, bool* pError)\
{\
   return toXmlString(EnumWrapper<eName__::EnumType>(val), pError);\
}\

Definition at line 192 of file StringUtilitiesMacros.h.

#define ENUM_MAPPING_TO_XML_STRING_VEC ( eName__   ) 

Value:

template<>\
std::string toXmlString(const vector<eName__>& vec, bool* pError)\
{\
   return convertVectorToString(vec, pError, ", ", false);\
}\

Definition at line 219 of file StringUtilitiesMacros.h.

#define STRINGSTREAM_MAPPING ( __type   )     STRINGSTREAM_MAPPING_PRECISION(__type, -1) \

Definition at line 543 of file StringUtilitiesMacros.h.

#define STRINGSTREAM_MAPPING_CAST ( __type,
__cast   )     STRINGSTREAM_MAPPING_PRECISION_CAST(__type, __cast, -1)

Definition at line 556 of file StringUtilitiesMacros.h.

#define STRINGSTREAM_MAPPING_FROM_DISPLAY_STRING ( type__   ) 

Value:

template<>\
type__ fromDisplayString<type__>(std::string value, bool* pError)\
{\
   stringstream buf(value);\
   type__ parsedValue;\
   buf >> parsedValue;\
   if (pError != NULL)\
   {\
      *pError = buf.fail();\
   }\
   return parsedValue;\
}\

Definition at line 489 of file StringUtilitiesMacros.h.

#define STRINGSTREAM_MAPPING_FROM_DISPLAY_STRING_CAST ( type__,
cast__   ) 

Value:

template<>\
type__ fromDisplayString<type__>(std::string value, bool* pError)\
{\
   stringstream buf(value);\
   cast__ parsedValue;\
   buf >> parsedValue;\
   if (pError != NULL)\
   {\
      *pError = buf.fail() || parsedValue > std::numeric_limits<type__>::max()\
         || parsedValue < std::numeric_limits<type__>::min();\
   }\
   if (parsedValue > std::numeric_limits<type__>::max())\
   {\
      return std::numeric_limits<type__>::max();\
   }\
   if (parsedValue < std::numeric_limits<type__>::min())\
   {\
      return std::numeric_limits<type__>::min();\
   }\
   return static_cast<type__>(parsedValue);\
}\

Definition at line 503 of file StringUtilitiesMacros.h.

#define STRINGSTREAM_MAPPING_FROM_DISPLAY_STRING_VEC ( type__   ) 

Value:

template<>\
vector<type__> fromDisplayString<vector<type__> >(std::string value, bool* pError)\
{\
   return convertStringToVector<type__>(value, pError, ", ", true);\
}\

Definition at line 526 of file StringUtilitiesMacros.h.

#define STRINGSTREAM_MAPPING_FROM_XML_STRING ( type__   ) 

Value:

template<>\
type__ fromXmlString<type__>(std::string value, bool* pError)\
{\
   stringstream buf(value);\
   type__ parsedValue;\
   buf >> parsedValue;\
   if (pError != NULL)\
   {\
      *pError = buf.fail();\
   }\
   return parsedValue;\
}\

Definition at line 445 of file StringUtilitiesMacros.h.

#define STRINGSTREAM_MAPPING_FROM_XML_STRING_CAST ( type__,
cast__   ) 

Value:

template<>\
type__ fromXmlString<type__>(std::string value, bool* pError)\
{\
   stringstream buf(value);\
   cast__ parsedValue;\
   buf >> parsedValue;\
   if (pError != NULL)\
   {\
      *pError = buf.fail() || parsedValue > std::numeric_limits<type__>::max()\
         || parsedValue < std::numeric_limits<type__>::min();\
   }\
   if (parsedValue > std::numeric_limits<type__>::max())\
   {\
      return std::numeric_limits<type__>::max();\
   }\
   if (parsedValue < std::numeric_limits<type__>::min())\
   {\
      return std::numeric_limits<type__>::min();\
   }\
   return static_cast<type__>(parsedValue);\
}\

Definition at line 459 of file StringUtilitiesMacros.h.

#define STRINGSTREAM_MAPPING_FROM_XML_STRING_VEC ( type__   ) 

Value:

template<>\
vector<type__> fromXmlString<vector<type__> >(std::string value, bool* pError)\
{\
   return convertStringToVector<type__>(value, pError, ", ", false);\
}\

Definition at line 482 of file StringUtilitiesMacros.h.

#define STRINGSTREAM_MAPPING_PRECISION ( type__,
precision__   ) 

#define STRINGSTREAM_MAPPING_PRECISION_CAST ( type__,
cast__,
precision__   ) 

#define STRINGSTREAM_MAPPING_TO_DISPLAY_STRING ( type__,
__precision   ) 

Value:

template<>\
std::string toDisplayString(const type__ & val, bool* pError)\
{\
   stringstream buf;\
   if (__precision != -1)\
   {\
      buf.precision(__precision);\
   }\
   buf << val;\
   if (pError != NULL)\
   {\
      *pError = buf.fail();\
   }\
   return buf.str();\
}\

Definition at line 403 of file StringUtilitiesMacros.h.

#define STRINGSTREAM_MAPPING_TO_DISPLAY_STRING_CAST ( type__,
cast__,
precision__   ) 

Value:

template<>\
std::string toDisplayString(const type__ & val, bool* pError)\
{\
   stringstream buf;\
   if (precision__ != -1)\
   {\
      buf.precision(precision__);\
   }\
   buf << static_cast<cast__>(val);\
   if (pError != NULL)\
   {\
      *pError = buf.fail();\
   }\
   return buf.str();\
}\

Definition at line 420 of file StringUtilitiesMacros.h.

#define STRINGSTREAM_MAPPING_TO_DISPLAY_STRING_VEC ( type__   ) 

Value:

template<>\
std::string toDisplayString(const vector<type__> & vec, bool* pError)\
{\
   return convertVectorToString(vec, pError, ", ", true);\
}\

Definition at line 437 of file StringUtilitiesMacros.h.

#define STRINGSTREAM_MAPPING_TO_XML_STRING ( type__,
__precision   ) 

Value:

template<>\
std::string toXmlString(const type__ & val, bool* pError)\
{\
   stringstream buf;\
   if (__precision != -1)\
   {\
      buf.precision(__precision);\
   }\
   buf << val;\
   if (pError != NULL)\
   {\
      *pError = buf.fail();\
   }\
   return buf.str();\
}\

Definition at line 362 of file StringUtilitiesMacros.h.

#define STRINGSTREAM_MAPPING_TO_XML_STRING_CAST ( type__,
cast__,
precision__   ) 

Value:

template<>\
std::string toXmlString(const type__ & val, bool* pError)\
{\
   stringstream buf;\
   if (precision__ != -1)\
   {\
      buf.precision(precision__);\
   }\
   buf << static_cast<cast__>(val);\
   if (pError != NULL)\
   {\
      *pError = buf.fail();\
   }\
   return buf.str();\
}\

Definition at line 379 of file StringUtilitiesMacros.h.

#define STRINGSTREAM_MAPPING_TO_XML_STRING_VEC ( type__   ) 

Value:

template<>\
std::string toXmlString(const vector<type__> & vec, bool* pError)\
{\
   return convertVectorToString(vec, pError, ", ", false);\
}\

Definition at line 396 of file StringUtilitiesMacros.h.

#define TO_DISPLAY_POINTER_VARIATIONS ( interface__   ) 

Value:

template<>\
std::string toDisplayString<interface__>(const interface__ & val, bool* pError)\
{\
   return toDisplayString<const interface__ *>(&val, pError);\
}\
template<>\
std::string toDisplayString<interface__ *>(interface__ * const & val, bool* pError)\
{\
   return toDisplayString<const interface__*>(val, pError);\
}\

Definition at line 559 of file StringUtilitiesMacros.h.

#define TO_XML_POINTER_VARIATIONS ( interface__   ) 

Value:

template<>\
std::string toXmlString<interface__>(const interface__ & val, bool* pError)\
{\
   return toXmlString<const interface__ *>(&val, pError);\
}\
template<>\
std::string toXmlString<interface__ *>(interface__ * const & val, bool* pError)\
{\
   return toXmlString<const interface__*>(val, pError);\
}

Definition at line 571 of file StringUtilitiesMacros.h.


Function Documentation

template<class T>
std::vector<T> convertStringToVector ( string  value,
bool *  pError,
std::string  sep,
bool  forDisplay 
)

Definition at line 89 of file StringUtilitiesMacros.h.

template<typename T>
std::string convertVectorToString ( const std::vector< T > &  vec,
bool *  pError,
std::string  sep,
bool  forDisplay 
)

Definition at line 52 of file StringUtilitiesMacros.h.


Software Development Kit - Opticks 4.9.0 Build 16218