SHOGUN  4.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LineReader.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2013 Evgeniy Andreev (gsomix)
8  */
9 
10 #ifndef __LINE_READER_H__
11 #define __LINE_READER_H__
12 
13 #include <shogun/lib/config.h>
14 
15 #include <shogun/lib/SGVector.h>
16 #include <shogun/base/SGObject.h>
17 
18 namespace shogun
19 {
20 class CCircularBuffer;
21 class CTokenizer;
22 
24 class CLineReader : public CSGObject
25 {
26 public:
28  CLineReader();
29 
35  CLineReader(FILE* stream, CTokenizer* tokenizer);
36 
44  CLineReader(int32_t max_string_length, FILE* stream, CTokenizer* tokenizer);
45 
47  virtual ~CLineReader();
48 
53  virtual bool has_next();
54 
56  virtual void skip_line();
57 
59  virtual SGVector<char> read_line();
60 
62  void reset();
63 
68  void set_tokenizer(CTokenizer* tokenizer);
69 
71  virtual const char* get_name() const { return "LineReader"; }
72 
73 private:
75  void init();
76 
78  int32_t read(int32_t& bytes_to_skip);
79 
81  SGVector<char> read_token(int32_t line_len);
82 
83 private:
85  CCircularBuffer* m_buffer;
86 
88  CTokenizer* m_tokenizer;
89 
91  FILE* m_stream;
92 
94  int32_t m_max_token_length;
95 
97  int32_t m_next_token_length;
98 };
99 
100 }
101 
102 #endif /* __FILE_READER_H__ */

SHOGUN Machine Learning Toolbox - Documentation