17#include "RelationalAccess/ICursor.h"
19#include "CoralBase/Attribute.h"
20#include "CoralBase/AttributeList.h"
21#include "CoralBase/AttributeSpecification.h"
28 ,
const std::string& tableName)
33 m_values =
new coral::AttributeList(attList.specification(),
false);
34 m_values->fastCopyData (attList);
36 for(
unsigned int i=0; i<m_values->size(); i++) {
37 std::string key = (*m_values)[i].specification().name();
51 throw std::runtime_error(
"Wrong name for the field " +
m_tableName+
"."+fieldName);
54 const coral::AttributeList& values = *m_values;
55 return values[it->second].isNull();
62 throw std::runtime_error(
"Wrong name for the field " +
m_tableName+
"."+fieldName);
65 const coral::AttributeList& values = *m_values;
66 if(values[it->second].specification().type()==
typeid(
int)) {
67 return values[it->second].data<
int>();
69 else if(values[it->second].specification().type()==
typeid(
long)) {
70 return (
int)values[it->second].data<
long>();
73 throw std::runtime_error(
"Field " + fieldName +
" is NOT of integer type\n");
81 throw std::runtime_error(
"Wrong name for the field " +
m_tableName+
"."+fieldName);
84 const coral::AttributeList& values = *m_values;
85 if(values[it->second].specification().type()==
typeid(
long)) {
86 return values[it->second].data<
long>();
88 else if(values[it->second].specification().type()==
typeid(
int)) {
89 return (
long)values[it->second].data<
int>();
91 else if(values[it->second].specification().type()==
typeid(
long long)) {
92 return (
long)values[it->second].data<
long long>();
95 throw std::runtime_error(
"Field " + fieldName +
" is NOT of long type");
103 throw std::runtime_error(
"Wrong name for the field " +
m_tableName+
"."+fieldName);
106 const coral::AttributeList& values = *m_values;
107 if(values[it->second].specification().type()==
typeid(
double)) {
108 return values[it->second].data<
double>();
111 throw std::runtime_error(
"Field " + fieldName +
" is NOT of double type");
119 throw std::runtime_error(
"Wrong name for the field " +
m_tableName+
"."+fieldName);
122 const coral::AttributeList& values = *m_values;
123 if(values[it->second].specification().type()==
typeid(
float)) {
124 return values[it->second].data<
float>();
127 throw std::runtime_error(
"Field " + fieldName +
" is NOT of float type");
135 throw std::runtime_error(
"Wrong name for the field " +
m_tableName+
"."+fieldName);
138 const coral::AttributeList& values = *m_values;
139 if(values[it->second].specification().type()==
typeid(std::string)) {
140 return values[it->second].data<std::string>();
143 throw std::runtime_error(
"Field " + fieldName +
" is NOT of string type");
151 throw std::runtime_error(
"Wrong name for the array field " +
m_tableName+
"."+fieldName +
" or index=" + std::to_string(
index) +
" is out of range");
154 const coral::AttributeList& values = *m_values;
155 if(values[it->second].specification().type()==
typeid(
int)) {
156 return values[it->second].data<
int>();
158 else if(values[it->second].specification().type()==
typeid(
long)) {
159 return (
int)values[it->second].data<
long>();
162 throw std::runtime_error(
"Field " + fieldName +
" is NOT of integer type\n");
170 throw std::runtime_error(
"Wrong name for the array field " +
m_tableName+
"."+fieldName +
" or index=" + std::to_string(
index) +
" is out of range");
173 const coral::AttributeList& values = *m_values;
174 if(values[it->second].specification().type()==
typeid(
long)) {
175 return values[it->second].data<
long>();
177 else if(values[it->second].specification().type()==
typeid(
int)) {
178 return (
long)values[it->second].data<
int>();
181 throw std::runtime_error(
"Field " + fieldName +
" is NOT of long type");
189 throw std::runtime_error(
"Wrong name for the array field " +
m_tableName+
"."+fieldName +
" or index=" + std::to_string(
index) +
" is out of range");
192 const coral::AttributeList& values = *m_values;
193 if(values[it->second].specification().type()==
typeid(
double)) {
194 return values[it->second].data<
double>();
197 throw std::runtime_error(
"Field " + fieldName +
" is NOT of double type");
205 throw std::runtime_error(
"Wrong name for the array field " +
m_tableName+
"."+fieldName +
" or index=" + std::to_string(
index) +
" is out of range");
208 const coral::AttributeList& values = *m_values;
209 if(values[it->second].specification().type()==
typeid(
float)) {
210 return values[it->second].data<
float>();
213 throw std::runtime_error(
"Field " + fieldName +
" is NOT of float type");
221 throw std::runtime_error(
"Wrong name for the array field " +
m_tableName+
"."+fieldName +
" or index=" + std::to_string(
index) +
" is out of range");
224 const coral::AttributeList& values = *m_values;
225 if(values[it->second].specification().type()==
typeid(std::string)) {
226 return values[it->second].data<std::string>();
229 throw std::runtime_error(
"Field " + fieldName +
" is NOT of string type");
235 const coral::AttributeList& myAttList = *m_values;
236 const coral::AttributeList& rhsAttList = *rhs.m_values;
238 if(myAttList.size()!=rhsAttList.size())
return true;
240 for(
size_t i(0); i<myAttList.size(); ++i) {
241 const coral::Attribute& myAtt = myAttList[i];
242 const std::string name = myAtt.specification().name();
244 for(
size_t j(0); j<rhsAttList.size(); ++j) {
245 const coral::Attribute& rhsAtt = rhsAttList[j];
246 if(rhsAtt.specification().name()==name) {
262 m_values->toOutputStream(os);
Definition of RDBRecord class.
bool isFieldNull(const std::string &fieldName) const override
Check if the field value is NULL.
bool operator!=(const RDBRecord &rhs) const
RDBRecord(const RDBRecord &)=delete
std::ostream & toOutputStream(std::ostream &os) const
RDBRecord()
Empty private constructor.
virtual const std::string & getString(const std::string &fieldName) const override
Get string field value.
~RDBRecord() override
Destructor.
double getDouble(const std::string &fieldName) const override
Get double field value.
long getLong(const std::string &fieldName) const override
Get long field value.
float getFloat(const std::string &fieldName) const override
Get float field value.
int getInt(const std::string &fieldName) const override
Get int field value.
FieldName2ListIndex m_name2Index
bool exists(const std::string &filename)
does a file exist