3 #include <memory/memoryStructure.h>
11 template <
typename T>
class WordObserver;
12 template <
typename T>
class WordModifier;
48 constexpr
Word(
const std::vector<T>& word);
94 [[nodiscard]] const T&
front() const;
99 [[nodiscard]] std::optional<T>
front_opt() const noexcept;
126 Utils::MessageException(message),
133 std::ostringstream ss;
134 ss << this->msg << std::endl;
135 ss <<
" length: " << length << std::endl;
136 ss <<
" position: " << position << std::endl;
156 word(word), position(0)
161 word(other.word), position(other.position)
166 word(std::move(other.word)), position(std::move(other.position))
173 position = other.position;
181 word = std::move(other.word);
182 position = std::move(other.position);
189 if(position < word.size()) {
190 return word[position++];
197 if(position < word.size()) {
198 return word[position++];
205 if(position < word.size()) {
206 return word[position];
213 if(position < word.size()) {
214 return std::make_optional(word[position]);
221 return position == word.size();
228 template <
typename T>
245 return this->memory->position;
251 [[nodiscard]]
const std::vector<T>&
getWord() const noexcept {
252 return this->memory->word;
258 [[nodiscard]]
size_t getSize() const noexcept {
259 return this->memory->word.size();
267 template <
typename T>
285 if(position > this->memory->word.size()) {
286 throw WordOverflowException(
"Illegal position in WordModifier<T>::setPosition", this->memory->word.size(), position);
288 this->memory->position = position;
297 if(position >= this->memory->word.size()) {
298 throw WordOverflowException(
"Illegal position in WordModifier<T>::operator[]", this->memory->word.size(), position);
300 return this->memory->word[position];
309 constexpr
void setWord(
const std::vector<T>& word) {
310 if(this->memory->position > word.size()) {
311 throw WordOverflowException(
"Illegal position in WordModifier<T>::setWord", this->memory->word.size(), this->memory->position);
313 this->memory->word = word;