g4tools  5.4.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tools::value Class Reference
Collaboration diagram for tools::value:
Collaboration graph
[legend]

Public Types

enum  e_type {
  NONE = 0, UNSIGNED_SHORT = 12, SHORT = 13, UNSIGNED_INT = 14,
  INT = 15, UNSIGNED_INT64 = 16, INT64 = 17, FLOAT = 30,
  DOUBLE = 31, BOOL = 50, STRING = 51, VOID_STAR = 100,
  DOUBLE_STAR = 101, FLOAT_STAR = 102, INT_STAR = 103, ARRAY_UNSIGNED_SHORT = 1012,
  ARRAY_SHORT = 1013, ARRAY_UNSIGNED_INT = 1014, ARRAY_INT = 1015, ARRAY_UNSIGNED_INT64 = 1016,
  ARRAY_INT64 = 1017, ARRAY_FLOAT = 1030, ARRAY_DOUBLE = 1031, ARRAY_BOOL = 1050,
  ARRAY_STRING = 1051
}
 

Public Member Functions

 value ()
 
 value (bool a_value)
 
 value (short a_value)
 
 value (int a_value)
 
 value (int64 a_value)
 
 value (uint64 a_value)
 
 value (float a_value)
 
 value (double a_value)
 
 value (unsigned short a_value)
 
 value (unsigned int a_value)
 
 value (void *a_value)
 
 value (double *a_value)
 
 value (float *a_value)
 
 value (int *a_value)
 
 value (const char *a_value)
 
 value (const std::string &a_value)
 
virtual ~value ()
 
 value (const value &a_from)
 
valueoperator= (const value &a_from)
 
void set_itag (unsigned int a_itag)
 
unsigned int itag () const
 
void set_label (const std::string &a_s)
 
const std::string & label () const
 
e_type type () const
 
void set_type (e_type a_type)
 
void set_none ()
 
void set (short a_value)
 
void set (unsigned short a_value)
 
void set (int a_value)
 
void set (unsigned int a_value)
 
void set (int64 a_value)
 
void set (uint64 a_value)
 
void set (float a_value)
 
void set (double a_value)
 
void set (bool a_value)
 
void set (const std::string &a_value)
 
void set (const char *a_value)
 
void set (void *a_value)
 
void set (double *a_value)
 
void set (float *a_value)
 
void set (int *a_value)
 
unsigned int get_unsigned_int () const
 
int get_int () const
 
int64 get_int64 () const
 
uint64 get_unsigned_int64 () const
 
unsigned short get_unsigned_short () const
 
short get_short () const
 
float get_float () const
 
double get_double () const
 
void * get_void_star () const
 
double * get_double_star () const
 
float * get_float_star () const
 
int * get_int_star () const
 
bool get_bool () const
 
const std::string & get_string () const
 
bool s_type (std::string &a_s) const
 
bool tos (std::string &a_s) const
 
bool to_double (double &a_d) const
 
bool is_array () const
 
size_t array_size () const
 
std::string stype () const
 

Static Public Member Functions

static bool s_type (value::e_type a_type, std::string &a_s)
 
static bool tos (const value &a_v, std::string &a_s)
 
static std::string stype (e_type a_type)
 
static std::string error_div_zero ()
 
static bool assign (value &, const value &, std::string &)
 
static bool minus (value &, std::string &)
 
static bool do_not (value &, std::string &)
 
static bool add (value &, const value &, std::string &)
 
static bool subtract (value &, const value &, std::string &)
 
static bool multiply (value &, const value &, std::string &)
 
static bool divide (value &, const value &, std::string &)
 
static bool if_gt (value &, const value &, std::string &)
 
static bool if_eq (value &, const value &, std::string &)
 
static bool if_ne (value &aThis, const value &aV, std::string &aError)
 
static bool if_ge (value &aThis, const value &aV, std::string &aError)
 
static bool if_lt (value &aThis, const value &aV, std::string &aError)
 
static bool if_le (value &aThis, const value &aV, std::string &aError)
 
static bool if_and (value &, const value &, std::string &)
 
static bool if_or (value &, const value &, std::string &)
 
static bool to_double (const value &, double &)
 
static bool cxx_type (const value &, std::string &)
 
static std::string to_string (const value &)
 

Protected Member Functions

void reset ()
 

Protected Attributes

std::string * m_label
 
unsigned int m_itag
 
e_type m_type
 
union {
   bool   m_bool
 
   int   m_int
 
   short   m_short
 
   int64   m_int64
 
   float   m_float
 
   double   m_double
 
   unsigned short   m_unsigned_short
 
   unsigned int   m_unsigned_int
 
   uint64   m_unsigned_int64
 
   void *   m_void_star
 
   double *   m_double_star
 
   float *   m_float_star
 
   int *   m_int_star
 
   std::string *   m_string
 
   array< unsigned char > *   m_array_unsigned_char
 
   array< char > *   m_array_char
 
   array< unsigned short > *   m_array_unsigned_short
 
   array< short > *   m_array_short
 
   array< uint64 > *   m_array_unsigned_int64
 
   array< int64 > *   m_array_int64
 
   array< unsigned int > *   m_array_unsigned_int
 
   array< int > *   m_array_int
 
   array< float > *   m_array_float
 
   array< double > *   m_array_double
 
   array< bool > *   m_array_bool
 
   array< std::string > *   m_array_string
 
u
 

Detailed Description

Definition at line 18 of file value.

Member Enumeration Documentation

◆ e_type

Enumerator
NONE 
UNSIGNED_SHORT 
SHORT 
UNSIGNED_INT 
INT 
UNSIGNED_INT64 
INT64 
FLOAT 
DOUBLE 
BOOL 
STRING 
VOID_STAR 
DOUBLE_STAR 
FLOAT_STAR 
INT_STAR 
ARRAY_UNSIGNED_SHORT 
ARRAY_SHORT 
ARRAY_UNSIGNED_INT 
ARRAY_INT 
ARRAY_UNSIGNED_INT64 
ARRAY_INT64 
ARRAY_FLOAT 
ARRAY_DOUBLE 
ARRAY_BOOL 
ARRAY_STRING 

Definition at line 24 of file value.

24  {
25  NONE = 0,
26  // integers :
27  //UNSIGNED_CHAR = 10,
28  //CHAR = 11,
29  UNSIGNED_SHORT = 12,
30  SHORT = 13,
31  UNSIGNED_INT = 14,
32  INT = 15,
33  UNSIGNED_INT64 = 16,
34  INT64 = 17,
35  // reals :
36  FLOAT = 30,
37  DOUBLE = 31,
38  // else :
39  BOOL = 50,
40  STRING = 51,
41  // pointers :
42  VOID_STAR = 100,
43  DOUBLE_STAR = 101,
44  FLOAT_STAR = 102,
45  INT_STAR = 103,
46 
47  // multidimensional vectors (1000+base type) :
48  //ARRAY_UNSIGNED_CHAR = 1010,
49  //ARRAY_CHAR = 1011,
50  ARRAY_UNSIGNED_SHORT = 1012,
51  ARRAY_SHORT = 1013,
52  ARRAY_UNSIGNED_INT = 1014,
53  ARRAY_INT = 1015,
54  ARRAY_UNSIGNED_INT64 = 1016,
55  ARRAY_INT64 = 1017,
56  ARRAY_FLOAT = 1030,
57  ARRAY_DOUBLE = 1031,
58  ARRAY_BOOL = 1050,
59  ARRAY_STRING = 1051
60  };

Constructor & Destructor Documentation

◆ value() [1/17]

tools::value::value ( )
inline

Definition at line 79 of file value.

79  :m_label(0),m_itag(0){
80 #ifdef TOOLS_MEM
81  mem::increment(s_class().c_str());
82 #endif
83  m_type = NONE;
84  u.m_unsigned_int64 = 0;
85  }

◆ value() [2/17]

tools::value::value ( bool  a_value)
inline

Definition at line 87 of file value.

87  :m_label(0),m_itag(0) {
88 #ifdef TOOLS_MEM
89  mem::increment(s_class().c_str());
90 #endif
91  m_type = BOOL;
92  u.m_bool = a_value;
93  }

◆ value() [3/17]

tools::value::value ( short  a_value)
inline

Definition at line 101 of file value.

101  :m_label(0),m_itag(0) {
102 #ifdef TOOLS_MEM
103  mem::increment(s_class().c_str());
104 #endif
105  m_type = SHORT;
106  u.m_short = a_value;
107  }

◆ value() [4/17]

tools::value::value ( int  a_value)
inline

Definition at line 108 of file value.

108  :m_label(0),m_itag(0) {
109 #ifdef TOOLS_MEM
110  mem::increment(s_class().c_str());
111 #endif
112  m_type = INT;
113  u.m_int = a_value;
114  }

◆ value() [5/17]

tools::value::value ( int64  a_value)
inline

Definition at line 115 of file value.

115  :m_label(0),m_itag(0) {
116 #ifdef TOOLS_MEM
117  mem::increment(s_class().c_str());
118 #endif
119  m_type = INT64;
120  u.m_int64 = a_value;
121  }

◆ value() [6/17]

tools::value::value ( uint64  a_value)
inline

Definition at line 122 of file value.

122  :m_label(0),m_itag(0) {
123 #ifdef TOOLS_MEM
124  mem::increment(s_class().c_str());
125 #endif
127  u.m_unsigned_int64 = a_value;
128  }

◆ value() [7/17]

tools::value::value ( float  a_value)
inline

Definition at line 129 of file value.

129  :m_label(0),m_itag(0) {
130 #ifdef TOOLS_MEM
131  mem::increment(s_class().c_str());
132 #endif
133  m_type = FLOAT;
134  u.m_float = a_value;
135  }

◆ value() [8/17]

tools::value::value ( double  a_value)
inline

Definition at line 136 of file value.

136  :m_label(0),m_itag(0) {
137 #ifdef TOOLS_MEM
138  mem::increment(s_class().c_str());
139 #endif
140  m_type = DOUBLE;
141  u.m_double = a_value;
142  }

◆ value() [9/17]

tools::value::value ( unsigned short  a_value)
inline

Definition at line 151 of file value.

151  :m_label(0),m_itag(0) {
152 #ifdef TOOLS_MEM
153  mem::increment(s_class().c_str());
154 #endif
156  u.m_unsigned_short = a_value;
157  }

◆ value() [10/17]

tools::value::value ( unsigned int  a_value)
inline

Definition at line 158 of file value.

158  :m_label(0),m_itag(0) {
159 #ifdef TOOLS_MEM
160  mem::increment(s_class().c_str());
161 #endif
163  u.m_unsigned_int = a_value;
164  }

◆ value() [11/17]

tools::value::value ( void *  a_value)
inline

Definition at line 165 of file value.

165  :m_label(0),m_itag(0) {
166 #ifdef TOOLS_MEM
167  mem::increment(s_class().c_str());
168 #endif
169  m_type = VOID_STAR;
170  u.m_void_star = a_value;
171  }

◆ value() [12/17]

tools::value::value ( double *  a_value)
inline

Definition at line 172 of file value.

172  :m_label(0),m_itag(0) {
173 #ifdef TOOLS_MEM
174  mem::increment(s_class().c_str());
175 #endif
177  u.m_double_star = a_value;
178  }

◆ value() [13/17]

tools::value::value ( float *  a_value)
inline

Definition at line 179 of file value.

179  :m_label(0),m_itag(0) {
180 #ifdef TOOLS_MEM
181  mem::increment(s_class().c_str());
182 #endif
183  m_type = FLOAT_STAR;
184  u.m_float_star = a_value;
185  }

◆ value() [14/17]

tools::value::value ( int *  a_value)
inline

Definition at line 186 of file value.

186  :m_label(0),m_itag(0) {
187 #ifdef TOOLS_MEM
188  mem::increment(s_class().c_str());
189 #endif
190  m_type = INT_STAR;
191  u.m_int_star = a_value;
192  }

◆ value() [15/17]

tools::value::value ( const char *  a_value)
inline

Definition at line 194 of file value.

194  :m_label(0),m_itag(0) {
195 #ifdef TOOLS_MEM
196  mem::increment(s_class().c_str());
197 #endif
198  m_type = STRING;
199  u.m_string = new std::string(a_value?a_value:"");
200  }

◆ value() [16/17]

tools::value::value ( const std::string &  a_value)
inline

Definition at line 201 of file value.

201  :m_label(0),m_itag(0) {
202 #ifdef TOOLS_MEM
203  mem::increment(s_class().c_str());
204 #endif
205  m_type = STRING;
206  u.m_string = new std::string(a_value);
207  }

◆ ~value()

virtual tools::value::~value ( )
inlinevirtual

Definition at line 275 of file value.

275  {
276  delete m_label;
277  reset();
278 #ifdef TOOLS_MEM
279  mem::decrement(s_class().c_str());
280 #endif
281  }

◆ value() [17/17]

tools::value::value ( const value a_from)
inline

Definition at line 283 of file value.

283  :m_label(0),m_itag(a_from.m_itag){
284 #ifdef TOOLS_MEM
285  mem::increment(s_class().c_str());
286 #endif
287 
288  if(a_from.m_label) m_label = new std::string(*a_from.m_label);
289  m_type = a_from.m_type;
290 
291  if(a_from.m_type==STRING) {
292  u.m_string = new std::string(*a_from.u.m_string);
293 
294  //} else if(a_from.m_type==ARRAY_UNSIGNED_CHAR) {
295  // u.m_array_unsigned_char =
296  // new array<unsigned char>(*a_from.u.m_array_unsigned_char);
297 
298  //} else if(a_from.m_type==ARRAY_CHAR) {
299  // u.m_array_char = new array<char>(*a_from.u.m_array_char);
300 
301  } else if(a_from.m_type==ARRAY_UNSIGNED_SHORT) {
302  u.m_array_unsigned_short =
303  new array<unsigned short>(*a_from.u.m_array_unsigned_short);
304 
305  } else if(a_from.m_type==ARRAY_SHORT) {
306  u.m_array_short = new array<short>(*a_from.u.m_array_short);
307 
308  } else if(a_from.m_type==ARRAY_UNSIGNED_INT) {
309  u.m_array_unsigned_int = new array<unsigned int>(*a_from.u.m_array_unsigned_int);
310 
311  } else if(a_from.m_type==ARRAY_INT) {
312  u.m_array_int = new array<int>(*a_from.u.m_array_int);
313 
314  } else if(a_from.m_type==ARRAY_UNSIGNED_INT64) {
315  u.m_array_unsigned_int64 = new array<uint64>(*a_from.u.m_array_unsigned_int64);
316 
317  } else if(a_from.m_type==ARRAY_INT64) {
318  u.m_array_int64 = new array<int64>(*a_from.u.m_array_int64);
319 
320  } else if(a_from.m_type==ARRAY_FLOAT) {
321  u.m_array_float = new array<float>(*a_from.u.m_array_float);
322 
323  } else if(a_from.m_type==ARRAY_DOUBLE) {
324  u.m_array_double = new array<double>(*a_from.u.m_array_double);
325 
326  } else if(a_from.m_type==ARRAY_BOOL) {
327  u.m_array_bool = new array<bool>(*a_from.u.m_array_bool);
328 
329  } else if(a_from.m_type==ARRAY_STRING) {
330  u.m_array_string = new array<std::string>(*a_from.u.m_array_string);
331 
332  } else {
333  u = a_from.u;
334  }
335  }

Member Function Documentation

◆ add()

static bool tools::value::add ( value ,
const value ,
std::string &   
)
static

◆ array_size()

size_t tools::value::array_size ( ) const
inline

Definition at line 941 of file value.

941  {
942  switch(m_type) {
943  case INT:
944  case DOUBLE:
945  case UNSIGNED_SHORT:
946  case UNSIGNED_INT:
947  case SHORT:
948  case INT64:
949  case UNSIGNED_INT64:
950  case FLOAT:
951  //case UNSIGNED_CHAR:
952  //case CHAR:
953  case BOOL:
954  case NONE:
955  case STRING:
956  case VOID_STAR:
957  case DOUBLE_STAR:
958  case FLOAT_STAR:
959  case INT_STAR:
960  return 0;
961 
962  //case ARRAY_UNSIGNED_CHAR:
963  //case ARRAY_CHAR:
965  return u.m_array_unsigned_short->size();
966  case ARRAY_SHORT:
967  return u.m_array_short->size();
968  case ARRAY_UNSIGNED_INT:
969  return u.m_array_unsigned_int->size();
970  case ARRAY_INT:
971  return u.m_array_int->size();
973  return u.m_array_unsigned_int64->size();
974  case ARRAY_INT64:
975  return u.m_array_int64->size();
976  case ARRAY_FLOAT:
977  return u.m_array_float->size();
978  case ARRAY_DOUBLE:
979  return u.m_array_double->size();
980  case ARRAY_BOOL:
981  return u.m_array_bool->size();
982  case ARRAY_STRING:
983  return u.m_array_string->size();
984  }
985  return 0;
986  }

◆ assign()

static bool tools::value::assign ( value ,
const value ,
std::string &   
)
static

◆ cxx_type()

static bool tools::value::cxx_type ( const value ,
std::string &   
)
static

◆ divide()

static bool tools::value::divide ( value ,
const value ,
std::string &   
)
static

◆ do_not()

static bool tools::value::do_not ( value ,
std::string &   
)
static

◆ error_div_zero()

static std::string tools::value::error_div_zero ( )
inlinestatic

Definition at line 1021 of file value.

1021 {return "divide by zero.";}

◆ get_bool()

bool tools::value::get_bool ( ) const
inline

Definition at line 595 of file value.

595 {return u.m_bool;}

◆ get_double()

double tools::value::get_double ( ) const
inline

Definition at line 590 of file value.

590 {return u.m_double;}

◆ get_double_star()

double* tools::value::get_double_star ( ) const
inline

Definition at line 592 of file value.

592 {return u.m_double_star;}

◆ get_float()

float tools::value::get_float ( ) const
inline

Definition at line 589 of file value.

589 {return u.m_float;}

◆ get_float_star()

float* tools::value::get_float_star ( ) const
inline

Definition at line 593 of file value.

593 {return u.m_float_star;}

◆ get_int()

int tools::value::get_int ( ) const
inline

Definition at line 582 of file value.

582 {return u.m_int;}

◆ get_int64()

int64 tools::value::get_int64 ( ) const
inline

Definition at line 584 of file value.

584 {return u.m_int64;}

◆ get_int_star()

int* tools::value::get_int_star ( ) const
inline

Definition at line 594 of file value.

594 {return u.m_int_star;}

◆ get_short()

short tools::value::get_short ( ) const
inline

Definition at line 588 of file value.

588 {return u.m_short;}

◆ get_string()

const std::string& tools::value::get_string ( ) const
inline

Definition at line 597 of file value.

597 {return *u.m_string;}

◆ get_unsigned_int()

unsigned int tools::value::get_unsigned_int ( ) const
inline

Definition at line 581 of file value.

581 {return u.m_unsigned_int;}

◆ get_unsigned_int64()

uint64 tools::value::get_unsigned_int64 ( ) const
inline

Definition at line 585 of file value.

585 {return u.m_unsigned_int64;}

◆ get_unsigned_short()

unsigned short tools::value::get_unsigned_short ( ) const
inline

Definition at line 587 of file value.

587 {return u.m_unsigned_short;}

◆ get_void_star()

void* tools::value::get_void_star ( ) const
inline

Definition at line 591 of file value.

591 {return u.m_void_star;}

◆ if_and()

static bool tools::value::if_and ( value ,
const value ,
std::string &   
)
static

◆ if_eq()

static bool tools::value::if_eq ( value ,
const value ,
std::string &   
)
static

◆ if_ge()

static bool tools::value::if_ge ( value aThis,
const value aV,
std::string &  aError 
)
inlinestatic

Definition at line 1043 of file value.

1044  {
1045  value tmp(aThis);
1046  if(!if_eq(aThis,aV,aError)) return false;
1047  if(aThis.u.m_bool) return true;
1048  // then not equal, check gt :
1049  if(!if_gt(tmp,aV,aError)) return false;
1050  aThis.u.m_bool = tmp.u.m_bool;
1051  return true;
1052  }

◆ if_gt()

static bool tools::value::if_gt ( value ,
const value ,
std::string &   
)
static

◆ if_le()

static bool tools::value::if_le ( value aThis,
const value aV,
std::string &  aError 
)
inlinestatic

Definition at line 1061 of file value.

1062  {
1063  if(!if_gt(aThis,aV,aError)) return false;
1064  aThis.u.m_bool = (aThis.u.m_bool?false:true);
1065  return true;
1066  }

◆ if_lt()

static bool tools::value::if_lt ( value aThis,
const value aV,
std::string &  aError 
)
inlinestatic

Definition at line 1054 of file value.

1055  {
1056  if(!if_ge(aThis,aV,aError)) return false;
1057  aThis.u.m_bool = (aThis.u.m_bool?false:true);
1058  return true;
1059  }

◆ if_ne()

static bool tools::value::if_ne ( value aThis,
const value aV,
std::string &  aError 
)
inlinestatic

Definition at line 1037 of file value.

1038  {
1039  if(!if_eq(aThis,aV,aError)) return false;
1040  aThis.u.m_bool = (aThis.u.m_bool?false:true);
1041  return true;
1042  }

◆ if_or()

static bool tools::value::if_or ( value ,
const value ,
std::string &   
)
static

◆ is_array()

bool tools::value::is_array ( ) const
inline

Definition at line 903 of file value.

903  {
904  switch(m_type) {
905  case INT:
906  case DOUBLE:
907  case UNSIGNED_SHORT:
908  case UNSIGNED_INT:
909  case SHORT:
910  case INT64:
911  case UNSIGNED_INT64:
912  case FLOAT:
913  //case UNSIGNED_CHAR:
914  //case CHAR:
915  case BOOL:
916  case NONE:
917  case STRING:
918  case VOID_STAR:
919  case DOUBLE_STAR:
920  case FLOAT_STAR:
921  case INT_STAR:
922  return false;
923 
924  //case ARRAY_UNSIGNED_CHAR:
925  //case ARRAY_CHAR:
927  case ARRAY_SHORT:
928  case ARRAY_UNSIGNED_INT:
929  case ARRAY_INT:
931  case ARRAY_INT64:
932  case ARRAY_FLOAT:
933  case ARRAY_DOUBLE:
934  case ARRAY_BOOL:
935  case ARRAY_STRING:
936  return true;
937  }
938  return false;
939  }

◆ itag()

unsigned int tools::value::itag ( ) const
inline

Definition at line 433 of file value.

433 {return m_itag;} //gopaw

◆ label()

const std::string& tools::value::label ( ) const
inline

Definition at line 438 of file value.

438 {return m_label?(*m_label):s_empty();}

◆ minus()

static bool tools::value::minus ( value ,
std::string &   
)
static

◆ multiply()

static bool tools::value::multiply ( value ,
const value ,
std::string &   
)
static

◆ operator=()

value& tools::value::operator= ( const value a_from)
inline

Definition at line 337 of file value.

337  {
338  if(&a_from==this) return *this;
339 
340  delete m_label;m_label = 0;
341  if(a_from.m_label) m_label = new std::string(*a_from.m_label);
342 
343  m_itag = a_from.m_itag;
344 
345  reset();
346 
347  m_type = a_from.m_type;
348 
349  if(a_from.m_type==STRING) {
350  u.m_string = new std::string(*a_from.u.m_string);
351 
352  //} else if(a_from.m_type==ARRAY_UNSIGNED_CHAR) {
353  // u.m_array_unsigned_char =
354  // new array<unsigned char>(*a_from.u.m_array_unsigned_char);
355 
356  //} else if(a_from.m_type==ARRAY_CHAR) {
357  // u.m_array_char = new array<char>(*a_from.u.m_array_char);
358 
359  } else if(a_from.m_type==ARRAY_UNSIGNED_SHORT) {
360  u.m_array_unsigned_short = new array<unsigned short>(*a_from.u.m_array_unsigned_short);
361 
362  } else if(a_from.m_type==ARRAY_SHORT) {
363  u.m_array_short = new array<short>(*a_from.u.m_array_short);
364 
365  } else if(a_from.m_type==ARRAY_UNSIGNED_INT) {
366  u.m_array_unsigned_int = new array<unsigned int>(*a_from.u.m_array_unsigned_int);
367 
368  } else if(a_from.m_type==ARRAY_INT) {
369  u.m_array_int = new array<int>(*a_from.u.m_array_int);
370 
371  } else if(a_from.m_type==ARRAY_UNSIGNED_INT64) {
372  u.m_array_unsigned_int64 = new array<uint64>(*a_from.u.m_array_unsigned_int64);
373 
374  } else if(a_from.m_type==ARRAY_INT64) {
375  u.m_array_int64 = new array<int64>(*a_from.u.m_array_int64);
376 
377  } else if(a_from.m_type==ARRAY_FLOAT) {
378  u.m_array_float = new array<float>(*a_from.u.m_array_float);
379 
380  } else if(a_from.m_type==ARRAY_DOUBLE) {
381  u.m_array_double = new array<double>(*a_from.u.m_array_double);
382 
383  } else if(a_from.m_type==ARRAY_BOOL) {
384  u.m_array_bool = new array<bool>(*a_from.u.m_array_bool);
385 
386  } else if(a_from.m_type==ARRAY_STRING) {
387  u.m_array_string = new array<std::string>(*a_from.u.m_array_string);
388 
389  } else {
390  u = a_from.u;
391  }
392 
393  return *this;
394  }

◆ reset()

void tools::value::reset ( )
inlineprotected

Definition at line 1078 of file value.

1078  {
1079  if(m_type==STRING) {
1080  delete u.m_string;
1081  u.m_string = 0;
1082 
1083  //} else if(m_type==ARRAY_UNSIGNED_CHAR) {
1084  // delete u.m_array_unsigned_char;u.m_array_unsigned_char = 0;
1085 
1086  //} else if(m_type==ARRAY_CHAR) {
1087  // delete u.m_array_char;u.m_array_char = 0;
1088 
1089  } else if(m_type==ARRAY_UNSIGNED_SHORT) {
1090  delete u.m_array_unsigned_short;u.m_array_unsigned_short = 0;
1091 
1092  } else if(m_type==ARRAY_SHORT) {
1093  delete u.m_array_short;u.m_array_short = 0;
1094 
1095  } else if(m_type==ARRAY_UNSIGNED_INT) {
1096  delete u.m_array_unsigned_int;u.m_array_unsigned_int = 0;
1097 
1098  } else if(m_type==ARRAY_INT) {
1099  delete u.m_array_int;u.m_array_int = 0;
1100 
1101  } else if(m_type==ARRAY_UNSIGNED_INT64) {
1102  delete u.m_array_unsigned_int64;u.m_array_unsigned_int64 = 0;
1103 
1104  } else if(m_type==ARRAY_INT64) {
1105  delete u.m_array_int64;u.m_array_int64 = 0;
1106 
1107  } else if(m_type==ARRAY_FLOAT) {
1108  delete u.m_array_float;u.m_array_float = 0;
1109 
1110  } else if(m_type==ARRAY_DOUBLE) {
1111  delete u.m_array_double;u.m_array_double = 0;
1112 
1113  } else if(m_type==ARRAY_BOOL) {
1114  delete u.m_array_bool;u.m_array_bool = 0;
1115 
1116  } else if(m_type==ARRAY_STRING) {
1117  delete u.m_array_string;u.m_array_string = 0;
1118 
1119  } else {
1120  u.m_unsigned_int64 = 0;
1121  }
1122  }

◆ s_type() [1/2]

bool tools::value::s_type ( std::string &  a_s) const
inline

Definition at line 670 of file value.

670 {return s_type(m_type,a_s);}

◆ s_type() [2/2]

static bool tools::value::s_type ( value::e_type  a_type,
std::string &  a_s 
)
inlinestatic

Definition at line 672 of file value.

672  {
673  switch(a_type) {
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;
680  case DOUBLE_STAR:a_s = "DOUBLE_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;
686  //case CHAR:a_s = "CHAR";return true;
687  //case UNSIGNED_CHAR:a_s = "UNSIGNED_CHAR";return true;
688  case UNSIGNED_SHORT:a_s = "UNSIGNED_SHORT";return true;
689  case UNSIGNED_INT:a_s = "UNSIGNED_INT";return true;
690  case UNSIGNED_INT64:a_s = "UNSIGNED_INT64";return true;
691  //case ARRAY_UNSIGNED_CHAR:a_s = "ARRAY_UNSIGNED_CHAR";return true;
692  //case ARRAY_CHAR:a_s = "ARRAY_CHAR";return true;
693  case ARRAY_UNSIGNED_SHORT:a_s = "ARRAY_UNSIGNED_SHORT";return true;
694  case ARRAY_SHORT:a_s = "ARRAY_SHORT";return true;
695  case ARRAY_UNSIGNED_INT:a_s = "ARRAY_UNSIGNED_INT";return true;
696  case ARRAY_INT:a_s = "ARRAY_INT";return true;
697  case ARRAY_UNSIGNED_INT64:a_s = "ARRAY_UNSIGNED_INT64";return true;
698  case ARRAY_INT64:a_s = "ARRAY_INT64";return true;
699  case ARRAY_FLOAT:a_s = "ARRAY_FLOAT";return true;
700  case ARRAY_DOUBLE:a_s = "ARRAY_DOUBLE";return true;
701  case ARRAY_BOOL:a_s = "ARRAY_BOOL";return true;
702  case ARRAY_STRING:a_s = "ARRAY_STRING";return true;
703  default:a_s.clear();return false;
704  }
705 
706  }

◆ set() [1/15]

void tools::value::set ( bool  a_value)
inline

Definition at line 539 of file value.

539  {
540  reset();
541  m_type = BOOL;
542  u.m_bool = a_value;
543  }

◆ set() [2/15]

void tools::value::set ( const char *  a_value)
inline

Definition at line 550 of file value.

550  {
551  // To avoid the bool, const std::string& and passing "text" problem.
552  reset();
553  m_type = STRING;
554  u.m_string = new std::string(a_value);
555  }

◆ set() [3/15]

void tools::value::set ( const std::string &  a_value)
inline

Definition at line 545 of file value.

545  {
546  reset();
547  m_type = STRING;
548  u.m_string = new std::string(a_value);
549  }

◆ set() [4/15]

void tools::value::set ( double *  a_value)
inline

Definition at line 563 of file value.

563  {
564  reset();
566  u.m_double_star = a_value;
567  }

◆ set() [5/15]

void tools::value::set ( double  a_value)
inline

Definition at line 534 of file value.

534  {
535  reset();
536  m_type = DOUBLE;
537  u.m_double = a_value;
538  }

◆ set() [6/15]

void tools::value::set ( float *  a_value)
inline

Definition at line 568 of file value.

568  {
569  reset();
570  m_type = FLOAT_STAR;
571  u.m_float_star = a_value;
572  }

◆ set() [7/15]

void tools::value::set ( float  a_value)
inline

Definition at line 529 of file value.

529  {
530  reset();
531  m_type = FLOAT;
532  u.m_float = a_value;
533  }

◆ set() [8/15]

void tools::value::set ( int *  a_value)
inline

Definition at line 573 of file value.

573  {
574  reset();
575  m_type = INT_STAR;
576  u.m_int_star = a_value;
577  }

◆ set() [9/15]

void tools::value::set ( int  a_value)
inline

Definition at line 509 of file value.

509  {
510  reset();
511  m_type = INT;
512  u.m_int = a_value;
513  }

◆ set() [10/15]

void tools::value::set ( int64  a_value)
inline

Definition at line 519 of file value.

519  {
520  reset();
521  m_type = INT64;
522  u.m_int64 = a_value;
523  }

◆ set() [11/15]

void tools::value::set ( short  a_value)
inline

Definition at line 499 of file value.

499  {
500  reset();
501  m_type = SHORT;
502  u.m_short = a_value;
503  }

◆ set() [12/15]

void tools::value::set ( uint64  a_value)
inline

Definition at line 524 of file value.

524  {
525  reset();
527  u.m_unsigned_int64 = a_value;
528  }

◆ set() [13/15]

void tools::value::set ( unsigned int  a_value)
inline

Definition at line 514 of file value.

514  {
515  reset();
517  u.m_unsigned_int = a_value;
518  }

◆ set() [14/15]

void tools::value::set ( unsigned short  a_value)
inline

Definition at line 504 of file value.

504  {
505  reset();
507  u.m_unsigned_short = a_value;
508  }

◆ set() [15/15]

void tools::value::set ( void *  a_value)
inline

Definition at line 557 of file value.

557  {
558  reset();
559  m_type = VOID_STAR;
560  u.m_void_star = a_value;
561  }

◆ set_itag()

void tools::value::set_itag ( unsigned int  a_itag)
inline

Definition at line 432 of file value.

432 {m_itag = a_itag;} //gopaw

◆ set_label()

void tools::value::set_label ( const std::string &  a_s)
inline

Definition at line 434 of file value.

434  {
435  delete m_label;
436  m_label = new std::string(a_s);
437  }

◆ set_none()

void tools::value::set_none ( )
inline

Definition at line 484 of file value.

484  {
485  reset();
486  m_type = NONE;
487  u.m_unsigned_int64 = 0;
488  }

◆ set_type()

void tools::value::set_type ( e_type  a_type)
inline

Definition at line 441 of file value.

441  {
442  reset();
443  m_type = a_type;
444  switch(a_type) {
445  case NONE: u.m_unsigned_int64 = 0;break;
446  //case UNSIGNED_CHAR: u.m_unsigned_char = 0;break;
447  //case CHAR: u.m_char = 0;break;
448  case UNSIGNED_SHORT: u.m_unsigned_short = 0;break;
449  case SHORT: u.m_short = 0;break;
450  case UNSIGNED_INT: u.m_unsigned_int = 0;break;
451  case INT: u.m_int = 0;break;
452  case UNSIGNED_INT64: u.m_unsigned_int64 =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;
457  case VOID_STAR: u.m_void_star = 0;break;
458  case DOUBLE_STAR: u.m_double_star = 0;break;
459  case FLOAT_STAR: u.m_float_star = 0;break;
460  case INT_STAR: u.m_int_star = 0;break;
461  case STRING: u.m_string = new std::string("");break;
462  //case ARRAY_UNSIGNED_CHAR:
463  // u.m_array_unsigned_char = new array<unsigned char>();break;
464  //case ARRAY_CHAR:u.m_array_char = new array<char>();break;
465 
467  u.m_array_unsigned_short = new array<unsigned short>();break;
468  case ARRAY_SHORT:u.m_array_short = new array<short>();break;
469 
470  case ARRAY_UNSIGNED_INT:
471  u.m_array_unsigned_int = new array<unsigned int>();break;
472  case ARRAY_INT:u.m_array_int = new array<int>();break;
474  u.m_array_unsigned_int64 = new array<uint64>();break;
475  case ARRAY_INT64:u.m_array_int64 = new array<int64>();break;
476 
477  case ARRAY_FLOAT:u.m_array_float = new array<float>();break;
478  case ARRAY_DOUBLE:u.m_array_double = new array<double>();break;
479  case ARRAY_BOOL:u.m_array_bool = new array<bool>();break;
480  case ARRAY_STRING:u.m_array_string = new array<std::string>();break;
481  }
482  }

◆ stype() [1/2]

std::string tools::value::stype ( ) const
inline

Definition at line 1009 of file value.

1009  {
1010  std::string s;
1011  if(!s_type(s)) return "unknown";
1012  return s;
1013  }

◆ stype() [2/2]

static std::string tools::value::stype ( e_type  a_type)
inlinestatic

Definition at line 1015 of file value.

1015  {
1016  std::string s;
1017  if(!s_type(a_type,s)) return "unknown";
1018  return s;
1019  }

◆ subtract()

static bool tools::value::subtract ( value ,
const value ,
std::string &   
)
static

◆ to_double() [1/2]

static bool tools::value::to_double ( const value ,
double &   
)
static

◆ to_double() [2/2]

bool tools::value::to_double ( double &  a_d) const
inline

Definition at line 844 of file value.

844  {
845  switch(m_type) {
846  case INT:
847  a_d = u.m_int;
848  return true;
849  case DOUBLE:
850  a_d = u.m_double;
851  return true;
852  case UNSIGNED_SHORT:
853  a_d = u.m_unsigned_short;
854  return true;
855  case UNSIGNED_INT:
856  a_d = u.m_unsigned_int;
857  return true;
858  case SHORT:
859  a_d = u.m_short;
860  return true;
861  case INT64:
862  a_d = (double)u.m_int64;
863  return true;
864  case UNSIGNED_INT64:
865  a_d = (double)u.m_unsigned_int64;
866  return true;
867  case FLOAT:
868  a_d = u.m_float;
869  return true;
870  //case UNSIGNED_CHAR:
871  // a_d = u.m_unsigned_char;
872  // return true;
873  //case CHAR:
874  // a_d = u.m_char;
875  // return true;
876  case BOOL:
877  a_d = u.m_bool?1:0;
878  return true;
879  case NONE:
880  case STRING:
881  case VOID_STAR:
882  case DOUBLE_STAR:
883  case FLOAT_STAR:
884  case INT_STAR:
885  //case ARRAY_UNSIGNED_CHAR:
886  //case ARRAY_CHAR:
888  case ARRAY_SHORT:
889  case ARRAY_UNSIGNED_INT:
890  case ARRAY_INT:
892  case ARRAY_INT64:
893  case ARRAY_FLOAT:
894  case ARRAY_DOUBLE:
895  case ARRAY_BOOL:
896  case ARRAY_STRING:
897  break;
898  }
899  a_d = 0;
900  return false;
901  }

◆ to_string()

static std::string tools::value::to_string ( const value )
static

◆ tos() [1/2]

static bool tools::value::tos ( const value a_v,
std::string &  a_s 
)
inlinestatic

Definition at line 709 of file value.

709  {
710  switch(a_v.m_type) {
711  case NONE:
712  sprintf(a_s,5,"(nil)");
713  return true;
714  case BOOL:
715  sprintf(a_s,5,"%s",a_v.u.m_bool?"true":"false");
716  return true;
717  //case UNSIGNED_CHAR:
718  // sprintf(a_s,32,"%c",a_v.u.m_unsigned_char);
719  // return true;
720  //case CHAR:
721  // sprintf(a_s,32,"%c",a_v.u.m_char);
722  // return true;
723  case UNSIGNED_SHORT:
724  sprintf(a_s,32,"%u",a_v.u.m_unsigned_short);
725  return true;
726  case SHORT:
727  sprintf(a_s,32,"%d",a_v.u.m_short);
728  return true;
729  case UNSIGNED_INT:
730  sprintf(a_s,32,"%u",a_v.u.m_unsigned_int);
731  return true;
732  case INT:
733  sprintf(a_s,32,"%d",a_v.u.m_int);
734  return true;
735  case UNSIGNED_INT64:
736  sprintf(a_s,32,int64_format(),a_v.u.m_unsigned_int64);
737  return true;
738  case INT64:
739  sprintf(a_s,32,int64_format(),a_v.u.m_int64);
740  return true;
741  case FLOAT:
742  sprintf(a_s,32,"%g",a_v.u.m_float);
743  return true;
744  case DOUBLE:
745  sprintf(a_s,32,"%g",a_v.u.m_double);
746  return true;
747  case VOID_STAR:
748  sprintf(a_s,32,upointer_format_x(),(upointer)a_v.u.m_void_star);
749  return true;
750  case DOUBLE_STAR:
751  sprintf(a_s,32,upointer_format_x(),(upointer)a_v.u.m_double_star);
752  return true;
753  case FLOAT_STAR:
754  sprintf(a_s,32,upointer_format_x(),(upointer)a_v.u.m_float_star);
755  return true;
756  case INT_STAR:
757  sprintf(a_s,32,upointer_format_x(),(upointer)a_v.u.m_int_star);
758  return true;
759  case STRING:
760  a_s = *a_v.u.m_string;
761  return true;
762 
763  //case ARRAY_UNSIGNED_CHAR:
764  // a_s = tos<unsigned char>(a_v.u.m_array_unsigned_char->vector());
765  // return true;
766  //case ARRAY_CHAR:
767  // a_s = tos<char>(a_v.u.m_array_char->vector());
768  // return true;
769 
771  return nums2s<unsigned short>(a_v.u.m_array_unsigned_short->vector(),a_s);
772  case ARRAY_SHORT:
773  return nums2s<short>(a_v.u.m_array_short->vector(),a_s);
774 
775  case ARRAY_UNSIGNED_INT:
776  return nums2s<unsigned int>(a_v.u.m_array_unsigned_int->vector(),a_s);
777  case ARRAY_INT:
778  return nums2s<int>(a_v.u.m_array_int->vector(),a_s);
779 
781  return nums2s<uint64>(a_v.u.m_array_unsigned_int64->vector(),a_s);
782  case ARRAY_INT64:
783  return nums2s<int64>(a_v.u.m_array_int64->vector(),a_s);
784 
785  case ARRAY_FLOAT:
786  return nums2s<float>(a_v.u.m_array_float->vector(),a_s);
787  case ARRAY_DOUBLE:
788  return nums2s<double>(a_v.u.m_array_double->vector(),a_s);
789  case ARRAY_BOOL:
790  b2s(a_v.u.m_array_bool->vector(),a_s);
791  return true;
792  case ARRAY_STRING:
793  return nums2s<std::string>(a_v.u.m_array_string->vector(),a_s);
794  default:
795  a_s.clear();
796  return false;
797  }
798  }

◆ tos() [2/2]

bool tools::value::tos ( std::string &  a_s) const
inline

Definition at line 707 of file value.

707 {return tos(*this,a_s);}

◆ type()

e_type tools::value::type ( ) const
inline

Definition at line 440 of file value.

440 {return m_type;}

Member Data Documentation

◆ m_array_bool

array<bool>* tools::value::m_array_bool

Definition at line 1156 of file value.

◆ m_array_char

array<char>* tools::value::m_array_char

Definition at line 1147 of file value.

◆ m_array_double

array<double>* tools::value::m_array_double

Definition at line 1155 of file value.

◆ m_array_float

array<float>* tools::value::m_array_float

Definition at line 1154 of file value.

◆ m_array_int

array<int>* tools::value::m_array_int

Definition at line 1153 of file value.

◆ m_array_int64

array<int64>* tools::value::m_array_int64

Definition at line 1151 of file value.

◆ m_array_short

array<short>* tools::value::m_array_short

Definition at line 1149 of file value.

◆ m_array_string

array<std::string>* tools::value::m_array_string

Definition at line 1157 of file value.

◆ m_array_unsigned_char

array<unsigned char>* tools::value::m_array_unsigned_char

Definition at line 1146 of file value.

◆ m_array_unsigned_int

array<unsigned int>* tools::value::m_array_unsigned_int

Definition at line 1152 of file value.

◆ m_array_unsigned_int64

array<uint64>* tools::value::m_array_unsigned_int64

Definition at line 1150 of file value.

◆ m_array_unsigned_short

array<unsigned short>* tools::value::m_array_unsigned_short

Definition at line 1148 of file value.

◆ m_bool

bool tools::value::m_bool

Definition at line 1129 of file value.

◆ m_double

double tools::value::m_double

Definition at line 1135 of file value.

◆ m_double_star

double* tools::value::m_double_star

Definition at line 1141 of file value.

◆ m_float

float tools::value::m_float

Definition at line 1134 of file value.

◆ m_float_star

float* tools::value::m_float_star

Definition at line 1142 of file value.

◆ m_int

int tools::value::m_int

Definition at line 1131 of file value.

◆ m_int64

int64 tools::value::m_int64

Definition at line 1133 of file value.

◆ m_int_star

int* tools::value::m_int_star

Definition at line 1143 of file value.

◆ m_itag

unsigned int tools::value::m_itag
protected

Definition at line 1125 of file value.

◆ m_label

std::string* tools::value::m_label
protected

Definition at line 1124 of file value.

◆ m_short

short tools::value::m_short

Definition at line 1132 of file value.

◆ m_string

std::string* tools::value::m_string

Definition at line 1144 of file value.

◆ m_type

e_type tools::value::m_type
protected

Definition at line 1127 of file value.

◆ m_unsigned_int

unsigned int tools::value::m_unsigned_int

Definition at line 1138 of file value.

◆ m_unsigned_int64

uint64 tools::value::m_unsigned_int64

Definition at line 1139 of file value.

◆ m_unsigned_short

unsigned short tools::value::m_unsigned_short

Definition at line 1137 of file value.

◆ m_void_star

void* tools::value::m_void_star

Definition at line 1140 of file value.

◆ u

union { ... } tools::value::u

The documentation for this class was generated from the following file:
tools::upointer_format_x
const char * upointer_format_x()
Definition: typedefs:80
tools::value::ARRAY_SHORT
@ ARRAY_SHORT
Definition: value:51
tools::value::if_eq
static bool if_eq(value &, const value &, std::string &)
tools::value::reset
void reset()
Definition: value:1078
tools::value::ARRAY_FLOAT
@ ARRAY_FLOAT
Definition: value:56
tools::value::INT_STAR
@ INT_STAR
Definition: value:45
tools::value::FLOAT
@ FLOAT
Definition: value:36
tools::value::DOUBLE_STAR
@ DOUBLE_STAR
Definition: value:43
tools::value::UNSIGNED_SHORT
@ UNSIGNED_SHORT
Definition: value:29
tools::value::m_type
e_type m_type
Definition: value:1127
tools::value::m_itag
unsigned int m_itag
Definition: value:1125
tools::value::if_gt
static bool if_gt(value &, const value &, std::string &)
tools::value::ARRAY_DOUBLE
@ ARRAY_DOUBLE
Definition: value:57
tools::value::DOUBLE
@ DOUBLE
Definition: value:37
tools::value::ARRAY_STRING
@ ARRAY_STRING
Definition: value:59
tools::value::tos
bool tos(std::string &a_s) const
Definition: value:707
tools::value::ARRAY_UNSIGNED_INT
@ ARRAY_UNSIGNED_INT
Definition: value:52
tools::value::ARRAY_INT64
@ ARRAY_INT64
Definition: value:55
tools::value::u
union tools::value::@0 u
tools::value::ARRAY_INT
@ ARRAY_INT
Definition: value:53
tools::value::FLOAT_STAR
@ FLOAT_STAR
Definition: value:44
tools::value::VOID_STAR
@ VOID_STAR
Definition: value:42
tools::b2s
void b2s(bool a_value, std::string &a_s)
Definition: b2s:11
tools::value::STRING
@ STRING
Definition: value:40
tools::upointer
unsigned long upointer
Definition: typedefs:78
tools::int64_format
const char * int64_format()
Definition: typedefs:69
tools::value::if_ge
static bool if_ge(value &aThis, const value &aV, std::string &aError)
Definition: value:1043
tools::value::m_label
std::string * m_label
Definition: value:1124
tools::value::UNSIGNED_INT
@ UNSIGNED_INT
Definition: value:31
tools::sprintf
bool sprintf(std::string &a_string, int a_length, const char *a_format,...)
Definition: sprintf:34
tools::value::ARRAY_BOOL
@ ARRAY_BOOL
Definition: value:58
tools::value::UNSIGNED_INT64
@ UNSIGNED_INT64
Definition: value:33
tools::value::ARRAY_UNSIGNED_INT64
@ ARRAY_UNSIGNED_INT64
Definition: value:54
tools::value::SHORT
@ SHORT
Definition: value:30
tools::value::ARRAY_UNSIGNED_SHORT
@ ARRAY_UNSIGNED_SHORT
Definition: value:50
tools::value::INT
@ INT
Definition: value:32
tools::value::s_type
bool s_type(std::string &a_s) const
Definition: value:670
tools::value::value
value()
Definition: value:79
tools::value::INT64
@ INT64
Definition: value:34
tools::value::BOOL
@ BOOL
Definition: value:39
tools::value::NONE
@ NONE
Definition: value:25