SHOGUN  v3.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/SGVector.h>
14 #include <shogun/lib/Tokenizer.h>
16 
17 namespace shogun
18 {
20 class CLineReader : public CSGObject
21 {
22 public:
24  CLineReader();
25 
30  CLineReader(FILE* stream, CTokenizer* tokenizer);
31 
38  CLineReader(int32_t max_string_length, FILE* stream, CTokenizer* tokenizer);
39 
41  virtual ~CLineReader();
42 
47  virtual bool has_next();
48 
50  virtual void skip_line();
51 
53  virtual SGVector<char> read_line();
54 
56  void reset();
57 
62  void set_tokenizer(CTokenizer* tokenizer);
63 
65  virtual const char* get_name() const { return "LineReader"; }
66 
67 private:
69  void init();
70 
72  int32_t read(int32_t& bytes_to_skip);
73 
75  SGVector<char> read_token(int32_t line_len);
76 
77 private:
79  CCircularBuffer* m_buffer;
80 
82  CTokenizer* m_tokenizer;
83 
85  FILE* m_stream;
86 
88  int32_t m_max_token_length;
89 
91  int32_t m_next_token_length;
92 };
93 
94 }
95 
96 #endif /* __FILE_READER_H__ */

SHOGUN Machine Learning Toolbox - Documentation