SHOGUN
v3.2.0
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Written (W) 2013 Evgeniy Andreev (gsomix) 00008 */ 00009 00010 #ifndef __LINE_READER_H__ 00011 #define __LINE_READER_H__ 00012 00013 #include <shogun/lib/SGVector.h> 00014 #include <shogun/lib/Tokenizer.h> 00015 #include <shogun/lib/CircularBuffer.h> 00016 00017 namespace shogun 00018 { 00020 class CLineReader : public CSGObject 00021 { 00022 public: 00024 CLineReader(); 00025 00031 CLineReader(FILE* stream, CTokenizer* tokenizer); 00032 00040 CLineReader(int32_t max_string_length, FILE* stream, CTokenizer* tokenizer); 00041 00043 virtual ~CLineReader(); 00044 00049 virtual bool has_next(); 00050 00052 virtual void skip_line(); 00053 00055 virtual SGVector<char> read_line(); 00056 00058 void reset(); 00059 00064 void set_tokenizer(CTokenizer* tokenizer); 00065 00067 virtual const char* get_name() const { return "LineReader"; } 00068 00069 private: 00071 void init(); 00072 00074 int32_t read(int32_t& bytes_to_skip); 00075 00077 SGVector<char> read_token(int32_t line_len); 00078 00079 private: 00081 CCircularBuffer* m_buffer; 00082 00084 CTokenizer* m_tokenizer; 00085 00087 FILE* m_stream; 00088 00090 int32_t m_max_token_length; 00091 00093 int32_t m_next_token_length; 00094 }; 00095 00096 } 00097 00098 #endif /* __FILE_READER_H__ */