Warning, /include/Geant4/tools/cids is written in an unsupported language. File is not indexed.
0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003
0004 #ifndef tools_cids
0005 #define tools_cids
0006
0007 #include "cid"
0008
0009 #include <string>
0010 #include "typedefs" //byte
0011
0012 namespace tools {
0013
0014 inline cid _cid(byte) {return 1;}
0015 inline cid _cid(char) {return 2;}
0016 inline cid _cid(unsigned short) {return 3;}
0017 inline cid _cid(short) {return 4;}
0018 inline cid _cid(unsigned int) {return 5;}
0019 inline cid _cid(int) {return 6;}
0020 inline cid _cid(float) {return 7;}
0021 inline cid _cid(double) {return 8;}
0022 inline cid _cid(bool) {return 9;}
0023
0024 // not compiler types :
0025 inline cid _cid(uint64) {return 10;}
0026 inline cid _cid(int64) {return 11;}
0027 inline cid _cid(const std::string&) {return 12;}
0028 inline cid _cid(fits_bit) {return 13;}
0029 inline cid _cid(csv_time) {return 14;}
0030
0031 //NOTE : avoid time_t which is defined in general as a long
0032 // and is then ambiguous relative to int/int64.
0033
0034 //NOTE : if adding some, it must not exceed 20. Else, you have to change
0035 // the below for std::vector.
0036
0037 }
0038
0039 #include <vector>
0040
0041 namespace tools {
0042
0043 // For rntuple and rroot::ntuple::column_element.
0044 // The read::icolumn<T> needs a _cid(T) with T :
0045 // std::vector< [basic_type, std::vector<basic_type>] >
0046
0047 template <class T>
0048 inline cid _cid(const std::vector<T>&) {return 20+_cid(T());}
0049
0050 template <class T>
0051 inline cid _cid_std_vector() {
0052 static const T s_v = T(); //do that for T = std::string.
0053 return 20+_cid(s_v);
0054 }
0055
0056 // Then : cid for std::vector< std::vector<T> > is going to be :
0057 // 20+_cid(std::vector<T>) = 2*20+_cid(T)
0058
0059 //WARNING : rroot/cids start at 100.
0060 //WARNING : rroot/geo_cids start at 1000.
0061
0062 }
0063
0064 namespace tools {
0065
0066 inline bool cid2s(cid a_id,std::string& a_s) {
0067 // NOTE : the returned string must not contain space.
0068
0069 if(a_id==_cid(char(0))) {a_s = "char";return true;}
0070 else if(a_id==_cid(short(0))) {a_s = "short";return true;}
0071 else if(a_id==_cid(int(0))) {a_s = "int";return true;}
0072 else if(a_id==_cid(float(0))) {a_s = "float";return true;}
0073 else if(a_id==_cid(double(0))) {a_s = "double";return true;}
0074 else if(a_id==_cid(std::string())) {a_s = "string";return true;}
0075
0076 // NOTE : the below do not follow the AIDA convention.
0077 else if(a_id==_cid((unsigned char)0)) {a_s = "uchar";return true;} //AIDA=byte
0078 else if(a_id==_cid((unsigned short)0)) {a_s = "ushort";return true;} //AIDA not defined
0079 else if(a_id==_cid((unsigned int)0)) {a_s = "uint";return true;} //AIDA not defined
0080 else if(a_id==_cid(bool(true))) {a_s = "bool";return true;} //AIDA=boolean
0081 else if(a_id==_cid(int64(0))) {a_s = "int64";return true;} //AIDA=long
0082 else if(a_id==_cid(uint64(0))) {a_s = "uint64";return true;} //AIDA=not defined
0083
0084 else if(a_id==_cid_std_vector<char>()) {a_s = "char[]";return true;}
0085 else if(a_id==_cid_std_vector<short>()) {a_s = "short[]";return true;}
0086 else if(a_id==_cid_std_vector<int>()) {a_s = "int[]";return true;}
0087 else if(a_id==_cid_std_vector<float>()) {a_s = "float[]";return true;}
0088 else if(a_id==_cid_std_vector<double>()) {a_s = "double[]";return true;}
0089 else if(a_id==_cid_std_vector<std::string>()) {a_s = "string[]";return true;}
0090
0091 else if(a_id==_cid_std_vector<unsigned char>()) {a_s = "uchar[]";return true;}
0092 else if(a_id==_cid_std_vector<unsigned short>()) {a_s = "ushort[]";return true;}
0093 else if(a_id==_cid_std_vector<unsigned int>()) {a_s = "uint[]";return true;}
0094 else if(a_id==_cid_std_vector<bool>()) {a_s = "bool[]";return true;}
0095 else if(a_id==_cid_std_vector<int64>()) {a_s = "int64[]";return true;}
0096 else if(a_id==_cid_std_vector<uint64>()) {a_s = "uint64[]";return true;}
0097
0098 a_s.clear();
0099 return false;
0100 }
0101
0102 }
0103
0104 #endif