blob: 4818952124da93d14b852dbc1a7958d0cf8fc41d [file] [log] [blame]
akmhoque298385a2014-02-13 14:13:09 -06001#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
akmhoque1fd8c1e2014-02-19 19:41:49 -060011namespace nlsr
12{
akmhoqueb1710aa2014-02-19 17:13:36 -060013
akmhoque1fd8c1e2014-02-19 19:41:49 -060014 using namespace std;
15 using namespace boost;
akmhoque298385a2014-02-13 14:13:09 -060016
akmhoque1fd8c1e2014-02-19 19:41:49 -060017 class nlsrTokenizer
18 {
19 public:
20 nlsrTokenizer(const string& inputString)
21 :firstToken(),
22 restOfTheLine()
23 {
24 seps = " ";
25 originalString = inputString;
26 makeToken();
27 }
akmhoque298385a2014-02-13 14:13:09 -060028
akmhoque1fd8c1e2014-02-19 19:41:49 -060029 nlsrTokenizer(const string& inputString, const string& separator)
30 :firstToken(),
31 restOfTheLine()
32 {
33 seps = separator;
34 originalString = inputString;
35 makeToken();
36 }
akmhoque298385a2014-02-13 14:13:09 -060037
akmhoque1fd8c1e2014-02-19 19:41:49 -060038 string getFirstToken()
39 {
40 return firstToken;
41 }
akmhoque298385a2014-02-13 14:13:09 -060042
akmhoque1fd8c1e2014-02-19 19:41:49 -060043 string getRestOfLine()
44 {
45 return restOfTheLine;
46 }
akmhoque298385a2014-02-13 14:13:09 -060047
akmhoque1fd8c1e2014-02-19 19:41:49 -060048 int getTokenPosition(string& token);
49 string getTokenString(int from , int to);
50 string getTokenString(int from);
51 bool doesTokenExist(string token);
akmhoque298385a2014-02-13 14:13:09 -060052
akmhoque1fd8c1e2014-02-19 19:41:49 -060053 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 };
akmhoque298385a2014-02-13 14:13:09 -060064
akmhoqueb1710aa2014-02-19 17:13:36 -060065}//namespace nlsr
akmhoque298385a2014-02-13 14:13:09 -060066#endif