summaryrefslogtreecommitdiff
path: root/src/ast/item.hpp
blob: cc88f3e23e5290ecc9b8332f3b60777d63349262 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

#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&&) = default;
    NamedNS(const NamedNS&) = default;
    NamedNS& operator=(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>
{
    Named():
        NamedNS<T>()
    {}
    Named(Named&&) = default;
    Named(const Named&) = default;
    Named& operator=(Named&&) = default;
    Named(::std::string name, T data, bool is_pub):
        NamedNS<T>( ::std::move(name), ::std::move(data), is_pub )
    {}
};

template <typename T>
using NamedList = ::std::vector<Named<T> >;

}   // namespace AST