/* Copyright 2012 Willem Vermin, SARA Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ class token{ private: std::string value; long id; unsigned int committed; std::fstream *file; char status; unsigned int pmarkerlen; std::string pmarker; // following lenths in char: static const unsigned int pointerlen = 16; // length of pointer static const unsigned int statstart = 0; static const unsigned int statlen = 1; // length of status static const unsigned int comstart = statstart + statlen; static const unsigned int comlen = 4; // length of nr commits static const unsigned int linenrstart = comstart + comlen; static const unsigned int linenrlen = 10; // length of linenr static const unsigned int valuestart = linenrstart + linenrlen; unsigned int linenr; unsigned int lenlen; public: token(void); void setid(long id); long getid(void); void ready(void); bool getready(void); void clearstatus(void); char getstatus(void); void setlinenr(unsigned int l); unsigned int getlinenr(void); void setvalue(std::string v); std::string getvalue(void); void setcommitted(unsigned int c); unsigned int getcommitted(void); void inccommitted(void); std::string gettotal(void); int puttotal(std::string t); void setfile(std::fstream& file); int readnext(std::streampos pos, std::streampos& posused,std::streampos& posnext); int writetoken(std::streampos& p); int writelocpointer(std::streampos locpointer); std::streampos readlocpointer(void); };