Go to the documentation of this file.
19 static const std::string& s_class() {
20 static const std::string s_v(
"tools::value");
81 mem::increment(s_class().c_str());
84 u.m_unsigned_int64 = 0;
89 mem::increment(s_class().c_str());
103 mem::increment(s_class().c_str());
110 mem::increment(s_class().c_str());
117 mem::increment(s_class().c_str());
124 mem::increment(s_class().c_str());
127 u.m_unsigned_int64 = a_value;
131 mem::increment(s_class().c_str());
138 mem::increment(s_class().c_str());
141 u.m_double = a_value;
153 mem::increment(s_class().c_str());
156 u.m_unsigned_short = a_value;
160 mem::increment(s_class().c_str());
163 u.m_unsigned_int = a_value;
167 mem::increment(s_class().c_str());
170 u.m_void_star = a_value;
174 mem::increment(s_class().c_str());
177 u.m_double_star = a_value;
181 mem::increment(s_class().c_str());
184 u.m_float_star = a_value;
188 mem::increment(s_class().c_str());
191 u.m_int_star = a_value;
196 mem::increment(s_class().c_str());
199 u.m_string =
new std::string(a_value?a_value:
"");
203 mem::increment(s_class().c_str());
206 u.m_string =
new std::string(a_value);
210 #define TOOLS_VALUE_CSTOR(a_what,a_m_what,a_type) \
211 value(const std::vector<a_what>& a_v):m_label(0),m_itag(0){\
212 mem::increment(s_class().c_str());\
214 std::vector<unsigned int> is(1);\
215 is[0] = (unsigned int)a_v.size();\
216 u.a_m_what = new array<a_what>(is);\
217 u.a_m_what->fill(a_v);\
220 #define TOOLS_VALUE_CSTOR(a_what,a_m_what,a_type) \
221 value(const std::vector<a_what>& a_v):m_label(0),m_itag(0){\
223 std::vector<unsigned int> is(1);\
224 is[0] = (unsigned int)a_v.size();\
225 u.a_m_what = new array<a_what>(is);\
226 u.a_m_what->fill(a_v);\
243 #undef TOOLS_VALUE_CSTOR
246 #define TOOLS_VALUE_CSTORA(a_what,a_m_what,a_type) \
247 value(const array<a_what>& a_a):m_label(0),m_itag(0){\
248 mem::increment(s_class().c_str());\
250 u.a_m_what = new array<a_what>(a_a);\
253 #define TOOLS_VALUE_CSTORA(a_what,a_m_what,a_type) \
254 value(const array<a_what>& a_a):m_label(0),m_itag(0){\
256 u.a_m_what = new array<a_what>(a_a);\
273 #undef TOOLS_VALUE_CSTORA
279 mem::decrement(s_class().c_str());
285 mem::increment(s_class().c_str());
292 u.m_string =
new std::string(*a_from.
u.
m_string);
302 u.m_array_unsigned_short =
338 if(&a_from==
this)
return *
this;
350 u.m_string =
new std::string(*a_from.
u.
m_string);
427 static const std::string& s_empty() {
428 static const std::string s_v(
"");
436 m_label =
new std::string(a_s);
438 const std::string&
label()
const {
return m_label?(*m_label):s_empty();}
445 case NONE:
u.m_unsigned_int64 = 0;
break;
449 case SHORT:
u.m_short = 0;
break;
451 case INT:
u.m_int = 0;
break;
453 case INT64:
u.m_int64 = 0;
break;
454 case FLOAT:
u.m_float = 0;
break;
455 case DOUBLE:
u.m_double = 0;
break;
456 case BOOL:
u.m_bool =
false;
break;
461 case STRING:
u.m_string =
new std::string(
"");
break;
487 u.m_unsigned_int64 = 0;
504 void set(
unsigned short a_value) {
507 u.m_unsigned_short = a_value;
514 void set(
unsigned int a_value) {
517 u.m_unsigned_int = a_value;
527 u.m_unsigned_int64 = a_value;
534 void set(
double a_value) {
537 u.m_double = a_value;
545 void set(
const std::string& a_value) {
548 u.m_string =
new std::string(a_value);
550 void set(
const char* a_value) {
554 u.m_string =
new std::string(a_value);
560 u.m_void_star = a_value;
563 void set(
double* a_value) {
566 u.m_double_star = a_value;
568 void set(
float* a_value) {
571 u.m_float_star = a_value;
576 u.m_int_star = a_value;
599 #define TOOLS_VALUE_SET(a_what,a_m_what,a_type) \
600 void set(const std::vector<unsigned int>& a_orders,const std::vector<a_what>& a_v){\
603 u.a_m_what = new array<a_what>(a_orders);\
604 u.a_m_what->fill(a_v);\
620 #undef TOOLS_VALUE_SET
622 #define TOOLS_VALUE_SET2(a_what,a_m_what,a_type) \
623 void set(const std::vector<a_what>& a_v){\
626 std::vector<unsigned int> is(1);\
627 is[0] = (unsigned int)a_v.size();\
628 u.a_m_what = new array<a_what>(is);\
629 u.a_m_what->fill(a_v);\
645 #undef TOOLS_VALUE_SET2
647 #define TOOLS_VALUE_GET(a_what,a_get_what,a_m_what) \
648 const std::vector<a_what>& a_get_what(std::vector<unsigned int>& a_orders) const {\
649 a_orders = u.a_m_what->orders();\
650 return u.a_m_what->vector();\
666 #undef TOOLS_VALUE_GET
674 case NONE:a_s =
"NONE";
return true;
675 case INT:a_s =
"INT";
return true;
676 case INT64:a_s =
"INT64";
return true;
677 case DOUBLE:a_s =
"DOUBLE";
return true;
678 case STRING:a_s =
"STRING";
return true;
679 case VOID_STAR:a_s =
"VOID_STAR";
return true;
681 case FLOAT_STAR:a_s =
"FLOAT_STAR";
return true;
682 case INT_STAR:a_s =
"INT_STAR";
return true;
683 case BOOL:a_s =
"BOOL";
return true;
684 case SHORT:a_s =
"SHORT";
return true;
685 case FLOAT:a_s =
"FLOAT";
return true;
696 case ARRAY_INT:a_s =
"ARRAY_INT";
return true;
701 case ARRAY_BOOL:a_s =
"ARRAY_BOOL";
return true;
703 default:a_s.clear();
return false;
707 bool tos(std::string& a_s)
const {
return tos(*
this,a_s);}
709 static bool tos(
const value& a_v,std::string& a_s){
853 a_d =
u.m_unsigned_short;
856 a_d =
u.m_unsigned_int;
862 a_d = (double)
u.m_int64;
865 a_d = (
double)
u.m_unsigned_int64;
965 return u.m_array_unsigned_short->size();
967 return u.m_array_short->size();
969 return u.m_array_unsigned_int->size();
971 return u.m_array_int->size();
973 return u.m_array_unsigned_int64->size();
975 return u.m_array_int64->size();
977 return u.m_array_float->size();
979 return u.m_array_double->size();
981 return u.m_array_bool->size();
983 return u.m_array_string->size();
988 #define TOOLS_ARRAY_VEC(a_what,a_get_what,a_m_what) \
989 const std::vector<a_what>& a_get_what() const {return u.a_m_what->vector();}\
990 std::vector<a_what>& a_get_what() {return u.a_m_what->vector();}
1005 #undef TOOLS_ARRAY_VEC
1011 if(!
s_type(s))
return "unknown";
1017 if(!
s_type(a_type,s))
return "unknown";
1038 std::string& aError) {
1039 if(!
if_eq(aThis,aV,aError))
return false;
1044 std::string& aError){
1046 if(!
if_eq(aThis,aV,aError))
return false;
1047 if(aThis.
u.
m_bool)
return true;
1049 if(!
if_gt(tmp,aV,aError))
return false;
1055 std::string& aError){
1056 if(!
if_ge(aThis,aV,aError))
return false;
1062 std::string& aError){
1063 if(!
if_gt(aThis,aV,aError))
return false;
1090 delete u.m_array_unsigned_short;
u.m_array_unsigned_short = 0;
1093 delete u.m_array_short;
u.m_array_short = 0;
1096 delete u.m_array_unsigned_int;
u.m_array_unsigned_int = 0;
1099 delete u.m_array_int;
u.m_array_int = 0;
1102 delete u.m_array_unsigned_int64;
u.m_array_unsigned_int64 = 0;
1105 delete u.m_array_int64;
u.m_array_int64 = 0;
1108 delete u.m_array_float;
u.m_array_float = 0;
1111 delete u.m_array_double;
u.m_array_double = 0;
1114 delete u.m_array_bool;
u.m_array_bool = 0;
1117 delete u.m_array_string;
u.m_array_string = 0;
1120 u.m_unsigned_int64 = 0;
#define TOOLS_VALUE_CSTOR(a_what, a_m_what, a_type)
#define TOOLS_VALUE_CSTORA(a_what, a_m_what, a_type)
#define TOOLS_VALUE_SET(a_what, a_m_what, a_type)
#define TOOLS_VALUE_GET(a_what, a_get_what, a_m_what)
#define TOOLS_VALUE_SET2(a_what, a_m_what, a_type)
#define TOOLS_ARRAY_VEC(a_what, a_get_what, a_m_what)