-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsli_trietype.h
63 lines (51 loc) · 1.21 KB
/
sli_trietype.h
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
54
55
56
57
58
59
60
61
62
63
#ifndef SLI_TRIETYPE_H
#define SLI_TRIETYPE_H
#include "sli_type.h"
#include "sli_type_trie.h"
#include <cassert>
namespace sli3
{
class TrieType: public SLIType
{
public:
TrieType(SLIInterpreter *sli, char const name[], sli_typeid type)
:SLIType(sli, name, type,true){}
refcount_t add_reference(Token const& t) const
{
return t.data_.trie_val->add_reference();
}
void remove_reference(Token &t) const
{
if(t.data_.trie_val->remove_reference() ==0)
{
t.type_=0;
t.data_.trie_val=0;
}
}
void clear(Token &t) const
{
remove_reference(t);
t.data_.trie_val=0;
t.type_=0;
}
refcount_t references(Token const &t) const
{
return t.data_.trie_val->references();
}
bool compare(const Token&t1, const Token&t2) const
{
return *(t1.data_.trie_val) == *(t2.data_.trie_val);
}
std::ostream & print(std::ostream& out, const Token &t) const
{
out << '+' << t.data_.trie_val->get_name() << '+';
return out;
}
std::ostream & pprint(std::ostream&out, const Token &t) const
{
out << '+' << t.data_.trie_val->get_name() << '+';
return out;
}
};
}
#endif