TDbiFieldType.hxx

Go to the documentation of this file.
00001 
00002 #ifndef DBIFIELDTYPE_H
00003 #define DBIFIELDTYPE_H
00004 
00005 
00006 //////////////////////////////////////////////////////////////////////////
00007 ////////////////////////////     ROOT API     ////////////////////////////
00008 //////////////////////////////////////////////////////////////////////////
00009 
00010 /**
00011  *
00012  * $Id: TDbiFieldType.hxx,v 1.1 2011/01/18 05:49:20 finch Exp $
00013  *
00014  * \class TDbiFieldType
00015  *
00016  *
00017  * \brief
00018  * <b>Concept</b> Database neutral table column field types.
00019  *
00020  * \brief
00021  * <b>Purpose</b> To provide mappings and check compatibility between
00022  * database types and application types.
00023  *
00024  * Contact: A.Finch@lancaster.ac.uk
00025  *
00026  *
00027  */
00028 
00029 #include <string>
00030 using std::string;
00031 
00032 #include "TDbi.hxx"
00033 
00034 
00035 class TDbiFieldType
00036 {
00037 
00038 
00039 public:
00040 
00041  enum PrecisionLimits{ kMaxTinyInt       = 4,
00042                        kMaxSmallInt      = 6,
00043                        kMaxInt           = 11,
00044                        kMaxChar          = 3,
00045                        kMaxMySQLVarchar  = 255,
00046                        kMaxMySQLText     = 65535
00047 };
00048 
00049 // Constructors and destructors.
00050            TDbiFieldType(Int_t type = TDbi::kInt);
00051            TDbiFieldType(Int_t type,
00052                         Int_t size,
00053                         const char* typeName);
00054            TDbiFieldType(const TDbiFieldType& from);
00055            TDbiFieldType(const string& sql,
00056                         Int_t size);
00057   virtual ~TDbiFieldType();
00058 
00059 // State testing member functions
00060 
00061  string AsString() const;
00062  string AsSQLString() const;
00063  string UndefinedValue() const;
00064  UInt_t GetConcept() const { return fConcept; }
00065  UInt_t GetSize() const { return fSize; }
00066  UInt_t GetType() const { return fType; }
00067  Bool_t IsCompatible(const TDbiFieldType& other) const;
00068  Bool_t IsEqual(const TDbiFieldType& other) const
00069                                         { return fType == other.fType; }
00070  Bool_t IsSmaller(const TDbiFieldType& other) const
00071                                   { return fSize < other.fSize; }
00072  Bool_t IsSigned() const          { return fConcept ==  TDbi::kInt; }
00073 
00074 
00075 // State modifying member functions
00076 
00077    void SetUnsigned() {if (this->IsSigned()) {++fConcept; ++fType;}}
00078 
00079 private:
00080 
00081 void Init(Int_t type, Int_t size = -1);
00082 
00083 // Data members
00084 
00085 /// Concept e.g. kInt or kFloat
00086       unsigned int fConcept;
00087 /// Size in bytes(0 if unknown).
00088       unsigned int fSize;
00089 /// Concept e.g. kShort or kDouble
00090       unsigned int fType;
00091 
00092 ClassDef(TDbiFieldType,0)        // Table column field types.
00093 
00094 };
00095 
00096 
00097 #endif  // DBIFIELDTYPE_H
00098 

Generated on 11 Aug 2013 for SKDatabase by  doxygen 1.6.1