SHOGUN  3.2.1
 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 #include <stdio.h>
18 
19 namespace shogun
20 {
21 class CCircularBuffer;
22 class CTokenizer;
23 
25 class CLineReader : public CSGObject
26 {
27 public:
29  CLineReader();
30 
36  CLineReader(FILE* stream, CTokenizer* tokenizer);
37 
45  CLineReader(int32_t max_string_length, FILE* stream, CTokenizer* tokenizer);
46 
48  virtual ~CLineReader();
49 
54  virtual bool has_next();
55 
57  virtual void skip_line();
58 
60  virtual SGVector<char> read_line();
61 
63  void reset();
64 
69  void set_tokenizer(CTokenizer* tokenizer);
70 
72  virtual const char* get_name() const { return "LineReader"; }
73 
74 private:
76  void init();
77 
79  int32_t read(int32_t& bytes_to_skip);
80 
82  SGVector<char> read_token(int32_t line_len);
83 
84 private:
86  CCircularBuffer* m_buffer;
87 
89  CTokenizer* m_tokenizer;
90 
92  FILE* m_stream;
93 
95  int32_t m_max_token_length;
96 
98  int32_t m_next_token_length;
99 };
100 
101 }
102 
103 #endif /* __FILE_READER_H__ */

SHOGUN Machine Learning Toolbox - Documentation