Subversion Repositories public

Rev

Rev 47 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
45 luk 1
 
2
/// string tokenizer header
3
/**
4
 * \file strtok.h
5
 *
6
 * string tokenizer
7
 *
8
 * Copyright (C) 2006 Lukas Jelinek, <lukas@aiken.cz>
9
 *
10
 * This program is free software; you can redistribute it and/or
11
 * modify it under the terms of one of the following licenses:
12
 *
13
 * \li 1. X11-style license (see LICENSE-X11)
14
 * \li 2. GNU Lesser General Public License, version 2.1 (see LICENSE-LGPL)
15
 * \li 3. GNU General Public License, version 2  (see LICENSE-GPL)
16
 *
17
 * If you want to help with choosing the best license for you,
18
 * please visit http://www.gnu.org/licenses/license-list.html.
19
 *
20
 */
21
 
22
 
23
#ifndef _STRTOK_H_
24
#define _STRTOK_H_
25
 
26
 
27
#include <string>
28
 
29
 
30
class StringTokenizer
31
{
32
public:
33
  StringTokenizer(const std::string& rStr, char cDelim = ',');
34
 
35
  ~StringTokenizer() {}
36
 
37
  inline bool HasMoreTokens() const
38
  {
39
    return m_pos < m_len;
40
  }
41
 
42
  std::string GetNextToken();
43
 
44
  inline void SetDelimiter(char cDelim)
45
  {
46
    m_cDelim = cDelim;
47
  }
48
 
49
  inline char GetDelimiter() const
50
  {
51
    return m_cDelim;
52
  }
53
 
54
  inline void Reset()
55
  {
56
    m_pos = 0;
57
  }
58
 
59
private:
60
  std::string m_str;
61
  char m_cDelim;
62
  std::string::size_type m_pos;
63
  std::string::size_type m_len;
64
};
65
 
66
 
67
#endif //_STRTOK_H_