PGROUTING  2.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StringTokenizer Class Reference

#include "utils.h"

Collaboration diagram for StringTokenizer:

Public Member Functions

 StringTokenizer ()
 
bool getToken (std::string &strToken, long iTokenIndex)
 
size_t getTokenCount ()
 
bool getTokens (StringVector &vecTokensRef)
 
bool parse (std::string strInput, std::string chDelim)
 
void reset ()
 

Private Attributes

std::string strInput
 
StringVector vecTokens
 

Detailed Description

Definition at line 51 of file utils.h.

Constructor & Destructor Documentation

StringTokenizer::StringTokenizer ( )
inline

Definition at line 53 of file utils.h.

References reset().

53  {
54  reset();
55  }
void reset()
Definition: utils.h:56

Here is the call graph for this function:

Member Function Documentation

bool StringTokenizer::getToken ( std::string &  strToken,
long  iTokenIndex 
)
inline

Definition at line 86 of file utils.h.

References vecTokens.

86  {
87  long lTokenCount = vecTokens.size();
88  if (iTokenIndex < 0 || iTokenIndex < lTokenCount) {
89  strToken = vecTokens[iTokenIndex];
90  return true;
91  }
92  return false;
93  }
StringVector vecTokens
Definition: utils.h:102
size_t StringTokenizer::getTokenCount ( )
inline

Definition at line 82 of file utils.h.

References vecTokens.

82  {
83  return vecTokens.size();
84  }
StringVector vecTokens
Definition: utils.h:102
bool StringTokenizer::getTokens ( StringVector vecTokensRef)
inline

Definition at line 95 of file utils.h.

References vecTokens.

95  {
96  vecTokensRef = vecTokens;
97  return true;
98  }
StringVector vecTokens
Definition: utils.h:102
bool StringTokenizer::parse ( std::string  strInput,
std::string  chDelim 
)
inline

Definition at line 60 of file utils.h.

References vecTokens.

60  {
61  size_t iStartPos = 0;
62  while (true) {
63  size_t iPos = strInput.find(chDelim[0], iStartPos);
64  if (iPos != std::string::npos) {
65  std::string strToken;
66  strToken = strInput.substr(iStartPos, iPos - iStartPos);
67  vecTokens.push_back(strToken);
68  iStartPos = iPos + 1;
69  } else if (iPos == std::string::npos && strInput.length() > 0) {
70  std::string strToken;
71  strToken = strInput.substr(iStartPos,
72  strInput.length() - iStartPos);
73  if (strToken.length() > 0)
74  vecTokens.push_back(strToken);
75  break;
76  } else {
77  break;
78  }
79  }
80  return true;
81  }
StringVector vecTokens
Definition: utils.h:102
std::string strInput
Definition: utils.h:101
void StringTokenizer::reset ( )
inline

Definition at line 56 of file utils.h.

References strInput, and vecTokens.

Referenced by StringTokenizer().

56  {
57  vecTokens.clear();
58  strInput = "";
59  }
StringVector vecTokens
Definition: utils.h:102
std::string strInput
Definition: utils.h:101

Here is the caller graph for this function:

Member Data Documentation

std::string StringTokenizer::strInput
private

Definition at line 101 of file utils.h.

Referenced by reset().

StringVector StringTokenizer::vecTokens
private

Definition at line 102 of file utils.h.

Referenced by getToken(), getTokenCount(), getTokens(), parse(), and reset().


The documentation for this class was generated from the following file: