/usr/include/shogun/io/LineReader.h is in libshogun-dev 3.2.0-7.3build4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | /*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Written (W) 2013 Evgeniy Andreev (gsomix)
*/
#ifndef __LINE_READER_H__
#define __LINE_READER_H__
#include <shogun/lib/SGVector.h>
#include <shogun/lib/Tokenizer.h>
#include <shogun/lib/CircularBuffer.h>
namespace shogun
{
/** @brief Class for buffered reading from a ascii file */
class CLineReader : public CSGObject
{
public:
/** default constructor */
CLineReader();
/** create object associated with the stream to read
*
* @param stream readable stream
* @param tokenizer enabling to parse different ascii file formats (.csv, ...)
*/
CLineReader(FILE* stream, CTokenizer* tokenizer);
/** create object associated with the stream to read
* and specify maximum length of a string that can be read
*
* @param max_string_length the maximum string length a line is allowed to have
* @param stream readable stream
* @param tokenizer enabling to parse different ascii file formats (.csv, ...)
*/
CLineReader(int32_t max_string_length, FILE* stream, CTokenizer* tokenizer);
/** deconstructor */
virtual ~CLineReader();
/** check for next line in the stream
*
* @return true if there is next line, false - otherwise
*/
virtual bool has_next();
/** skip next line */
virtual void skip_line();
/** read string */
virtual SGVector<char> read_line();
/** set position of stream to the beginning and clear buffer */
void reset();
/** set tokenizer
*
* @param tokenizer tokenizer
*/
void set_tokenizer(CTokenizer* tokenizer);
/** @return object name */
virtual const char* get_name() const { return "LineReader"; }
private:
/** class initialization */
void init();
/** read file into memory */
int32_t read(int32_t& bytes_to_skip);
/** read token from internal buffer */
SGVector<char> read_token(int32_t line_len);
private:
/** internal buffer for searching */
CCircularBuffer* m_buffer;
/** */
CTokenizer* m_tokenizer;
/** readable stream */
FILE* m_stream;
/** maximum length of a line that can be read */
int32_t m_max_token_length;
/** length of next line in the buffer */
int32_t m_next_token_length;
};
}
#endif /* __FILE_READER_H__ */
|