Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00031 #ifndef GENAPI_VALUE2STRING_H
00032 #define GENAPI_VALUE2STRING_H
00033
00034 #include <sstream>
00035 #include <cctype>
00036 #include <iomanip>
00037
00038 #include "Base/GCBase.h"
00039 #include "../GenApiDll.h"
00040 #include "PolyReference.h"
00041 #include "Internal_Compatibility.h"
00042
00043
00044 namespace GENAPI_NAMESPACE
00045 {
00047 template< typename T >
00048 void Values2String(const T & Values, GENICAM_NAMESPACE::gcstring &ValueStr)
00049 {
00050 std::ostringstream s;
00051 typename T::const_iterator it(Values.begin());
00052 if (it != Values.end())
00053 s << *it++;
00054 while (it != Values.end())
00055 s << "\t" << *it++ ;
00056
00057 ValueStr = s.str().c_str();
00058 }
00059
00061 template< typename T >
00062 void Value2String(T Value, GENICAM_NAMESPACE::gcstring &ValueStr)
00063 {
00064 static const int precision(36);
00065 std::ostringstream s;
00066 s << std::setprecision( precision ) << Value;
00067 ValueStr = s.str().c_str();
00068 }
00069
00071 template< typename T >
00072 bool String2Value(const GENICAM_NAMESPACE::gcstring &ValueStr, T* Value)
00073 {
00074 std::istringstream s(ValueStr.c_str());
00075 if( ValueStr.length() > 2
00076 && (ValueStr[0] == '0' && (ValueStr[1] == 'x' || ValueStr[1] == 'X') ))
00077 {
00078 s.ignore( 2 );
00079 s >> std::hex >> *Value;
00080 }
00081 else
00082 s >> *Value;
00083
00084 return !s.fail();
00085 }
00086
00088 GENAPI_DECL bool String2Value(const char* ValueStr, int64_t* Value, ERepresentation Representation = PureNumber);
00089
00091 GENAPI_DECL void Value2String(int64_t Value, GENICAM_NAMESPACE::gcstring &ValueStr, ERepresentation Representation = PureNumber);
00092
00094 GENAPI_DECL void Value2String(CIntegerPolyRef Value, GENICAM_NAMESPACE::gcstring &ValueStr);
00095
00097 GENAPI_DECL bool String2Value(const GENICAM_NAMESPACE::gcstring &ValueStr, CIntegerPolyRef* Value);
00098
00100 GENAPI_DECL void Value2String(CBooleanPolyRef Value, GENICAM_NAMESPACE::gcstring &ValueStr);
00101
00103 GENAPI_DECL bool String2Value(const GENICAM_NAMESPACE::gcstring &ValueStr, CBooleanPolyRef* Value);
00104
00106 GENAPI_DECL void Value2String(CFloatPolyRef Value, GENICAM_NAMESPACE::gcstring &ValueStr);
00107
00109 GENAPI_DECL bool String2Value(const GENICAM_NAMESPACE::gcstring &ValueStr, CFloatPolyRef* Value);
00110
00112 GENAPI_DECL void Value2String(CStringPolyRef Value, GENICAM_NAMESPACE::gcstring &ValueStr);
00113
00115 GENAPI_DECL bool String2Value(const GENICAM_NAMESPACE::gcstring &ValueStr, CStringPolyRef* Value);
00116
00118 GENAPI_DECL bool String2Value(const GENICAM_NAMESPACE::gcstring &ValueStr, GUID* Value);
00119
00121 GENAPI_DECL void Value2String(const GUID &Value, GENICAM_NAMESPACE::gcstring &ValueStr);
00122
00124 GENAPI_DECL void Value2String(uint8_t *pValue, GENICAM_NAMESPACE::gcstring &ValueStr, int64_t len);
00125
00127 GENAPI_DECL bool String2Value(const GENICAM_NAMESPACE::gcstring &ValueStr, uint8_t *pValue, int64_t len);
00128
00130 GENAPI_DECL bool String2Value( const GENICAM_NAMESPACE::gcstring &ValueStr, bool* pValue );
00131
00133 #pragma BullseyeCoverage off
00134 inline char Hex2Byte(uint8_t Hex)
00135 {
00136 if( 0x30 <= Hex && Hex <= 0x39 )
00137 return Hex - 0x30;
00138 else if( 0x41 <= Hex && Hex <= 0x46 )
00139 return Hex - 0x41 + 0x0a;
00140 else if( 0x61 <= Hex && Hex <= 0x66 )
00141 return Hex - 0x61 + 0x0a;
00142 else
00143 {
00144 assert(false && "if you are here its not an ASCII digit");
00145 return '0';
00146 }
00147 }
00148 #pragma BullseyeCoverage on
00149
00150
00151
00152 }
00153 #endif // ifndef GENAPI_VALUE2STRING_H