Concept Input stream with type checking. More...
#include <TDbiInRowStream.hxx>
Public Member Functions | |
TDbiInRowStream (TDbiStatement *stmtDb, const TDbiString &sql, const TDbiTableMetaData *metaData, const TDbiTableProxy *tableProxy, UInt_t dbNo, const string &fillOpts="") | |
virtual | ~TDbiInRowStream () |
Bool_t | CurColExists () const |
string | CurColString () const |
string | CurColValue () const |
UInt_t | CurRowNum () const |
UInt_t | GetDbNo () const |
string | GetFillOpts () const |
const TDbiTableProxy * | GetTableProxy () const |
Bool_t | IsBeforeFirst () const |
Bool_t | IsExhausted () const |
void | RowAsCsv (string &row) const |
TDbiInRowStream & | operator>> (Bool_t &dest) |
TDbiInRowStream & | operator>> (Char_t &dest) |
TDbiInRowStream & | operator>> (Short_t &dest) |
TDbiInRowStream & | operator>> (UShort_t &dest) |
TDbiInRowStream & | operator>> (Int_t &dest) |
TDbiInRowStream & | operator>> (UInt_t &dest) |
TDbiInRowStream & | operator>> (Long_t &dest) |
TDbiInRowStream & | operator>> (ULong_t &dest) |
TDbiInRowStream & | operator>> (Float_t &dest) |
TDbiInRowStream & | operator>> (Double_t &dest) |
TDbiInRowStream & | operator>> (string &dest) |
TDbiInRowStream & | operator>> (TVldTimeStamp &dest) |
Bool_t | FetchRow () |
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 | |
string & | AsString (TDbi::DataTypes type) |
Bool_t | LoadCurValue () const |
TString | GetStringFromTSQL (Int_t col) const |
Private Attributes | |
Int_t | fCurRow |
Current row in query (0...). | |
UInt_t | fDbNo |
Cascade no. of source. | |
TDbiStatement * | fStatement |
TSQLStatement * | fTSQLStatement |
Pointer to owned statement, may be 0. | |
Bool_t | fExhausted |
True is result set missing or exhausted. | |
const TDbiTableProxy * | fTableProxy |
TDbiTableProxy that produced this set. | |
string | fValString |
Buffer for assembling value. | |
string | fFillOpts |
Optional fill options. |
Concept Input stream with type checking.
Purpose This is an interface to TSQLResultSet. 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 45 of file TDbiInRowStream.hxx.
TDbiInRowStream::TDbiInRowStream | ( | TDbiStatement * | stmtDb, | |
const TDbiString & | sql, | |||
const TDbiTableMetaData * | metaData, | |||
const TDbiTableProxy * | tableProxy, | |||
UInt_t | dbNo, | |||
const string & | fillOpts = "" | |||
) |
Purpose: Default constructor Arguments: stmtDb in TDbiStatement to be used for query. May be zero. sql in The query to be applied to the statement. metaData in Meta data for query. tableProxy in Source TDbiTableProxy. dbNo in Cascade no. of source. Return: n/a Contact: N. West Specification:- ============= o Create ResultSet for query.
TDbiInRowStream::~TDbiInRowStream | ( | ) | [virtual] |
Purpose: Destructor Arguments: None. Return: n/a Contact: N. West Specification:- ============= o Destroy ResultSet and owned TDbiStatement if any.
Definition at line 105 of file TDbiInRowStream.cxx.
References fStatement, fTSQLStatement, and SK_DBI_Trace.
00105 { 00106 00107 // Program Notes:- 00108 // ============= 00109 00110 // None. 00111 00112 00113 SK_DBI_Trace( "Destroying TDbiInRowStream" << " "); 00114 delete fTSQLStatement; 00115 fTSQLStatement = 0; 00116 delete fStatement; 00117 fStatement = 0; 00118 00119 }
string & TDbiInRowStream::AsString | ( | TDbi::DataTypes | type | ) | [private] |
Purpose: Return current column value as a modifiable string and move on. Arguments: type in Required data type (as defined in TDbi.hxx). Return: Current column value as a string (null if missing) Note: Caller must dispose of value before calling this member function again as the value is assembled into fValString. Contact: N. West Specification:- ============= o Return the datum at current (row,column) as a string and increment column number. o Check for compatibility between required data type and table data type, report problems and return default if incompatible.
Definition at line 216 of file TDbiInRowStream.cxx.
References TDbiFieldType::AsString(), TDbiTableMetaData::ColFieldType(), TDbiRowStream::ColName(), TDbiRowStream::CurColNum(), fCurRow, fValString, TDbiFieldType::GetConcept(), TDbiRowStream::IncrementCurCol(), TDbiFieldType::IsCompatible(), TDbiFieldType::IsSmaller(), TDbi::kChar, LoadCurValue(), TDbiRowStream::MetaData(), SK_DBI_Severe, SK_DBI_Warn, TDbiRowStream::TableNameTc(), and TDbiFieldType::UndefinedValue().
Referenced by operator>>().
00216 { 00217 // 00218 00219 // Program Notes:- 00220 // ============= 00221 00222 // None. 00223 00224 TDbiFieldType reqdt(type); 00225 00226 // Place table value string in value string buffer. 00227 00228 Bool_t fail = ! LoadCurValue(); 00229 // Internally columns number from zero. 00230 UInt_t col = CurColNum(); 00231 IncrementCurCol(); 00232 00233 if ( fail ) { 00234 string udef = reqdt.UndefinedValue(); 00235 SK_DBI_Severe( "... value \"" << udef 00236 << "\" will be substitued." << " "); 00237 fValString = udef; 00238 return fValString; 00239 } 00240 00241 // Check for compatibility with required data type. 00242 00243 const TDbiFieldType& actdt = MetaData()->ColFieldType(col); 00244 00245 if ( reqdt.IsCompatible(actdt) ) { 00246 Bool_t smaller = reqdt.IsSmaller(actdt); 00247 // Allow one character String to be stored in Char 00248 if ( reqdt.GetConcept() == TDbi::kChar && fValString.size() == 1 00249 ) smaller = kFALSE; 00250 if ( smaller ) { 00251 SK_DBI_Warn( "In table " << TableNameTc() 00252 << " row " << fCurRow 00253 << " column "<< col 00254 << " (" << MetaData()->ColName(col) << ")" 00255 << " value \"" << fValString 00256 << "\" of type " << actdt.AsString() 00257 << " may be truncated before storing in " << reqdt.AsString() 00258 << " "); 00259 } 00260 } 00261 else { 00262 string udef = reqdt.UndefinedValue(); 00263 SK_DBI_Severe( "In table " << TableNameTc() 00264 << " row " << fCurRow 00265 << " column "<< col 00266 << " (" << MetaData()->ColName(col) << ")" 00267 << " value \"" << fValString 00268 << "\" of type " << actdt.AsString() 00269 << " is incompatible with user type " << reqdt.AsString() 00270 << ", value \"" << udef 00271 << "\" will be substituted." << " "); 00272 fValString = udef; 00273 } 00274 00275 return fValString; 00276 }
virtual void TDbiRowStream::ClearCurCol | ( | ) | [inline, protected, virtual, inherited] |
Definition at line 64 of file TDbiRowStream.hxx.
References TDbiRowStream::fCurCol.
Referenced by TDbiOutRowStream::Clear(), and 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 AsString().
00125 { 00126 // 00127 // 00128 // Purpose: Return specified column name, if defined 00129 00130 return fMetaData->ColName(col); 00131 }
Bool_t TDbiInRowStream::CurColExists | ( | ) | const |
Purpose: Test if current column exists. Arguments: None. Return: kTRUE if column exists. Contact: N. West Specification:- ============= o Test if current column exists.
Definition at line 295 of file TDbiInRowStream.cxx.
References TDbiRowStream::CurColNum(), fCurRow, IsExhausted(), TDbiRowStream::NumCols(), SK_DBI_Severe, and TDbiRowStream::TableNameTc().
Referenced by CurColString(), and LoadCurValue().
00295 { 00296 00297 // Program Notes:- 00298 // ============= 00299 00300 // None. 00301 00302 Int_t col = CurColNum(); 00303 00304 if ( IsExhausted() ) { 00305 SK_DBI_Severe( "In table " << TableNameTc() 00306 << " attempting to access row " << fCurRow 00307 << " column " << col 00308 << " but only " << fCurRow << " rows in table." << " "); 00309 return kFALSE; 00310 } 00311 00312 int numCols = NumCols(); 00313 if ( col > numCols ) { 00314 SK_DBI_Severe( "In table " << TableNameTc() 00315 << " row " << fCurRow 00316 << " attempting to access column "<< col 00317 << " but only " << NumCols() << " in table ." << " "); 00318 return kFALSE; 00319 } 00320 00321 return kTRUE; 00322 00323 }
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(), LoadCurValue(), TDbiOutRowStream::Store(), and TDbiOutRowStream::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 TDbiOutRowStream::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 AsString(), CurColExists(), CurColString(), TDbiOutRowStream::IsComplete(), LoadCurValue(), TDbiOutRowStream::Store(), and TDbiOutRowStream::StoreDefaultIfInvalid().
00045 { return fCurCol;}
string TDbiInRowStream::CurColString | ( | ) | const |
Purpose: Return current column as a string. Arguments: None. Return: Current column as a string (or null string if non-existant). Contact: N. West Specification:- ============= o Return current column as a string.
Definition at line 340 of file TDbiInRowStream.cxx.
References CurColExists(), TDbiRowStream::CurColNum(), and GetStringFromTSQL().
00340 { 00341 00342 // Program Notes:- 00343 // ============= 00344 00345 // None. 00346 00347 if ( ! CurColExists() ) return ""; 00348 00349 TString valStr = this->GetStringFromTSQL(CurColNum()); 00350 return valStr.Data(); 00351 00352 }
string TDbiInRowStream::CurColValue | ( | ) | const [inline] |
Definition at line 82 of file TDbiInRowStream.hxx.
References fValString, and LoadCurValue().
Referenced by TDbiConfigSet::Fill().
00082 { LoadCurValue(); return fValString;}
UInt_t TDbiInRowStream::CurRowNum | ( | ) | const [inline] |
Definition at line 83 of file TDbiInRowStream.hxx.
References fCurRow.
Referenced by TDbiValidityRec::Fill().
00083 { return fCurRow;}
virtual void TDbiRowStream::DecrementCurCol | ( | ) | [inline, virtual, inherited] |
Definition at line 56 of file TDbiRowStream.hxx.
References TDbiRowStream::fCurCol.
Referenced by ClassImp().
Bool_t TDbiInRowStream::FetchRow | ( | ) |
Purpose: Fetch next row of result set.. Arguments: None. Return: kTRUE if row exists, kFALSE otherwise. Contact: N. West Specification:- ============= o Load next row with string lengths.
Definition at line 370 of file TDbiInRowStream.cxx.
References TDbiRowStream::ClearCurCol(), fCurRow, fExhausted, fTSQLStatement, and IsExhausted().
Referenced by ClassImp(), and fCreationDate().
00370 { 00371 00372 00373 // Program Notes:- 00374 // ============= 00375 00376 // None. 00377 00378 ClearCurCol(); 00379 if ( IsExhausted() ) return kFALSE; 00380 ++fCurRow; 00381 if ( ! fTSQLStatement->NextResultRow() ) fExhausted = true; 00382 return ! fExhausted; 00383 00384 }
UInt_t TDbiInRowStream::GetDbNo | ( | ) | const [inline] |
Definition at line 84 of file TDbiInRowStream.hxx.
References fDbNo.
Referenced by TDbiValidityRec::Fill().
00084 { return fDbNo; }
string TDbiInRowStream::GetFillOpts | ( | ) | const [inline] |
TString TDbiInRowStream::GetStringFromTSQL | ( | Int_t | col | ) | const [private] |
Purpose: Get string from underlying TSQL interface N.B. No check that col is valid - caller beware. Specification:- ============= o Get string from underlying TSQL interface.
Definition at line 398 of file TDbiInRowStream.cxx.
References fTSQLStatement.
Referenced by CurColString(), LoadCurValue(), and RowAsCsv().
00398 { 00399 00400 // Caution: Column numbering in TSQLStatement starts at 0. 00401 TString valStr = fTSQLStatement->GetString(col-1); 00402 return valStr; 00403 }
const TDbiTableProxy* TDbiInRowStream::GetTableProxy | ( | ) | const [inline] |
Definition at line 86 of file TDbiInRowStream.hxx.
References fTableProxy.
Referenced by TDbiValidityRec::Fill().
00086 { return fTableProxy; }
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 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 AsString(), ClassImp(), TDbiConfigSet::Fill(), and TDbiOutRowStream::Store().
00060 { ++fCurCol; }
Bool_t TDbiInRowStream::IsBeforeFirst | ( | ) | const [inline] |
IsBeforeFirst not needed for ROOT API, but leave a dummy for now so as not to disturb TDbiInRowStream API.
Definition at line 89 of file TDbiInRowStream.hxx.
Referenced by ClassImp().
Bool_t TDbiInRowStream::IsExhausted | ( | ) | const [inline] |
Definition at line 90 of file TDbiInRowStream.hxx.
References fExhausted.
Referenced by ClassImp(), CurColExists(), fCreationDate(), and FetchRow().
00090 { return fExhausted; }
Bool_t TDbiRowStream::IsVLDTable | ( | ) | const [inline, inherited] |
Definition at line 48 of file TDbiRowStream.hxx.
References TDbiRowStream::fIsVLDTable.
Referenced by ClassImp().
00048 { return fIsVLDTable; }
Bool_t TDbiInRowStream::LoadCurValue | ( | ) | const [private] |
Purpose: Load current value into buffer fValString Arguments: None. Return: kTRUE if current column in range, otherwise kFALSE. Contact: N. West Specification:- ============= o Load current value into buffer fValString stripping off any enclosing quotes.
Definition at line 422 of file TDbiInRowStream.cxx.
References CurColExists(), TDbiRowStream::CurColFieldType(), TDbiRowStream::CurColNum(), fTSQLStatement, fValString, GetStringFromTSQL(), TDbi::kDouble, and TDbi::kFloat.
Referenced by AsString(), and CurColValue().
00422 { 00423 00424 00425 fValString.clear(); 00426 00427 if ( ! CurColExists() ) return kFALSE; 00428 00429 Int_t col = CurColNum(); 00430 TString valStr = this->GetStringFromTSQL(col); 00431 00432 // For floating point, use binary interface to preserve precision 00433 // e.g.-1.234567890123457e-100 as string is -0.000000 00434 if ( CurColFieldType().GetConcept() == TDbi::kFloat ) { 00435 ostringstream out; 00436 out << setprecision(8); 00437 if ( CurColFieldType().GetType() == TDbi::kDouble ) out << setprecision(16); 00438 // Caution: Column numbering in TSQLStatement starts at 0. 00439 out << fTSQLStatement->GetDouble(col-1); 00440 valStr = out.str().c_str(); 00441 } 00442 int len = valStr.Length(); 00443 00444 00445 00446 const char* pVal = valStr.Data(); 00447 // Remove leading and trailing quotes if dealing with a string. 00448 if ( len >= 2 00449 && ( *pVal == *(pVal+len-1) ) 00450 && ( *pVal == '\'' || *pVal == '"' ) ) { 00451 ++pVal; 00452 len -= 2; 00453 } 00454 fValString.assign(pVal,len); 00455 00456 return kTRUE; 00457 00458 }
virtual const TDbiTableMetaData* TDbiRowStream::MetaData | ( | ) | const [inline, virtual, inherited] |
Definition at line 53 of file TDbiRowStream.hxx.
References TDbiRowStream::fMetaData.
Referenced by AsString(), and 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 CurColExists(), TDbiConfigSet::Fill(), TDbiOutRowStream::IsComplete(), and 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 }
TDbiInRowStream & TDbiInRowStream::operator>> | ( | TVldTimeStamp & | dest | ) |
Definition at line 189 of file TDbiInRowStream.cxx.
References AsString(), TDbi::kDate, and TDbi::MakeTimeStamp().
00189 { 00190 dest=TDbi::MakeTimeStamp(AsString(TDbi::kDate)); return *this;}
TDbiInRowStream & TDbiInRowStream::operator>> | ( | string & | dest | ) |
Definition at line 187 of file TDbiInRowStream.cxx.
References AsString(), and TDbi::kString.
00187 { 00188 dest = AsString(TDbi::kString); return *this;}
TDbiInRowStream & TDbiInRowStream::operator>> | ( | Double_t & | dest | ) |
Definition at line 182 of file TDbiInRowStream.cxx.
References IN2, and TDbi::kDouble.
00182 { 00183 IN2(TDbi::kDouble,GetDouble);return *this;}
TDbiInRowStream & TDbiInRowStream::operator>> | ( | Float_t & | dest | ) |
Definition at line 180 of file TDbiInRowStream.cxx.
References IN2, and TDbi::kFloat.
00180 { 00181 IN2(TDbi::kFloat,GetDouble); return *this;}
TDbiInRowStream & TDbiInRowStream::operator>> | ( | ULong_t & | dest | ) |
Definition at line 178 of file TDbiInRowStream.cxx.
References IN3.
00178 { 00179 IN3(Long_t); return *this;}
TDbiInRowStream & TDbiInRowStream::operator>> | ( | Long_t & | dest | ) |
Definition at line 176 of file TDbiInRowStream.cxx.
References IN2, and TDbi::kLong.
00176 { 00177 IN2(TDbi::kLong, GetLong); return *this;}
TDbiInRowStream & TDbiInRowStream::operator>> | ( | UInt_t & | dest | ) |
Definition at line 174 of file TDbiInRowStream.cxx.
References IN3.
00174 { 00175 IN3(Int_t); return *this;}
TDbiInRowStream & TDbiInRowStream::operator>> | ( | Int_t & | dest | ) |
Definition at line 172 of file TDbiInRowStream.cxx.
References IN2, and TDbi::kInt.
00172 { 00173 IN2(TDbi::kInt,GetInt); return *this;}
TDbiInRowStream & TDbiInRowStream::operator>> | ( | UShort_t & | dest | ) |
Definition at line 170 of file TDbiInRowStream.cxx.
References IN3.
00170 { 00171 IN3(Short_t); return *this;}
TDbiInRowStream & TDbiInRowStream::operator>> | ( | Short_t & | dest | ) |
Definition at line 168 of file TDbiInRowStream.cxx.
References IN2, and TDbi::kInt.
00168 { 00169 IN2(TDbi::kInt,GetInt); return *this;}
TDbiInRowStream & TDbiInRowStream::operator>> | ( | Char_t & | dest | ) |
Definition at line 166 of file TDbiInRowStream.cxx.
References IN, and TDbi::kChar.
00166 { 00167 IN(TDbi::kChar) >> dest; return *this;}
TDbiInRowStream & TDbiInRowStream::operator>> | ( | Bool_t & | dest | ) |
Definition at line 164 of file TDbiInRowStream.cxx.
References IN, and TDbi::kBool.
00164 { 00165 IN(TDbi::kBool) >> dest; return *this;}
void TDbiInRowStream::RowAsCsv | ( | string & | row | ) | const |
Purpose: Append row as a Comma Separated Values string. Arguments: row in String to append to.
Definition at line 468 of file TDbiInRowStream.cxx.
References TDbiTableMetaData::ColFieldConcept(), TDbiTableMetaData::ColFieldType(), TDbiTableMetaData::ColMustDelimit(), fTSQLStatement, GetStringFromTSQL(), TDbiFieldType::GetType(), TDbi::kDouble, TDbi::kFloat, TDbi::kString, UtilString::MakePrintable(), TDbiRowStream::MetaData(), and TDbiRowStream::NumCols().
Referenced by fCreationDate().
00468 { 00469 00470 const TDbiTableMetaData* md = this->MetaData(); 00471 00472 Int_t maxCol = this->NumCols(); 00473 for (Int_t col = 1; col <= maxCol; ++col) { 00474 // Deal with NULL values. Caution: Column numbering in TSQLStatement starts at 0. 00475 if ( fTSQLStatement->IsNull(col-1) ) { 00476 row += "NULL"; 00477 if ( col < maxCol ) row += ','; 00478 continue; 00479 } 00480 Bool_t mustDelimit = md->ColMustDelimit(col); 00481 UInt_t concept = md->ColFieldConcept(col); 00482 if ( mustDelimit ) row += '\''; 00483 TString str = this->GetStringFromTSQL(col); 00484 const char* value = str.Data(); 00485 00486 // Make strings printable. 00487 if ( concept == TDbi::kString ) UtilString::MakePrintable(value,row); 00488 00489 // For floating point, use binary interface to preserve precision 00490 // e.g.-1.234567890123457e-100 as string is -0.000000 00491 else if ( concept == TDbi::kFloat ) { 00492 ostringstream out; 00493 out << setprecision(8); 00494 if ( md->ColFieldType(col).GetType() == TDbi::kDouble ) out << setprecision(16); 00495 out << fTSQLStatement->GetDouble(col-1); 00496 row += out.str(); 00497 } 00498 00499 // Everything else (!) is O.K. 00500 else row += value; 00501 00502 if ( mustDelimit ) row += '\''; 00503 if ( col < maxCol ) row += ','; 00504 } 00505 }
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 AsString(), CurColExists(), TDbiOutRowStream::StoreDefaultIfInvalid(), and TDbiResultSet::TDbiResultSet().
00230 { 00231 // 00232 // 00233 // Purpose: Return table name in true case. 00234 00235 return fMetaData->TableName(); 00236 }
Int_t TDbiInRowStream::fCurRow [private] |
Current row in query (0...).
Definition at line 119 of file TDbiInRowStream.hxx.
Referenced by AsString(), CurColExists(), CurRowNum(), and FetchRow().
UInt_t TDbiInRowStream::fDbNo [private] |
Bool_t TDbiInRowStream::fExhausted [private] |
True is result set missing or exhausted.
Definition at line 134 of file TDbiInRowStream.hxx.
Referenced by FetchRow(), and IsExhausted().
string TDbiInRowStream::fFillOpts [private] |
Optional fill options.
Definition at line 143 of file TDbiInRowStream.hxx.
Referenced by GetFillOpts().
TDbiStatement* TDbiInRowStream::fStatement [private] |
Owned TDbiStatement. May be 0. It's only use is to create a TSQLStatement in the ctor but it is not destroyed until the dtor to prevent a premature attempt to close the connection.
Definition at line 128 of file TDbiInRowStream.hxx.
Referenced by ~TDbiInRowStream().
const TDbiTableProxy* TDbiInRowStream::fTableProxy [private] |
TDbiTableProxy that produced this set.
Definition at line 137 of file TDbiInRowStream.hxx.
Referenced by GetTableProxy().
TSQLStatement* TDbiInRowStream::fTSQLStatement [private] |
Pointer to owned statement, may be 0.
Definition at line 131 of file TDbiInRowStream.hxx.
Referenced by FetchRow(), GetStringFromTSQL(), LoadCurValue(), RowAsCsv(), and ~TDbiInRowStream().
string TDbiInRowStream::fValString [mutable, private] |
Buffer for assembling value.
Definition at line 140 of file TDbiInRowStream.hxx.
Referenced by AsString(), CurColValue(), and LoadCurValue().