diff options
Diffstat (limited to 'src/ast/item.hpp')
| -rw-r--r-- | src/ast/item.hpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/ast/item.hpp b/src/ast/item.hpp new file mode 100644 index 00000000..7b5437c4 --- /dev/null +++ b/src/ast/item.hpp @@ -0,0 +1,57 @@ + +#pragma once + +#include <string> +#include <serialise.hpp> + +namespace AST { + +template <typename T> +struct NamedNS +{ + ::std::string name; + T data; + bool is_pub; + + NamedNS(): + is_pub(false) + {} + NamedNS(NamedNS&&) noexcept = default; + NamedNS(const NamedNS&) = default; + NamedNS(::std::string name, T data, bool is_pub): + name( ::std::move(name) ), + data( ::std::move(data) ), + is_pub( is_pub ) + { + } + + //friend ::std::ostream& operator<<(::std::ostream& os, const Named& i) { + // return os << (i.is_pub ? "pub " : " ") << i.name << ": " << i.data; + //} +}; + +template <typename T> +struct Named: + public NamedNS<T>, + public Serialisable +{ + Named(): + NamedNS<T>() + {} + Named(Named&&) noexcept = default; + Named(const Named&) = default; + Named(::std::string name, T data, bool is_pub): + NamedNS<T>( ::std::move(name), ::std::move(data), is_pub ) + {} + SERIALISE_TYPE_A(, "Named", { + s.item(this->name); + s.item(this->data); + s.item(this->is_pub); + }) +}; + +template <typename T> +using NamedList = ::std::vector<Named<T> >; + +} // namespace AST + |
