NLSR - (Hello Protocol + FIB Update)
diff --git a/src/utility/nlsr_tokenizer.cpp b/src/utility/nlsr_tokenizer.cpp
index 809e395..35d6625 100644
--- a/src/utility/nlsr_tokenizer.cpp
+++ b/src/utility/nlsr_tokenizer.cpp
@@ -9,102 +9,102 @@
namespace nlsr
{
- using namespace std;
- using namespace boost;
+ using namespace std;
+ using namespace boost;
- void
- nlsrTokenizer::makeToken()
+ void
+ nlsrTokenizer::makeToken()
+ {
+ char_separator<char> sep(seps.c_str());
+ tokenizer< char_separator<char> >tokens(originalString, sep);
+ tokenizer< char_separator<char> >::iterator tok_iter = tokens.begin();
+ for ( ; tok_iter != tokens.end(); ++tok_iter)
{
- char_separator<char> sep(seps.c_str());
- tokenizer< char_separator<char> >tokens(originalString, sep);
- tokenizer< char_separator<char> >::iterator tok_iter = tokens.begin();
- for ( ; tok_iter != tokens.end(); ++tok_iter)
- {
- string oneToken(*tok_iter);
- trim(oneToken);
- if(!oneToken.empty())
- {
- insertToken(oneToken);
- }
- }
- firstToken=vTokenList[0];
- makeRestOfTheLine();
+ string oneToken(*tok_iter);
+ trim(oneToken);
+ if(!oneToken.empty())
+ {
+ insertToken(oneToken);
+ }
}
+ firstToken=vTokenList[0];
+ makeRestOfTheLine();
+ }
- void
- nlsrTokenizer::insertToken(const string& token)
- {
- tokenList.push_back(token);
- vTokenList.push_back(token);
- }
+ void
+ nlsrTokenizer::insertToken(const string& token)
+ {
+ tokenList.push_back(token);
+ vTokenList.push_back(token);
+ }
- int
- nlsrTokenizer::getTokenPosition(string& token)
+ int
+ nlsrTokenizer::getTokenPosition(string& token)
+ {
+ int pos=-1;
+ int i=0;
+ for(std::list<string>::iterator it=tokenList.begin();
+ it!=tokenList.end(); it++)
{
- int pos=-1;
- int i=0;
- for(std::list<string>::iterator it=tokenList.begin();
- it!=tokenList.end(); it++)
- {
- if( (*it) == token )
- {
- break;
- }
- i++;
- }
- if( i < tokenList.size() )
- {
- pos=i;
- }
- return pos;
+ if( (*it) == token )
+ {
+ break;
+ }
+ i++;
}
+ if( i < tokenList.size() )
+ {
+ pos=i;
+ }
+ return pos;
+ }
- string
- nlsrTokenizer::getTokenString(int from , int to)
+ string
+ nlsrTokenizer::getTokenString(int from , int to)
+ {
+ string returnString="";
+ if((from>=0 && to<tokenList.size()) &&
+ (to>=from && to <tokenList.size()))
{
- string returnString="";
- if((from>=0 && to<tokenList.size()) &&
- (to>=from && to <tokenList.size()))
- {
- for(int i=from; i<=to; i++)
- {
- returnString+=seps;
- returnString+=vTokenList[i];
- }
- }
- trim(returnString);
- return returnString;
+ for(int i=from; i<=to; i++)
+ {
+ returnString+=seps;
+ returnString+=vTokenList[i];
+ }
}
+ trim(returnString);
+ return returnString;
+ }
- string
- nlsrTokenizer::getTokenString(int from)
- {
- return getTokenString(from,tokenList.size()-1);
- }
+ string
+ nlsrTokenizer::getTokenString(int from)
+ {
+ return getTokenString(from,tokenList.size()-1);
+ }
- static bool
- tokenCompare(string& s1, string& s2)
- {
- return s1==s2;
- }
+ static bool
+ tokenCompare(string& s1, string& s2)
+ {
+ return s1==s2;
+ }
- void
- nlsrTokenizer::makeRestOfTheLine()
- {
- restOfTheLine=getTokenString(1);
- }
+ void
+ nlsrTokenizer::makeRestOfTheLine()
+ {
+ restOfTheLine=getTokenString(1);
+ }
- bool
- nlsrTokenizer::doesTokenExist(string token)
+ bool
+ nlsrTokenizer::doesTokenExist(string token)
+ {
+ std::list<string >::iterator it = std::find_if( tokenList.begin(),
+ tokenList.end(),
+ bind(&tokenCompare, _1 , token));
+ if( it != tokenList.end() )
{
- std::list<string >::iterator it = std::find_if( tokenList.begin(),
- tokenList.end(),
- bind(&tokenCompare, _1 , token));
- if( it != tokenList.end() )
- {
- return true;
- }
- return false;
+ return true;
}
+ return false;
+ }
}//namespace nlsr