[4] | 1 | |
---|
| 2 | /* |
---|
| 3 | Copyright 2012 Willem Vermin, SARA |
---|
| 4 | |
---|
| 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
---|
| 6 | you may not use this file except in compliance with the License. |
---|
| 7 | You may obtain a copy of the License at |
---|
| 8 | |
---|
| 9 | http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 10 | |
---|
| 11 | Unless required by applicable law or agreed to in writing, software |
---|
| 12 | distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 14 | See the License for the specific language governing permissions and |
---|
| 15 | limitations under the License. |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | class token{ |
---|
| 19 | private: |
---|
| 20 | std::string value; |
---|
| 21 | long id; |
---|
| 22 | unsigned int committed; |
---|
| 23 | std::fstream *file; |
---|
| 24 | char status; |
---|
| 25 | unsigned int pmarkerlen; |
---|
| 26 | std::string pmarker; |
---|
| 27 | // following lenths in char: |
---|
| 28 | static const unsigned int pointerlen = 16; // length of pointer |
---|
| 29 | static const unsigned int statstart = 0; |
---|
| 30 | static const unsigned int statlen = 1; // length of status |
---|
| 31 | static const unsigned int comstart = statstart + statlen; |
---|
| 32 | static const unsigned int comlen = 4; // length of nr commits |
---|
| 33 | static const unsigned int linenrstart = comstart + comlen; |
---|
| 34 | static const unsigned int linenrlen = 10; // length of linenr |
---|
| 35 | static const unsigned int valuestart = linenrstart + linenrlen; |
---|
| 36 | unsigned int linenr; |
---|
| 37 | unsigned int lenlen; |
---|
| 38 | public: |
---|
| 39 | token(void); |
---|
| 40 | void setid(long id); |
---|
| 41 | long getid(void); |
---|
| 42 | void ready(void); |
---|
| 43 | bool getready(void); |
---|
| 44 | void clearstatus(void); |
---|
| 45 | char getstatus(void); |
---|
| 46 | void setlinenr(unsigned int l); |
---|
| 47 | unsigned int getlinenr(void); |
---|
| 48 | void setvalue(std::string v); |
---|
| 49 | std::string getvalue(void); |
---|
| 50 | void setcommitted(unsigned int c); |
---|
| 51 | unsigned int getcommitted(void); |
---|
| 52 | void inccommitted(void); |
---|
| 53 | std::string gettotal(void); |
---|
| 54 | int puttotal(std::string t); |
---|
| 55 | void setfile(std::fstream& file); |
---|
| 56 | int readnext(std::streampos pos, std::streampos& posused,std::streampos& posnext); |
---|
| 57 | int writetoken(std::streampos& p); |
---|
| 58 | int writelocpointer(std::streampos locpointer); |
---|
| 59 | std::streampos readlocpointer(void); |
---|
| 60 | }; |
---|