DUECA/DUSIME
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
dueca::smartstring Class Reference

"Smart" string class. More...

#include <smartstring.hxx>

Inheritance diagram for dueca::smartstring:
Inheritance graph
[legend]
Collaboration diagram for dueca::smartstring:
Collaboration graph
[legend]

Classes

struct  json_string_writer
 Helper struct to create a json writer. More...
 
struct  xml_string_writer
 Helper struct to use an std::string as buffer for XML writing with pugi. More...
 

Public Member Functions

 smartstring ()
 Constructor, default.
 
 smartstring (const char *s)
 Constructor from char*.
 
 smartstring (const char *s, size_t n)
 Constructor from char* and size limit.
 
 smartstring (AmorphReStore &s)
 Constructor with an AmorphReStore, for unpacking.
 
 smartstring (const std::string &o)
 Copy constructor.
 
 smartstring (const smartstring &o)
 Copy constructor.
 
 smartstring (size_t n, char c)
 Fill constructor.
 
smartstringoperator= (const char *o)
 Assignment operator, with const char*.
 
smartstringoperator= (const smartstring &o)
 Assignment operator, with another smartstring.
 
smartstringoperator= (const std::string &o)
 Assignment, from a standard string.
 
 ~smartstring ()
 Destructor.
 
template<class DCO >
void decodexml (DCO &obj) const
 Decode the XML in the string to the given DCO object.
 
template<class DCO >
void encodexml (const DCO &obj)
 Encode the given DCO object as XML in this string.
 
template<class DCO >
void decodejson (DCO &obj) const
 Decode the JSON in the string to the given DCO object.
 
template<class DCO >
void encodejson (const DCO &obj)
 Encode the given DCO object as JSON in this string.
 

Detailed Description

"Smart" string class.

This class adds facilities for coding and decoding DCO objects to and from JSON or XML in the string. This string class can be used in DCO objects, to provide an easy means to wrap other DCO objects or data, e.g., to provide initialization.

Member Function Documentation

◆ decodexml()

template<class DCO >
void dueca::smartstring::decodexml ( DCO & obj) const
inline

Decode the XML in the string to the given DCO object.

Template Parameters
DCODueca Communication Object, or comparable
Parameters
objDCO object
Exceptions
smartdecodeerrorfor type or dataclass mis-matches

◆ encodexml()

template<class DCO >
void dueca::smartstring::encodexml ( const DCO & obj)
inline

Encode the given DCO object as XML in this string.

Template Parameters
DCODueca Communication Object, or comparable
Parameters
objDCO object

◆ decodejson()

template<class DCO >
void dueca::smartstring::decodejson ( DCO & obj) const
inline

Decode the JSON in the string to the given DCO object.

Template Parameters
DCODueca Communication Object, or comparable
Parameters
objDCO object
Exceptions
smartdecodeerrorWhen JSON cannot be parsed

◆ encodejson()

template<class DCO >
void dueca::smartstring::encodejson ( const DCO & obj)
inline

Encode the given DCO object as JSON in this string.

Template Parameters
DCODueca Communication Object, or comparable
Parameters
objDCO object

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