50#ifndef DOXYGEN_SHOULD_SKIP_THIS
63 const NumericalDiscreteVariable& var,
64 const std::vector< std::string >& missing_symbols,
65 std::size_t max_dico_entries) :
73 if (var.domainSize() > max_dico_entries) {
74 GUM_ERROR(SizeError,
"the dictionary induced by the variable is too large")
78 for (
auto iter = this->missing_symbols_.beginSafe(); iter != this->missing_symbols_.endSafe();
80 if (DBCell::isReal(*iter)) {
81 char* endptr = nullptr;
82 const double missing_val = std::strtod(iter->c_str(), &endptr);
83 if (_variable_.isValue(missing_val)) { this->missing_symbols_.erase(iter); }
89 for (
const auto& label: var.labels()) {
95 if (this->missing_symbols_.exists(label)) { this->missing_symbols_.erase(label); }
102 GUM_CONSTRUCTOR(DBTranslator4NumericalDiscreteVariable);
106 DBTranslator4NumericalDiscreteVariable::DBTranslator4NumericalDiscreteVariable(
107 const NumericalDiscreteVariable& var,
108 std::size_t max_dico_entries) :
109 DBTranslator(DBTranslatedValueType::
DISCRETE, true, false, max_dico_entries),
112 if (var.domainSize() > max_dico_entries) {
113 GUM_ERROR(SizeError,
"the dictionary induced by the variable is too large")
117 std::size_t size = 0;
118 for (
const auto& label: var.labels()) {
119 this->back_dico_.insert(size, label);
124 GUM_CONSTRUCTOR(DBTranslator4NumericalDiscreteVariable);
128 DBTranslator4NumericalDiscreteVariable::DBTranslator4NumericalDiscreteVariable(
129 const DBTranslator4NumericalDiscreteVariable& from) :
130 DBTranslator(from), _variable_(from._variable_) {
132 GUM_CONS_CPY(DBTranslator4NumericalDiscreteVariable);
136 DBTranslator4NumericalDiscreteVariable::DBTranslator4NumericalDiscreteVariable(
137 DBTranslator4NumericalDiscreteVariable&& from) :
138 DBTranslator(
std::move(from)), _variable_(
std::move(from._variable_)) {
140 GUM_CONS_MOV(DBTranslator4NumericalDiscreteVariable);
144 DBTranslator4NumericalDiscreteVariable* DBTranslator4NumericalDiscreteVariable::clone()
const {
145 return new DBTranslator4NumericalDiscreteVariable(*
this);
149 DBTranslator4NumericalDiscreteVariable& DBTranslator4NumericalDiscreteVariable::operator=(
150 const DBTranslator4NumericalDiscreteVariable& from) {
152 DBTranslator::operator=(from);
153 _variable_ = from._variable_;
160 DBTranslator4NumericalDiscreteVariable& DBTranslator4NumericalDiscreteVariable::operator=(
161 DBTranslator4NumericalDiscreteVariable&& from) {
163 DBTranslator::operator=(std::move(from));
164 _variable_ = std::move(from._variable_);
The databases' cell translators for numerical discrete variables.
The databases' cell translators for integer variables.
void insert(const T1 &first, const T2 &second)
DBTranslator4NumericalDiscreteVariable(const NumericalDiscreteVariable &var, const std::vector< std::string > &missing_symbols, std::size_t max_dico_entries=std::numeric_limits< std::size_t >::max())
default constructor with a numerical discrete variable as translator
The base class for all the tabular database cell translators.
Bijection< std::size_t, std::string > back_dico_
the bijection relating back translated values and their original strings.
DBTranslatedValueType
The nature of the elements handled by translators (discrete, continuous).
include the inlined functions if necessary
gum is the global namespace for all aGrUM entities