SyDEVS  v0.6.5
Multiscale Simulation and Systems Modeling Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sydevs::string_builder Class Reference

A class for converting stream objects to string values. More...

#include <string_builder.h>

Public Member Functions

 string_builder ()
 Constructs a string_builder object. More...
 string_builder (const string_builder &)=delete
 No copy constructor. More...
string_builderoperator= (const string_builder &)=delete
 No copy assignment. More...
 string_builder (string_builder &&)=delete
 No move constructor. More...
string_builderoperator= (string_builder &&)=delete
 No move assignment. More...
 ~string_builder ()=default
 Destructor. More...
std::string str () const
 Obtains the data stored in the string_builder object as a std::string. More...
template<class T >
string_builderoperator<< (T const &value)
 Inserts data into the stream. More...

Detailed Description

A class for converting stream objects to string values.

Several sydevs classes overload the operator<< to append a textual representation of the class instance to a std::ostream object. The string_builder class provides a convenient way to convert these std::ostream objects into std::string values without requiring additional lines of code. Primitives and other classes can also be converted to strings.

std::string s1 = (string_builder() << "n:" << (3 + 5)).str(); // s1 = "n:8"
std::string s2 = (string_builder() << "t:" << (1_min + 7_sec)).str(); // s2 = "t:67_s"

Constructor & Destructor Documentation

sydevs::string_builder::string_builder ( )

Constructs a string_builder object.

sydevs::string_builder::string_builder ( const string_builder )

No copy constructor.

sydevs::string_builder::string_builder ( string_builder &&  )

No move constructor.

sydevs::string_builder::~string_builder ( )


Member Function Documentation

template<class T >
string_builder & sydevs::string_builder::operator<< ( T const &  value)

Inserts data into the stream.

If an operation such as operator<<(std::ostream&, const T&) is defined for type T, then a copy of the information in value is inserted into the string_builder object for later retrieval via str().

valueThe value to be inserted.
A reference to the string_builder object, allowing multiple values to be inserted in a single line.
string_builder& sydevs::string_builder::operator= ( const string_builder )

No copy assignment.

string_builder& sydevs::string_builder::operator= ( string_builder &&  )

No move assignment.

std::string sydevs::string_builder::str ( ) const

Obtains the data stored in the string_builder object as a std::string.

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