Line | |
---|
1 | #include <string> |
---|
2 | #include <vector> |
---|
3 | #include "stopos.h" |
---|
4 | #include "wutils.h" |
---|
5 | #include "stopos_key.h" |
---|
6 | |
---|
7 | stopos_key::stopos_key() |
---|
8 | { |
---|
9 | this->set(0,""); |
---|
10 | } |
---|
11 | |
---|
12 | stopos_key::stopos_key(const std::string & s) |
---|
13 | { |
---|
14 | std::vector <std::string> v; |
---|
15 | v = split(v,s,keysep); |
---|
16 | this->value = v[0]; |
---|
17 | if (v.size()>1) |
---|
18 | this->slot = v[1]; |
---|
19 | } |
---|
20 | |
---|
21 | void stopos_key::impossible() |
---|
22 | { |
---|
23 | this->value="%%%%"; |
---|
24 | } |
---|
25 | |
---|
26 | void stopos_key::increment(void) |
---|
27 | { // notused |
---|
28 | int p = this->value.size(); |
---|
29 | while(1) |
---|
30 | { |
---|
31 | p--; |
---|
32 | if (this->value[p] == lastchar) |
---|
33 | { |
---|
34 | this->value[p] = firstchar; |
---|
35 | if (p == 0) |
---|
36 | { |
---|
37 | this->value = firstchar + this->value; |
---|
38 | p = 1; |
---|
39 | } |
---|
40 | } |
---|
41 | else |
---|
42 | { |
---|
43 | this->value[p] ++; |
---|
44 | break; |
---|
45 | } |
---|
46 | } |
---|
47 | } |
---|
48 | |
---|
49 | std::string stopos_key::str(void) const |
---|
50 | { |
---|
51 | if (this->slot == "") |
---|
52 | return value; |
---|
53 | |
---|
54 | return this->value+keysep+this->slot; |
---|
55 | } |
---|
56 | |
---|
57 | std::string stopos_key::get_key(void) const |
---|
58 | { |
---|
59 | return this->value; |
---|
60 | } |
---|
61 | |
---|
62 | std::string stopos_key::get_slot(void) const |
---|
63 | { |
---|
64 | return this->slot; |
---|
65 | } |
---|
66 | |
---|
67 | bool stopos_key::operator==(const stopos_key &k) const |
---|
68 | { |
---|
69 | return k.value == this->value; |
---|
70 | } |
---|
71 | |
---|
72 | bool stopos_key::operator!=(const stopos_key &k) const |
---|
73 | { |
---|
74 | return k.value != this->value; |
---|
75 | } |
---|
76 | |
---|
Note: See
TracBrowser
for help on using the repository browser.