SHOGUN  v3.2.0
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 
LineReader.h
浏览该文件的文档.
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 
31  CLineReader(FILE* stream, CTokenizer* tokenizer);
32 
40  CLineReader(int32_t max_string_length, FILE* stream, CTokenizer* tokenizer);
41 
43  virtual ~CLineReader();
44 
49  virtual bool has_next();
50 
52  virtual void skip_line();
53 
55  virtual SGVector<char> read_line();
56 
58  void reset();
59 
64  void set_tokenizer(CTokenizer* tokenizer);
65 
67  virtual const char* get_name() const { return "LineReader"; }
68 
69 private:
71  void init();
72 
74  int32_t read(int32_t& bytes_to_skip);
75 
77  SGVector<char> read_token(int32_t line_len);
78 
79 private:
81  CCircularBuffer* m_buffer;
82 
84  CTokenizer* m_tokenizer;
85 
87  FILE* m_stream;
88 
90  int32_t m_max_token_length;
91 
93  int32_t m_next_token_length;
94 };
95 
96 }
97 
98 #endif /* __FILE_READER_H__ */
virtual bool has_next()
Definition: LineReader.cpp:56
Implementation of circular buffer This buffer has logical structure such as queue (FIFO)...
Class for buffered reading from a ascii file.
Definition: LineReader.h:20
virtual SGVector< char > read_line()
Definition: LineReader.cpp:86
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:102
The class CTokenizer acts as a base class in order to implement tokenizers. Sub-classes must implemen...
Definition: Tokenizer.h:27
virtual void skip_line()
Definition: LineReader.cpp:76
virtual ~CLineReader()
Definition: LineReader.cpp:50
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:16
void set_tokenizer(CTokenizer *tokenizer)
Definition: LineReader.cpp:109
virtual const char * get_name() const
Definition: LineReader.h:67

SHOGUN Machine Learning Toolbox - Documentation