Value2String.h
Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 //  (c) 2006 by Basler Vision Technologies
00003 //  Section: Vision Components
00004 //  Project: GenApi
00005 //  Author:  Fritz Dierks
00006 //  $Header$
00007 //
00008 //  License: This file is published under the license of the EMVA GenICam  Standard Group.
00009 //  A text file describing the legal terms is included in  your installation as 'GenICam_license.pdf'.
00010 //  If for some reason you are missing  this file please contact the EMVA or visit the website
00011 //  (http://www.genicam.org) for a full copy.
00012 //
00013 //  THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
00014 //  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00015 //  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00016 //  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD  GROUP
00017 //  OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,  SPECIAL,
00018 //  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT  LIMITED TO,
00019 //  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,  DATA, OR PROFITS;
00020 //  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY  THEORY OF LIABILITY,
00021 //  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE)
00022 //  ARISING IN ANY WAY OUT OF THE USE  OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00023 //  POSSIBILITY OF SUCH DAMAGE.
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);  // For the MS STL, values > 36 ( == _MAX_SIG_DIG ) are leading to trailing zeroes
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


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Thu Jun 6 2019 18:42:47