SqliteRecord is one record in the SqliteRecordset object.
More...
#include <SqliteRecord.h>
SqliteRecord is one record in the SqliteRecordset object.
Definition at line 48 of file SqliteRecord.h.
◆ FieldCheckResult
◆ Record
◆ RecordCIterator
◆ FieldCheckCode
| Enumerator |
|---|
| FIELD_CHECK_OK | |
| FIELD_CHECK_BAD_NAME | |
| FIELD_CHECK_BAD_TYPE | |
| FIELD_CHECK_NULL_VAL | |
Definition at line 130 of file SqliteRecord.h.
◆ SqliteRecord() [1/3]
◆ SqliteRecord() [2/3]
| SqliteRecord::SqliteRecord |
( |
| ) |
|
|
delete |
◆ SqliteRecord() [3/3]
◆ ~SqliteRecord()
| SqliteRecord::~SqliteRecord |
( |
| ) |
|
|
override |
◆ addValue()
| void SqliteRecord::addValue |
( |
std::string_view | field, |
|
|
SqliteInp | value ) |
Definition at line 104 of file SqliteRecord.cxx.
105{
107 if(!result) throw std::runtime_error(std::format("Unexpected error when adding new value for the field {}. Duplicate field name?", field));
108}
◆ checkField()
Definition at line 146 of file SqliteRecord.h.
148{
151
152 auto defIt =
m_def->find(field);
155
160 }
161 }
162 return std::make_tuple(checkIt,checkCode);
163}
Record::const_iterator RecordCIterator
◆ dump()
| void SqliteRecord::dump |
( |
| ) |
const |
Dump to cout.
Definition at line 110 of file SqliteRecord.cxx.
111{
112 boost::io::ios_all_saver saver (std::cout);
114 for(
const auto& [colName,colType] : *
m_def) {
115 if(first) {
117 }
118 else {
119 std::cout << ", ";
120 }
121 auto recIt =
m_record.find(colName);
122 bool fieldNull = (recIt==
m_record.end());
123 std::cout << "[" << colName << " (";
124 switch(colType) {
126 std::cout << "int) : " << (fieldNull? "NULL" : std::to_string(std::get<int>(recIt->second))) << "]";
127 break;
129 std::cout << "long) : " << (fieldNull? "NULL" : std::to_string(std::get<long>(recIt->second))) << "]";
130 break;
132 std::cout << "float) : ";
133 if (fieldNull) {
134 std::cout << "NULL";
135 }
136 else {
137 std::cout << std::setprecision(10) << std::get<float>(recIt->second) << "]";
138 }
139 break;
141 std::cout << "double) : ";
142 if (fieldNull) {
143 std::cout << "NULL";
144 }
145 else {
146 std::cout << std::setprecision(10) << std::get<double>(recIt->second) << "]";
147 }
148 break;
150 std::cout << "string) : " << (fieldNull? "NULL" : ("\"" + std::get<std::string>(recIt->second)) + "\"") << "]";
151 break;
152 default:
153 std::cout << "ERROR) : ]";
154 }
155 }
156 std::cout << std::endl;
157}
◆ getDouble() [1/2]
| double SqliteRecord::getDouble |
( |
std::string_view | field | ) |
const |
|
overridevirtual |
Get double field value.
- Parameters
-
- Returns
- field value
Implements IRDBRecord.
Definition at line 53 of file SqliteRecord.cxx.
54{
57 return std::get<double>(recIt->second);
58 }
60 return 0.;
61}
void handleError(std::string_view field, FieldCheckCode checkCode) const
FieldCheckResult checkField(std::string_view field, SqliteInpType fieldType) const
◆ getDouble() [2/2]
| double SqliteRecord::getDouble |
( |
std::string_view | field, |
|
|
unsigned int | index ) const |
|
overridevirtual |
Get array double field value.
- Parameters
-
| field | [IN] field name |
| index | [IN] index in the array |
- Returns
- field value
Implements IRDBRecord.
Definition at line 89 of file SqliteRecord.cxx.
90{
91 return getDouble(std::format(
"{}_{}", field, index));
92}
double getDouble(std::string_view field) const override
Get double field value.
◆ getFloat() [1/2]
| float SqliteRecord::getFloat |
( |
std::string_view | field | ) |
const |
|
overridevirtual |
◆ getFloat() [2/2]
| float SqliteRecord::getFloat |
( |
std::string_view | field, |
|
|
unsigned int | index ) const |
|
overridevirtual |
Get array float field value.
- Parameters
-
| field | [IN] field name |
| index | [IN] index in the array |
- Returns
- field value
Implements IRDBRecord.
Definition at line 94 of file SqliteRecord.cxx.
95{
96 return getFloat(std::format(
"{}_{}", field, index));
97}
float getFloat(std::string_view field) const override
Get float field value.
◆ getInt() [1/2]
| int SqliteRecord::getInt |
( |
std::string_view | field | ) |
const |
|
overridevirtual |
Get int field value.
- Parameters
-
- Returns
- field value
Implements IRDBRecord.
Definition at line 37 of file SqliteRecord.cxx.
38{
41 return std::get<int>(recIt->second);
42 }
44 return 0;
45}
◆ getInt() [2/2]
| int SqliteRecord::getInt |
( |
std::string_view | field, |
|
|
unsigned int | index ) const |
|
overridevirtual |
Get array int field value.
- Parameters
-
| field | [IN] field name |
| index | [IN] index in the array |
- Returns
- field value
Implements IRDBRecord.
Definition at line 79 of file SqliteRecord.cxx.
80{
81 return getInt(std::format(
"{}_{}", field, index));
82}
int getInt(std::string_view field) const override
Get int field value.
◆ getLong() [1/2]
| long SqliteRecord::getLong |
( |
std::string_view | field | ) |
const |
|
overridevirtual |
◆ getLong() [2/2]
| long SqliteRecord::getLong |
( |
std::string_view | field, |
|
|
unsigned int | index ) const |
|
overridevirtual |
Get array long field value.
- Parameters
-
| field | [IN] field name |
| index | [IN] index in the array |
- Returns
- field value
Implements IRDBRecord.
Definition at line 84 of file SqliteRecord.cxx.
85{
86 return getLong(std::format(
"{}_{}", field, index));
87}
long getLong(std::string_view field) const override
Get long field value.
◆ getString() [1/2]
| const std::string & SqliteRecord::getString |
( |
std::string_view | field | ) |
const |
|
overridevirtual |
Get string field value.
- Parameters
-
- Returns
- field value
Implements IRDBRecord.
Definition at line 69 of file SqliteRecord.cxx.
70{
73 return std::get<std::string>(recIt->second);
74 }
76 throw std::runtime_error("Unexpected error in SqliteRecord::getString()");
77}
◆ getString() [2/2]
| const std::string & SqliteRecord::getString |
( |
std::string_view | field, |
|
|
unsigned int | index ) const |
|
overridevirtual |
Get array string field value.
- Parameters
-
| field | [IN] field name |
| index | [IN] index in the array |
- Returns
- field value
Implements IRDBRecord.
Definition at line 99 of file SqliteRecord.cxx.
100{
101 return getString(std::format(
"{}_{}", field, index));
102}
virtual const std::string & getString(std::string_view field) const override
Get string field value.
◆ handleError()
| void SqliteRecord::handleError |
( |
std::string_view | field, |
|
|
FieldCheckCode | checkCode ) const |
|
private |
Definition at line 160 of file SqliteRecord.cxx.
161{
162 switch(checkCode) {
164 throw std::runtime_error( std::format("handleError: Wrong name for the field {}",field));
166 throw std::runtime_error( std::format("handleError: Wrong data type requested for the field {}",field));
168 throw std::runtime_error( std::format("handleError: {} is NULL", field));
169 default:
170 break;
171 }
172 return;
173}
◆ isFieldNull()
| bool SqliteRecord::isFieldNull |
( |
std::string_view | field | ) |
const |
|
overridevirtual |
Check if the field value is NULL.
- Parameters
-
| field | [IN] field name @retun TRUE if the field is NULL, FALSE otherwise |
Implements IRDBRecord.
Definition at line 30 of file SqliteRecord.cxx.
31{
33 if(
m_def->find(field)==
m_def->end())
throw std::runtime_error( std::format(
"Wrong name for the field {}",field));
34 return true;
35}
◆ operator=()
◆ m_def
◆ m_record
The documentation for this class was generated from the following files: