Loading...
Searching...
No Matches
arr.hpp
Go to the documentation of this file.
1
2#pragma once
3
5
6struct arrIntegTest;
7
8namespace by {
9
15 class _nout arr: public tbridge<narr>, public tucontainable<node>, public tarrayable<node> {
16 // arr uses instance variable 'ntype':
17 // ntype contains beanType as 'const type*' instance variable. so user should be
18 // careful when calling ttype<arr>. because it will also return ntype instance
19 // as a consequences, but it won't contain beanType.
20 //
21 // the most appropriate getter for ntype of arr is to call getType() of instance
22 // to arr.
24
25 public:
26 typedef typename tucontainable<node>::iter iter;
28 typedef std::map<const node*, tstr<scope>> cache;
29 friend class interpreter; // for _cache
30 friend struct ::arrIntegTest;
31
32 public:
33 arr();
34 arr(const node& elemType);
35 arr(const me& rhs);
36
37 public:
38 using tarrayable<node>::operator[];
39 node& operator[](nidx n) override;
40
41 public:
42 const ntype& getType() const override;
43
44 using super::subs;
45 scope& subs() override;
46
47 ncnt len() const override;
48
49 using super::in;
50 nbool in(nidx n) const override;
51
52 // get:
53 using tarrayable<node>::get;
54 using super::get;
55 using tucontainable<node>::get;
56
57 /* TODO: can I remove this?
58 template <typename E> E* get(std::function<nbool(const E&)> l) const {
59 for(const node* elem : *this) {
60 const E& cast = elem->template cast<E>() OR_CONTINUE;
61 if(l(cast)) // elem should be typeProvidable.
62 return cast;
63 }
64
65 return nullptr;
66 }
67 node& get(std::function<nbool(const node&)> l) const;
68
69 template <typename E> tnarr<E, strTactic> getAll(std::function<nbool(const E&)> l) const {
70 tnarr<E> ret;
71 for(const node& elem: *this) {
72 const E* cast = elem.template cast<E>();
73 if(cast && l(*cast)) ret.add(cast);
74 }
75
76 return ret;
77 }
78 narr getAll(std::function<nbool(const node&)> l) const;
79 */
80
81 node* get(nidx n) override;
82
83 // set:
84 using tucontainable<node>::set;
85 using tarrayable<node>::set;
86 nbool set(const iter& at, const node& new1) override;
87 nbool set(nidx n, const node& new1) override;
88
89 // add:
90 using tucontainable<node>::add;
91 using tarrayable<node>::add;
92 nbool add(const iter& at, const node& new1) override;
93 nbool add(nidx n, const node& new1) override;
94 void add(const iter& here, const iter& from, const iter& to) override;
95
96 // del:
97 using tucontainable<node>::del;
98 nbool del(nidx n) override;
99 nbool del(const iter& it) override;
100 nbool del(const iter& from, const iter& to) override;
101
102 // etc:
103 void rel() override;
104
105 const baseObj& getOrigin() const override;
106
107 std::string asStr() const;
108
109 protected:
110 iteration* _onMakeIteration(ncnt step, nbool isReversed) const override;
111
112 private:
113 scope& _defGeneric(const baseObj& paramType);
114 scope& _getOriginScope();
115
116 private:
117 static inline cache _cache;
118 mutable str _org;
119 mgdType _type;
120 };
121} // namespace by
Scripted array container for byeol language.
Definition arr.hpp:15
nbool del(nidx n) override
nbool add(nidx n, const node &new1) override
void rel() override
Base class for representing byeol objects.
Definition baseObj.hpp:73
High-level interpreter for byeol language.
Definition interpreter.hpp:35
Script type for byeol objects.
Definition mgdType.hpp:18
Base class for all AST nodes in the byeol language.
Definition node.hpp:195
represents native c++ type system for byeol language
Definition ntype.hpp:33
Definition tarrayable.hpp:11
C++ native class bridge.
Definition tbridge.hpp:19
Definition tnarr.hpp:9
Template unidirectional container interface.
Definition tucontainable.hpp:20
Bidirectional iterator for key-value containers.
Definition biter.hpp:10
Definition biteration.hpp:5
to Top