EIC Software
Reference for
EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
FairDbOutRowStream.cxx
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file FairDbOutRowStream.cxx
1
2
#include <sstream>
3
4
#include "
FairDbFieldType.h
"
5
#include "
FairDbOutRowStream.h
"
6
#include "
FairDbTableMetaData.h
"
7
#include "
FairDbString.h
"
8
#include "
ValTimeStamp.h
"
9
10
ClassImp
(
FairDbOutRowStream
)
11
12
#define OUT(t,v) \
13
if ( ! StoreDefaultIfInvalid(t) ) { \
14
ostringstream out; \
15
out << v; \
16
Store(out.str()); \
17
} \
18
19
// If writing unsigned dat as signed, convert bit pattern to signed,
20
// extending sign bit if necessary.
21
// For BIGINT (size 8) make an exception. It's used only as
22
// an alternative to unsigned int so can written without conversion.
23
#define OUT2(t,v) \
24
const FairDbFieldType& fType = this->ColFieldType(this->CurColNum()); \
25
if ( fType.IsSigned() && fType.GetSize() != 8 ) { \
26
Int_t v_signed = (Int_t) v; \
27
if ( fType.GetType() == FairDb::kTiny && v & 0x80 ) v_signed |= 0xffffff00; \
28
if ( fType.GetType() == FairDb::kShort && v & 0x8000 ) v_signed |= 0xffff0000; \
29
OUT(FairDb::kInt,v_signed); } \
30
else { \
31
OUT(t,v); \
32
} \
33
34
35
FairDbOutRowStream::FairDbOutRowStream
(
const
FairDbTableMetaData
* metaData) :
36
FairDbRowStream
(metaData),
37
fBadData(kFALSE),
38
fCSV()
39
{
40
41
42
}
43
44
45
//.....................................................................
46
47
FairDbOutRowStream::~FairDbOutRowStream
()
48
{
49
50
}
51
52
//.....................................................................
53
54
FairDbOutRowStream
&
FairDbOutRowStream::operator<<
(Bool_t src)
55
{
56
OUT
(
FairDb::kBool
,src);
57
return
*
this
;
58
}
59
60
FairDbOutRowStream
&
FairDbOutRowStream::operator<<
(Char_t src)
61
{
62
OUT
(
FairDb::kChar
,src);
63
return
*
this
;
64
}
65
66
FairDbOutRowStream
&
FairDbOutRowStream::operator<<
(
const
Char_t* src)
67
{
68
OUT
(
FairDb::kString
,src);
69
return
*
this
;
70
}
71
72
FairDbOutRowStream
&
FairDbOutRowStream::operator<<
(Short_t src)
73
{
74
OUT
(
FairDb::kShort
,src);
75
return
*
this
;
76
}
77
78
FairDbOutRowStream
&
FairDbOutRowStream::operator<<
(UShort_t src)
79
{
80
OUT2
(
FairDb::kUShort
,src);
81
return
*
this
;
82
}
83
84
FairDbOutRowStream
&
FairDbOutRowStream::operator<<
(Int_t src)
85
{
86
OUT
(
FairDb::kInt
,src);
87
return
*
this
;
88
}
89
90
FairDbOutRowStream
&
FairDbOutRowStream::operator<<
(UInt_t src)
91
{
92
OUT2
(
FairDb::kUInt
,src);
93
return
*
this
;
94
}
95
96
FairDbOutRowStream
&
FairDbOutRowStream::operator<<
(Float_t src)
97
{
98
OUT
(
FairDb::kFloat
,src);
99
return
*
this
;
100
}
101
102
FairDbOutRowStream
&
FairDbOutRowStream::operator<<
(Double_t src)
103
{
104
OUT
(
FairDb::kDouble
,src);
105
return
*
this
;
106
}
107
108
FairDbOutRowStream
&
FairDbOutRowStream::operator<<
(
const
string
& src)
109
{
110
OUT
(
FairDb::kString
,src);
111
return
*
this
;
112
}
113
114
FairDbOutRowStream
&
FairDbOutRowStream::operator<<
(
const
ValTimeStamp
& src)
115
{
116
if
( !
StoreDefaultIfInvalid
(
FairDb::kDate
) ) {
117
Store
(
FairDb::MakeDateTimeString
(src).Data());
118
}
119
return
*
this
;
120
}
121
122
123
Bool_t
FairDbOutRowStream::StoreDefaultIfInvalid
(
FairDb::DataTypes
type)
124
{
125
126
FairDbFieldType
typeSupplied(type);
127
FairDbFieldType
typeRequired(
CurColFieldType
());
128
if
( typeSupplied.
IsCompatible
(typeRequired) ) {
return
kFALSE; }
129
130
string
udef = typeRequired.
UndefinedValue
();
131
cout
132
<<
"In table "
<<
TableNameTc
()
133
<<
" column "
<<
CurColNum
()
134
<<
" ("
<<
CurColName
() <<
")"
135
<<
" of type "
<< typeRequired.
AsString
()
136
<<
" is incompatible with user type "
<< typeSupplied.
AsString
()
137
<<
", value \""
<< udef
138
<<
"\" will be substituted."
<< endl;
139
Store
(udef.c_str());
140
fBadData
= kTRUE;
141
return
kTRUE;
142
143
}
144
void
FairDbOutRowStream::Store
(
const
string
& str)
145
{
146
147
UInt_t concept =
CurColFieldType
().
GetConcept
();
148
string
delim =
""
;
149
if
( concept ==
FairDb::kString
150
|| concept ==
FairDb::kDate
151
|| concept ==
FairDb::kChar
) { delim =
"\'"
; }
152
153
if
(
CurColNum
()> 1 ) {
fCSV
+=
','
; }
154
fCSV
+= delim;
155
if
( concept !=
FairDb::kString
) {
fCSV
+= str; }
156
// When exporting strings, take care of special characters.
157
else
{
158
FairUtilString::MakePrintable
(str.c_str(),
fCSV
);
159
}
160
fCSV
+= delim;
161
IncrementCurCol
();
162
}
163
EicRoot
blob
master
dbase
dbInterface
FairDbOutRowStream.cxx
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:33
using
1.8.2 with
EIC GitHub integration