Gromacs  2016.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions
gmx::StringInputStream Class Reference

#include <gromacs/utility/stringstream.h>

+ Inheritance diagram for gmx::StringInputStream:
+ Collaboration diagram for gmx::StringInputStream:

Description

Helper class to convert static string data to a stream.

Provides a text input stream that returns lines from a string

Public Member Functions

 StringInputStream (const std::string &input)
 Constructor that stores input lines in a string. More...
 
 StringInputStream (const std::vector< std::string > &input)
 Constructor that stores input lines in a string. More...
 
 StringInputStream (ConstArrayRef< const char * > const &input)
 Constructor that stores input lines in a string. More...
 
virtual bool readLine (std::string *line)
 Reads a line (with newline included) from the stream. More...
 
virtual void close ()
 Closes the stream. More...
 

Constructor & Destructor Documentation

gmx::StringInputStream::StringInputStream ( const std::string &  input)
explicit

Constructor that stores input lines in a string.

The string is internally but no processing is done.

Parameters
[in]inputString to be served by the stream.
gmx::StringInputStream::StringInputStream ( const std::vector< std::string > &  input)
explicit

Constructor that stores input lines in a string.

The vector of strings is stored as a string separated by newline.

Parameters
[in]inputString to be served by the stream.
gmx::StringInputStream::StringInputStream ( ConstArrayRef< const char * > const &  input)
explicit

Constructor that stores input lines in a string.

The array of char * is stored as a string separated by newline.

Parameters
[in]inputArray of char * to be served by the stream.

Member Function Documentation

virtual void gmx::StringInputStream::close ( )
inlinevirtual

Closes the stream.

It is not allowed to read from a stream after it has been closed. See TextOutputStream::close() for rationale for a close() method separate from the destructor. For input, failures during close should be rare, but it is clearer to keep the interface symmetric.

Implements gmx::TextInputStream.

bool gmx::StringInputStream::readLine ( std::string *  line)
virtual

Reads a line (with newline included) from the stream.

Parameters
[out]lineString to receive the line.
Returns
false if nothing was read because the stream ended.

On error or when false is returned, line will be empty.

Implements gmx::TextInputStream.


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