From a7e74749a1c4edb2f8bc34c79e9bd1562de86ee9 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Tue, 19 Dec 2017 01:54:28 +0100 Subject: Change to Qt5 conding conventions Data structure changes: - Structogram is no longer just a scope, because it needs to store metadata - All structures now use QString instead of std::string, to integrate better in the Qt framework New code: - MainWindow ui code, building layout - MetadataDialog to change the metadata stored in the Structogram - Painter is a widget (still unimplemented) to show the structogram on the GUI --- src/diagram/scope.cpp | 57 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 19 deletions(-) (limited to 'src/diagram/scope.cpp') 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(); } -- cgit v1.2.1