SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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__ */
virtual bool has_next()
Definition: LineReader.cpp:59
Implementation of circular buffer This buffer has logical structure such as queue (FIFO)...
Class for buffered reading from a ascii file.
Definition: LineReader.h:24
virtual SGVector< char > read_line()
Definition: LineReader.cpp:89
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:115
The class CTokenizer acts as a base class in order to implement tokenizers. Sub-classes must implemen...
Definition: Tokenizer.h:29
virtual void skip_line()
Definition: LineReader.cpp:79
virtual ~CLineReader()
Definition: LineReader.cpp:53
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
void set_tokenizer(CTokenizer *tokenizer)
Definition: LineReader.cpp:112
virtual const char * get_name() const
Definition: LineReader.h:71

SHOGUN Machine Learning Toolbox - Documentation