50#ifndef DOXYGEN_SHOULD_SKIP_THIS
67 _translators_.clear();
69 _highest_column_ = std::size_t(0);
74 if (_translators_.size() != 0)
clear();
79 const std::size_t
size = from._translators_.size();
80 _translators_.reserve(
size);
81 _columns_.reserve(
size);
82 _translators_.resize(
size);
83 _columns_.resize(
size);
87 for (i = std::size_t(0); i <
size; ++i) {
88 _translators_[i] = from._translators_[i]->clone();
89 _columns_[i] = from._columns_[i];
92 _translators_.resize(i);
97 _highest_column_ = from._highest_column_;
115 const std::size_t column,
116 const std::vector< std::string >& missing_symbols,
117 const bool unique_column) {
131 const std::size_t column,
132 const bool unique_column) {
136 const std::size_t
size = _translators_.size();
138 for (std::size_t i = std::size_t(0); i <
size; ++i) {
139 if (_columns_[i] == column)
141 "There already exists a DBTranslator that parses Column" << column)
146 _translators_.reserve(
size + 1);
147 _columns_.reserve(
size + 1);
150 DBTranslator* new_translator =
translator.clone();
152 _translators_.resize(
size + 1);
153 _columns_.resize(
size + 1);
154 _translators_[
size] = new_translator;
155 _columns_[
size] = column;
158 if (column > _highest_column_) _highest_column_ = column;
165 const std::size_t nb_trans = _translators_.size();
167 if (!k_is_input_col) {
168 if (nb_trans < k)
return;
171 delete _translators_[k];
173 const std::size_t colk = _columns_[k];
174 _translators_.erase(_translators_.begin() + k);
175 _columns_.erase(_columns_.begin() + k);
179 if (_highest_column_ == colk) {
180 _highest_column_ = std::size_t(0);
181 for (
const auto col: _columns_)
182 if (_highest_column_ < col) _highest_column_ = col;
186 auto iter_trans = _translators_.rbegin();
187 bool translator_found =
false;
188 for (
auto iter_col = _columns_.rbegin(); iter_col != _columns_.rend();
189 ++iter_col, ++iter_trans) {
190 if (*iter_col == k) {
194 _translators_.erase((iter_trans + 1).base());
195 _columns_.erase((iter_col + 1).base());
196 translator_found =
true;
202 if (translator_found && (k == _highest_column_)) {
203 _highest_column_ = std::size_t(0);
204 for (
const auto col: _columns_)
205 if (_highest_column_ < col) _highest_column_ = col;
A class for storing several translators.
the class for packing together the translators used to preprocess the datasets
void eraseTranslator(const std::size_t k, const bool k_is_input_col=false)
erases either the kth translator or those parsing the kth column of the input database
DBTranslatorSet & operator=(const DBTranslatorSet &from)
copy operator
std::size_t size() const
returns the number of translators stored into the set
DBTranslator & translator(const std::size_t k)
returns the kth translator
void clear()
remove all the translators
std::size_t insertTranslator(const DBTranslator &translator, const std::size_t column, const bool unique_column=true)
inserts a new translator at the end of the translator set
The base class for all the tabular database cell translators.
#define GUM_ERROR(type, msg)
DBTranslator * create(const Variable &var, const bool editable_dictionary=false, std::size_t max_dico_entries=std::numeric_limits< std::size_t >::max())
named constructor
include the inlined functions if necessary
gum is the global namespace for all aGrUM entities