50 alphabet_(alpha), content_()
56 alphabet_(alpha), content_()
64 alphabet_(list.getAlphabet()), content_(list.getContent()) {}
67 alphabet_(list.getAlphabet()), content_(list.getContent()) {}
88 vector<int> coded(list.size());
89 for (
size_t i = 0; i < list.size(); i++)
90 if(!alphabet_->isCharInAlphabet(list[i]))
throw BadCharException(list[i],
"BasicSymbolList::setContent", alphabet_);
92 for (
size_t i = 0; i < list.size(); i++)
93 coded[i] = alphabet_->charToInt(list[i]);
104 for (
size_t i = 0; i < list.size(); i++)
105 if(!alphabet_->isIntInAlphabet(list[i]))
106 throw BadIntException(list[i],
"BasicSymbolList::setContent", alphabet_);
123 content_.push_back(alphabet_->charToInt(c));
130 if(pos >= content_.size())
throw IndexOutOfBoundsException(
"BasicSymbolList::addElement. Invalid position.", pos, 0, size() - 1);
131 content_.insert(content_.begin() +
static_cast<ptrdiff_t
>(pos), alphabet_->charToInt(c));
138 if(pos >= content_.size())
139 throw IndexOutOfBoundsException(
"BasicSymbolList::setElement. Invalid position.", pos, 0, size() - 1);
140 content_[pos] = alphabet_->charToInt(c);
147 if(pos >= content_.size())
148 throw IndexOutOfBoundsException(
"BasicSymbolList::getChar. Invalid position.", pos, 0, size() - 1);
152 c = alphabet_->intToChar(content_[pos]);
165 if(pos >= content_.size())
166 throw IndexOutOfBoundsException(
"BasicSymbolList::deleteElement. Invalid position.", pos, 0, size() - 1);
167 content_.erase(content_.begin() +
static_cast<ptrdiff_t
>(pos));
174 if (pos + len > content_.size())
175 throw IndexOutOfBoundsException(
"BasicSymbolList::deleteElements. Invalid position.", pos + len, 0, size() - 1);
176 content_.erase(content_.begin() +
static_cast<ptrdiff_t
>(pos), content_.begin() +
static_cast<ptrdiff_t
>(pos + len));
184 alphabet_->intToChar(v);
185 content_.push_back(v);
193 if(pos >= content_.size())
194 throw IndexOutOfBoundsException(
"BasicSymbolList::addElement. Invalid position.", pos, 0, size() - 1);
195 alphabet_->intToChar(v);
196 content_.insert(content_.begin() +
static_cast<ptrdiff_t
>(pos), v);
204 if(pos >= content_.size())
205 throw IndexOutOfBoundsException(
"BasicSymbolList::setElement. Invalid position.", pos, 0, size() - 1);
206 alphabet_->intToChar(v);
214 if(pos >= content_.size())
215 throw IndexOutOfBoundsException(
"BasicSymbolList::getValue. Invalid position.", pos, 0, size() - 1);
216 return content_[pos];
225 alphabet_(alpha), propagateEvents_(
true), content_(), listeners_()
231 alphabet_(alpha), propagateEvents_(
true), content_(), listeners_()
239 alphabet_(list.getAlphabet()), propagateEvents_(true), content_(list.getContent()), listeners_() {}
242 alphabet_(list.getAlphabet()), propagateEvents_(list.propagateEvents_), content_(list.getContent()), listeners_(list.listeners_)
244 for (
size_t i = 0; i <
listeners_.size(); ++i)
254 for (
size_t i = 0; i <
listeners_.size(); ++i)
266 for (
size_t i = 0; i <
listeners_.size(); ++i)
269 for (
size_t i = 0; i <
listeners_.size(); ++i)
280 fireBeforeSequenceChanged(event);
283 vector<int> coded(list.size());
284 for (
size_t i = 0; i < list.size(); i++)
285 if (!alphabet_->isCharInAlphabet(list[i]))
throw BadCharException(list[i],
"EdSymbolList::setContent", alphabet_);
287 for (
size_t i = 0; i < list.size(); i++)
288 coded[i] = alphabet_->charToInt(list[i]);
292 fireAfterSequenceChanged(event);
300 fireBeforeSequenceChanged(event);
303 for (
size_t i = 0; i < list.size(); i++)
304 if(!alphabet_->isIntInAlphabet(list[i]))
309 fireAfterSequenceChanged(event);
324 fireBeforeSequenceInserted(event);
325 content_.push_back(alphabet_->charToInt(c));
326 fireAfterSequenceInserted(event);
333 if (pos >= content_.size())
throw IndexOutOfBoundsException(
"EdSymbolList::addElement. Invalid position.", pos, 0, size() - 1);
335 fireBeforeSequenceInserted(event);
336 content_.insert(content_.begin() +
static_cast<ptrdiff_t
>(pos), alphabet_->charToInt(c));
337 fireAfterSequenceInserted(event);
344 if (pos >= content_.size())
345 throw IndexOutOfBoundsException(
"EdSymbolList::setElement. Invalid position.", pos, 0, size() - 1);
347 fireBeforeSequenceSubstituted(event);
348 content_[pos] = alphabet_->charToInt(c);
349 fireAfterSequenceSubstituted(event);
356 if (pos >= content_.size())
357 throw IndexOutOfBoundsException(
"EdSymbolList::getChar. Invalid position.", pos, 0, size() - 1);
360 c = alphabet_->intToChar(content_[pos]);
371 if (pos >= content_.size())
372 throw IndexOutOfBoundsException(
"EdSymbolList::deleteElement. Invalid position.", pos, 0, size() - 1);
374 fireBeforeSequenceDeleted(event);
375 content_.erase(content_.begin() +
static_cast<ptrdiff_t
>(pos));
376 fireAfterSequenceDeleted(event);
383 if(pos + len > content_.size())
384 throw IndexOutOfBoundsException(
"EdSymbolList::deleteElements. Invalid position.", pos + len, 0, size() - 1);
386 fireBeforeSequenceDeleted(event);
387 content_.erase(content_.begin() +
static_cast<ptrdiff_t
>(pos), content_.begin() +
static_cast<ptrdiff_t
>(pos + len));
388 fireAfterSequenceDeleted(event);
397 fireBeforeSequenceInserted(event);
399 alphabet_->intToChar(v);
400 content_.push_back(v);
401 fireAfterSequenceInserted(event);
409 if (pos >= content_.size())
410 throw IndexOutOfBoundsException(
"EdSymbolList::addElement. Invalid position.", pos, 0, size() - 1);
412 fireBeforeSequenceInserted(event);
413 alphabet_->intToChar(v);
414 content_.insert(content_.begin() +
static_cast<ptrdiff_t
>(pos), v);
415 fireAfterSequenceInserted(event);
423 if (pos >= content_.size())
424 throw IndexOutOfBoundsException(
"EdSymbolList::setElement. Invalid position.", pos, 0, size() - 1);
426 fireBeforeSequenceSubstituted(event);
427 alphabet_->intToChar(v);
429 fireAfterSequenceSubstituted(event);
436 if (pos >= content_.size())
437 throw IndexOutOfBoundsException(
"EdSymbolList::getValue. Invalid position.", pos, 0, size() - 1);
438 return content_[pos];
std::vector< int > content_
The list content.
virtual const std::vector< int > & getContent() const
Get the whole content of the list as a vector of int.
An alphabet exception thrown when trying to specify a bad char to the alphabet.
EdSymbolList(const Alphabet *alpha)
Build a new void BasicSymbolList object with the specified alphabet.
The SymbolList interface.
virtual const Alphabet * getAlphabet() const
Get the alphabet associated to the list.
const Alphabet * alphabet_
The Alphabet attribute must be initialized in constructor and then can never be changed.
BasicSymbolList & operator=(const SymbolList &list)
The generic assignment operator.
This alphabet is used to deal NumericAlphabet.
virtual void setContent(const std::vector< int > &list)
Set the whole content of the list.
virtual std::string getChar(size_t pos) const
Get the element at position 'pos' as a character.
virtual std::string toString() const
Convert the list as a string.
virtual void deleteElement(size_t pos)
Delete the element at position 'pos'.
std::vector< SymbolListListener * > listeners_
Contains the listeners.
virtual void deleteElements(size_t pos, size_t len)
Delete the elements at position 'pos'.
virtual int getValue(size_t pos) const
Get the element at position 'pos' as an int.
virtual const std::vector< int > & getContent() const
Get the whole content of the list as a vector of int.
virtual void setElement(size_t pos, const std::string &c)
Set the element at position 'pos' to character 'c'.
virtual std::string getChar(size_t pos) const
Get the element at position 'pos' as a character.
virtual void setContent(const std::vector< int > &list)
Set the whole content of the list.
virtual void addElement(const std::string &c)
Add a character to the end of the list.
virtual int getValue(size_t pos) const
Get the element at position 'pos' as an int.
A basic SymbolList object.
virtual void deleteElements(size_t pos, size_t len)
Delete the elements at position 'pos'.
std::vector< int > content_
The list content.
EdSymbolList & operator=(const SymbolList &list)
The generic assignment operator.
virtual const Alphabet * getAlphabet() const =0
Get the alphabet associated to the list.
virtual const std::vector< int > & getContent() const =0
Get the whole content of the list as a vector of int.
virtual std::string toString() const
Convert the list as a string.
An alphabet exception thrown when trying to specify a bad int to the alphabet.
virtual const Alphabet * getAlphabet() const
Get the alphabet associated to the list.
A event-driven SymbolList object.
const Alphabet * alphabet_
The Alphabet attribute must be initialized in constructor and then can never be changed.
virtual void setElement(size_t pos, const std::string &c)
Set the element at position 'pos' to character 'c'.
virtual void deleteElement(size_t pos)
Delete the element at position 'pos'.
virtual void addElement(const std::string &c)
Add a character to the end of the list.
BasicSymbolList(const Alphabet *alpha)
Build a new void BasicSymbolList object with the specified alphabet.