Image Component Library (ICL)
StrTok.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLUtils/src/ICLUtils/StrTok.h **
10 ** Module : ICLUtils **
11 ** Authors: Christof Elbrechter **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/CompatMacros.h>
34 #include <vector>
35 #include <string>
36 
37 namespace icl{
38  namespace utils{
39 
42  public:
43 
45 
54  StrTok(const std::string &s,const std::string &delims, bool singleCharDelims=true, char escapeChar='\0');
55 
57 
59  bool hasMoreTokens() const;
60 
62  const std::string &nextToken();
63 
65  unsigned int nTokens() const;
66 
68  const std::vector<std::string> &allTokens() const;
69 
71  void reset() { m_uiPos = 0; }
72 
74  typedef std::vector<std::string>::reverse_iterator reverse_iterator;
75 
77  typedef std::vector<std::string>::const_reverse_iterator const_reverse_iterator;
78 
80  typedef std::vector<std::string>::iterator iterator;
81 
83  typedef std::vector<std::string>::const_iterator const_iterator;
84 
86  inline iterator begin() { return m_oTokens.begin(); }
87 
89  inline const_iterator begin() const { return m_oTokens.begin(); }
90 
92  inline reverse_iterator rbegin() { return m_oTokens.rbegin(); }
93 
95  inline const_reverse_iterator rbegin() const { return m_oTokens.rbegin(); }
96 
98  inline iterator end() { return m_oTokens.end(); }
99 
101  inline const_iterator end() const { return m_oTokens.end(); }
102 
104  inline reverse_iterator rend() { return m_oTokens.rend(); }
105 
107  inline const_reverse_iterator rend() const { return m_oTokens.rend(); }
108 
109 
110  private:
112  std::vector<std::string> m_oTokens;
113 
115  unsigned int m_uiPos;
116  };
117 
118  } // namespace utils
119 }
120 
121 
undocument this line if you encounter any issues!
Definition: Any.h:37
const_reverse_iterator rbegin() const
returns const reverse begin-iterator
Definition: StrTok.h:95
reverse_iterator rbegin()
returns reverse begin-iterator
Definition: StrTok.h:92
std::vector< std::string > m_oTokens
internal data storage
Definition: StrTok.h:112
std::vector< std::string >::const_iterator const_iterator
constant iterator type
Definition: StrTok.h:83
const_iterator end() const
returns const end-iterator
Definition: StrTok.h:101
#define ICLUtils_API
this macros are important for creating dll's
Definition: CompatMacros.h:171
String Tokenizer Utility class.
Definition: StrTok.h:41
std::vector< std::string >::iterator iterator
iterator type
Definition: StrTok.h:80
iterator begin()
returns begin-iterator
Definition: StrTok.h:86
std::vector< std::string >::reverse_iterator reverse_iterator
reverse iterator type
Definition: StrTok.h:74
void reset()
resets internal position indicator
Definition: StrTok.h:71
const_iterator begin() const
returns const begin-iterator
Definition: StrTok.h:89
iterator end()
returns end-iterator
Definition: StrTok.h:98
unsigned int m_uiPos
current position indicator
Definition: StrTok.h:115
reverse_iterator rend()
returns reverse end-iterator
Definition: StrTok.h:104
const_reverse_iterator rend() const
returns const reverse end-iterator
Definition: StrTok.h:107
std::vector< std::string >::const_reverse_iterator const_reverse_iterator
constant reverse iterator type
Definition: StrTok.h:77