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
 
TString TypeName () const
 
columnUNIQUE ()
 

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()

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

clean up binary data

Definition at line 92 of file SQLiteDB.h.

Member Function Documentation

◆ binary_data()

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

Definition at line 252 of file SQLiteDB.h.

◆ data()

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

Definition at line 242 of file SQLiteDB.h.

◆ DEFAULT() [1/4]

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

set DEFAULT string value

Definition at line 234 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 200 of file SQLiteDB.h.

◆ DEFAULT() [3/4]

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

set DEFAULT floating value

Definition at line 226 of file SQLiteDB.h.

◆ DEFAULT() [4/4]

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

set DEFAULT signed integer value

Definition at line 218 of file SQLiteDB.h.

◆ get_data()

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

Definition at line 247 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 1525 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 499 of file SQLiteDB.cpp.

◆ get_table()

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

return name of parent table

Definition at line 115 of file SQLiteDB.h.

◆ index()

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

Definition at line 125 of file SQLiteDB.h.

◆ is_null()

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

Definition at line 153 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 193 of file SQLiteDB.h.

◆ operator=()

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

set data in column

Definition at line 142 of file SQLiteDB.h.

◆ print()

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

Definition at line 130 of file SQLiteDB.h.

◆ rowid_alias()

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

Definition at line 256 of file SQLiteDB.h.

◆ set_binary_data() [1/2]

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

Definition at line 159 of file SQLiteDB.h.

◆ set_binary_data() [2/2]

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

Definition at line 166 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:186
column & DEFAULT(default_time t)
Definition: SQLiteDB.h:200

Definition at line 175 of file SQLiteDB.h.

◆ set_data() [1/2]

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

Definition at line 1420 of file SQLiteDB.cpp.

◆ set_data() [2/2]

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

Definition at line 135 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 1479 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 1435 of file SQLiteDB.cpp.

◆ set_null()

void KVSQLite::column::set_null ( )
inline

Definition at line 149 of file SQLiteDB.h.

◆ set_rowidalias()

void KVSQLite::column::set_rowidalias ( )
inline

Definition at line 260 of file SQLiteDB.h.

◆ set_table()

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

set parent table name

Definition at line 120 of file SQLiteDB.h.

◆ type()

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

Definition at line 106 of file SQLiteDB.h.

◆ TypeName()

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

Definition at line 110 of file SQLiteDB.h.

◆ UNIQUE()

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

set UNIQUE constraint on column

Examples
db_sqlite_examples.C.

Definition at line 186 of file SQLiteDB.h.

Friends And Related Function Documentation

◆ database

friend class database
friend

Definition at line 62 of file SQLiteDB.h.