akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 1 | #ifndef NLSR_TOKENIZER_HPP |
| 2 | #define NLSR_TOKENIZER_HPP |
| 3 | |
| 4 | #include <iostream> |
| 5 | #include <boost/tokenizer.hpp> |
| 6 | #include <boost/algorithm/string.hpp> |
| 7 | #include <string> |
| 8 | #include <list> |
| 9 | #include <ndn-cpp-dev/face.hpp> |
| 10 | |
akmhoque | b1710aa | 2014-02-19 17:13:36 -0600 | [diff] [blame^] | 11 | namespace nlsr { |
| 12 | |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 13 | using namespace std; |
| 14 | using namespace boost; |
| 15 | |
| 16 | class nlsrTokenizer{ |
| 17 | public: |
| 18 | nlsrTokenizer(const string& inputString) |
| 19 | :firstToken(), |
| 20 | restOfTheLine() |
| 21 | { |
| 22 | seps = " "; |
| 23 | originalString = inputString; |
| 24 | makeToken(); |
| 25 | } |
| 26 | |
| 27 | nlsrTokenizer(const string& inputString, const string& separator) |
| 28 | :firstToken(), |
| 29 | restOfTheLine() |
| 30 | { |
| 31 | seps = separator; |
| 32 | originalString = inputString; |
| 33 | makeToken(); |
| 34 | } |
| 35 | |
| 36 | string getFirstToken(){ |
| 37 | return firstToken; |
| 38 | } |
| 39 | |
| 40 | string getRestOfLine(){ |
| 41 | return restOfTheLine; |
| 42 | } |
| 43 | |
| 44 | int getTokenPosition(string& token); |
| 45 | string getTokenString(int from , int to); |
| 46 | string getTokenString(int from); |
| 47 | bool doesTokenExist(string token); |
| 48 | |
| 49 | private: |
| 50 | |
| 51 | void makeToken(); |
| 52 | void insertToken(const string& token); |
| 53 | |
| 54 | string seps; |
| 55 | string originalString; |
| 56 | string firstToken; |
| 57 | string restOfTheLine; |
| 58 | std::list<string> tokenList; |
| 59 | }; |
| 60 | |
akmhoque | b1710aa | 2014-02-19 17:13:36 -0600 | [diff] [blame^] | 61 | }//namespace nlsr |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 62 | #endif |