state_impl.hpp
1.87 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
* File: _state_impl.hpp
* Author: mlenart
*
* Created on 21 październik 2013, 15:20
*/
#ifndef _STATE_IMPL_HPP
#define _STATE_IMPL_HPP
#include <typeinfo>
#include <cstdio>
#include "fsa.hpp"
using namespace std;
template <class T>
State<T>::State(const FSA<T>& fsa)
: fsa(fsa), offset(0), accepting(false), sink(false), value(), valueSize(0) {
}
template <class T>
bool State<T>::isSink() const {
return this->sink;
}
template <class T>
bool State<T>::isAccepting() const {
return this->accepting;
}
template <class T>
void State<T>::proceedToNext(const char c) {
if (this->sink) {
return;
}
else {
this->fsa.proceedToNext(c, *this);
}
}
template <class T>
unsigned long State<T>::getOffset() const {
assert(!this->isSink());
return this->offset;
}
template <class T>
const T& State<T>::getValue() const {
assert(this->isAccepting());
return this->value;
}
template <class T>
unsigned long State<T>::getValueSize() const {
assert(this->isAccepting());
return this->valueSize;
}
template <class T>
unsigned char State<T>::getLastTransitionValue() const {
return this->lastTransitionValue;
}
template <class T>
void State<T>::setLastTransitionValue(unsigned char val) {
this->lastTransitionValue = val;
}
template <class T>
State<T>::~State() {
}
template <class T>
void State<T>::setNext(const unsigned long offset) {
// assert(!this->isSink());
this->offset = offset;
this->accepting = false;
}
template <class T>
void State<T>::setNext(const unsigned long offset, const T& value, const unsigned long valueSize) {
// assert(!this->isSink());
this->offset = offset;
this->accepting = true;
this->value = value;
this->valueSize = valueSize;
}
template <class T>
void State<T>::setNextAsSink() {
this->sink = true;
this->accepting = false;
}
#endif /* _STATE_IMPL_HPP */