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5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  2 // See the file tools.license for terms.
  3 
  4 #ifndef tools_cids
  5 #define tools_cids
  6 
  7 #include "cid"
  8 
  9 #include <string>
 10 #include "typedefs" //byte
 11 
 12 namespace tools {
 13 
 14 inline cid _cid(byte)           {return 1;}
 15 inline cid _cid(char)           {return 2;}
 16 inline cid _cid(unsigned short) {return 3;}
 17 inline cid _cid(short)          {return 4;}
 18 inline cid _cid(unsigned int)   {return 5;}
 19 inline cid _cid(int)            {return 6;}
 20 inline cid _cid(float)          {return 7;}
 21 inline cid _cid(double)         {return 8;}
 22 inline cid _cid(bool)           {return 9;}
 23 
 24 // not compiler types :
 25 inline cid _cid(uint64)             {return 10;}
 26 inline cid _cid(int64)              {return 11;}
 27 inline cid _cid(const std::string&) {return 12;}
 28 inline cid _cid(fits_bit)           {return 13;}
 29 inline cid _cid(csv_time)           {return 14;}
 30 
 31 //NOTE : avoid time_t which is defined in general as a long
 32 //       and is then ambiguous relative to int/int64.
 33 
 34 //NOTE : if adding some, it must not exceed 20. Else, you have to change
 35 //       the below for std::vector.
 36 
 37 }
 38 
 39 #include <vector>
 40 
 41 namespace tools {
 42 
 43 // For rntuple and rroot::ntuple::column_element.
 44 // The read::icolumn<T> needs a _cid(T) with T :
 45 //   std::vector< [basic_type, std::vector<basic_type>] >
 46 
 47 template <class T>
 48 inline cid _cid(const std::vector<T>&) {return 20+_cid(T());}
 49 
 50 template <class T>
 51 inline cid _cid_std_vector() {
 52   static const T s_v = T(); //do that for T = std::string.
 53   return 20+_cid(s_v);
 54 }
 55 
 56 // Then : cid for std::vector< std::vector<T> > is going to be :
 57 //   20+_cid(std::vector<T>) = 2*20+_cid(T)
 58 
 59 //WARNING : rroot/cids start at 100.
 60 //WARNING : rroot/geo_cids start at 1000.
 61 
 62 }
 63 
 64 namespace tools {
 65 
 66 inline bool cid2s(cid a_id,std::string& a_s) {
 67   // NOTE : the returned string must not contain space.
 68 
 69        if(a_id==_cid(char(0)))       {a_s = "char";return true;}
 70   else if(a_id==_cid(short(0)))      {a_s = "short";return true;}
 71   else if(a_id==_cid(int(0)))        {a_s = "int";return true;}
 72   else if(a_id==_cid(float(0)))      {a_s = "float";return true;}
 73   else if(a_id==_cid(double(0)))     {a_s = "double";return true;}
 74   else if(a_id==_cid(std::string())) {a_s = "string";return true;}
 75 
 76   // NOTE : the below do not follow the AIDA convention.
 77   else if(a_id==_cid((unsigned char)0))  {a_s = "uchar";return true;}   //AIDA=byte
 78   else if(a_id==_cid((unsigned short)0)) {a_s = "ushort";return true;}  //AIDA not defined
 79   else if(a_id==_cid((unsigned int)0))   {a_s = "uint";return true;}    //AIDA not defined
 80   else if(a_id==_cid(bool(true)))        {a_s = "bool";return true;}    //AIDA=boolean
 81   else if(a_id==_cid(int64(0)))          {a_s = "int64";return true;}   //AIDA=long
 82   else if(a_id==_cid(uint64(0)))         {a_s = "uint64";return true;}  //AIDA=not defined
 83 
 84   else if(a_id==_cid_std_vector<char>())        {a_s = "char[]";return true;}
 85   else if(a_id==_cid_std_vector<short>())       {a_s = "short[]";return true;}
 86   else if(a_id==_cid_std_vector<int>())         {a_s = "int[]";return true;}
 87   else if(a_id==_cid_std_vector<float>())       {a_s = "float[]";return true;}
 88   else if(a_id==_cid_std_vector<double>())      {a_s = "double[]";return true;}
 89   else if(a_id==_cid_std_vector<std::string>()) {a_s = "string[]";return true;}
 90 
 91   else if(a_id==_cid_std_vector<unsigned char>())        {a_s = "uchar[]";return true;}
 92   else if(a_id==_cid_std_vector<unsigned short>())       {a_s = "ushort[]";return true;}
 93   else if(a_id==_cid_std_vector<unsigned int>())         {a_s = "uint[]";return true;}
 94   else if(a_id==_cid_std_vector<bool>())                 {a_s = "bool[]";return true;}
 95   else if(a_id==_cid_std_vector<int64>())                {a_s = "int64[]";return true;}
 96   else if(a_id==_cid_std_vector<uint64>())               {a_s = "uint64[]";return true;}
 97 
 98   a_s.clear();
 99   return false;
100 }
101 
102 }
103 
104 #endif