File: tokenizer.hh

package info (click to toggle)
augustus 3.4.0%2Bdfsg2-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 758,480 kB
  • sloc: cpp: 65,451; perl: 21,436; python: 3,927; ansic: 1,240; makefile: 1,032; sh: 189; javascript: 32
file content (36 lines) | stat: -rw-r--r-- 934 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

/*
*   added by Giovanna Migliorelli 24.07.2019 
*   Tokenizer class can handle more than one separator at the time 
*   aknowledgement : https://stackoverflow.com/questions/53849/how-do-i-tokenize-a-string-in-c
*   todo : make it a template
*/

#ifndef TOKENIZER_HH
#define TOKENIZER_HH

#include <string>
using namespace std;

class Tokenizer 
{
    public:
        static const std::string DELIMITERS;
        Tokenizer(const std::string& str);
        Tokenizer(const std::string& str, const std::string& delimiters);
        bool NextToken();
        bool NextTokenBlank();
        bool NextTokenBlank(const std::string& delimiters); 
        bool NextToken(const std::string& delimiters);
        string GetToken(){return m_token;};
        void Reset();
    protected:
        const std::string m_string;
        size_t m_offset;
        int m_blanks;
        std::string m_token;
        std::string m_delimiters;
};


#endif