Gromacs  2025.0-dev-20241011-013a99c
 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/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 (ArrayRef< const char *const > const &input)
 Constructor that stores input lines in a string. More...
 
bool readLine (std::string *line) override
 Reads a line (with newline included) from the stream. More...
 
void close () override
 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 ( ArrayRef< const char *const > 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

void gmx::StringInputStream::close ( )
inlineoverridevirtual

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)
overridevirtual

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: