strusBase  0.17
Public Member Functions | List of all members
strus::InputStream Class Reference

Abstraction of input stream. More...

#include <inputStream.hpp>

Public Member Functions

 InputStream (const std::string &docpath)
 Constructor. More...
 
 ~InputStream ()
 Destructor. More...
 
std::size_t read (char *buf, std::size_t bufsize)
 Read some data. More...
 
const char * readLine (char *buf, std::size_t bufsize, bool failOnNoLine=false)
 Read a line. More...
 
std::size_t readAhead (char *buf, std::size_t bufsize)
 Read some data and keep it in a buffer for the next read. More...
 
unsigned int error () const
 Get the last error (system errno) occurred. More...
 
bool eof ()
 Check if there is more data to read. More...
 

Detailed Description

Abstraction of input stream.

Constructor & Destructor Documentation

strus::InputStream::InputStream ( const std::string &  docpath)
explicit

Constructor.

Parameters
[in]docpathpath to file to read or "-" for stdin
strus::InputStream::~InputStream ( )

Destructor.

Member Function Documentation

bool strus::InputStream::eof ( )

Check if there is more data to read.

unsigned int strus::InputStream::error ( ) const

Get the last error (system errno) occurred.

Returns
the last error
std::size_t strus::InputStream::read ( char *  buf,
std::size_t  bufsize 
)

Read some data.

Parameters
[in,out]bufwhere to write to
[in]bufsizeallocation size of 'buf' (capacity)
Returns
the number of bytes read, 0 in case of EOF or an error occurred
std::size_t strus::InputStream::readAhead ( char *  buf,
std::size_t  bufsize 
)

Read some data and keep it in a buffer for the next read.

Parameters
[in,out]bufwhere to write to
[in]bufsizeallocation size of 'buf' (capacity)
Returns
the number of bytes read or 0 in case of EOF or an error occurred
const char* strus::InputStream::readLine ( char *  buf,
std::size_t  bufsize,
bool  failOnNoLine = false 
)

Read a line.

Parameters
[in,out]bufwhere to write to
[in]bufsizeallocation size of 'buf' (capacity)
[in]failOnNoLinetrue, if an error should be reported in case of buffer too small for line read
Returns
pointer to the \0 terminated line read or NULL in case of no line to read left

The documentation for this class was generated from the following file: