diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-24 01:32:07 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-24 01:32:07 +1000 |
commit | 179f220bb4f1cc3e9e53d760ece6497a6f2044a8 (patch) | |
tree | f8203d9e4631f28d499639a129b1ce5c00e94ce6 | |
parent | 6832c10ed5482530b4a423a78700b279fc73212a (diff) |
Moved my silly nested directives experiment to a new branch
-rw-r--r-- | source/game/CMakeLists.txt | 2 | ||||
-rw-r--r-- | source/game/StarDirectives.cpp | 51 | ||||
-rw-r--r-- | source/game/StarDirectives.hpp | 50 |
3 files changed, 0 insertions, 103 deletions
diff --git a/source/game/CMakeLists.txt b/source/game/CMakeLists.txt index c7399b1..1ff95ff 100644 --- a/source/game/CMakeLists.txt +++ b/source/game/CMakeLists.txt @@ -38,7 +38,6 @@ SET (star_game_HEADERS StarDamageManager.hpp StarDamageTypes.hpp StarDanceDatabase.hpp - StarDirectives.hpp StarDrawable.hpp StarDungeonGenerator.hpp StarDungeonImagePart.hpp @@ -297,7 +296,6 @@ SET (star_game_SOURCES StarDamageManager.cpp StarDamageTypes.cpp StarDanceDatabase.cpp - StarDirectives.cpp StarDrawable.cpp StarDungeonGenerator.cpp StarDungeonImagePart.cpp diff --git a/source/game/StarDirectives.cpp b/source/game/StarDirectives.cpp deleted file mode 100644 index 4dc661d..0000000 --- a/source/game/StarDirectives.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "StarImage.hpp" -#include "StarImageProcessing.hpp" -#include "StarDirectives.hpp" - -namespace Star { - -NestedDirectives::NestedDirectives() {} -NestedDirectives::NestedDirectives(String const& string) : m_root{ Leaf{ parseImageOperations(string), string} } {} - -void NestedDirectives::addBranch(const Branch& newBranch) { - convertToBranches(); - - m_root.value.get<Branches>().emplace_back(newBranch); -} - -String NestedDirectives::toString() const { - String string; - buildString(string, m_root); - return string; -} - -void NestedDirectives::forEach() const { - -} - -Image NestedDirectives::apply(Image& image) const { - Image current = image; - - return current; -} - -void NestedDirectives::buildString(String& string, const Cell& cell) const { - if (auto leaf = cell.value.ptr<Leaf>()) - string += leaf->string; - else { - for (auto& branch : cell.value.get<Branches>()) - buildString(string, *branch); - } -} - -void NestedDirectives::convertToBranches() { - if (m_root.value.is<Branches>()) - return; - - Leaf& leaf = m_root.value.get<Leaf>(); - Branches newBranches; - newBranches.emplace_back(std::make_shared<Cell const>(move(leaf))); - m_root.value = move(newBranches); -} - -}
\ No newline at end of file diff --git a/source/game/StarDirectives.hpp b/source/game/StarDirectives.hpp deleted file mode 100644 index 3540ee1..0000000 --- a/source/game/StarDirectives.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef STAR_DIRECTIVES_HPP -#define STAR_DIRECTIVES_HPP - -#include "StarImageProcessing.hpp" - -namespace Star { - -STAR_CLASS(NestedDirectives); - -// Attempt at reducing memory allocation and per-frame string parsing for extremely long directives -class NestedDirectives { -public: - struct Leaf { - List<ImageOperation> operations; - String string; - }; - - struct Cell; - typedef std::shared_ptr<Cell const> Branch; - typedef List<Branch> Branches; - - struct Cell { - Variant<Leaf, Branches> value; - - Cell() : value(Leaf()) {}; - Cell(Leaf&& leaf) : value(move(leaf)) {}; - Cell(Branches&& branches) : value(move(branches)) {}; - Cell(const Leaf& leaf) : value(leaf) {}; - Cell(const Branches& branches) : value(branches) {}; - }; - - - NestedDirectives(); - NestedDirectives(String const& string); - - void addBranch(const Branch& newBranch); - const Branch& branch() const; - String toString() const; - void forEach() const; - Image apply(Image& image) const; -private: - void buildString(String& string, const Cell& cell) const; - void convertToBranches(); - - Cell m_root; -}; - -} - -#endif |