leaf.hpp
Go to the documentation of this file.
1
2#pragma once
3
4#include "leaf/common.hpp"
5
6namespace by {
7
12 class _nout leaf: public instance {
13 BY(ME(leaf, instance), CLONE(me), INIT_META(leaf))
14
15 typedef std::map<std::string, tstr<me>> myMap;
16 typedef myMap::iterator iterator;
17
18 public:
19 leaf(std::initializer_list<me*> subs, const std::string& name = "");
20 leaf(const me& rhs, const std::string& name = "");
21 leaf(const std::string& name = "");
22
23 public:
24 me& operator[](const std::string& name);
25 const me& operator[](const std::string& name) const BY_CONST_FUNC(operator[](name));
26 me& operator[](const nchar* name);
27 const me& operator[](const nchar* name) const BY_CONST_FUNC(operator[](name));
28 explicit operator nbool() const;
29
30 public:
31 me& sub(const std::string& name);
32 me& sub(const std::string* it) BY_SIDE_FUNC(it, sub(*it), *this);
33 const me& sub(const std::string& name) const BY_CONST_FUNC(sub(name))
34 const me& sub(const std::string* name) const BY_CONST_FUNC(sub(name))
35 me& sub(const nchar* name);
36 const me& sub(const nchar* name) const BY_CONST_FUNC(sub(name))
37 me& sub(nidx n);
38 const me& sub(nidx n) const BY_CONST_FUNC(sub(n))
39
40 nbool has(const std::string& name) const;
41 nbool has(const std::string* it) const BY_SIDE_FUNC(has);
42
43 void add(const leaf& it);
44 void add(const leaf* it) BY_SIDE_FUNC(add);
45 void add(std::initializer_list<leaf*> subs);
46 void del(const leaf& it);
47 void del(const leaf* it) BY_SIDE_FUNC(del);
48 void del(const std::string& name);
49 void del(const std::string* it) BY_SIDE_FUNC(del);
50 void del(const nchar* name);
51
52 const std::string& getName() const;
53 void setName(const std::string& newName);
54 void setName(const std::string* it) BY_SIDE_FUNC(setName);
55 void setName(const nchar* newName);
56
57 ncnt len() const;
58
59 iterator begin();
60 iterator end();
61
62 const type& getType() const override;
63
64 virtual nint asInt() const;
65 virtual nchar asChar() const;
66 virtual const std::string& asStr() const;
67 virtual nbool asBool() const;
68 virtual nbool isExist() const;
69
70 private:
71 myMap _subs;
72 std::string _name;
73 };
74} // namespace by
Deferred execution utility like defer keyword in other languages.
Definition: end.hpp:14
Base class for all managed instances in memlite system.
Definition: instance.hpp:20
Core AST node for leaf configuration language.
Definition: leaf.hpp:12
Base class for runtime type information in byeol language.
Definition: type.hpp:12