inlib  1.2.0
/Users/barrand/private/dev/softinex/old/inexlib-1.2/inlib/inlib/value
Go to the documentation of this file.
00001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
00002 // See the file inlib.license for terms.
00003 
00004 #ifndef inlib_value
00005 #define inlib_value
00006 
00007 #include <string>
00008 
00009 #include "array"
00010 #include "typedefs"
00011 #include "tos" //for tos
00012 
00013 #ifdef INLIB_MEM
00014 #include "mem"
00015 #endif
00016 
00017 namespace inlib {
00018 
00019 class value {
00020   static const std::string& s_class() {
00021     static const std::string s_v("inlib::value");
00022     return s_v;
00023   }
00024 public:
00025   enum e_type {
00026     NONE = 0,
00027     // integers :
00028     //UNSIGNED_CHAR = 10,
00029     //CHAR = 11,
00030     UNSIGNED_SHORT = 12,
00031     SHORT = 13,
00032     UNSIGNED_INT = 14,
00033     INT = 15,
00034     UNSIGNED_INT64 = 16,
00035     INT64 = 17,
00036     // reals :
00037     FLOAT = 30,
00038     DOUBLE = 31,
00039     // else :
00040     BOOL = 50,
00041     STRING = 51,
00042     // pointers :
00043     VOID_STAR = 100,
00044     DOUBLE_STAR = 101,
00045     FLOAT_STAR = 102,
00046     INT_STAR = 103,
00047 
00048     // multidimensional vectors (1000+base type) :
00049     //ARRAY_UNSIGNED_CHAR = 1010,
00050     //ARRAY_CHAR = 1011,
00051     ARRAY_UNSIGNED_SHORT = 1012,
00052     ARRAY_SHORT = 1013,
00053     ARRAY_UNSIGNED_INT = 1014,
00054     ARRAY_INT = 1015,
00055     ARRAY_UNSIGNED_INT64 = 1016,
00056     ARRAY_INT64 = 1017,
00057     ARRAY_FLOAT = 1030,
00058     ARRAY_DOUBLE = 1031,
00059     ARRAY_BOOL = 1050,
00060     ARRAY_STRING = 1051
00061   };
00062 public:
00063   value():m_label(0){
00064 #ifdef INLIB_MEM
00065     mem::increment(s_class().c_str());
00066 #endif
00067     m_type = NONE;
00068     u.m_unsigned_int64 = 0;
00069   }
00070 
00071   value(bool a_value):m_label(0) {
00072 #ifdef INLIB_MEM
00073     mem::increment(s_class().c_str());
00074 #endif
00075     m_type = BOOL;
00076     u.m_bool = a_value;
00077   }
00078 //  value(char a_value):m_label(0) {
00079 //#ifdef INLIB_MEM
00080 //    mem::increment(s_class().c_str());
00081 //#endif
00082 //    m_type = CHAR;
00083 //    u.m_char = a_value;
00084 //  }
00085   value(short a_value):m_label(0) {
00086 #ifdef INLIB_MEM
00087     mem::increment(s_class().c_str());
00088 #endif
00089     m_type = SHORT;
00090     u.m_short = a_value;
00091   }
00092   value(int a_value):m_label(0) {
00093 #ifdef INLIB_MEM
00094     mem::increment(s_class().c_str());
00095 #endif
00096     m_type = INT;
00097     u.m_int = a_value;
00098   }
00099   value(int64 a_value):m_label(0) {
00100 #ifdef INLIB_MEM
00101     mem::increment(s_class().c_str());
00102 #endif
00103     m_type = INT64;
00104     u.m_int64 = a_value;
00105   }
00106   value(uint64 a_value):m_label(0) {
00107 #ifdef INLIB_MEM
00108     mem::increment(s_class().c_str());
00109 #endif
00110     m_type = UNSIGNED_INT64;
00111     u.m_unsigned_int64 = a_value;
00112   }
00113   value(float a_value):m_label(0) {
00114 #ifdef INLIB_MEM
00115     mem::increment(s_class().c_str());
00116 #endif
00117     m_type = FLOAT;
00118     u.m_float = a_value;
00119   }
00120   value(double a_value):m_label(0) {
00121 #ifdef INLIB_MEM
00122     mem::increment(s_class().c_str());
00123 #endif
00124     m_type = DOUBLE;
00125     u.m_double = a_value;
00126   }
00127 
00128 //  value(unsigned char a_value):m_label(0) {
00129 //#ifdef INLIB_MEM
00130 //    mem::increment(s_class().c_str());
00131 //#endif
00132 //    m_type = UNSIGNED_CHAR;
00133 //    u.m_unsigned_char = a_value;
00134 //  }
00135   value(unsigned short a_value):m_label(0) {
00136 #ifdef INLIB_MEM
00137     mem::increment(s_class().c_str());
00138 #endif
00139     m_type = UNSIGNED_SHORT;
00140     u.m_unsigned_short = a_value;
00141   }
00142   value(unsigned int a_value):m_label(0) {
00143 #ifdef INLIB_MEM
00144     mem::increment(s_class().c_str());
00145 #endif
00146     m_type = UNSIGNED_INT;
00147     u.m_unsigned_int = a_value;
00148   }
00149   value(void* a_value):m_label(0) {
00150 #ifdef INLIB_MEM
00151     mem::increment(s_class().c_str());
00152 #endif
00153     m_type = VOID_STAR;
00154     u.m_void_star = a_value;
00155   }
00156   value(double* a_value):m_label(0) {
00157 #ifdef INLIB_MEM
00158     mem::increment(s_class().c_str());
00159 #endif
00160     m_type = DOUBLE_STAR;
00161     u.m_double_star = a_value;
00162   }
00163   value(float* a_value):m_label(0) {
00164 #ifdef INLIB_MEM
00165     mem::increment(s_class().c_str());
00166 #endif
00167     m_type = FLOAT_STAR;
00168     u.m_float_star = a_value;
00169   }
00170   value(int* a_value):m_label(0) {
00171 #ifdef INLIB_MEM
00172     mem::increment(s_class().c_str());
00173 #endif
00174     m_type = INT_STAR;
00175     u.m_int_star = a_value;
00176   }
00177 
00178   value(const char* a_value):m_label(0) {
00179 #ifdef INLIB_MEM
00180     mem::increment(s_class().c_str());
00181 #endif
00182     m_type = STRING;
00183     u.m_string = new std::string(a_value?a_value:"");
00184   }
00185   value(const std::string& a_value):m_label(0) {
00186 #ifdef INLIB_MEM
00187     mem::increment(s_class().c_str());
00188 #endif
00189     m_type = STRING;
00190     u.m_string = new std::string(a_value);
00191   }
00192 /*
00193   Value(const std::vector<double>& aValue):fLabel(0),fDimension(0){
00194     //Debug::increment("Lib::Value");
00195     fType = ARRAY_DOUBLE;
00196     std::vector<unsigned int> is(1);
00197     is[0] = aValue.size();
00198     u.f_array_double = new inlib::array<double>(is);
00199     u.f_array_double->fill(aValue);
00200   }
00201 
00202 #define SLASH_VALUE_CSTOR(a_what,a_f_what,a_type) \
00203   Value(const std::vector<unsigned int>& aOrders,\
00204                const std::vector<a_what>& aValues)\
00205   :fLabel(0),fDimension(0){\
00206     fType = a_type;\
00207     u.a_f_what = new inlib::array<a_what>(aOrders);\
00208     u.a_f_what->fill(aValues);\
00209   }
00210 
00211   SLASH_VALUE_CSTOR(unsigned char,f_array_unsigned_char,Slash::Core::IValue::ARRAY_UNSIGNED_CHAR)
00212   SLASH_VALUE_CSTOR(char,f_array_char,Slash::Core::IValue::ARRAY_CHAR)
00213   SLASH_VALUE_CSTOR(unsigned short,f_array_unsigned_short,Slash::Core::IValue::ARRAY_UNSIGNED_SHORT)
00214   SLASH_VALUE_CSTOR(short,f_array_short,Slash::Core::IValue::ARRAY_SHORT)
00215   SLASH_VALUE_CSTOR(unsigned int,f_array_unsigned_int,Slash::Core::IValue::ARRAY_UNSIGNED_INT)
00216   SLASH_VALUE_CSTOR(int,f_array_int,Slash::Core::IValue::ARRAY_INT)
00217   SLASH_VALUE_CSTOR(Slash::uint64,f_array_unsigned_int64,Slash::Core::IValue::ARRAY_UNSIGNED_INT64)
00218   SLASH_VALUE_CSTOR(Slash::int64,f_array_int64,Slash::Core::IValue::ARRAY_INT64)
00219   SLASH_VALUE_CSTOR(float,f_array_float,Slash::Core::IValue::ARRAY_FLOAT)
00220   SLASH_VALUE_CSTOR(double,f_array_double,Slash::Core::IValue::ARRAY_DOUBLE)
00221   SLASH_VALUE_CSTOR(bool,f_array_bool,Slash::Core::IValue::ARRAY_BOOL)
00222   SLASH_VALUE_CSTOR(std::string,f_array_string,Slash::Core::IValue::ARRAY_STRING)
00223 
00224 #undef SLASH_VALUE_CSTOR
00225 
00226 */
00227 
00228   virtual ~value() {
00229     delete m_label;
00230     reset();
00231 #ifdef INLIB_MEM
00232     mem::decrement(s_class().c_str());
00233 #endif
00234   }
00235 public:
00236   value(const value& a_from):m_label(0){
00237 #ifdef INLIB_MEM
00238     mem::increment(s_class().c_str());
00239 #endif
00240 
00241     if(a_from.m_label) m_label = new std::string(*a_from.m_label);
00242     m_type = a_from.m_type;
00243 
00244     if(a_from.m_type==STRING) {
00245       u.m_string = new std::string(*a_from.u.m_string);
00246 
00247     //} else if(a_from.m_type==ARRAY_UNSIGNED_CHAR) {
00248     //  u.m_array_unsigned_char = 
00249     //    new array<unsigned char>(*a_from.u.m_array_unsigned_char);
00250 
00251     //} else if(a_from.m_type==ARRAY_CHAR) {
00252     //  u.m_array_char = new array<char>(*a_from.u.m_array_char);
00253 
00254     } else if(a_from.m_type==ARRAY_UNSIGNED_SHORT) {
00255       u.m_array_unsigned_short = 
00256         new array<unsigned short>(*a_from.u.m_array_unsigned_short);
00257 
00258     } else if(a_from.m_type==ARRAY_SHORT) {
00259       u.m_array_short = new array<short>(*a_from.u.m_array_short);
00260 
00261     } else if(a_from.m_type==ARRAY_UNSIGNED_INT) {
00262       u.m_array_unsigned_int = 
00263         new array<unsigned int>(*a_from.u.m_array_unsigned_int);
00264 
00265     } else if(a_from.m_type==ARRAY_INT) {
00266       u.m_array_int = new array<int>(*a_from.u.m_array_int);
00267 
00268     } else if(a_from.m_type==ARRAY_UNSIGNED_INT64) {
00269       u.m_array_unsigned_int64 = 
00270         new array<uint64>(*a_from.u.m_array_unsigned_int64);
00271 
00272     } else if(a_from.m_type==ARRAY_INT64) {
00273       u.m_array_int64 = new array<int64>(*a_from.u.m_array_int64);
00274 
00275     } else if(a_from.m_type==ARRAY_FLOAT) {
00276       u.m_array_float = new array<float>(*a_from.u.m_array_float);
00277 
00278     } else if(a_from.m_type==ARRAY_DOUBLE) {
00279       u.m_array_double = new array<double>(*a_from.u.m_array_double);
00280 
00281     } else if(a_from.m_type==ARRAY_BOOL) {
00282       u.m_array_bool = new array<bool>(*a_from.u.m_array_bool);
00283 
00284     } else if(a_from.m_type==ARRAY_STRING) {
00285       u.m_array_string = new array<std::string>(*a_from.u.m_array_string);
00286 
00287     } else {
00288       u = a_from.u;
00289     }
00290   }
00291 
00292   value& operator=(const value& a_from) {
00293     delete m_label;
00294     m_label = 0;
00295     if(a_from.m_label) m_label = new std::string(*a_from.m_label);
00296     reset();
00297 
00298     m_type = a_from.m_type;
00299 
00300     if(a_from.m_type==STRING) {
00301       u.m_string = new std::string(*a_from.u.m_string);
00302 
00303     //} else if(a_from.m_type==ARRAY_UNSIGNED_CHAR) {
00304     //  u.m_array_unsigned_char =
00305     //    new array<unsigned char>(*a_from.u.m_array_unsigned_char);
00306 
00307     //} else if(a_from.m_type==ARRAY_CHAR) {
00308     //  u.m_array_char = new array<char>(*a_from.u.m_array_char);
00309 
00310     } else if(a_from.m_type==ARRAY_UNSIGNED_SHORT) {
00311       u.m_array_unsigned_short = 
00312         new array<unsigned short>(*a_from.u.m_array_unsigned_short);
00313 
00314     } else if(a_from.m_type==ARRAY_SHORT) {
00315       u.m_array_short = new array<short>(*a_from.u.m_array_short);
00316 
00317     } else if(a_from.m_type==ARRAY_UNSIGNED_INT) {
00318       u.m_array_unsigned_int = 
00319         new array<unsigned int>(*a_from.u.m_array_unsigned_int);
00320 
00321     } else if(a_from.m_type==ARRAY_INT) {
00322       u.m_array_int = new array<int>(*a_from.u.m_array_int);
00323 
00324     } else if(a_from.m_type==ARRAY_UNSIGNED_INT64) {
00325       u.m_array_unsigned_int64 = 
00326         new array<uint64>(*a_from.u.m_array_unsigned_int64);
00327 
00328     } else if(a_from.m_type==ARRAY_INT64) {
00329       u.m_array_int64 = new array<int64>(*a_from.u.m_array_int64);
00330 
00331     } else if(a_from.m_type==ARRAY_FLOAT) {
00332       u.m_array_float = new array<float>(*a_from.u.m_array_float);
00333 
00334     } else if(a_from.m_type==ARRAY_DOUBLE) {
00335       u.m_array_double = new array<double>(*a_from.u.m_array_double);
00336 
00337     } else if(a_from.m_type==ARRAY_BOOL) {
00338       u.m_array_bool = new array<bool>(*a_from.u.m_array_bool);
00339 
00340     } else if(a_from.m_type==ARRAY_STRING) {
00341       u.m_array_string = new array<std::string>(*a_from.u.m_array_string);
00342   
00343     } else {
00344       u = a_from.u;
00345     }
00346 
00347     return *this;
00348   }
00349 public:
00350   void set_label(const std::string& a_s) {
00351     delete m_label;
00352     m_label = new std::string(a_s);
00353   }
00354   std::string label() const {return m_label?(*m_label):"";}
00355 
00356   e_type type() const {return m_type;}
00357   void set_type(e_type a_type) {
00358     reset();
00359     m_type = a_type;
00360     switch(a_type) {
00361     case NONE:      u.m_unsigned_int64 = 0;break;
00362     //case UNSIGNED_CHAR:    u.m_unsigned_char = 0;break;
00363     //case CHAR:      u.m_char = 0;break;
00364     case UNSIGNED_SHORT:   u.m_unsigned_short = 0;break;
00365     case SHORT:     u.m_short = 0;break;
00366     case UNSIGNED_INT:     u.m_unsigned_int = 0;break;
00367     case INT:       u.m_int = 0;break;
00368     case UNSIGNED_INT64:   u.m_unsigned_int64 =0;break;
00369     case INT64:     u.m_int64 = 0;break;
00370     case FLOAT:     u.m_float = 0;break;
00371     case DOUBLE:    u.m_double = 0;break;
00372     case BOOL:      u.m_bool = false;break;
00373     case VOID_STAR:        u.m_void_star = 0;break;
00374     case DOUBLE_STAR:      u.m_double_star = 0;break;
00375     case FLOAT_STAR:       u.m_float_star = 0;break;
00376     case INT_STAR:         u.m_int_star = 0;break;
00377     case STRING:       u.m_string = new std::string("");break;
00378     //case ARRAY_UNSIGNED_CHAR:
00379     //  u.m_array_unsigned_char = new inlib::array<unsigned char>();break;
00380     //case ARRAY_CHAR:u.m_array_char = new inlib::array<char>();break;
00381   
00382     case ARRAY_UNSIGNED_SHORT:
00383       u.m_array_unsigned_short = new inlib::array<unsigned short>();break;
00384     case ARRAY_SHORT:u.m_array_short = new inlib::array<short>();break;
00385   
00386     case ARRAY_UNSIGNED_INT:
00387       u.m_array_unsigned_int = new inlib::array<unsigned int>();break;
00388     case ARRAY_INT:u.m_array_int = new inlib::array<int>();break;
00389     case ARRAY_UNSIGNED_INT64:
00390       u.m_array_unsigned_int64 = new inlib::array<uint64>();break;
00391     case ARRAY_INT64:u.m_array_int64 = new inlib::array<int64>();break;
00392   
00393     case ARRAY_FLOAT:u.m_array_float = new inlib::array<float>();break;
00394     case ARRAY_DOUBLE:u.m_array_double = new inlib::array<double>();break;
00395     case ARRAY_BOOL:u.m_array_bool = new inlib::array<bool>();break;
00396     case ARRAY_STRING:u.m_array_string = new inlib::array<std::string>();break;
00397     }
00398   }
00399 
00400   void set(void* a_value) {
00401     reset();
00402     m_type = VOID_STAR;
00403     u.m_void_star = a_value;
00404   }
00405 
00406   unsigned char get_unsigned_char() const {return u.m_unsigned_char;}
00407   char get_char() const {return u.m_char;}
00408   unsigned int get_unsigned_int() const {return u.m_unsigned_int;}
00409   int get_int() const {return u.m_int;}
00410 
00411   int64 get_int64() const {return u.m_int64;}
00412   uint64 get_unsigned_int64() const {return u.m_unsigned_int64;}
00413 
00414   unsigned short get_unsigned_short() const{return u.m_unsigned_short;}
00415   short get_short() const {return u.m_short;}
00416   float get_float() const {return u.m_float;}
00417   double get_double() const {return u.m_double;}
00418   void* get_void_star() const {return u.m_void_star;}
00419   double* get_double_star() const {return u.m_double_star;}
00420   float* get_float_star() const {return u.m_float_star;}
00421   int* get_int_star() const {return u.m_int_star;}
00422   bool get_bool() const {return u.m_bool;}
00423   std::string get_string() const {return *u.m_string;}
00424 
00425 public:
00426   bool s_type(std::string& a_s) const {return s_type(m_type,a_s);}
00427   static bool s_type(inlib::value::e_type a_type,std::string& a_s){
00428     switch(a_type) {
00429     case NONE:a_s = "NONE";return true;
00430     case INT:a_s = "INT";return true;
00431     case INT64:a_s = "INT64";return true;
00432     case DOUBLE:a_s = "DOUBLE";return true;
00433     case STRING:a_s = "STRING";return true;
00434     case VOID_STAR:a_s = "VOID_STAR";return true;
00435     case DOUBLE_STAR:a_s = "DOUBLE_STAR";return true;
00436     case FLOAT_STAR:a_s = "FLOAT_STAR";return true;
00437     case INT_STAR:a_s = "INT_STAR";return true;
00438     case BOOL:a_s = "BOOL";return true;
00439     case SHORT:a_s = "SHORT";return true;
00440     case FLOAT:a_s = "FLOAT";return true;
00441     //case CHAR:a_s = "CHAR";return true;
00442     //case UNSIGNED_CHAR:a_s = "UNSIGNED_CHAR";return true;
00443     case UNSIGNED_SHORT:a_s = "UNSIGNED_SHORT";return true;
00444     case UNSIGNED_INT:a_s = "UNSIGNED_INT";return true;
00445     case UNSIGNED_INT64:a_s = "UNSIGNED_INT64";return true;
00446     //case ARRAY_UNSIGNED_CHAR:a_s = "ARRAY_UNSIGNED_CHAR";return true;
00447     //case ARRAY_CHAR:a_s = "ARRAY_CHAR";return true;
00448     case ARRAY_UNSIGNED_SHORT:a_s = "ARRAY_UNSIGNED_SHORT";return true;
00449     case ARRAY_SHORT:a_s = "ARRAY_SHORT";return true;
00450     case ARRAY_UNSIGNED_INT:a_s = "ARRAY_UNSIGNED_INT";return true;
00451     case ARRAY_INT:a_s = "ARRAY_INT";return true;
00452     case ARRAY_UNSIGNED_INT64:a_s = "ARRAY_UNSIGNED_INT64";return true;
00453     case ARRAY_INT64:a_s = "ARRAY_INT64";return true;
00454     case ARRAY_FLOAT:a_s = "ARRAY_FLOAT";return true;
00455     case ARRAY_DOUBLE:a_s = "ARRAY_DOUBLE";return true;
00456     case ARRAY_BOOL:a_s = "ARRAY_BOOL";return true;
00457     case ARRAY_STRING:a_s = "ARRAY_STRING";return true;
00458     default:a_s.clear();return false;
00459     }
00460 
00461   }
00462   bool tos(std::string& a_s) const {return tos(*this,a_s);}
00463 
00464   static bool tos(const value& a_v,std::string& a_s){
00465     switch(a_v.m_type) {
00466     case NONE:
00467       inlib::sprintf(a_s,5,"(nil)");
00468       return true;
00469     case INT:
00470       inlib::sprintf(a_s,16,"%d",a_v.u.m_int);
00471       return true;
00472     case DOUBLE:
00473       inlib::sprintf(a_s,16,"%g",a_v.u.m_double);
00474       return true;
00475     case VOID_STAR:
00476       inlib::sprintf(a_s,16,"0x%lx",(unsigned long)a_v.u.m_void_star);
00477       return true;
00478     case UNSIGNED_SHORT:
00479       inlib::sprintf(a_s,16,"%u",a_v.u.m_unsigned_short);
00480       return true;
00481     case UNSIGNED_INT:
00482       inlib::sprintf(a_s,16,"%u",a_v.u.m_unsigned_int);
00483       return true;
00484     case BOOL:
00485       inlib::sprintf(a_s,5,"%s",a_v.u.m_bool?"true":"false");
00486       return true;
00487     case SHORT:
00488       inlib::sprintf(a_s,16,"%d",a_v.u.m_short);
00489       return true;
00490     case INT64:
00491       inlib::sprintf(a_s,16,inlib::int64_format(),a_v.u.m_int64);
00492       return true;
00493     case UNSIGNED_INT64:
00494       inlib::sprintf(a_s,16,inlib::int64_format(),a_v.u.m_unsigned_int64);
00495       return true;
00496     case FLOAT:
00497       inlib::sprintf(a_s,16,"%g",a_v.u.m_float);
00498       return true;
00499     //case UNSIGNED_CHAR:
00500     //  inlib::sprintf(a_s,16,"%c",a_v.u.m_unsigned_char);
00501     //  return true;
00502     //case CHAR:
00503     //  inlib::sprintf(a_s,16,"%c",a_v.u.m_char);
00504     //  return true;
00505     case DOUBLE_STAR:
00506       inlib::sprintf(a_s,16,"0x%lx",(unsigned long)a_v.u.m_double_star);
00507       return true;
00508     case FLOAT_STAR:
00509       inlib::sprintf(a_s,16,"0x%lx",(unsigned long)a_v.u.m_float_star);
00510       return true;
00511     case INT_STAR:
00512       inlib::sprintf(a_s,16,"0x%lx",(unsigned long)a_v.u.m_int_star);
00513       return true;
00514     case STRING:
00515       a_s = *a_v.u.m_string;
00516       return true;
00517 
00518     //case ARRAY_UNSIGNED_CHAR:
00519     //  a_s = inlib::tos<unsigned char>(a_v.u.m_array_unsigned_char->vector());
00520     //  return true;
00521     //case ARRAY_CHAR:
00522     //  a_s = inlib::tos<char>(a_v.u.m_array_char->vector());
00523     //  return true;
00524   
00525     case ARRAY_UNSIGNED_SHORT:
00526       a_s = inlib::tos<unsigned short>(a_v.u.m_array_unsigned_short->vector());
00527       return true;
00528     case ARRAY_SHORT:
00529       a_s = inlib::tos<short>(a_v.u.m_array_short->vector());
00530       return true;
00531   
00532     case ARRAY_UNSIGNED_INT:
00533       a_s = inlib::tos<unsigned int>(a_v.u.m_array_unsigned_int->vector());
00534       return true;
00535     case ARRAY_INT:
00536       a_s = inlib::tos<int>(a_v.u.m_array_int->vector());
00537       return true;
00538   
00539     case ARRAY_UNSIGNED_INT64:
00540       a_s = inlib::tos<uint64>(a_v.u.m_array_unsigned_int64->vector());
00541       return true;
00542     case ARRAY_INT64:
00543       a_s = inlib::tos<int64>(a_v.u.m_array_int64->vector());
00544       return true;
00545   
00546     case ARRAY_FLOAT:
00547       a_s = inlib::tos<float>(a_v.u.m_array_float->vector());
00548       return true;
00549     case ARRAY_DOUBLE:
00550       a_s = inlib::tos<double>(a_v.u.m_array_double->vector());
00551       return true;
00552     case ARRAY_BOOL:
00553       a_s = inlib::tos<bool>(a_v.u.m_array_bool->vector());
00554       return true;
00555     case ARRAY_STRING:
00556       a_s = inlib::tos<std::string>(a_v.u.m_array_string->vector());
00557       return true;
00558     default:
00559       a_s.clear();  
00560       return false;
00561     }
00562   }
00563 /*
00564 */
00565 protected:
00566   void reset() {
00567     if(m_type==STRING) {
00568       delete u.m_string;
00569       u.m_string = 0;
00570   
00571     //} else if(m_type==ARRAY_UNSIGNED_CHAR) {
00572     //  delete u.m_array_unsigned_char;u.m_array_unsigned_char = 0;
00573 
00574     //} else if(m_type==ARRAY_CHAR) {
00575     //  delete u.m_array_char;u.m_array_char = 0;
00576 
00577     } else if(m_type==ARRAY_UNSIGNED_SHORT) {
00578       delete u.m_array_unsigned_short;u.m_array_unsigned_short = 0;
00579 
00580     } else if(m_type==ARRAY_SHORT) {
00581       delete u.m_array_short;u.m_array_short = 0;
00582 
00583     } else if(m_type==ARRAY_UNSIGNED_INT) {
00584       delete u.m_array_unsigned_int;u.m_array_unsigned_int = 0;
00585 
00586     } else if(m_type==ARRAY_INT) {
00587       delete u.m_array_int;u.m_array_int = 0;
00588 
00589     } else if(m_type==ARRAY_UNSIGNED_INT64) {
00590       delete u.m_array_unsigned_int64;u.m_array_unsigned_int64 = 0;
00591 
00592     } else if(m_type==ARRAY_INT64) {
00593       delete u.m_array_int64;u.m_array_int64 = 0;
00594 
00595     } else if(m_type==ARRAY_FLOAT) {
00596       delete u.m_array_float;u.m_array_float = 0;
00597 
00598     } else if(m_type==ARRAY_DOUBLE) {
00599       delete u.m_array_double;u.m_array_double = 0;
00600 
00601     } else if(m_type==ARRAY_BOOL) {
00602       delete u.m_array_bool;u.m_array_bool = 0;
00603 
00604     } else if(m_type==ARRAY_STRING) {
00605       delete u.m_array_string;u.m_array_string = 0;
00606 
00607     } else {
00608       u.m_unsigned_int64 = 0;
00609     }
00610   }
00611 protected:
00612   std::string* m_label;
00613   //unsigned int m_dim;
00614 protected:
00615   e_type m_type;
00616   union {
00617     bool m_bool;
00618     char m_char;
00619     int m_int;
00620     short m_short;
00621     int64 m_int64;
00622     float m_float;
00623     double m_double;
00624     unsigned char m_unsigned_char;
00625     unsigned short m_unsigned_short;
00626     unsigned int m_unsigned_int;
00627     uint64 m_unsigned_int64;
00628     void* m_void_star;
00629     double* m_double_star;
00630     float* m_float_star;
00631     int* m_int_star;
00632     std::string* m_string;
00633 
00634     inlib::array<unsigned char>* m_array_unsigned_char;
00635     inlib::array<char>* m_array_char;
00636     inlib::array<unsigned short>* m_array_unsigned_short;
00637     inlib::array<short>* m_array_short;
00638     inlib::array<uint64>* m_array_unsigned_int64;
00639     inlib::array<int64>* m_array_int64;
00640     inlib::array<unsigned int>* m_array_unsigned_int;
00641     inlib::array<int>* m_array_int;
00642     inlib::array<float>* m_array_float;
00643     inlib::array<double>* m_array_double;
00644     inlib::array<bool>* m_array_bool;
00645     inlib::array<std::string>* m_array_string;
00646   } u;
00647 };
00648 
00649 }
00650 
00651 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines