Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <memory>
- #include <string>
- #include <utility>
- #include <any>
- #include <variant>
- namespace Org {
- class Node;
- class Headline;
- using OrgType = std::variant<Node, Headline>;
- using OrgTypePtr = std::shared_ptr<OrgType>;
- using OrgTypeVector = std::vector<std::shared_ptr<std::variant<Node, Headline>>>;
- /* test to play from
- https://www.fluentcpp.com/2021/01/29/inheritance-without-pointers/
- /*
- //template <Interface>
- class NodeImplementation
- {
- public:
- template<typename NodeType>
- NodeImplementation(NodeType &&node)
- : storage{std::forward<NodeType>(node)},
- getter{[](std::any &storage)->Node& { return std::any_cast<NodeType&>(storage);}}
- { }
- Node *operator->() { return &getter(storage); }
- private:
- std::any storage;
- Node& (*getter)(std::any&);
- };
- */
- class Node
- {
- enum NodeType {ROOT, HEADLINE, LIST, TABLE, TAG}; //?
- public:
- Node(OrgTypePtr parent=nullptr, std::string content={}) :
- m_parent(parent),
- m_content(content)
- {}
- //private:
- OrgTypePtr m_parent;
- OrgTypeVector m_children;
- std::string m_content;
- //virtual void parse_content()=0;
- };
- class Headline: public Node
- {
- public:
- Headline(OrgTypePtr parent=nullptr, std::string content={})
- : Node(parent, content) {};
- enum State { EMPTY, TODO, DONE, WAITING } state;
- int level;
- };
- class List: public Node
- {
- public:
- int blyat;
- };
- }; // end of namespace
Advertisement
Add Comment
Please, Sign In to add comment