TkN 2.4
Toolkit for Nuclei
Loading...
Searching...
No Matches
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 * Licensed under the MIT License <http://opensource.org/licenses/MIT>. *
11 * SPDX-License-Identifier: MIT *
12 ********************************************************************************/
13
14#ifndef tkdb_column_H
15#define tkdb_column_H
16
17#include <limits>
18#include <iomanip>
19#include <sstream>
20
21#include "tkstring.h"
22
23namespace tkn {
24
26{
27protected:
28 tkstring fName;
29 tkstring fType;
30 tkstring fCurrentValue;
31
32public:
33 tkdb_column(const char* _name, const char* _type);
35
36 const char* get_name()const {return fName.c_str();}
37 const char* get_type()const {return fType.c_str();}
38 tkstring get_value()const{return fCurrentValue.c_str();}
39
40 void set_name(const char* _name) {fName=_name;}
41 void set_type(const char* _type) {fType=_type;}
42
43 template<typename T>
44 void set_value( const T & t) {
45 if(fType.contains("AUTOINCREMENT")) return;
46 std::ostringstream oss;
47 oss << std::setprecision(std::numeric_limits<double>::digits10) << t; // Use a miximal precision
48 fCurrentValue = oss.str();
49 }
50
51 void set_value_str(const char* val) {
52 fCurrentValue = val;
53 }
54
55 bool is_empty(){return get_value()=="";}
56 bool is_text() {tkstring val=get_type(); return val.contains("TEXT");}
57
58 virtual ~tkdb_column();
59
60#ifdef HAS_ROOT
62 ClassDef(tkdb_column,0);
63#endif
64
65};
66}
67#endif
void set_name(const char *_name)
Definition tkdb_column.h:40
void set_type(const char *_type)
Definition tkdb_column.h:41
tkdb_column(const char *_name, const char *_type)
const char * get_name() const
Definition tkdb_column.h:36
void set_value_str(const char *val)
Definition tkdb_column.h:51
void set_value(const T &t)
Definition tkdb_column.h:44
virtual ~tkdb_column()
const char * get_type() const
Definition tkdb_column.h:37
tkstring get_value() const
Definition tkdb_column.h:38
std::string with usefull tricks from TString (ROOT) and KVString (KaliVeda) and more....
Definition tkstring.h:31
bool contains(const char *_pat, ECaseCompare _cmp=kExact) const
Definition tkstring.h:174
Definition tklog.cpp:16