00001 #ifndef DBIOUTROWSTREAM_H 00002 #define DBIOUTROWSTREAM_H 00003 00004 /** 00005 * 00006 * $Id: TDbiOutRowStream.hxx,v 1.1 2011/01/18 05:49:20 finch Exp $ 00007 * 00008 * \class TDbiOutRowStream 00009 * 00010 * 00011 * \brief 00012 * <b>Concept</b> Output stream for the values of a single table row 00013 * with type checking and deferred sequence number asignment. 00014 * 00015 * \brief 00016 * <b>Purpose</b> This is a helper class for TDbiSqlValPacket. Its 00017 * primary purpose is to provide an << operator with built-type 00018 * checking to simplify the writing of TDbiTableRow subclasses. 00019 * 00020 * Contact: A.Finch@lancaster.ac.uk 00021 * 00022 * 00023 */ 00024 00025 #include <string> 00026 00027 #include "TDbi.hxx" 00028 #include "TDbiRowStream.hxx" 00029 00030 class TDbiTableMetaData; 00031 class TVldTimeStamp; 00032 class TDbiValidityRec; 00033 00034 class TDbiOutRowStream : public TDbiRowStream 00035 { 00036 00037 friend class TDbiConfigSet; //To allow it to use private Store method 00038 00039 public: 00040 00041 // Constructors and destructors. 00042 TDbiOutRowStream(const TDbiTableMetaData* metaData); 00043 virtual ~TDbiOutRowStream(); 00044 00045 // State testing member functions 00046 Bool_t HasGoodData() const { return ! fBadData && IsComplete(); } 00047 const string& GetCSV() const { return fCSV; } 00048 Bool_t IsComplete() const { return CurColNum() == NumCols()+1; } 00049 00050 // State changing member functions 00051 00052 TDbiOutRowStream& operator<<(Bool_t src); 00053 TDbiOutRowStream& operator<<(Char_t src); 00054 TDbiOutRowStream& operator<<(const Char_t* src); 00055 TDbiOutRowStream& operator<<(Short_t src); 00056 TDbiOutRowStream& operator<<(UShort_t src); 00057 TDbiOutRowStream& operator<<(Int_t src); 00058 TDbiOutRowStream& operator<<(UInt_t src); 00059 /* TDbiOutRowStream& operator<<(Long_t& src); */ 00060 /* TDbiOutRowStream& operator<<(ULong_t& src); */ 00061 TDbiOutRowStream& operator<<(Float_t src); 00062 TDbiOutRowStream& operator<<(Double_t src); 00063 TDbiOutRowStream& operator<<(const string& src); 00064 TDbiOutRowStream& operator<<(const TVldTimeStamp& src); 00065 00066 void Clear() { fBadData = kFALSE; fCSV.erase(); ClearCurCol();} 00067 00068 private: 00069 00070 // State testing member functions 00071 00072 // State changing member functions 00073 void Store(const string& str); 00074 Bool_t StoreDefaultIfInvalid(TDbi::DataTypes type); 00075 00076 // Data members 00077 00078 /// Set KTRUE if streamed bad data 00079 Bool_t fBadData; 00080 00081 /// Comma separated list of values. 00082 string fCSV; 00083 00084 ClassDef(TDbiOutRowStream,0) //Output stream for single table row 00085 00086 }; 00087 00088 00089 00090 #endif // DBIOUTROWSTREAM_H 00091