Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TSQLTypes.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TSQLTypes.h
1 // $Id: TSQLTypes.h,v 1.1.1.1 2004/02/18 20:58:02 dave Exp $
2 
3 #ifndef RDBC_TSQLTypes_h
4 #define RDBC_TSQLTypes_h
5 
6 //
7 // TSQLTypes, TSQLDate, TSQLTime, TSQLTimestamp classes
8 //
9 
10 #ifndef ROOT_TObject
11 #include <TObject.h>
12 #endif
13 #ifndef ROOT_TString
14 #include <TString.h>
15 #endif
16 #ifndef ROOT_TDatime
17 #include <TDatime.h>
18 #endif
19 
20 enum ESQLTypes {
21  kBIGINT = -5,
22  kBINARY = -2,
23  kBIT = -7,
24  kCHAR = 1,
25 #ifdef ODBC_VER_LESS_30
26  kDATE = 9,
27  kTIME = 10,
28  kTIMESTAMP = 11,
29 #endif
30  kDATE = 91,
31  kTIME = 92,
32  kTIMESTAMP = 93,
33  kSMALLINT = 5,
34  kDECIMAL = 3,
35  kDOUBLE = 8,
36  kFLOAT = 6,
37  kINTEGER = 4,
40  kNUMERIC = 2,
41  kREAL = 7,
42  kTINYINT = -6,
43  kVARBINARY = -3,
44  kVARCHAR = 12
45  };
46 
47 
49 class TSQLDate: public TDatime
50 {
51 public:
52 
53  TSQLDate(Int_t year, Int_t month, Int_t day);
54  TSQLDate():TDatime() {}
55  TSQLDate(UInt_t t) { fDatime=t; }
56 // TSQLDate(const TString& str);
57  TSQLDate(const TSQLDate& d):TDatime(d) {}
58  virtual ~TSQLDate() {}
59 
60  TSQLDate& operator=(const TSQLDate& d);
61 
62 // UInt_t GetTime() const { return Convert(); }
63  Int_t GetYear() const { return (fDatime>>26)+1995; }
64  Int_t GetMonth() const { return (fDatime<<6)>>28; }
65  Int_t GetDay() const { return (fDatime<<10)>>27; }
66  void SetYear(Int_t year);
67  void SetMonth(Int_t month);
68  void SetDay(Int_t day);
69  TString ToString() const;
70 
71 ClassDef(TSQLDate,0) // allows to identify this as a SQL_DATE
72 };
73 
75 class TSQLTime: public TDatime
76 {
77 public:
78 
79  TSQLTime(Int_t hour, Int_t minute, Int_t second);
80  TSQLTime():TDatime() {}
81  TSQLTime(UInt_t t) { fDatime=t; }
82 // TSQLTime(const TString& str);
83  TSQLTime(const TSQLTime& t):TDatime(t) {}
84  virtual ~TSQLTime() {}
85 
86  TSQLTime& operator=(const TSQLTime& d);
87 
88 // UInt_t getTime() const { return Convert(); }
89  Int_t GetHour() const { return (fDatime<<15)>>27; }
90  Int_t GetMinute() const { return (fDatime<<20)>>26; }
91  Int_t GetSecond() const { return (fDatime<<26)>>26; }
92  void SetHour(Int_t h);
93  void SetMinute(Int_t m);
94  void SetSecond(Int_t s);
95  TString ToString() const;
96 
97 ClassDef(TSQLTime,0) // allows to identify this as a SQL_TIME
98 };
99 
101 class TSQLTimestamp: public TDatime
102 {
103 protected:
104  Int_t fNanos; // nanoseconds
105 
106 public:
107 
108  TSQLTimestamp(Int_t year, Int_t month, Int_t day,
109  Int_t hour, Int_t minute, Int_t second, Int_t nanos =0)
110  { Set(year,month,day,hour,minute,second); SetNanos(nanos); }
111 
112  TSQLTimestamp():TDatime(),fNanos(0) {}
113  TSQLTimestamp(UInt_t t):fNanos(0) { fDatime=t; }
114 // TSQLTimestamp(const TString& s);
115  TSQLTimestamp(const TSQLTimestamp& t):TDatime(t),fNanos(0) {}
116  virtual ~TSQLTimestamp() {}
118 
119 // UInt_t GetTime() const { return Convert(); }
120  Int_t GetYear() const { return (fDatime>>26)+1995; }
121  Int_t GetMonth() const { return (fDatime<<6)>>28; }
122  Int_t GetDay() const { return (fDatime<<10)>>27; }
123  Int_t GetHour() const { return (fDatime<<15)>>27; }
124  Int_t GetMinute() const { return (fDatime<<20)>>26; }
125  Int_t GetSecond() const { return (fDatime<<26)>>26; }
126  Int_t GetNanos() const { return fNanos; }
127  void SetYear(Int_t year);
128  void SetMonth(Int_t month);
129  void SetDay(Int_t day);
130  void SetHour(Int_t h);
131  void SetMinute(Int_t m);
132  void SetSecond(Int_t s);
133  void SetNanos(Int_t nanos) { fNanos = nanos>0 ? nanos: 0; }
134 // Bool_t After(const TSQLTimestamp& t) const;
135 // Bool_t Before(const TSQLTimestamp& t) const;
136 // Bool_t Equals(const TSQLTimestamp& t) const;
137  TString ToString() const;
138 
139 ClassDef(TSQLTimestamp,0) // allows to identify this as a SQL_TIMESTAMP
140 };
141 
142 //___________________________________________________________________
144 {
145  // Assignment operator
146 
147  fDatime = d.fDatime;
148  return *this;
149 }
150 
151 //___________________________________________________________________
153 {
154  // Assignment operator
155 
156  fDatime = d.fDatime;
157  return *this;
158 }
159 
160 //___________________________________________________________________
162 {
163  // Assignment operator
164 
165  fDatime = d.fDatime;
166  fNanos = d.fNanos;
167  return *this;
168 }
169 
170 #endif // RDBC_TSQLTypes_h