Concept Output stream for the values of a single table row with type checking and deferred sequence number asignment. More...
#include <TDbiOutRowStream.hxx>
Public Member Functions | |
TDbiOutRowStream (const TDbiTableMetaData *metaData) | |
virtual | ~TDbiOutRowStream () |
Bool_t | HasGoodData () const |
const string & | GetCSV () const |
Bool_t | IsComplete () const |
TDbiOutRowStream & | operator<< (Bool_t src) |
TDbiOutRowStream & | operator<< (Char_t src) |
TDbiOutRowStream & | operator<< (const Char_t *src) |
TDbiOutRowStream & | operator<< (Short_t src) |
TDbiOutRowStream & | operator<< (UShort_t src) |
TDbiOutRowStream & | operator<< (Int_t src) |
TDbiOutRowStream & | operator<< (UInt_t src) |
TDbiOutRowStream & | operator<< (Float_t src) |
TDbiOutRowStream & | operator<< (Double_t src) |
TDbiOutRowStream & | operator<< (const string &src) |
TDbiOutRowStream & | operator<< (const TVldTimeStamp &src) |
void | Clear () |
virtual const TDbiFieldType & | ColFieldType (UInt_t col) const |
virtual string | ColName (UInt_t col) const |
virtual const TDbiFieldType & | CurColFieldType () const |
virtual string | CurColName () const |
virtual UInt_t | CurColNum () const |
Bool_t | HasEpoch () const |
Bool_t | HasRowCounter () const |
Bool_t | IsVLDTable () const |
virtual UInt_t | NumCols () const |
virtual string | TableName () const |
virtual string | TableNameTc () const |
virtual const TDbiTableMetaData * | MetaData () const |
virtual void | DecrementCurCol () |
virtual void | IncrementCurCol () |
Protected Member Functions | |
virtual void | ClearCurCol () |
Private Member Functions | |
void | Store (const string &str) |
Bool_t | StoreDefaultIfInvalid (TDbi::DataTypes type) |
Private Attributes | |
Bool_t | fBadData |
Set KTRUE if streamed bad data. | |
string | fCSV |
Comma separated list of values. | |
Friends | |
class | TDbiConfigSet |
Concept Output stream for the values of a single table row with type checking and deferred sequence number asignment.
Purpose This is a helper class for TDbiSqlValPacket. Its primary purpose is to provide an << operator with built-type checking to simplify the writing of TDbiTableRow subclasses. Contact: A.Finch@lancaster.ac.uk
Definition at line 34 of file TDbiOutRowStream.hxx.
TDbiOutRowStream::TDbiOutRowStream | ( | const TDbiTableMetaData * | metaData | ) |
TDbiOutRowStream::~TDbiOutRowStream | ( | ) | [virtual] |
Definition at line 71 of file TDbiOutRowStream.cxx.
References SK_DBI_Trace.
00071 { 00072 // 00073 // 00074 // Purpose: Destructor 00075 00076 00077 SK_DBI_Trace( "Destroying TDbiOutRowStream" << " "); 00078 00079 }
void TDbiOutRowStream::Clear | ( | ) | [inline] |
Definition at line 66 of file TDbiOutRowStream.hxx.
References TDbiRowStream::ClearCurCol(), fBadData, and fCSV.
00066 { fBadData = kFALSE; fCSV.erase(); ClearCurCol();}
virtual void TDbiRowStream::ClearCurCol | ( | ) | [inline, protected, virtual, inherited] |
Definition at line 64 of file TDbiRowStream.hxx.
References TDbiRowStream::fCurCol.
Referenced by Clear(), and TDbiInRowStream::FetchRow().
00064 { fCurCol = 1; }
const TDbiFieldType & TDbiRowStream::ColFieldType | ( | UInt_t | col | ) | const [virtual, inherited] |
Definition at line 114 of file TDbiRowStream.cxx.
References TDbiTableMetaData::ColFieldType(), and TDbiRowStream::fMetaData.
00114 { 00115 // 00116 // 00117 // Purpose: Return specified column type, if defined 00118 // 00119 // Arguments: None. 00120 00121 return fMetaData->ColFieldType(col); 00122 }
string TDbiRowStream::ColName | ( | UInt_t | col | ) | const [virtual, inherited] |
Definition at line 125 of file TDbiRowStream.cxx.
References TDbiTableMetaData::ColName(), and TDbiRowStream::fMetaData.
Referenced by TDbiInRowStream::AsString().
00125 { 00126 // 00127 // 00128 // Purpose: Return specified column name, if defined 00129 00130 return fMetaData->ColName(col); 00131 }
const TDbiFieldType & TDbiRowStream::CurColFieldType | ( | ) | const [virtual, inherited] |
Definition at line 134 of file TDbiRowStream.cxx.
References TDbiTableMetaData::ColFieldType(), TDbiRowStream::fCurCol, and TDbiRowStream::fMetaData.
Referenced by TDbiConfigSet::Fill(), TDbiInRowStream::LoadCurValue(), Store(), and StoreDefaultIfInvalid().
00134 { 00135 // 00136 // 00137 // Purpose: Return current column type, if defined 00138 // 00139 // Arguments: None. 00140 // 00141 // Return: Current column type, if defined. Unknown otherwise. 00142 // 00143 // Contact: N. West 00144 // 00145 // Specification:- 00146 // ============= 00147 // 00148 // o Current column name, if defined. unknown otherwise. 00149 00150 // Program Notes:- 00151 // ============= 00152 00153 // None. 00154 00155 return fMetaData->ColFieldType(fCurCol); 00156 }
string TDbiRowStream::CurColName | ( | ) | const [virtual, inherited] |
Definition at line 160 of file TDbiRowStream.cxx.
References TDbiTableMetaData::ColName(), TDbiRowStream::fCurCol, and TDbiRowStream::fMetaData.
Referenced by ClassImp(), TDbiConfigSet::Fill(), and StoreDefaultIfInvalid().
00160 { 00161 // 00162 // 00163 // Purpose: Return current column name, if defined 00164 // 00165 // Arguments: None. 00166 // 00167 // Return: Current column name, if defined. "Undefined" otherwise. 00168 // 00169 // Contact: N. West 00170 // 00171 // Specification:- 00172 // ============= 00173 // 00174 // o Current column name, if defined. "Undefined" otherwise. 00175 00176 // Program Notes:- 00177 // ============= 00178 00179 // None. 00180 00181 return fMetaData->ColName(fCurCol); 00182 }
virtual UInt_t TDbiRowStream::CurColNum | ( | ) | const [inline, virtual, inherited] |
Definition at line 45 of file TDbiRowStream.hxx.
References TDbiRowStream::fCurCol.
Referenced by TDbiInRowStream::AsString(), TDbiInRowStream::CurColExists(), TDbiInRowStream::CurColString(), IsComplete(), TDbiInRowStream::LoadCurValue(), Store(), and StoreDefaultIfInvalid().
00045 { return fCurCol;}
virtual void TDbiRowStream::DecrementCurCol | ( | ) | [inline, virtual, inherited] |
Definition at line 56 of file TDbiRowStream.hxx.
References TDbiRowStream::fCurCol.
Referenced by ClassImp().
const string& TDbiOutRowStream::GetCSV | ( | ) | const [inline] |
Definition at line 47 of file TDbiOutRowStream.hxx.
References fCSV.
Referenced by TDbiSqlValPacket::AddRow(), and TDbiSqlValPacket::Recreate().
00047 { return fCSV; }
Bool_t TDbiRowStream::HasEpoch | ( | ) | const [inherited] |
Definition at line 213 of file TDbiRowStream.cxx.
References TDbiRowStream::fMetaData, and TDbiTableMetaData::HasEpoch().
Referenced by TDbiValidityRec::Fill(), and TDbiValidityRec::Store().
Bool_t TDbiOutRowStream::HasGoodData | ( | ) | const [inline] |
Definition at line 46 of file TDbiOutRowStream.hxx.
References fBadData, and IsComplete().
Referenced by TDbiSqlValPacket::AddRow().
00046 { return ! fBadData && IsComplete(); }
Bool_t TDbiRowStream::HasRowCounter | ( | ) | const [inline, inherited] |
Definition at line 47 of file TDbiRowStream.hxx.
References TDbiRowStream::fHasRowCounter.
00047 { return fHasRowCounter; }
virtual void TDbiRowStream::IncrementCurCol | ( | ) | [inline, virtual, inherited] |
Definition at line 60 of file TDbiRowStream.hxx.
References TDbiRowStream::fCurCol.
Referenced by TDbiInRowStream::AsString(), ClassImp(), TDbiConfigSet::Fill(), and Store().
00060 { ++fCurCol; }
Bool_t TDbiOutRowStream::IsComplete | ( | ) | const [inline] |
Definition at line 48 of file TDbiOutRowStream.hxx.
References TDbiRowStream::CurColNum(), and TDbiRowStream::NumCols().
Referenced by TDbiSqlValPacket::AddRow(), and HasGoodData().
Bool_t TDbiRowStream::IsVLDTable | ( | ) | const [inline, inherited] |
Definition at line 48 of file TDbiRowStream.hxx.
References TDbiRowStream::fIsVLDTable.
Referenced by ClassImp().
00048 { return fIsVLDTable; }
virtual const TDbiTableMetaData* TDbiRowStream::MetaData | ( | ) | const [inline, virtual, inherited] |
Definition at line 53 of file TDbiRowStream.hxx.
References TDbiRowStream::fMetaData.
Referenced by TDbiInRowStream::AsString(), and TDbiInRowStream::RowAsCsv().
00053 { return fMetaData; }
UInt_t TDbiRowStream::NumCols | ( | ) | const [virtual, inherited] |
Definition at line 186 of file TDbiRowStream.cxx.
References TDbiRowStream::fMetaData, and TDbiTableMetaData::NumCols().
Referenced by TDbiInRowStream::CurColExists(), TDbiConfigSet::Fill(), IsComplete(), and TDbiInRowStream::RowAsCsv().
00186 { 00187 // 00188 // 00189 // Purpose: Return the number of columns. 00190 // 00191 // Arguments: None. 00192 // 00193 // Return: the number of columns 00194 // 00195 // Contact: N. West 00196 // 00197 // Specification:- 00198 // ============= 00199 // 00200 // o Return the number of columns. 00201 00202 // Program Notes:- 00203 // ============= 00204 00205 // None. 00206 00207 return fMetaData->NumCols(); 00208 00209 }
TDbiOutRowStream & TDbiOutRowStream::operator<< | ( | const TVldTimeStamp & | src | ) |
Definition at line 113 of file TDbiOutRowStream.cxx.
References TDbi::kDate, TDbi::MakeDateTimeString(), Store(), and StoreDefaultIfInvalid().
00113 { 00114 if ( ! StoreDefaultIfInvalid(TDbi::kDate) ) 00115 Store(TDbi::MakeDateTimeString(src).c_str()); 00116 return *this; 00117 }
TDbiOutRowStream & TDbiOutRowStream::operator<< | ( | const string & | src | ) |
Definition at line 110 of file TDbiOutRowStream.cxx.
References TDbi::kString, and OUT.
00110 { 00111 OUT(TDbi::kString,src); return *this;}
TDbiOutRowStream & TDbiOutRowStream::operator<< | ( | Double_t | src | ) |
Definition at line 107 of file TDbiOutRowStream.cxx.
References TDbi::kDouble, and OUT.
00107 { 00108 OUT(TDbi::kDouble,src); return *this;}
TDbiOutRowStream & TDbiOutRowStream::operator<< | ( | Float_t | src | ) |
Definition at line 104 of file TDbiOutRowStream.cxx.
References TDbi::kFloat, and OUT.
00104 { 00105 OUT(TDbi::kFloat,src); return *this;}
TDbiOutRowStream & TDbiOutRowStream::operator<< | ( | UInt_t | src | ) |
Definition at line 101 of file TDbiOutRowStream.cxx.
References TDbi::kUInt, and OUT2.
00101 { 00102 OUT2(TDbi::kUInt,src); return *this;}
TDbiOutRowStream & TDbiOutRowStream::operator<< | ( | Int_t | src | ) |
Definition at line 98 of file TDbiOutRowStream.cxx.
References TDbi::kInt, and OUT.
00098 { 00099 OUT(TDbi::kInt,src); return *this;}
TDbiOutRowStream & TDbiOutRowStream::operator<< | ( | UShort_t | src | ) |
Definition at line 95 of file TDbiOutRowStream.cxx.
References TDbi::kUShort, and OUT2.
00095 { 00096 OUT2(TDbi::kUShort,src); return *this;}
TDbiOutRowStream & TDbiOutRowStream::operator<< | ( | Short_t | src | ) |
Definition at line 92 of file TDbiOutRowStream.cxx.
References TDbi::kShort, and OUT.
00092 { 00093 OUT(TDbi::kShort,src); return *this;}
TDbiOutRowStream & TDbiOutRowStream::operator<< | ( | const Char_t * | src | ) |
Definition at line 89 of file TDbiOutRowStream.cxx.
References TDbi::kString, and OUT.
00089 { 00090 OUT(TDbi::kString,src); return *this;}
TDbiOutRowStream & TDbiOutRowStream::operator<< | ( | Char_t | src | ) |
Definition at line 86 of file TDbiOutRowStream.cxx.
References TDbi::kChar, and OUT.
00086 { 00087 OUT(TDbi::kChar,src); return *this;}
TDbiOutRowStream & TDbiOutRowStream::operator<< | ( | Bool_t | src | ) |
Definition at line 83 of file TDbiOutRowStream.cxx.
References TDbi::kBool, and OUT.
00083 { 00084 OUT(TDbi::kBool,src); return *this;}
void TDbiOutRowStream::Store | ( | const string & | str | ) | [private] |
Definition at line 167 of file TDbiOutRowStream.cxx.
References TDbiRowStream::CurColFieldType(), TDbiRowStream::CurColNum(), fCSV, TDbiFieldType::GetConcept(), TDbiRowStream::IncrementCurCol(), TDbi::kChar, TDbi::kDate, TDbi::kString, and UtilString::MakePrintable().
Referenced by operator<<(), TDbiConfigSet::Store(), and StoreDefaultIfInvalid().
00167 { 00168 // 00169 // 00170 // Purpose: Store string value as comma separated values but exclude SeqNo. 00171 // 00172 // Arguments: 00173 // str in Value to be stored. 00174 // 00175 // Return: 00176 // 00177 // Contact: N. West 00178 // 00179 // Specification:- 00180 // ============= 00181 // 00182 // o Store string value in CSV with separator from 00183 // previous value and increment fNumValues. If required 00184 // enclose value in quotes. If storing the SeqNo column then 00185 // store a single '?' instead which will be replace during 00186 // SQL generation - see 00187 00188 // Program Notes:- 00189 // ============= 00190 00191 // None. 00192 00193 UInt_t concept = CurColFieldType().GetConcept(); 00194 string delim = ""; 00195 if ( concept == TDbi::kString 00196 || concept == TDbi::kDate 00197 || concept == TDbi::kChar ) delim = "\'"; 00198 00199 if ( CurColNum()> 1 ) fCSV += ','; 00200 fCSV += delim; 00201 if ( concept != TDbi::kString ) fCSV += str; 00202 // When exporting strings, take care of special characters. 00203 else { 00204 UtilString::MakePrintable(str.c_str(),fCSV); 00205 } 00206 fCSV += delim; 00207 IncrementCurCol(); 00208 }
Bool_t TDbiOutRowStream::StoreDefaultIfInvalid | ( | TDbi::DataTypes | type | ) | [private] |
Definition at line 124 of file TDbiOutRowStream.cxx.
References TDbiFieldType::AsString(), TDbiRowStream::CurColFieldType(), TDbiRowStream::CurColName(), TDbiRowStream::CurColNum(), fBadData, TDbiFieldType::IsCompatible(), SK_DBI_Severe, Store(), TDbiRowStream::TableNameTc(), and TDbiFieldType::UndefinedValue().
Referenced by operator<<().
00124 { 00125 // 00126 // 00127 // Purpose: Store default value if illegal type supplied. 00128 // 00129 // Arguments: 00130 // type in Type of supplied value. 00131 // 00132 // Return: kTRUE if illegal type supplied. 00133 // 00134 // Contact: N. West 00135 // 00136 // Specification:- 00137 // ============= 00138 // 00139 // o If type of supplied value is incompatible with current column 00140 // type store default value, report error and return kTRUE, otherwise 00141 // return kFALSE. 00142 00143 // Program Notes:- 00144 // ============= 00145 00146 // None. 00147 00148 TDbiFieldType typeSupplied(type); 00149 TDbiFieldType typeRequired(CurColFieldType()); 00150 if ( typeSupplied.IsCompatible(typeRequired) ) return kFALSE; 00151 00152 string udef = typeRequired.UndefinedValue(); 00153 SK_DBI_Severe( "In table " << TableNameTc() 00154 << " column "<< CurColNum() 00155 << " (" << CurColName() << ")" 00156 << " of type " << typeRequired.AsString() 00157 << " is incompatible with user type " << typeSupplied.AsString() 00158 << ", value \"" << udef 00159 << "\" will be substituted." << " "); 00160 Store(udef.c_str()); 00161 fBadData = kTRUE; 00162 return kTRUE; 00163 00164 }
string TDbiRowStream::TableName | ( | ) | const [virtual, inherited] |
Definition at line 219 of file TDbiRowStream.cxx.
References TDbiRowStream::fMetaData, TDbiTableMetaData::TableName(), and UtilString::ToUpper().
00219 { 00220 // 00221 // 00222 // Purpose: Return table name in upper case. 00223 // 00224 00225 return UtilString::ToUpper(fMetaData->TableName()); 00226 }
string TDbiRowStream::TableNameTc | ( | ) | const [virtual, inherited] |
Definition at line 230 of file TDbiRowStream.cxx.
References TDbiRowStream::fMetaData, and TDbiTableMetaData::TableName().
Referenced by TDbiInRowStream::AsString(), TDbiInRowStream::CurColExists(), StoreDefaultIfInvalid(), and TDbiResultSet::TDbiResultSet().
00230 { 00231 // 00232 // 00233 // Purpose: Return table name in true case. 00234 00235 return fMetaData->TableName(); 00236 }
friend class TDbiConfigSet [friend] |
Definition at line 37 of file TDbiOutRowStream.hxx.
Bool_t TDbiOutRowStream::fBadData [private] |
Set KTRUE if streamed bad data.
Definition at line 79 of file TDbiOutRowStream.hxx.
Referenced by Clear(), HasGoodData(), and StoreDefaultIfInvalid().
string TDbiOutRowStream::fCSV [private] |
Comma separated list of values.
Definition at line 82 of file TDbiOutRowStream.hxx.