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