 |
ATLAS Offline Software
|
Go to the documentation of this file.
14 #include "boost/io/ios_state.hpp"
21 : m_def(std::move(def))
32 if(
m_def->find(
field)==
m_def->end())
throw std::runtime_error(
"Wrong name for the field "+
field);
40 return std::get<int>(recIt->second);
56 return std::get<double>(recIt->second);
72 return std::get<std::string>(recIt->second);
75 throw std::runtime_error(
"Unexpected error in SqliteRecord::getString()");
107 if(!
result)
throw std::runtime_error(
"Unexpected error when adding new value for the field " +
108 field +
". Duplicate field name?");
113 boost::io::ios_all_saver saver (std::cout);
115 for(
const auto& [colName,colType] : *
m_def) {
122 auto recIt =
m_record.find(colName);
123 bool fieldNull = (recIt==
m_record.end());
124 std::cout <<
"[" << colName <<
" (";
127 std::cout <<
"int) : " << (fieldNull?
"NULL" :
std::to_string(std::get<int>(recIt->second))) <<
"]";
130 std::cout <<
"long) : " << (fieldNull?
"NULL" :
std::to_string(std::get<long>(recIt->second))) <<
"]";
133 std::cout <<
"float) : ";
138 std::cout << std::setprecision(10) << std::get<float>(recIt->second) <<
"]";
142 std::cout <<
"double) : ";
147 std::cout << std::setprecision(10) << std::get<double>(recIt->second) <<
"]";
151 std::cout <<
"string) : " << (fieldNull?
"NULL" : (
"\"" + std::get<std::string>(recIt->second)) +
"\"") <<
"]";
154 std::cout <<
"ERROR) : ]";
157 std::cout << std::endl;
std::variant< int, long, float, double, std::string > SqliteInp
~SqliteRecord() override
Destructor.
Declaration of the SqliteRecord class.
float getFloat(const std::string &field) const override
Get float field value.
int getInt(const std::string &field) const override
Get int field value.
void addValue(const std::string &field, SqliteInp value)
void handleError(const std::string &field, FieldCheckCode checkCode) const
void dump() const
Dump to cout.
std::string to_string(const DetectorType &type)
long getLong(const std::string &field) const override
Get long field value.
FieldCheckResult checkField(const std::string &field, SqliteInpType fieldType) const
virtual const std::string & getString(const std::string &field) const override
Get string field value.
bool isFieldNull(const std::string &field) const override
Check if the field value is NULL.
std::shared_ptr< SqliteInpDef > SqliteInpDef_ptr
double getDouble(const std::string &field) const override
Get double field value.