Value2String.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // (c) 2006 by Basler Vision Technologies
3 // Section: Vision Components
4 // Project: GenApi
5 // Author: Fritz Dierks
6 // $Header$
7 //
8 // License: This file is published under the license of the EMVA GenICam Standard Group.
9 // A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'.
10 // If for some reason you are missing this file please contact the EMVA or visit the website
11 // (http://www.genicam.org) for a full copy.
12 //
13 // THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
14 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP
17 // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23 // POSSIBILITY OF SUCH DAMAGE.
24 //-----------------------------------------------------------------------------
31 #ifndef GENAPI_VALUE2STRING_H
32 #define GENAPI_VALUE2STRING_H
33 
34 #include <sstream>
35 #include <cctype>
36 #include <iomanip>
37 
38 #include "Base/GCBase.h"
39 #include "../GenApiDll.h"
40 #include "PolyReference.h"
41 #include "Internal_Compatibility.h"
42 
43 
44 namespace GENAPI_NAMESPACE
45 {
47  template< typename T >
48  void Values2String(const T & Values, GENICAM_NAMESPACE::gcstring &ValueStr)
49  {
51  typename T::const_iterator it(Values.begin());
52  if (it != Values.end())
53  s << *it++;
54  while (it != Values.end())
55  s << "\t" << *it++ ;
56 
57  ValueStr = s.str().c_str();
58  }
59 
61  template< typename T >
62  void Value2String(T Value, GENICAM_NAMESPACE::gcstring &ValueStr)
63  {
64  static const int precision(36); // For the MS STL, values > 36 ( == _MAX_SIG_DIG ) are leading to trailing zeroes
66  s << std::setprecision( precision ) << Value;
67  ValueStr = s.str().c_str();
68  }
69 
71  template< typename T >
72  bool String2Value(const GENICAM_NAMESPACE::gcstring &ValueStr, T* Value)
73  {
74  std::istringstream s(ValueStr.c_str());
75  if( ValueStr.length() > 2
76  && (ValueStr[0] == '0' && (ValueStr[1] == 'x' || ValueStr[1] == 'X') ))
77  {
78  s.ignore( 2 );
79  s >> std::hex >> *Value;
80  }
81  else
82  s >> *Value;
83 
84  return !s.fail();
85  }
86 
88  GENAPI_DECL bool String2Value(const char* ValueStr, int64_t* Value, ERepresentation Representation = PureNumber);
89 
92 
95 
98 
101 
104 
107 
110 
113 
116 
118  GENAPI_DECL bool String2Value(const GENICAM_NAMESPACE::gcstring &ValueStr, GUID* Value);
119 
121  GENAPI_DECL void Value2String(const GUID &Value, GENICAM_NAMESPACE::gcstring &ValueStr);
122 
124  GENAPI_DECL void Value2String(uint8_t *pValue, GENICAM_NAMESPACE::gcstring &ValueStr, int64_t len);
125 
127  GENAPI_DECL bool String2Value(const GENICAM_NAMESPACE::gcstring &ValueStr, uint8_t *pValue, int64_t len);
128 
130  GENAPI_DECL bool String2Value( const GENICAM_NAMESPACE::gcstring &ValueStr, bool* pValue );
131 
133  #pragma BullseyeCoverage off
134  inline char Hex2Byte(uint8_t Hex)
135  {
136  if( 0x30 <= Hex && Hex <= 0x39 )
137  return Hex - 0x30;
138  else if( 0x41 <= Hex && Hex <= 0x46 )
139  return Hex - 0x41 + 0x0a;
140  else if( 0x61 <= Hex && Hex <= 0x66 )
141  return Hex - 0x61 + 0x0a;
142  else
143  {
144  assert(false && "if you are here its not an ASCII digit");
145  return '0';
146  }
147  }
148  #pragma BullseyeCoverage on
149 
150 
151 
152 }
153 #endif // ifndef GENAPI_VALUE2STRING_H
A reference to a bool which can bei either an bool variable, or a pointer to an IInteger, an IEnumeration, or an IBoolean.
Decimal number in an edit control.
Definition: Types.h:94
__int64 int64_t
Definition: config-win32.h:21
virtual size_t length(void) const
std::string str()
#define GENAPI_DECL
Definition: GenApiDll.h:55
Common GenICam base include file.
enum GENAPI_NAMESPACE::_ERepresentation ERepresentation
recommended representation of a node value
Definition of polymorphical smart pointer.
char Hex2Byte(uint8_t Hex)
Converts an ASCII hex digit to a char value.
Definition: Value2String.h:134
void Values2String(const T &Values, GENICAM_NAMESPACE::gcstring &ValueStr)
Dump a value container into a string.
Definition: Value2String.h:48
A reference to a float which can be either a double variable, or a pointer to an IFloat, IInteger, or an IEnumeration interface.
A string class which is a clone of std::string.
Definition: GCString.h:52
A reference to an int64 which can bei either an int64 variable, or a pointer to an IInteger...
Definition: PolyReference.h:68
virtual const char * c_str(void) const
void Value2String(T Value, GENICAM_NAMESPACE::gcstring &ValueStr)
Converts an T property to a string.
Definition: Value2String.h:62
Lexical analyzer for CIntSwissKnife.
Definition: Autovector.h:48
A reference to a gcstring which can be either a gcstring variable, or a pointer to an IString...
bool String2Value(const GENICAM_NAMESPACE::gcstring &ValueStr, T *Value)
Converts a string to an T property.
Definition: Value2String.h:72


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Wed Mar 17 2021 02:48:41