-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Parser.h
92 lines (75 loc) · 2.04 KB
/
Parser.h
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Written (W) 2013 Evgeniy Andreev (gsomix)
*/
#ifndef __PARSER_H__
#define __PARSER_H__
#include <shogun/lib/SGVector.h>
#include <shogun/lib/Tokenizer.h>
namespace shogun
{
/** @brief Class for reading from a string */
class CParser : public CSGObject
{
public:
/** default constructor */
CParser();
/** constructor
*
* @param string the text to parse
* @param tokenizer tokenizer
*/
CParser(SGVector<char> string, CTokenizer* tokenizer);
/** destructor */
virtual ~CParser();
/** check for next line in the stream
*
* @return true if there is next line, false - otherwise
*/
virtual bool has_next();
/** skip next token */
virtual void skip_token();
/** read string */
virtual SGVector<char> read_string();
/** read one of the several base data types. */
//@{
virtual bool read_bool();
virtual char read_char(int32_t base=10);
virtual uint8_t read_byte(int32_t base=10);
virtual int16_t read_short(int32_t base=10);
virtual uint16_t read_word(int32_t base=10);
virtual int32_t read_int(int32_t base=10);
virtual uint32_t read_uint(int32_t base=10);
virtual int64_t read_long(int32_t base=10);
virtual uint64_t read_ulong(int32_t base=10);
virtual float32_t read_short_real();
virtual float64_t read_real();
virtual floatmax_t read_long_real();
//@}
/** set tokenizer
*
* @param tokenizer tokenizer
*/
void set_tokenizer(CTokenizer* tokenizer);
/** set the char array that requires tokenization
*
* @param txt the text to tokenize
*/
void set_text(SGVector<char> text);
/** @return object name */
virtual const char* get_name() const { return "Parser"; }
private:
/** class initialization */
void init();
private:
/** text to tokenizer */
SGVector<char> m_text;
/** tokenizer */
CTokenizer* m_tokenizer;
};
}
#endif /** __STRING_READER_H__ */