All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 #include <utility>
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 
94  GENAPI_DECL void Value2String(CIntegerPolyRef Value, GENICAM_NAMESPACE::gcstring &ValueStr);
95 
97  GENAPI_DECL bool String2Value(const GENICAM_NAMESPACE::gcstring &ValueStr, CIntegerPolyRef* Value);
98 
100  GENAPI_DECL void Value2String(CBooleanPolyRef Value, GENICAM_NAMESPACE::gcstring &ValueStr);
101 
103  GENAPI_DECL bool String2Value(const GENICAM_NAMESPACE::gcstring &ValueStr, CBooleanPolyRef* Value);
104 
106  GENAPI_DECL void Value2String(CFloatPolyRef Value, GENICAM_NAMESPACE::gcstring &ValueStr);
107 
109  GENAPI_DECL bool String2Value(const GENICAM_NAMESPACE::gcstring &ValueStr, CFloatPolyRef* Value);
110 
112  GENAPI_DECL void Value2String(CStringPolyRef Value, GENICAM_NAMESPACE::gcstring &ValueStr);
113 
115  GENAPI_DECL bool String2Value(const GENICAM_NAMESPACE::gcstring &ValueStr, CStringPolyRef* Value);
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  typedef std::pair<bool, int64_t> String2Value_ReturnType;
128 
129  GENAPI_DECL bool String2Value(const GENICAM_NAMESPACE::gcstring &ValueStr, uint8_t * pValue, const int64_t len, int64_t *filled);
130  GENAPI_DECL bool String2Value( const GENICAM_NAMESPACE::gcstring& ValueStr, uint8_t* pValue, int64_t len );
131 
133  GENAPI_DECL bool String2Value( const GENICAM_NAMESPACE::gcstring &ValueStr, bool* pValue );
134 
136  #pragma BullseyeCoverage off
137  inline char Hex2Byte(uint8_t Hex)
138  {
139  if( 0x30 <= Hex && Hex <= 0x39 )
140  return Hex - 0x30;
141  else if( 0x41 <= Hex && Hex <= 0x46 )
142  return Hex - 0x41 + 0x0a;
143  else if( 0x61 <= Hex && Hex <= 0x66 )
144  return Hex - 0x61 + 0x0a;
145  else
146  {
147  assert(false && "if you are here its not an ASCII digit");
148  return '0';
149  }
150  }
151  #pragma BullseyeCoverage on
152 
153 
154 
155 }
156 #endif // ifndef GENAPI_VALUE2STRING_H
GENAPI_NAMESPACE
Lexical analyzer for CIntSwissKnife.
Definition: Destructible.h:30
GENAPI_NAMESPACE::PureNumber
@ PureNumber
Decimal number in an edit control.
Definition: Types.h:93
PolyReference.h
Definition of polymorphical smart pointer.
GENAPI_NAMESPACE::Values2String
void Values2String(const T &Values, GENICAM_NAMESPACE::gcstring &ValueStr)
Dump a value container into a string.
Definition: Value2String.h:48
GENICAM_NAMESPACE::gcstring
A string class which is a clone of std::string.
Definition: GCString.h:52
GENAPI_NAMESPACE::Value2String
void Value2String(T Value, GENICAM_NAMESPACE::gcstring &ValueStr)
Converts an T property to a string.
Definition: Value2String.h:62
GENAPI_DECL
#define GENAPI_DECL
Definition: GenApiDll.h:55
GENAPI_NAMESPACE::ERepresentation
enum GENAPI_NAMESPACE::_ERepresentation ERepresentation
recommended representation of a node value
GENICAM_NAMESPACE::gcstring::length
virtual size_t length(void) const
GENAPI_NAMESPACE::Hex2Byte
char Hex2Byte(uint8_t Hex)
Converts an ASCII hex digit to a char value.
Definition: Value2String.h:137
GCBase.h
Common GenICam base include file.
std::ostringstream::str
std::string str()
GENAPI_NAMESPACE::String2Value
bool String2Value(const GENICAM_NAMESPACE::gcstring &ValueStr, T *Value)
Converts a string to an T property.
Definition: Value2String.h:72
GENAPI_NAMESPACE::String2Value_ReturnType
std::pair< bool, int64_t > String2Value_ReturnType
Converts a string to a byte array.
Definition: Value2String.h:127
int64_t
__int64 int64_t
Definition: config-win32.h:21
std::ostringstream
Definition: Portability.hh:42
GENICAM_NAMESPACE::gcstring::c_str
virtual const char * c_str(void) const


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Wed Dec 4 2024 03:10:12