51#ifndef DOXYGEN_SHOULD_SKIP_THIS
67 const bool is_lossless,
68 const std::vector< std::string >& missing_symbols,
69 const bool dynamic_dictionary,
70 std::size_t max_dico_entries) :
71 is_lossless_(is_lossless), is_dictionary_dynamic_(dynamic_dictionary),
72 max_dico_entries_(max_dico_entries), val_type_(val_type) {
73 const std::size_t size = missing_symbols.size();
77 missing_symbols_.resize((Size)missing_symbols.size());
78 for (
const auto& symbol: missing_symbols) {
79 missing_symbols_.insert(symbol);
83 GUM_CONSTRUCTOR(DBTranslator);
87 INLINE DBTranslator::DBTranslator(DBTranslatedValueType val_type,
88 const bool is_lossless,
89 const bool dynamic_dictionary,
90 std::size_t max_dico_entries) :
91 is_lossless_(is_lossless), is_dictionary_dynamic_(dynamic_dictionary),
92 max_dico_entries_(max_dico_entries), val_type_(val_type) {
93 GUM_CONSTRUCTOR(DBTranslator);
97 INLINE DBTranslator::DBTranslator(
const DBTranslator& from) :
98 is_lossless_(from.is_lossless_), is_dictionary_dynamic_(from.is_dictionary_dynamic_),
99 max_dico_entries_(from.max_dico_entries_), missing_symbols_(from.missing_symbols_),
100 back_dico_(from.back_dico_), val_type_(from.val_type_) {
101 GUM_CONS_CPY(DBTranslator);
105 INLINE DBTranslator::DBTranslator(DBTranslator&& from) :
106 is_lossless_(from.is_lossless_), is_dictionary_dynamic_(from.is_dictionary_dynamic_),
107 max_dico_entries_(from.max_dico_entries_),
108 missing_symbols_(
std::move(from.missing_symbols_)), back_dico_(
std::move(from.back_dico_)),
109 val_type_(from.val_type_) {
110 GUM_CONS_MOV(DBTranslator);
114 INLINE DBTranslator::~DBTranslator() { GUM_DESTRUCTOR(DBTranslator); }
117 INLINE DBTranslator& DBTranslator::operator=(
const DBTranslator& from) {
119 is_lossless_ = from.is_lossless_;
120 is_dictionary_dynamic_ = from.is_dictionary_dynamic_;
121 max_dico_entries_ = from.max_dico_entries_;
122 missing_symbols_ = from.missing_symbols_;
123 back_dico_ = from.back_dico_;
124 val_type_ = from.val_type_;
130 INLINE DBTranslator& DBTranslator::operator=(DBTranslator&& from) {
131 is_lossless_ = from.is_lossless_;
132 is_dictionary_dynamic_ = from.is_dictionary_dynamic_;
133 max_dico_entries_ = from.max_dico_entries_;
134 missing_symbols_ = std::move(from.missing_symbols_);
135 back_dico_ = std::move(from.back_dico_);
136 val_type_ = from.val_type_;
142 INLINE DBTranslatedValue DBTranslator::operator<<(std::string_view str) {
143 return translate(str);
147 INLINE std::string DBTranslator::operator>>(
const DBTranslatedValue translated_val) {
148 return translateBack(translated_val);
152 INLINE
bool DBTranslator::hasEditableDictionary()
const {
return is_dictionary_dynamic_; }
155 INLINE
void DBTranslator::setEditableDictionaryMode(
bool new_mode) {
156 is_dictionary_dynamic_ = new_mode;
160 INLINE
const Bijection< std::size_t, std::string >& DBTranslator::getDictionary()
const {
165 INLINE
const Set< std::string >& DBTranslator::missingSymbols()
const {
166 return missing_symbols_;
170 INLINE
bool DBTranslator::isMissingSymbol(std::string_view str)
const {
171 return missing_symbols_.exists(std::string(str));
175 INLINE
void DBTranslator::setVariableName(std::string_view str)
const {
176 const_cast< Variable*
>(this->variable())->setName(std::string(str));
180 INLINE
void DBTranslator::setVariableDescription(std::string_view str)
const {
181 const_cast< Variable*
>(this->variable())->setDescription(std::string(str));
185 INLINE
bool DBTranslator::isMissingValue(
const DBTranslatedValue& value)
const {
187 case DBTranslatedValueType::DISCRETE :
188 return value.discr_val == std::numeric_limits< std::size_t >::max();
190 case DBTranslatedValueType::CONTINUOUS :
191 return value.cont_val == std::numeric_limits< float >::max();
195 "No missing value interpretation for this "
196 "translated value type");
The base class for all the tabular databases' cell translators.
Exception : there is something wrong with an implementation.
DBTranslator(DBTranslatedValueType val_type, const bool is_lossless, const std::vector< std::string > &missing_symbols, const bool editable_dictionary=true, std::size_t max_dico_entries=std::numeric_limits< std::size_t >::max())
default constructor
bool is_lossless_
indicates whether the translation is lossless (e.g., ranges) or not
DBTranslatedValueType val_type_
the type of the values translated by the translator
bool isLossless() const
returns a Boolean indicating whether the translation is lossless or not
DBTranslatedValueType getValType() const
returns the type of values handled by the translator
#define GUM_ERROR(type, msg)
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