CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AnyData.h
Go to the documentation of this file.
1 #ifndef CondCore_ORA_AnyData_H
2 #define CondCore_ORA_AnyData_H
3 #include<string>
4 
5 namespace ora {
6  union AnyData {
7 
8  // size is 8 byte no matter which architecture
9  char v[8];
10  bool b;
11  char c;
12  unsigned char uc;
13  short s;
14  unsigned short us;
15  int i;
16  unsigned int ui;
17  long long l;
18  unsigned long long ul;
19  float f;
20  double d;
21  void * p;
22  char * ss;
23  // std::string ss;
24  void * address() { return v;}
25  void const * address() const { return v;}
26 
27  // for generic type T better be the pointer to it...
28  template<typename T>
29  inline T & data() { return *reinterpret_cast<T*>(address());}
30 
31  template<typename T>
32  inline T data() const { return *reinterpret_cast<T const*>(address());}
33 
34  };
35 
36 
37  template<>
38  inline int & AnyData::data<int>() { return i;}
39 
40  template<>
41  inline int AnyData::data<int>() const { return i;}
42 
43 
44 
45 }
46 
47 #endif // CondCore_ORA_AnyData_H
int i
Definition: DBlmapReader.cc:9
T & data()
Definition: AnyData.h:29
double d
Definition: AnyData.h:20
long long l
Definition: AnyData.h:17
char c
Definition: AnyData.h:11
unsigned int ui
Definition: AnyData.h:16
char v[8]
Definition: AnyData.h:9
unsigned long long ul
Definition: AnyData.h:18
unsigned short us
Definition: AnyData.h:14
unsigned char uc
Definition: AnyData.h:12
float f
Definition: AnyData.h:19
void * p
Definition: AnyData.h:21
string const
Definition: compareJSON.py:14
void const * address() const
Definition: AnyData.h:25
bool b
Definition: AnyData.h:10
short s
Definition: AnyData.h:13
T data() const
Definition: AnyData.h:32
char * ss
Definition: AnyData.h:22
long double T
void * address()
Definition: AnyData.h:24