Logo ROOT   6.08/07
Reference Guide
TSQLColumnInfo.h
Go to the documentation of this file.
1 // @(#)root/net:$Id$
2 // Author: Sergey Linev 31/05/2006
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TSQLColumnInfo
13 #define ROOT_TSQLColumnInfo
14 
15 #ifndef ROOT_TNamed
16 #include "TNamed.h"
17 #endif
18 
19 class TSQLColumnInfo : public TNamed {
20 
21 protected:
22  // Database specific fields
23  TString fTypeName; //! sql type name, as reported by DB. Should be as much as close to declaration of column in CREATE TABLE query
24 
25  // Database independent fields
26  Int_t fSQLType; //! datatype code (see TSQLServer::ESQLDataTypes constants), -1 if not defeined
27  Int_t fSize; //! size of column in bytes, -1 if not defing
28  Int_t fLength; //! datatype length definition, for instance VARCHAR(len) or FLOAT(len), -1 if not defined
29  Int_t fScale; //! datatype scale factor, used for instance in NUMBER(len,scale) definition. -1 if not defined
30  Int_t fSigned; //! if datatype signed or not, 0 - kFALSE, 1 - kTRUE, -1 - unknown
31  Bool_t fNullable; //! identify if value can be NULL
32 
33 public:
35  TSQLColumnInfo(const char* columnname,
36  const char* sqltypename = "unknown",
37  Bool_t nullable = kFALSE,
38  Int_t sqltype = -1,
39  Int_t size = -1,
40  Int_t length = -1,
41  Int_t scale = -1,
42  Int_t sign = -1);
43  virtual ~TSQLColumnInfo() {}
44 
45  const char* GetTypeName() const { return fTypeName.Data(); }
46  Bool_t IsNullable() const { return fNullable; }
47  Int_t GetSQLType() const { return fSQLType; }
48  Int_t GetSize() const { return fSize; }
49  Int_t GetLength() const { return fLength; }
50  Int_t GetScale() const { return fScale; }
51  Int_t GetSigned() const { return fSigned; }
52  Bool_t IsSigned() const { return fSigned==1; }
53  Bool_t IsUnsigned() const { return fSigned==0; }
54 
55  virtual void Print(Option_t* option = "") const;
56 
57  ClassDef(TSQLColumnInfo, 0) // Summury information about column from SQL table
58 };
59 
60 #endif
const char * GetTypeName() const
Int_t GetSQLType() const
const char Option_t
Definition: RtypesCore.h:62
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
Int_t fLength
size of column in bytes, -1 if not defing
Bool_t IsUnsigned() const
virtual ~TSQLColumnInfo()
Int_t GetScale() const
Bool_t fNullable
if datatype signed or not, 0 - kFALSE, 1 - kTRUE, -1 - unknown
#define ClassDef(name, id)
Definition: Rtypes.h:254
Bool_t IsNullable() const
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
Int_t GetSigned() const
Int_t fScale
datatype length definition, for instance VARCHAR(len) or FLOAT(len), -1 if not defined ...
Int_t GetLength() const
virtual void Print(Option_t *option="") const
Prints column information to standard output.
Bool_t IsSigned() const
TSQLColumnInfo()
identify if value can be NULL
Int_t fSize
datatype code (see TSQLServer::ESQLDataTypes constants), -1 if not defeined
Int_t GetSize() const
Int_t fSQLType
sql type name, as reported by DB. Should be as much as close to declaration of column in CREATE TABLE...
Int_t fSigned
datatype scale factor, used for instance in NUMBER(len,scale) definition. -1 if not defined ...
const char * Data() const
Definition: TString.h:349