diff options
Diffstat (limited to 'src/diagram/Scope.cpp')
-rw-r--r-- | src/diagram/Scope.cpp | 80 |
1 files changed, 45 insertions, 35 deletions
diff --git a/src/diagram/Scope.cpp b/src/diagram/Scope.cpp index 335cd20..721ee4b 100644 --- a/src/diagram/Scope.cpp +++ b/src/diagram/Scope.cpp @@ -5,73 +5,83 @@ #include "Scope.hpp" -namespace samb { +using namespace samb; /* Scope::iterator */ -Scope::iterator::iterator(Statement::pointer statement): m_current(statement) {} -Scope::iterator::~iterator() {} +Scope::iterator::iterator(Statement::pointer statement): m_current(statement) { + +} + +Scope::iterator::~iterator() { + +} Scope::iterator& Scope::iterator::operator++() { - if (m_current->next() == nullptr) { - // TODO: remote throw - throw std::logic_error("Statement::iterator::operator++() m_current->next() is nullptr"); - } + if (m_current->next() == nullptr) { + // TODO: remove throw + throw std::logic_error("Statement::iterator::operator++() m_current->next() is nullptr"); + } - m_current = m_current->next(); + m_current = m_current->next(); - return *this; + return *this; } Scope::iterator& Scope::iterator::operator++(int) { - static Scope::iterator old(*this); + static Scope::iterator old(*this); - old = *this; - operator++(); - return old; + old = *this; + operator++(); + return old; } Statement& Scope::iterator::operator*() const { - if (m_current == nullptr) { - throw std::logic_error("Statement::iterator::operator*() m_current is nullptr"); - } + if (m_current == nullptr) { + throw std::logic_error("Statement::iterator::operator*() m_current is nullptr"); + } - return *m_current; + return *m_current; } Statement::pointer Scope::iterator::operator->() const { - return m_current; + return m_current; } /* Scope */ -Scope::Scope(std::string label): Statement(Statement::Type::SCOPE, label, nullptr), m_head(nullptr), m_tail(nullptr) {} -Scope::Scope(std::string label, Statement::pointer first): Statement(Statement::Type::SCOPE, label, first), m_head(first), m_tail(first) {} +Scope::Scope(std::string label): Statement(Statement::Type::SCOPE, label, nullptr), m_head(nullptr), m_tail(nullptr) { + +} -Scope::~Scope() {} +Scope::Scope(std::string label, Statement::pointer first): Statement(Statement::Type::SCOPE, label, first), m_head(first), m_tail(first) { + +} + +Scope::~Scope() { + +} Scope::iterator Scope::insert_after(Scope::iterator it, Statement::pointer statement) { - if (statement == nullptr) { - throw std::invalid_argument("Statement::insert_after() cannot insert nullptr"); - } + if (statement == nullptr) { + throw std::invalid_argument("Statement::insert_after() cannot insert nullptr"); + } - statement->next(it->next()); - it->next(statement); + statement->next(it->next()); + it->next(statement); - m_size++; + m_size++; - return it; + return it; } Scope::iterator Scope::erase_after(Scope::iterator it) { - if (it->next() == nullptr) { - return end(); - } + if (it->next() == nullptr) { + return end(); + } - it->next(it->next()->next()); + it->next(it->next()->next()); - return it; + return it; } - -} /* namespace samb */ |