3#include <cgv/utils/convert.h>
5#include <cgv/type/standard_types.h>
6#include <cgv/type/info/type_id.h>
23 static T
get(
const std::string& value_type,
const void* value_ptr)
26 return (T) *
static_cast<const bool*
>(value_ptr);
28 return (T) *
static_cast<const int8_type*
>(value_ptr);
30 return (T) *
static_cast<const int16_type*
>(value_ptr);
32 return (T) *
static_cast<const int32_type*
>(value_ptr);
34 return (T) *
static_cast<const int64_type*
>(value_ptr);
36 return (T) *
static_cast<const uint8_type*
>(value_ptr);
38 return (T) *
static_cast<const uint16_type*
>(value_ptr);
40 return (T) *
static_cast<const uint32_type*
>(value_ptr);
42 return (T) *
static_cast<const uint64_type*
>(value_ptr);
44 return (T) *
static_cast<const flt32_type*
>(value_ptr);
46 return (T) *
static_cast<const flt64_type*
>(value_ptr);
48 return (T) atof(
static_cast<const std::string*
>(value_ptr)->c_str());
50 return (T) *
static_cast<const short*
>(value_ptr);
56 static void set(
const T& value,
const std::string& value_type,
void* value_ptr)
59 *
static_cast<bool*
>(value_ptr) = value != T();
92 static bool get(
const std::string& value_type,
const void* value_ptr)
95 return *
static_cast<const bool*
>(value_ptr);
97 return *
static_cast<const int8_type*
>(value_ptr) != 0;
99 return *
static_cast<const int16_type*
>(value_ptr) != 0;
101 return *
static_cast<const int32_type*
>(value_ptr) != 0;
103 return *
static_cast<const int64_type*
>(value_ptr) != 0;
105 return *
static_cast<const uint8_type*
>(value_ptr) != 0;
107 return *
static_cast<const uint16_type*
>(value_ptr) != 0;
109 return *
static_cast<const uint32_type*
>(value_ptr) != 0;
111 return *
static_cast<const uint64_type*
>(value_ptr) != 0;
113 return *
static_cast<const flt32_type*
>(value_ptr) != 0;
115 return *
static_cast<const flt64_type*
>(value_ptr) != 0;
117 return *
static_cast<const wchar_type*
>(value_ptr) != 0;
119 return *
static_cast<const std::string*
>(value_ptr) ==
"true";
121 return *
static_cast<const std::wstring*
>(value_ptr) == L
"true";
124 static void set(
const bool& value,
const std::string& value_type,
void* value_ptr)
127 *
static_cast<bool*
>(value_ptr) = value;
129 *
static_cast<int8_type*
>(value_ptr) = value?1:0;
131 *
static_cast<int16_type*
>(value_ptr) = value?1:0;
133 *
static_cast<int32_type*
>(value_ptr) = value?1:0;
135 *
static_cast<int64_type*
>(value_ptr) = value?1:0;
137 *
static_cast<uint8_type*
>(value_ptr) = value?1:0;
145 *
static_cast<flt32_type*
>(value_ptr) = value?1.0f:0.0f;
147 *
static_cast<flt64_type*
>(value_ptr) = value?1:0;
149 *
static_cast<wchar_type*
>(value_ptr) = value?1:0;
151 *
static_cast<std::string*
>(value_ptr) = value?
"true":
"false";
153 *
static_cast<std::wstring*
>(value_ptr) = value?L
"true":L
"false";
161 static std::string
get(
const std::string& value_type,
const void* value_ptr)
164 return *
static_cast<const bool*
>(value_ptr)?
"true":
"false";
188 return *
static_cast<const std::string*
>(value_ptr);
193 static void set(
const std::string& value,
const std::string& value_type,
void* value_ptr)
196 *
static_cast<bool*
>(value_ptr) = value==
"true"?
true:
false;
198 *
static_cast<int8_type*
>(value_ptr) = atoi(value.c_str());
218 *
static_cast<std::string*
>(value_ptr) = value;
220 *
static_cast<wchar_type*
>(value_ptr) = value.empty() ? 0 : value[0];
229 static std::wstring
get(
const std::string& value_type,
const void* value_ptr)
232 return *
static_cast<const std::wstring*
>(value_ptr);
235 static void set(
const std::wstring& value,
const std::string& value_type,
void* value_ptr)
238 *
static_cast<std::wstring*
>(value_ptr) = value;
250 static void set(
const char* value,
const std::string& value_type,
void* value_ptr)
257void set_variant(
const T& value,
const std::string& value_type,
void* value_ptr)
263void get_variant(T& value,
const std::string& value_type,
const void* value_ptr)
268extern CGV_API
void assign_variant(
const std::string& dst_value_type,
void* dst_value_ptr,
269 const std::string& src_value_type,
const void* src_value_ptr);
274#include <cgv/config/lib_end.h>
complete implementation of method actions that only call one method when entering a node
const char * get_type_name(TypeId tid)
function that returns the name of a type specified through TypeId
@ TI_INT16
signed integer stored in 8 bits
@ TI_INT32
signed integer stored in 16 bits
@ TI_STRING
wide character type
@ TI_WCHAR
floating point type stored in 64 bits
@ TI_FLT32
floating point type stored in 16 bits
@ TI_UINT32
unsigned integer stored in 16 bits
@ TI_UINT8
signed integer stored in 64 bits
@ TI_INT64
signed integer stored in 32 bits
@ TI_UINT16
unsigned integer stored in 8 bits
@ TI_FLT64
floating point type stored in 32 bits
@ TI_UINT64
unsigned integer stored in 32 bits
double flt64_type
this type provides a 64 bit floating point type
signed char int8_type
this type provides an 8 bit signed integer type
int int32_type
this type provides an 32 bit signed integer type
short int16_type
this type provides an 16 bit signed integer type
unsigned short uint16_type
this type provides an 16 bit unsigned integer type
unsigned long long uint64_type
this type provides an 64 bit unsigned integer type
wchar_t wchar_type
wide character type
unsigned int uint32_type
this type provides an 32 bit unsigned integer type
long long int64_type
this type provides an 64 bit signed integer type
float flt32_type
this type provides a 32 bit floating point type
unsigned char uint8_type
this type provides an 8 bit unsigned integer type
std::string to_string(const std::string &v, unsigned int w, unsigned int p, bool)
specialization of conversion from string to strings
std::wstring str2wstr(const std::string &s)
convert a 8-bit string to a 16-bit string
std::string wstr2str(const std::wstring &ws)
convert a 16-bit string to a 8-bit string
convenience template to access a value pointed to by a void pointer where the type of the value is gi...
static void set(const T &value, const std::string &value_type, void *value_ptr)
convert the first parameter of type T into value_type and store the value at the location pointed to ...
static T get(const std::string &value_type, const void *value_ptr)
convert the value pointed to by value_ptr of type value_type to type T and return it