25 #ifndef DOXYGEN_SHOULD_SKIP_THIS 55 if (!__strings().existsFirst(str)) {
56 __strings().insert(str, __string_max_index);
57 __val_index = __string_max_index;
60 __val_index = __strings().second(str);
69 std::memcpy(&__val_index, &(from.__val_index),
sizeof(UnionType));
78 std::memcpy(&__val_index, &(from.__val_index),
sizeof(UnionType));
93 std::memcpy(&__val_index, &(from.__val_index),
sizeof(UnionType));
103 __type = from.__type;
104 std::memcpy(&__val_index, &(from.__val_index),
sizeof(UnionType));
129 if (!__strings().existsFirst(str)) {
130 __strings().insert(str, __string_max_index);
131 __val_index = __string_max_index;
132 ++__string_max_index;
134 __val_index = __strings().second(str);
144 return (__type == from.__type)
146 || ((__type ==
EltType::REAL) && (__val_real == from.__val_real))
147 || (__val_integer == from.__val_integer));
166 GUM_ERROR(TypeError, __typeErrorMsg(
"a real number"));
180 GUM_ERROR(TypeError,
"the string does not contain a real number");
181 __val_real = std::stof(elt);
189 return __val_integer;
191 GUM_ERROR(TypeError, __typeErrorMsg(
"an integer"));
205 GUM_ERROR(TypeError,
"the string does not contain an integer");
206 __val_integer = std::stoi(elt);
214 return __strings().first(__val_index);
216 GUM_ERROR(TypeError, __typeErrorMsg(
"a string"));
225 GUM_ERROR(TypeError, __typeErrorMsg(
"a string"));
231 return __strings().first(index);
237 if (!__strings().existsFirst(str)) {
238 __strings().insert(str, __string_max_index);
239 __val_index = __string_max_index;
240 ++__string_max_index;
242 __val_index = __strings().second(str);
void setString(const std::string &elt)
sets the content of the DBCell
bool isMissing() const
indicates whether the cell contains a missing value
static bool isInteger(const std::string &str)
determines whether a string corresponds precisely to an integer
gum is the global namespace for all aGrUM entities
const std::string & string() const
returns the DBcell as a string
int integer() const
returns the DBcell as an integer
float real() const
returns the DBcell as a real number
The class representing the original values of the cells of databases.
static bool isReal(const std::string &str)
determine whether a string corresponds precisely to a real number
bool operator!=(const DBCell &from) const
test of inequality
DBCell & operator=(const DBCell &from)
copy operator
void setReal(const float x)
sets the content of the DBCell
int stringIndex() const
returns the DBcell as the index of a string in a static bijection
EltType type() const noexcept
returns the current type of the DBCell
bool operator==(const DBCell &from) const
test of equality
void setInteger(const int x)
sets the content of the DBCell
EltType
the set of types possibly taken by the last element read
void setMissingState()
sets the DBCell as a missing element
#define GUM_ERROR(type, msg)
DBCell()
default constructor (ontains a missing value)