TkN 2.1
Toolkit for Nuclei
tkdb_column.h
1/********************************************************************************
2 * Copyright (c) : Université de Lyon 1, CNRS/IN2P3, UMR5822, *
3 * IP2I, F-69622 Villeurbanne Cedex, France *
4 * Normandie Université, ENSICAEN, UNICAEN, CNRS/IN2P3, *
5 * LPC Caen, F-14000 Caen, France *
6 * Contibutor(s) : *
7 * Jérémie Dudouet jeremie.dudouet@cnrs.fr [2020] *
8 * Diego Gruyer diego.gruyer@cnrs.fr [2020] *
9 * *
10 * This software is governed by the CeCILL-B license under French law and *
11 * abiding by the rules of distribution of free software. You can use, *
12 * modify and/ or redistribute the software under the terms of the *
13 * CeCILL-B license as circulated by CEA, CNRS and INRIA at the following *
14 * URL \"http://www.cecill.info\". *
15 * *
16 * As a counterpart to the access to the source code and rights to copy, *
17 * modify and redistribute granted by the license, users are provided *
18 * only with a limited warranty and the software's author, the holder of *
19 * the economic rights, and the successive licensors have only limited *
20 * liability. *
21 * *
22 * In this respect, the user's attention is drawn to the risks associated *
23 * with loading, using, modifying and/or developing or reproducing the *
24 * software by the user in light of its specific status of free software, *
25 * that may mean that it is complicated to manipulate, and that also *
26 * therefore means that it is reserved for developers and experienced *
27 * professionals having in-depth computer knowledge. Users are therefore *
28 * encouraged to load and test the software's suitability as regards *
29 * their requirements in conditions enabling the security of their *
30 * systems and/or data to be ensured and, more generally, to use and *
31 * operate it in the same conditions as regards security. *
32 * *
33 * The fact that you are presently reading this means that you have had *
34 * knowledge of the CeCILL-B license and that you accept its terms. *
35 ********************************************************************************/
36
37#ifndef tkdb_column_H
38#define tkdb_column_H
39
40#include <limits>
41#include <iomanip>
42#include <sstream>
43
44#include "tkstring.h"
45
46namespace tkn {
47
49{
50protected:
51 tkstring fName;
52 tkstring fType;
53 tkstring fCurrentValue;
54
55public:
56 tkdb_column(const char* _name, const char* _type);
58
59 const char* get_name()const {return fName.c_str();}
60 const char* get_type()const {return fType.c_str();}
61 tkstring get_value()const{return fCurrentValue.c_str();}
62
63 void set_name(const char* _name) {fName=_name;}
64 void set_type(const char* _type) {fType=_type;}
65
66 template<typename T>
67 void set_value( const T & t) {
68 if(fType.contains("AUTOINCREMENT")) return;
69 std::ostringstream oss;
70 oss << std::setprecision(std::numeric_limits<double>::digits10) << t; // Use a miximal precision
71 fCurrentValue = oss.str();
72 }
73
74 void set_value_str(const char* val) {
75 fCurrentValue = val;
76 }
77
78 bool is_empty(){return get_value()=="";}
79 bool is_text() {tkstring val=get_type(); return val.contains("TEXT");}
80
81 virtual ~tkdb_column();
82
83#ifdef HAS_ROOT
85 ClassDef(tkdb_column,0);
86#endif
87
88};
89}
90#endif
Simple structure to store a table column.
Definition: tkdb_column.h:49
void set_name(const char *_name)
Definition: tkdb_column.h:63
void set_type(const char *_type)
Definition: tkdb_column.h:64
const char * get_name() const
Definition: tkdb_column.h:59
void set_value_str(const char *val)
Definition: tkdb_column.h:74
void set_value(const T &t)
Definition: tkdb_column.h:67
virtual ~tkdb_column()
const char * get_type() const
Definition: tkdb_column.h:60
tkstring get_value() const
Definition: tkdb_column.h:61
std::string with usefull tricks from TString (ROOT) and KVString (KaliVeda) and more....
Definition: tkstring.h:54
bool contains(const char *_pat, ECaseCompare _cmp=kExact) const
Definition: tkstring.h:197
Definition: tklog.cpp:39