27 #ifndef GUM_LEARNING_DB_CELL_H 28 #define GUM_LEARNING_DB_CELL_H 33 #include <type_traits> 36 #include <agrum/agrum.h> 37 #include <agrum/tools/core/bijection.h> 98 DBCell(
const std::string& str);
168 void setReal(
const std::string& elt);
188 const std::string& string()
const;
219 static const std::string& string(
const int index);
226 template <
template <
typename >
class ALLOC = std::allocator >
228 const std::vector< std::string, ALLOC< std::string > >& missingVals);
235 template <
template <
typename >
class ALLOC = std::allocator >
237 const std::vector< std::string, ALLOC< std::string > >& missingVals);
243 template <
template <
typename >
class ALLOC = std::allocator >
245 toString(
const std::vector< std::string, ALLOC< std::string > >& missingVals)
const;
248 static bool isInteger(
const std::string& str);
251 static bool isReal(
const std::string& str);
254 template <
template <
typename >
class ALLOC = std::allocator >
255 static bool isMissing(
const std::string& str,
256 const std::vector< std::string, ALLOC< std::string > >& missingVals);
261 #ifndef DOXYGEN_SHOULD_SKIP_THIS 280 std::string _typeErrorMsg_(
const std::string& real_type)
const;
284 static Bijection< std::string,
int >& _strings_();
287 static int _string_max_index_;
297 #ifndef GUM_NO_INLINE 298 # include <agrum/tools/database/DBCell_inl.h> 301 #include <agrum/tools/database/DBCell_tpl.h>
bool convertType(const EltType newtype)
try to convert the content of the DBCell into another type
void setString(const std::string &elt)
sets the content of the DBCell
DBCell(const int nb)
constructor for an integer number
DBCell(const std::string &str)
constructor for a string
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
INLINE void emplace(Args &&... args)
The class representing the original values of the cells of databases.
DBCell & operator=(const float x)
assignment operator
void setReal(const std::string &elt)
sets the content of the DBCell from a string
DBCell & operator=(DBCell &&from)
move operator
DBCell(const float nb)
constructor for a real number
static bool isMissing(const std::string &str, const std::vector< std::string, ALLOC< std::string > > &missingVals)
checks whether a string correspond to a missing value
static DBCell bestDBCell(const std::string &str, const std::vector< std::string, ALLOC< std::string > > &missingVals)
returns the DBCell with the best type for an element encoded as a string
int integer() const
returns the DBcell as an integer
float real() const
returns the DBcell as a real number
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
DBCell(const DBCell &from)
copy constructor
void setReal(const float x)
sets the content of the DBCell
DBCell(DBCell &&from)
move constructor
static EltType bestType(const std::string &str, const std::vector< std::string, ALLOC< std::string > > &missingVals)
returns the best type to store a given element encoded as a string
int stringIndex() const
returns the DBcell as the index of a string in a static bijection
void setInteger(const std::string &elt)
sets the content of the DBCell from a string
EltType type() const noexcept
returns the current type of the DBCell
bool operator==(const DBCell &from) const
test of equality
std::string toString(const std::vector< std::string, ALLOC< std::string > > &missingVals) const
returns the content of the DBCell as a string, whatever its type
void setInteger(const int x)
sets the content of the DBCell
DBCell & operator=(const std::string &x)
assignment operator
EltType
the set of types possibly taken by the last element read
Database(const std::string &filename, const BayesNet< GUM_SCALAR > &bn, const std::vector< std::string > &missing_symbols)
void setMissingState()
sets the DBCell as a missing element
DBCell()
default constructor (ontains a missing value)
DBCell & operator=(const int x)
assignment operator