KaliVeda
Toolkit for HIC analysis
KVSQLite::column Class Reference

Detailed Description

Definition at line 54 of file SQLiteDB.h.

#include <SQLiteDB.h>

Public Types

enum class  default_time { CURRENT_DATE , CURRENT_TIME , CURRENT_TIMESTAMP }
 

Public Member Functions

virtual ~column ()
 
template<typename T >
Tbinary_data () const
 
const KVNamedParameterdata () const
 
columnDEFAULT (const TString &s)
 
columnDEFAULT (default_time t)
 
columnDEFAULT (double d)
 
columnDEFAULT (int i)
 
template<typename T >
T get_data () const
 
TString get_data_string_for_insert ()
 
TString get_declaration () const
 
TString get_table () const
 
int index () const
 
bool is_null () const
 
const char * name () const
 
TString Name () const
 
columnNOT_NULL ()
 
template<typename T >
const columnoperator= (const T &x)
 
void print () const
 
bool rowid_alias () const
 
template<typename T >
void set_binary_data (T &x)
 
template<typename T >
void set_binary_data (T *x)
 
void set_constraint (const TString &c)
 
template<>
void set_data (const KVNamedParameter &x)
 
template<typename T >
void set_data (const T &x)
 
void set_data_from_statement (TSQLStatement *s, int idx=-1) const
 
void set_data_in_statement (TSQLStatement *, int idx=-1) const
 
void set_null ()
 
void set_rowidalias ()
 
void set_table (const TString &name)
 
KVSQLite_column_type type () const
 
const char * type_name () const
 
TString TypeName () const
 
columnUNIQUE ()
 

Private Member Functions

 column (int idx, const TString &name, KVSQLite_column_type type)
 
TString _type ()
 
void init_type_map ()
 

Private Attributes

voidfBlob
 
Long_t fBlobSize
 binary data More...
 
TString fConstraint
 
KVNamedParameter fData
 
int fIndex
 
bool fIsNull
 
bool fIsROWIDAlias
 
std::pair< TString, KVSQLite_column_typefNameType
 
TString fTable
 
bool has_data
 

Static Private Attributes

static std::map< KVSQLite::column_type::types, TStringinv_type_map
 

Friends

class database
 
class table
 Column in an SQLite database. More...
 

Member Enumeration Documentation

◆ default_time

Enumerator
CURRENT_DATE 
CURRENT_TIME 
CURRENT_TIMESTAMP 

Definition at line 87 of file SQLiteDB.h.

Constructor & Destructor Documentation

◆ column()

KVSQLite::column::column ( int  idx,
const TString name,
KVSQLite_column_type  type 
)
inlineprivate

Definition at line 79 of file SQLiteDB.h.

◆ ~column()

virtual KVSQLite::column::~column ( )
inlinevirtual

clean up binary data

Definition at line 92 of file SQLiteDB.h.

Member Function Documentation

◆ _type()

TString KVSQLite::column::_type ( )
private

Definition at line 1375 of file SQLiteDB.cpp.

◆ binary_data()

template<typename T >
T* KVSQLite::column::binary_data ( ) const
inline

Definition at line 256 of file SQLiteDB.h.

◆ data()

const KVNamedParameter& KVSQLite::column::data ( ) const
inline

Definition at line 246 of file SQLiteDB.h.

◆ DEFAULT() [1/4]

column& KVSQLite::column::DEFAULT ( const TString s)
inline

set DEFAULT string value

Definition at line 238 of file SQLiteDB.h.

◆ DEFAULT() [2/4]

column& KVSQLite::column::DEFAULT ( default_time  t)
inline

set DEFAULT value to one of CURRENT_TIME, CURRENT_DATE, or CURRENT_TIMESTAMP

Examples
db_sqlite_examples.C.

Definition at line 204 of file SQLiteDB.h.

◆ DEFAULT() [3/4]

column& KVSQLite::column::DEFAULT ( double  d)
inline

set DEFAULT floating value

Definition at line 230 of file SQLiteDB.h.

◆ DEFAULT() [4/4]

column& KVSQLite::column::DEFAULT ( int  i)
inline

set DEFAULT signed integer value

Definition at line 222 of file SQLiteDB.h.

◆ get_data()

template<typename T >
T KVSQLite::column::get_data ( ) const
inline

Definition at line 251 of file SQLiteDB.h.

◆ get_data_string_for_insert()

TString KVSQLite::column::get_data_string_for_insert ( )

write data in string; for TEXT data we enclose in single quotes

we also replace any "'" with "''" (otherwise SQL error on insert)

Definition at line 1489 of file SQLiteDB.cpp.

◆ get_declaration()

TString KVSQLite::column::get_declaration ( ) const

return declaration for column, including type & constraint

the name of the column is enclosed in double-quotes, in case it is the same as an SQL keyword

Definition at line 503 of file SQLiteDB.cpp.

◆ get_table()

TString KVSQLite::column::get_table ( ) const
inline

return name of parent table

Definition at line 119 of file SQLiteDB.h.

◆ index()

int KVSQLite::column::index ( ) const
inline

Definition at line 129 of file SQLiteDB.h.

◆ init_type_map()

void KVSQLite::column::init_type_map ( )
private

Definition at line 1362 of file SQLiteDB.cpp.

◆ is_null()

bool KVSQLite::column::is_null ( ) const
inline

Definition at line 157 of file SQLiteDB.h.

◆ name()

const char* KVSQLite::column::name ( ) const
inline

Definition at line 98 of file SQLiteDB.h.

◆ Name()

TString KVSQLite::column::Name ( ) const
inline

Definition at line 102 of file SQLiteDB.h.

◆ NOT_NULL()

column& KVSQLite::column::NOT_NULL ( )
inline

set NOT NULL constraint on column

Examples
db_sqlite_examples.C.

Definition at line 197 of file SQLiteDB.h.

◆ operator=()

template<typename T >
const column& KVSQLite::column::operator= ( const T x)
inline

set data in column

Definition at line 146 of file SQLiteDB.h.

◆ print()

void KVSQLite::column::print ( ) const
inline

Definition at line 134 of file SQLiteDB.h.

◆ rowid_alias()

bool KVSQLite::column::rowid_alias ( ) const
inline

Definition at line 260 of file SQLiteDB.h.

◆ set_binary_data() [1/2]

template<typename T >
void KVSQLite::column::set_binary_data ( T x)
inline

Definition at line 163 of file SQLiteDB.h.

◆ set_binary_data() [2/2]

template<typename T >
void KVSQLite::column::set_binary_data ( T x)
inline

Definition at line 170 of file SQLiteDB.h.

◆ set_constraint()

void KVSQLite::column::set_constraint ( const TString c)
inline

set constraint for column, one of:

CHECK
NOT NULL
column & UNIQUE()
Definition: SQLiteDB.h:190
column & DEFAULT(default_time t)
Definition: SQLiteDB.h:204

Definition at line 179 of file SQLiteDB.h.

◆ set_data() [1/2]

template<>
void KVSQLite::column::set_data ( const KVNamedParameter x)

Definition at line 1384 of file SQLiteDB.cpp.

◆ set_data() [2/2]

template<typename T >
void KVSQLite::column::set_data ( const T x)
inline

Definition at line 139 of file SQLiteDB.h.

◆ set_data_from_statement()

void KVSQLite::column::set_data_from_statement ( TSQLStatement s,
int  idx = -1 
) const

set value of column according to value of parameter in statement

any column which has a NULL value will be given value 0, 0.0 or "" (for INTEGER, REAL or TEXT type, respectively): use column::is_null() to check if this corresponds to a null column value.

Parameters
idxif given, use it as the statement parameter index instead of the column's index in the table (case where not all columns are treated in the statement)

Definition at line 1443 of file SQLiteDB.cpp.

◆ set_data_in_statement()

void KVSQLite::column::set_data_in_statement ( TSQLStatement s,
int  idx = -1 
) const

set value of parameter in SQLite statement corresponding to this column

Parameters
idxif given, use it as the statement parameter index instead of the column's index in the table (case where not all columns are treated in the statement)

Definition at line 1399 of file SQLiteDB.cpp.

◆ set_null()

void KVSQLite::column::set_null ( )
inline

Definition at line 153 of file SQLiteDB.h.

◆ set_rowidalias()

void KVSQLite::column::set_rowidalias ( )
inline

Definition at line 264 of file SQLiteDB.h.

◆ set_table()

void KVSQLite::column::set_table ( const TString name)
inline

set parent table name

Definition at line 124 of file SQLiteDB.h.

◆ type()

KVSQLite_column_type KVSQLite::column::type ( ) const
inline

Definition at line 106 of file SQLiteDB.h.

◆ type_name()

const char* KVSQLite::column::type_name ( ) const
inline

Definition at line 110 of file SQLiteDB.h.

◆ TypeName()

TString KVSQLite::column::TypeName ( ) const
inline

Definition at line 114 of file SQLiteDB.h.

◆ UNIQUE()

column& KVSQLite::column::UNIQUE ( )
inline

set UNIQUE constraint on column

Examples
db_sqlite_examples.C.

Definition at line 190 of file SQLiteDB.h.

Friends And Related Function Documentation

◆ database

friend class database
friend

Definition at line 62 of file SQLiteDB.h.

Member Data Documentation

◆ fBlob

void* KVSQLite::column::fBlob
mutableprivate

Definition at line 70 of file SQLiteDB.h.

◆ fBlobSize

Long_t KVSQLite::column::fBlobSize
mutableprivate

binary data

Definition at line 71 of file SQLiteDB.h.

◆ fConstraint

TString KVSQLite::column::fConstraint
private

Definition at line 65 of file SQLiteDB.h.

◆ fData

KVNamedParameter KVSQLite::column::fData
mutableprivate

Definition at line 68 of file SQLiteDB.h.

◆ fIndex

int KVSQLite::column::fIndex
private

Definition at line 66 of file SQLiteDB.h.

◆ fIsNull

bool KVSQLite::column::fIsNull
mutableprivate

Definition at line 73 of file SQLiteDB.h.

◆ fIsROWIDAlias

bool KVSQLite::column::fIsROWIDAlias
private

Definition at line 72 of file SQLiteDB.h.

◆ fNameType

std::pair<TString, KVSQLite_column_type> KVSQLite::column::fNameType
private

Definition at line 64 of file SQLiteDB.h.

◆ fTable

TString KVSQLite::column::fTable
private

Definition at line 74 of file SQLiteDB.h.

◆ has_data

bool KVSQLite::column::has_data
private

Definition at line 69 of file SQLiteDB.h.

◆ inv_type_map

std::map< KVSQLite::column_type::types, TString > KVSQLite::column::inv_type_map
staticprivate

Definition at line 67 of file SQLiteDB.h.