#ifndef STAR_DIRECTIVES_HPP #define STAR_DIRECTIVES_HPP #include "StarImageProcessing.hpp" namespace Star { STAR_CLASS(NestedDirectives); STAR_EXCEPTION(DirectivesException, StarException); // Kae: My attempt at reducing memory allocation and per-frame string parsing for extremely long directives class NestedDirectives { public: struct Leaf { struct Entry { ImageOperation operation; String string; bool operator==(Entry const& other) const; bool operator!=(Entry const& other) const; Entry(ImageOperation&& operation, String&& string); }; List entries; size_t length() const; bool operator==(NestedDirectives::Leaf const& other) const; bool operator!=(NestedDirectives::Leaf const& other) const; }; typedef function LeafCallback; typedef function LeafPairCallback; typedef function AbortableLeafCallback; typedef function AbortableLeafPairCallback; struct Cell; typedef std::shared_ptr Branch; typedef std::shared_ptr ConstBranch; typedef List Branches; struct Cell { Variant value; Cell(); Cell(Leaf&& leaf); Cell(Branches&& branches); Cell(const Leaf& leaf); Cell(const Branches& branches); void buildString(String& string) const; void forEach(LeafCallback& callback) const; bool forEachAbortable(AbortableLeafCallback& callback) const; }; NestedDirectives(); NestedDirectives(String const& directives); NestedDirectives(String&& directives); void parseDirectivesIntoLeaf(String const& directives); bool empty() const; bool compare(NestedDirectives const& other) const; void append(NestedDirectives const& other); NestedDirectives& operator+=(NestedDirectives const& other); bool operator==(NestedDirectives const& other) const; bool operator!=(NestedDirectives const& other) const; const ConstBranch& branch() const; String toString() const; void addToString(String& string) const; void forEach(LeafCallback callback) const; void forEachPair(LeafPairCallback callback) const; bool forEachAbortable(AbortableLeafCallback callback) const; bool forEachPairAbortable(AbortableLeafPairCallback callback) const; Image apply(Image& image) const; private: void buildString(String& string, const Cell& cell) const; Branches& convertToBranches(); Branch m_root; }; typedef NestedDirectives ImageDirectives; } #endif