Belle II Software development
DBRecord Class Reference

Public Member Functions

std::vector< std::string > & getFieldNames ()
 
DBFieldList & getFieldValues ()
 
bool hasField (const std::string &name)
 
size_t getNFields () const
 
const std::string get (const std::string &name) const
 
const std::string get (int i) const
 
unsigned long long int getULLInt (const std::string &name) const
 
int getInt (const std::string &name) const
 
int getInt (int i) const
 
bool getBool (const std::string &name) const
 
bool getBool (int i) const
 
float getFloat (const std::string &name) const
 
float getFloat (int i) const
 
std::vector< std::string > getArray (const std::string &name) const
 
std::vector< std::string > getArray (int i) const
 
std::vector< int > getIntArray (const std::string &name) const
 
std::vector< int > getIntArray (int i) const
 
std::vector< float > getFloatArray (const std::string &name) const
 
std::vector< float > getFloatArray (int i) const
 
const std::string getFieldName (int i) const
 
void reset ()
 
void add (std::string name, std::string value)
 

Private Attributes

std::vector< std::string > m_name_v
 
DBFieldList m_value_m
 

Detailed Description

Definition at line 23 of file DBRecord.h.

Constructor & Destructor Documentation

◆ DBRecord()

DBRecord ( )
inline

Definition at line 26 of file DBRecord.h.

26{};

◆ ~DBRecord()

~DBRecord ( )
inline

Definition at line 27 of file DBRecord.h.

27{};

Member Function Documentation

◆ add()

void add ( std::string  name,
std::string  value 
)

Definition at line 116 of file DBRecord.cc.

117{
118 m_name_v.push_back(name);
119 m_value_m.insert(DBFieldList::value_type(name, value));
120}

◆ get() [1/2]

const std::string get ( const std::string &  name) const

Definition at line 16 of file DBRecord.cc.

17{
18 if (m_value_m.find(name) != m_value_m.end()) return m_value_m[name];
19 else return "";
20}

◆ get() [2/2]

const std::string get ( int  i) const

Definition at line 22 of file DBRecord.cc.

23{
24 if (i >= 0 && i < (int)m_name_v.size())
25 return m_value_m[m_name_v[i]];
26 else return "";
27}

◆ getArray() [1/2]

std::vector< std::string > getArray ( const std::string &  name) const

Definition at line 64 of file DBRecord.cc.

65{
66 std::string value = StringUtil::replace(StringUtil::replace(get(name), "}", ""), "{", "");
67 return StringUtil::split(value, ',');
68}

◆ getArray() [2/2]

std::vector< std::string > getArray ( int  i) const

Definition at line 70 of file DBRecord.cc.

71{
72 std::string value = StringUtil::replace(StringUtil::replace(get(i), "}", ""), "{", "");
73 return StringUtil::split(value, ',');
74}

◆ getBool() [1/2]

bool getBool ( const std::string &  name) const

Definition at line 44 of file DBRecord.cc.

45{
46 return get(name) == "t";
47}

◆ getBool() [2/2]

bool getBool ( int  i) const

Definition at line 49 of file DBRecord.cc.

50{
51 return get(i) == "t";
52}

◆ getFieldName()

const std::string getFieldName ( int  i) const

Definition at line 122 of file DBRecord.cc.

123{
124 if (i >= 0 && i < (int) m_name_v.size()) return m_name_v[i];
125 return "";
126}

◆ getFieldNames()

std::vector< std::string > & getFieldNames ( )
inline

Definition at line 30 of file DBRecord.h.

30{ return m_name_v; }

◆ getFieldValues()

DBFieldList & getFieldValues ( )
inline

Definition at line 31 of file DBRecord.h.

31{ return m_value_m; }

◆ getFloat() [1/2]

float getFloat ( const std::string &  name) const

Definition at line 54 of file DBRecord.cc.

55{
56 return atof(get(name).c_str());
57}

◆ getFloat() [2/2]

float getFloat ( int  i) const

Definition at line 59 of file DBRecord.cc.

60{
61 return atof(get(i).c_str());
62}

◆ getFloatArray() [1/2]

std::vector< float > getFloatArray ( const std::string &  name) const

Definition at line 96 of file DBRecord.cc.

97{
98 std::vector<float> value_i_v;
99 std::vector<std::string> value_v = getArray(name);
100 for (size_t i = 0; i < value_v.size(); i++) {
101 value_i_v.push_back(atof(value_v[i].c_str()));
102 }
103 return value_i_v;
104}

◆ getFloatArray() [2/2]

std::vector< float > getFloatArray ( int  i) const

Definition at line 106 of file DBRecord.cc.

107{
108 std::vector<float> value_i_v;
109 std::vector<std::string> value_v = getArray(i);
110 for (size_t j = 0; j < value_v.size(); j++) {
111 value_i_v.push_back(atof(value_v[j].c_str()));
112 }
113 return value_i_v;
114}

◆ getInt() [1/2]

int getInt ( const std::string &  name) const

Definition at line 34 of file DBRecord.cc.

35{
36 return atoi(get(name).c_str());
37}

◆ getInt() [2/2]

int getInt ( int  i) const

Definition at line 39 of file DBRecord.cc.

40{
41 return atoi(get(i).c_str());
42}

◆ getIntArray() [1/2]

std::vector< int > getIntArray ( const std::string &  name) const

Definition at line 76 of file DBRecord.cc.

77{
78 std::vector<int> value_i_v;
79 std::vector<std::string> value_v = getArray(name);
80 for (size_t i = 0; i < value_v.size(); i++) {
81 value_i_v.push_back(atoi(value_v[i].c_str()));
82 }
83 return value_i_v;
84}

◆ getIntArray() [2/2]

std::vector< int > getIntArray ( int  i) const

Definition at line 86 of file DBRecord.cc.

87{
88 std::vector<int> value_i_v;
89 std::vector<std::string> value_v = getArray(i);
90 for (size_t j = 0; j < value_v.size(); j++) {
91 value_i_v.push_back(atoi(value_v[j].c_str()));
92 }
93 return value_i_v;
94}

◆ getNFields()

size_t getNFields ( ) const
inline

Definition at line 36 of file DBRecord.h.

36{ return m_name_v.size(); }

◆ getULLInt()

unsigned long long int getULLInt ( const std::string &  name) const

Definition at line 29 of file DBRecord.cc.

30{
31 return std::strtoull(get(name).c_str(), NULL, 10);
32}

◆ hasField()

bool hasField ( const std::string &  name)
inline

Definition at line 32 of file DBRecord.h.

33 {
34 return m_value_m.find(name) != m_value_m.end();
35 }

Member Data Documentation

◆ m_name_v

std::vector<std::string> m_name_v
private

Definition at line 57 of file DBRecord.h.

◆ m_value_m

DBFieldList m_value_m
mutableprivate

Definition at line 58 of file DBRecord.h.


The documentation for this class was generated from the following files: