aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2017-11-25 20:02:46 +0100
committerNao Pross <naopross@thearcway.org>2017-11-25 20:02:46 +0100
commit004fa309d6ede28ec8ab195647a2cbee490e104f (patch)
tree77caa08e70ba6ad02e3af0f143f3c5a24970ccd5
downloadOrbitingYeti-004fa309d6ede28ec8ab195647a2cbee490e104f.tar.gz
OrbitingYeti-004fa309d6ede28ec8ab195647a2cbee490e104f.zip
First commit
Diffstat (limited to '')
-rw-r--r--.cproject124
-rw-r--r--.project27
-rw-r--r--.settings/language.settings.xml25
-rw-r--r--src/diagram/Statement.cpp12
-rw-r--r--src/diagram/Statement.hpp60
-rw-r--r--src/diagram/Structogram.cpp27
-rw-r--r--src/diagram/Structogram.hpp32
-rw-r--r--src/main.cpp16
-rw-r--r--src/ui/AsciiRenderer.cpp97
-rw-r--r--src/ui/AsciiRenderer.h33
10 files changed, 453 insertions, 0 deletions
diff --git a/.cproject b/.cproject
new file mode 100644
index 0000000..46b958f
--- /dev/null
+++ b/.cproject
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+ <storageModule moduleId="org.eclipse.cdt.core.settings">
+ <cconfiguration id="cdt.managedbuild.config.gnu.exe.debug.843585591">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.debug.843585591" moduleId="org.eclipse.cdt.core.settings" name="Debug">
+ <externalSettings/>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.debug.843585591" name="Debug" parent="cdt.managedbuild.config.gnu.exe.debug">
+ <folderInfo id="cdt.managedbuild.config.gnu.exe.debug.843585591." name="/" resourcePath="">
+ <toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.1015131656" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
+ <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.623837482" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/>
+ <builder buildPath="${workspace_loc:/TitaniumLadybug}/Debug" id="cdt.managedbuild.target.gnu.builder.exe.debug.360197318" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/>
+ <tool id="cdt.managedbuild.tool.gnu.archiver.base.1299140126" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.1698391423" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug">
+ <option id="gnu.cpp.compiler.exe.debug.option.optimization.level.1212687966" name="Optimization Level" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.exe.debug.option.debugging.level.338161566" name="Debug Level" superClass="gnu.cpp.compiler.exe.debug.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.625532656" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1244401962" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug">
+ <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.exe.debug.option.optimization.level.1783088687" name="Optimization Level" superClass="gnu.c.compiler.exe.debug.option.optimization.level" useByScannerDiscovery="false" valueType="enumerated"/>
+ <option id="gnu.c.compiler.exe.debug.option.debugging.level.1639895866" name="Debug Level" superClass="gnu.c.compiler.exe.debug.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.308701119" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.1838111397" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.1222444446" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug">
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1037650282" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+ <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+ <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+ </inputType>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.assembler.exe.debug.1551897999" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug">
+ <inputType id="cdt.managedbuild.tool.gnu.assembler.input.780351174" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+ </tool>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ <cconfiguration id="cdt.managedbuild.config.gnu.exe.release.840720835">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.release.840720835" moduleId="org.eclipse.cdt.core.settings" name="Release">
+ <externalSettings/>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.840720835" name="Release" parent="cdt.managedbuild.config.gnu.exe.release">
+ <folderInfo id="cdt.managedbuild.config.gnu.exe.release.840720835." name="/" resourcePath="">
+ <toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.1755754153" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.release">
+ <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.release.940189872" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.release"/>
+ <builder buildPath="${workspace_loc:/TitaniumLadybug}/Release" id="cdt.managedbuild.target.gnu.builder.exe.release.1869347075" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.release"/>
+ <tool id="cdt.managedbuild.tool.gnu.archiver.base.836936169" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.687228204" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release">
+ <option id="gnu.cpp.compiler.exe.release.option.optimization.level.1543732841" name="Optimization Level" superClass="gnu.cpp.compiler.exe.release.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.exe.release.option.debugging.level.1251763013" name="Debug Level" superClass="gnu.cpp.compiler.exe.release.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1217803265" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.491282247" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release">
+ <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.exe.release.option.optimization.level.892590114" name="Optimization Level" superClass="gnu.c.compiler.exe.release.option.optimization.level" useByScannerDiscovery="false" valueType="enumerated"/>
+ <option id="gnu.c.compiler.exe.release.option.debugging.level.1773670527" name="Debug Level" superClass="gnu.c.compiler.exe.release.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.none" valueType="enumerated"/>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1423670698" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.linker.exe.release.1704930750" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.release.1171694406" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.release">
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.396221432" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+ <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+ <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+ </inputType>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.assembler.exe.release.623514705" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.release">
+ <inputType id="cdt.managedbuild.tool.gnu.assembler.input.437412052" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+ </tool>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="TitaniumLadybug.cdt.managedbuild.target.gnu.exe.997575682" name="Executable" projectType="cdt.managedbuild.target.gnu.exe"/>
+ </storageModule>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.843585591;cdt.managedbuild.config.gnu.exe.debug.843585591.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.1698391423;cdt.managedbuild.tool.gnu.cpp.compiler.input.625532656">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.840720835;cdt.managedbuild.config.gnu.exe.release.840720835.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.687228204;cdt.managedbuild.tool.gnu.cpp.compiler.input.1217803265">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.843585591;cdt.managedbuild.config.gnu.exe.debug.843585591.;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1244401962;cdt.managedbuild.tool.gnu.c.compiler.input.308701119">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.840720835;cdt.managedbuild.config.gnu.exe.release.840720835.;cdt.managedbuild.tool.gnu.c.compiler.exe.release.491282247;cdt.managedbuild.tool.gnu.c.compiler.input.1423670698">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+ <storageModule moduleId="refreshScope" versionNumber="2">
+ <configuration configurationName="Debug">
+ <resource resourceType="PROJECT" workspacePath="/TitaniumLadybug"/>
+ </configuration>
+ <configuration configurationName="Release">
+ <resource resourceType="PROJECT" workspacePath="/TitaniumLadybug"/>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
+ <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
+</cproject>
diff --git a/.project b/.project
new file mode 100644
index 0000000..9763d1b
--- /dev/null
+++ b/.project
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>TitaniumLadybug</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ </natures>
+</projectDescription>
diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml
new file mode 100644
index 0000000..e8985aa
--- /dev/null
+++ b/.settings/language.settings.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<project>
+ <configuration id="cdt.managedbuild.config.gnu.exe.debug.843585591" name="Debug">
+ <extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
+ <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
+ <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
+ <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
+ <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-217317491240734574" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
+ <language-scope id="org.eclipse.cdt.core.gcc"/>
+ <language-scope id="org.eclipse.cdt.core.g++"/>
+ </provider>
+ </extension>
+ </configuration>
+ <configuration id="cdt.managedbuild.config.gnu.exe.release.840720835" name="Release">
+ <extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
+ <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
+ <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
+ <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
+ <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-217317491240734574" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
+ <language-scope id="org.eclipse.cdt.core.gcc"/>
+ <language-scope id="org.eclipse.cdt.core.g++"/>
+ </provider>
+ </extension>
+ </configuration>
+</project>
diff --git a/src/diagram/Statement.cpp b/src/diagram/Statement.cpp
new file mode 100644
index 0000000..75770db
--- /dev/null
+++ b/src/diagram/Statement.cpp
@@ -0,0 +1,12 @@
+/*
+ * Statement.cpp
+ *
+ * Created on: Nov 23, 2017
+ * Author: naopross
+ */
+
+#include "../diagram/Statement.h"
+
+namespace samb {
+
+} /* namespace samb */
diff --git a/src/diagram/Statement.hpp b/src/diagram/Statement.hpp
new file mode 100644
index 0000000..a90e88d
--- /dev/null
+++ b/src/diagram/Statement.hpp
@@ -0,0 +1,60 @@
+/*
+ * Statement.h
+ *
+ * Created on: Nov 23, 2017
+ * Author: naopross
+ */
+
+#ifndef SRC_STATEMENT_H_
+#define SRC_STATEMENT_H_
+
+#include <string>
+
+namespace samb {
+
+
+/* Possible types of statement, according to the NS diagram paper
+ *
+ * PROCESS,
+ * DECISION,
+ * SWITCH,
+ * WHILE,
+ * UNTIL,
+ * SCOPE,
+ * PARALLEL,
+ */
+
+/* this class should behave like a std::list, or a std::map storing the data
+ * with a tree structure, BUT it is not a tree because allows 2 notes to point
+ * at a single node
+ *
+ * Normal Tree: Statements:
+ * A - B - C - D A - B - C - D - G
+ * \ \ /
+ * E - F E - F
+ *
+ * Because a statement contains branching elmeents. (if / switch)
+ */
+class Statement {
+private:
+ Statement *next;
+ Statement *prev;
+
+public:
+ const enum Type {
+ PROCESS,
+ DECISION,
+ SWITCH,
+ WHILE,
+ UNTIL,
+ SCOPE,
+ PARALLEL,
+ } m_type;
+
+ Statement(Type type, Statement *prev): m_type(type), m_prev(prev);
+ virtual ~Statement();
+};
+
+} /* namespace samb */
+
+#endif /* SRC_STATEMENT_H_ */
diff --git a/src/diagram/Structogram.cpp b/src/diagram/Structogram.cpp
new file mode 100644
index 0000000..dae9028
--- /dev/null
+++ b/src/diagram/Structogram.cpp
@@ -0,0 +1,27 @@
+/*
+ * Structogram.cpp
+ *
+ * Created on: Nov 14, 2017
+ * Author: naopross
+ */
+
+#include "../diagram/Structogram.h"
+#include <memory>
+
+
+namespace samb {
+
+Structogram::Structogram(std::string title): m_title(title) {
+
+}
+
+Structogram::~Structogram() {
+
+}
+
+const std::list<Statement>& Structogram::getStatements() const {
+ return m_statements;
+}
+
+
+} /* namespace structograms */
diff --git a/src/diagram/Structogram.hpp b/src/diagram/Structogram.hpp
new file mode 100644
index 0000000..2234142
--- /dev/null
+++ b/src/diagram/Structogram.hpp
@@ -0,0 +1,32 @@
+/*
+ * Structogram.h
+ *
+ * Created on: Nov 14, 2017
+ * Author: naopross
+ */
+
+#ifndef STRUCTOGRAM_H_
+#define STRUCTOGRAM_H_
+
+#include <iostream>
+#include <list>
+#include "../diagram/Statement.h"
+
+namespace samb {
+
+/* object that holds statements */
+class Structogram {
+private:
+ std::list<Statement> m_statements;
+ std::string m_title;
+
+public:
+ Structogram(std::string title);
+ virtual ~Structogram();
+
+ const std::list<Statement>& getStatements() const;
+};
+
+} /* namespace structograms */
+
+#endif /* STRUCTOGRAM_H_ */
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..5ea2172
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,16 @@
+#include "diagram/Structogram.h"
+#include <iostream>
+#include "ui/AsciiRenderer.h"
+
+int main(int argc, char *argv[]) {
+ samb::Structogram st("Demo");
+ samb::AsciiRenderer renderer(st, 60);
+
+ renderer.render();
+
+ return 0;
+}
+
+
+
+
diff --git a/src/ui/AsciiRenderer.cpp b/src/ui/AsciiRenderer.cpp
new file mode 100644
index 0000000..0f17d85
--- /dev/null
+++ b/src/ui/AsciiRenderer.cpp
@@ -0,0 +1,97 @@
+/*
+ * Renderer.cpp
+ *
+ * Created on: Nov 23, 2017
+ * Author: naopross
+ */
+
+#include "AsciiRenderer.h"
+
+#include <memory>
+
+namespace samb {
+
+AsciiRenderer::AsciiRenderer(Structogram& structogram, unsigned int width):
+ m_structogram(structogram), m_width(width) {}
+
+AsciiRenderer::~AsciiRenderer() {}
+
+void AsciiRenderer::drawPadding(unsigned int amt) {
+ while (amt--) {
+ std::cout << " ";
+ }
+}
+
+void AsciiRenderer::drawLine() const {
+ for (unsigned int i = 0; i < m_width; i++) {
+ std::cout << "-";
+ }
+
+ std::cout << std::endl;
+}
+
+void AsciiRenderer::drawText(std::string text, unsigned int width, std::string before, std::string after) const {
+
+ if (width == 0) {
+ width = m_width;
+ }
+
+ unsigned int textWidth = width - before.length() - after.length();
+
+
+ std::cout << before;
+ for (unsigned int i = 0; i < text.length(); i++) {
+ if (i % textWidth == 0) {
+ std::cout << after << "\n" << before;
+ }
+
+ std::cout << text[i];
+ }
+
+ std::cout << std::endl;
+}
+
+void AsciiRenderer::drawDecision(std::string condition, std::string trueText, std::string falseText, unsigned int width) const {
+ if (width == 0) {
+ width = m_width -2;
+ }
+
+ std::cout << "|";
+
+// drawPadding(width - condition.length());
+}
+
+void AsciiRenderer::render() {
+ const std::list<Statement>& statements = m_structogram.getStatements();
+
+ for (std::list<Statement>::const_iterator it = statements.begin(); it != statements.end(); it++) {
+ Statement st = *it;
+ switch (st.type) {
+ case Statement::Type::PROCESS:
+ drawLine();
+ drawText(st.text);
+ break;
+
+ case Statement::Type::DECISION:
+ drawLine();
+ break;
+
+ case Statement::Type::SWITCH:
+ break;
+
+ case Statement::Type::SCOPE:
+ break;
+
+ case Statement::Type::WHILE:
+ break;
+
+ case Statement::Type::UNTIL:
+ break;
+
+ case Statement::Type::PARALLEL:
+ break;
+ }
+ }
+}
+
+} /* namespace samb */
diff --git a/src/ui/AsciiRenderer.h b/src/ui/AsciiRenderer.h
new file mode 100644
index 0000000..4f9020a
--- /dev/null
+++ b/src/ui/AsciiRenderer.h
@@ -0,0 +1,33 @@
+/*
+ * Renderer.h
+ *
+ * Created on: Nov 23, 2017
+ * Author: naopross
+ */
+
+#ifndef SRC_UI_ASCIIRENDERER_H_
+#define SRC_UI_ASCIIRENDERER_H_
+
+#include "../diagram/Structogram.h"
+
+namespace samb {
+
+class AsciiRenderer {
+private:
+ Structogram m_structogram;
+ const unsigned int m_width;
+
+ void drawPadding(unsigned int amt);
+ void drawLine() const;
+ void drawText(std::string text, unsigned int width = 0, std::string before = "|", std::string after = "|") const;
+ void drawDecision(std::string condition, std::string trueText, std::string falseText, unsigned int width = 0) const;
+public:
+ AsciiRenderer(Structogram& structogram, unsigned int width);
+ ~AsciiRenderer();
+
+ void render();
+};
+
+} /* namespace samb */
+
+#endif /* SRC_UI_ASCIIRENDERER_H_ */