30 #ifndef DOXYGEN_SHOULD_SKIP_THIS 38 template <
template <
typename >
class ALLOC >
46 template <
template <
typename >
class ALLOC >
53 template <
template <
typename >
class ALLOC >
54 template <
template <
typename >
class XALLOC >
57 const std::vector< std::string, XALLOC< std::string > >& missing_symbols,
58 const bool dynamic_dictionary,
59 std::size_t max_dico_entries,
61 DBTranslator< ALLOC >::allocator_type(alloc),
62 _is_dictionary_dynamic(dynamic_dictionary),
63 _max_dico_entries(max_dico_entries), _val_type(val_type) {
64 const std::size_t size = missing_symbols.size();
69 for (
const auto& symbol : missing_symbols) {
79 template <
template <
typename >
class ALLOC >
82 const bool dynamic_dictionary,
83 std::size_t max_dico_entries,
93 template <
template <
typename >
class ALLOC >
95 const DBTranslator< ALLOC >& from,
107 template <
template <
typename >
class ALLOC >
113 template <
template <
typename >
class ALLOC >
115 DBTranslator< ALLOC >&& from,
127 template <
template <
typename >
class ALLOC >
133 template <
template <
typename >
class ALLOC >
140 template <
template <
typename >
class ALLOC >
142 operator=(
const DBTranslator< ALLOC >& from) {
155 template <
template <
typename >
class ALLOC >
157 operator=(DBTranslator< ALLOC >&& from) {
169 template <
template <
typename >
class ALLOC >
177 template <
template <
typename >
class ALLOC >
179 operator>>(
const DBTranslatedValue translated_val) {
185 template <
template <
typename >
class ALLOC >
192 template <
template <
typename >
class ALLOC >
199 template <
template <
typename >
class ALLOC >
200 INLINE
const Set< std::string, ALLOC< std::string > >&
207 template <
template <
typename >
class ALLOC >
215 template <
template <
typename >
class ALLOC >
218 const_cast< Variable*
>(this->
variable())->setName(str);
223 template <
template <
typename >
class ALLOC >
225 const std::string& str)
const {
226 const_cast< Variable*
>(this->
variable())->setDescription(str);
231 template <
template <
typename >
class ALLOC >
233 const DBTranslatedValue& value)
const {
236 return value.discr_val == std::numeric_limits< std::size_t >::max();
239 return value.cont_val == std::numeric_limits< float >::max();
243 "No missing value interpretation for this " 244 "translated value type");
Bijection< std::size_t, std::string, ALLOC< std::pair< float, std::string > > > _back_dico
the bijection relating back translated values and their original strings.
DBTranslatedValue operator<<(const std::string &str)
alias for method translate
ALLOC< DBTranslatedValue > allocator_type
type for the allocators passed in arguments of methods
virtual const RangeVariable * variable() const final
returns the variable stored into the translator
virtual std::string translateBack(const DBTranslatedValue translated_val) const final
returns the original value for a given translation
std::size_t _max_dico_entries
the maximum number of entries that the dictionary is allowed to contain
void setVariableName(const std::string &str) const
sets the name of the variable stored into the translator
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
DBTranslator(DBTranslatedValueType val_type, const std::vector< std::string, XALLOC< std::string > > &missing_symbols, const bool editable_dictionary=true, std::size_t max_dico_entries=std::numeric_limits< std::size_t >::max(), const allocator_type &alloc=allocator_type())
default constructor
virtual ~DBTranslator()
destructor
bool exists(const Key &k) const
Indicates whether a given elements belong to the set.
const Set< std::string, ALLOC< std::string > > & missingSymbols() const
returns the set of missing symbols taken into account by the translator
allocator_type getAllocator() const
returns the allocator used by the translator
bool isMissingValue(const DBTranslatedValue &val) const
indicates whether a translated value corresponds to a missing value
DBTranslatedValueType
The nature of the elements handled by translators (discrete, continuous).
void resize(Size new_capacity)
Changes the size of the underlying hash table containing the set.
Set< std::string, ALLOC< std::string > > _missing_symbols
the set of missing symbols
DBTranslator< ALLOC > & operator=(const DBTranslator< ALLOC > &from)
copy operator
virtual DBTranslatedValue translate(const std::string &str) final
returns the translation of a string
virtual void setEditableDictionaryMode(bool new_mode)
sets/unset the editable dictionary mode
DBTranslatedValueType _val_type
the type of the values translated by the translator
bool _is_dictionary_dynamic
indicates whether the dictionary can be updated or not
std::string operator>>(const DBTranslatedValue translated_val)
alias for method translateBack
virtual bool hasEditableDictionary() const
indicates whether the translator has an editable dictionary or not
bool isMissingSymbol(const std::string &str) const
indicates whether a string corresponds to a missing symbol
typename DBTranslator< ALLOC >::allocator_type allocator_type
type for the allocators passed in arguments of methods
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
void setVariableDescription(const std::string &str) const
sets the name of the variable stored into the translator
DBTranslatedValueType getValType() const
returns the type of values handled by the translator
void insert(const Key &k)
Inserts a new element into the set.
#define GUM_ERROR(type, msg)