diff options
Diffstat (limited to 'src/diagram')
-rw-r--r-- | src/diagram/branchstatement.cpp | 6 | ||||
-rw-r--r-- | src/diagram/iteratorstatement.cpp | 8 | ||||
-rw-r--r-- | src/diagram/scope.cpp | 57 | ||||
-rw-r--r-- | src/diagram/statement.cpp | 20 | ||||
-rw-r--r-- | src/diagram/structogram.cpp | 14 |
5 files changed, 77 insertions, 28 deletions
diff --git a/src/diagram/branchstatement.cpp b/src/diagram/branchstatement.cpp index 2835f35..6511c6c 100644 --- a/src/diagram/branchstatement.cpp +++ b/src/diagram/branchstatement.cpp @@ -1,8 +1,10 @@ -#include "diagram/BranchStatement.hpp" +#include "diagram/branchstatement.h" using namespace samb; -BranchStatement::BranchStatement(Type t, const std::string& condition, pointer next): Statement(t, condition, next) { +BranchStatement::BranchStatement(Type t, const QString &condition, pointer next) : + Statement(t, condition, next) +{ switch (t) { case Statement::Type::DECISION: case Statement::Type::SWITCH: diff --git a/src/diagram/iteratorstatement.cpp b/src/diagram/iteratorstatement.cpp index 675d8eb..a68234b 100644 --- a/src/diagram/iteratorstatement.cpp +++ b/src/diagram/iteratorstatement.cpp @@ -1,9 +1,11 @@ -#include "diagram/IteratorStatement.hpp" +#include "diagram/iteratorstatement.h" using namespace samb; -IteratorStatement::IteratorStatement(Statement::Type t, const std::string& condition, Statement::pointer next) - : Statement(t, condition, next), m_inner("") { +IteratorStatement::IteratorStatement(Statement::Type t, const QString &condition, Statement::pointer next) : + Statement(t, condition, next), + _inner("") +{ switch (t) { case Statement::Type::WHILE: diff --git a/src/diagram/scope.cpp b/src/diagram/scope.cpp index a1074a3..5f6b4df 100644 --- a/src/diagram/scope.cpp +++ b/src/diagram/scope.cpp @@ -1,29 +1,35 @@ -#include "diagram/Scope.hpp" +#include "diagram/scope.h" using namespace samb; /* Scope::iterator */ -Scope::iterator::iterator(Statement::pointer statement): m_current(statement) { +Scope::iterator::iterator(Statement::pointer statement) : + _current(statement) +{ } -Scope::iterator::~iterator() { +Scope::iterator::~iterator() +{ } -Scope::iterator& Scope::iterator::operator++() { - if (m_current->next() == nullptr) { +Scope::iterator& Scope::iterator::operator++() +{ + if (_current->next() == nullptr) + { // TODO: remove throw throw std::logic_error("Statement::iterator::operator++() m_current->next() is nullptr"); } - m_current = m_current->next(); + _current = _current->next(); return *this; } -Scope::iterator& Scope::iterator::operator++(int) { +Scope::iterator& Scope::iterator::operator++(int) +{ static Scope::iterator old(*this); old = *this; @@ -31,26 +37,35 @@ Scope::iterator& Scope::iterator::operator++(int) { return old; } -Statement& Scope::iterator::operator*() const { - if (m_current == nullptr) { +Statement& Scope::iterator::operator*() const +{ + if (_current == nullptr) + { throw std::logic_error("Statement::iterator::operator*() m_current is nullptr"); } - return *m_current; + return *_current; } -Statement::pointer Scope::iterator::operator->() const { - return m_current; +Statement::pointer Scope::iterator::operator->() const +{ + return _current; } /* Scope */ -Scope::Scope(std::string label): Statement(Statement::Type::SCOPE, label, nullptr), m_head(nullptr), m_tail(nullptr) { +Scope::Scope(const QString &label) : + Statement(Statement::Type::SCOPE, label, nullptr), + _head(nullptr), _tail(nullptr) +{ } -Scope::Scope(std::string label, Statement::pointer first): Statement(Statement::Type::SCOPE, label, first), m_head(first), m_tail(first) { +Scope::Scope(const QString &label, Statement::pointer first) : + Statement(Statement::Type::SCOPE, label, first), + _head(first), _tail(first) +{ } @@ -58,21 +73,25 @@ Scope::~Scope() { } -Scope::iterator Scope::insert_after(Scope::iterator it, Statement::pointer statement) { - if (statement == nullptr) { +Scope::iterator Scope::insert_after(Scope::iterator it, Statement::pointer statement) +{ + if (statement == nullptr) + { throw std::invalid_argument("Statement::insert_after() cannot insert nullptr"); } statement->next(it->next()); it->next(statement); - m_size++; + _size++; return it; } -Scope::iterator Scope::erase_after(Scope::iterator it) { - if (it->next() == nullptr) { +Scope::iterator Scope::erase_after(Scope::iterator it) +{ + if (it->next() == nullptr) + { return end(); } diff --git a/src/diagram/statement.cpp b/src/diagram/statement.cpp index 9cbcdb4..eae5cd3 100644 --- a/src/diagram/statement.cpp +++ b/src/diagram/statement.cpp @@ -1,13 +1,25 @@ -#include "diagram/Statement.hpp" +#include "diagram/statement.h" using namespace samb; /* Statement */ -Statement::Statement(Type t, const std::string& text): type(t), m_text(text), m_next(nullptr) {} -Statement::Statement(Type t, const std::string& text, Statement::pointer p): type(t), m_text(text), m_next(p) {} +Statement::Statement(Type t, const QString &text) : + type(t), _text(text), _next(nullptr) +{ -Statement::~Statement() {} +} + +Statement::Statement(Type t, const QString &text, Statement::pointer p) : + type(t), _text(text), _next(p) +{ + +} + +Statement::~Statement() +{ + +} bool Statement::operator==(const Statement& other) const { // comparison by pointers diff --git a/src/diagram/structogram.cpp b/src/diagram/structogram.cpp new file mode 100644 index 0000000..517d26e --- /dev/null +++ b/src/diagram/structogram.cpp @@ -0,0 +1,14 @@ +#include "diagram/structogram.h" + +using namespace samb; + +Structogram::Structogram(const QString &title, const QString &author) : + Scope(title), _author(author) +{ + +} + +Structogram::~Structogram() +{ + +} |