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