|
enum | Mode { Debug,
Binary,
XML,
JSON
} |
|
|
virtual std::string | serialize (Mode mode) const =0 |
|
template<> |
std::string | serialize (const bool &data, Mode mode) |
|
template<> |
std::string | serialize (const double &data, Mode mode) |
|
template<> |
std::string | serialize (const std::complex< double > &data, Mode mode) |
|
template<> |
std::string | serialize (const int &data, Mode mode) |
|
template<> |
std::string | serialize (const unsigned int &data, Mode mode) |
|
template<> |
std::string | serialize (const SpinMatrix &data, Mode mode) |
|
template<> |
std::string | serialize (const Statistics &data, Mode mode) |
|
template<> |
std::string | serialize (const std::vector< std::complex< double >> &data, Mode mode) |
|
template<> |
int | deserialize (const std::string &serialization, Mode mode) |
|
|
static bool | hasID (const std::string &serialization, Mode mode) |
|
static std::string | getID (const std::string &serialization, Mode mode) |
|
static std::string | extractComponent (const std::string &serialization, const std::string &containerID, const std::string &componentID, const std::string &componentName, Mode mode) |
|
|
static bool | validate (const std::string &serialization, const std::string &id, Mode mode) |
|
static std::string | getContent (const std::string &serialization, Mode mode) |
|
static std::vector< std::string > | split (const std::string &content, Mode mode) |
|
template<typename DataType > |
static std::enable_if<!std::is_pointer< DataType >::value, std::string >::type | serialize (const DataType &data, Mode mode) |
|
template<typename DataType > |
static std::enable_if< std::is_pointer< DataType >::value, std::string >::type | serialize (const DataType &data, Mode mode) |
|
template<typename DataType > |
static DataType | deserialize (const std::string &serialization, Mode mode) |
|
static std::string | extract (const std::string &serialization, Mode mode, std::string component) |
|
|
class | Index |
|
class | HoppingAmplitude |
|
class | SourceAmplitude |
|
class | OverlapAmplitude |
|
template<typename DataType > |
class | CArray |
|
◆ Mode
Serialization modes. Note that debug is not guaranteed to be backward compatible.
◆ deserialize()
template<typename DataType >
DataType TBTK::Serializable::deserialize |
( |
const std::string & |
serialization, |
|
|
Mode |
mode |
|
) |
| |
|
staticprotected |
Deserialize.
- Parameters
-
serialization | The serialization from which the data is to be deserialized. |
mode | The mode with which the data has been serialized. |
- Returns
- The data after deserialization.
◆ extract()
static std::string TBTK::Serializable::extract |
( |
const std::string & |
serialization, |
|
|
Mode |
mode, |
|
|
std::string |
component |
|
) |
| |
|
staticprotected |
Extracts a component of a serialization string, catching potential errors. In particular used to extract the serialization string for parents in the constructor of a child, because no try-catch block is possible to insert at this point.
◆ extractComponent()
static std::string TBTK::Serializable::extractComponent |
( |
const std::string & |
serialization, |
|
|
const std::string & |
containerID, |
|
|
const std::string & |
componentID, |
|
|
const std::string & |
componentName, |
|
|
Mode |
mode |
|
) |
| |
|
static |
Extract a component from a container serialization. When serializing classes, their parent are embedded inside the child class serialization. I.e. the parent class is a component contained in the child class serialization. However, when reconstructing a serialized class, its parent constructor has to be called before the child class is constructed. This function provides the means to extract the serialization of a parent class from the serialization of a child class.
- Parameters
-
containerID | ID for the container (child class). |
componentID | ID for the component (parent class). |
componentName | Name used to refer to the parent object. Only used in some modes. |
mode | Mode with which the string has been serialized. |
- Returns
- The serialization string for the component.
◆ getContent()
static std::string TBTK::Serializable::getContent |
( |
const std::string & |
serialization, |
|
|
Mode |
mode |
|
) |
| |
|
staticprotected |
Get the content of a serializtion string.
◆ getID()
static std::string TBTK::Serializable::getID |
( |
const std::string & |
serialization, |
|
|
Mode |
mode |
|
) |
| |
|
static |
Get the ID of a serialization string.
◆ hasID()
static bool TBTK::Serializable::hasID |
( |
const std::string & |
serialization, |
|
|
Mode |
mode |
|
) |
| |
|
static |
Returns true if the serialization string has an ID.
◆ serialize() [1/2]
template<typename DataType >
std::enable_if< std::is_pointer< DataType >::value, std::string >::type TBTK::Serializable::serialize |
( |
const DataType & |
data, |
|
|
Mode |
mode |
|
) |
| |
|
staticprotected |
Serialize.
- Parameters
-
data | The data to serialize. |
mode | The mode with which to serialize the data. |
- Returns
- A string containing the serialization of the data.
◆ serialize() [2/2]
virtual std::string TBTK::Serializable::serialize |
( |
Mode |
mode | ) |
const |
|
pure virtual |
Serialize object.
Implemented in TBTK::Property::EnergyResolvedProperty< DataType >, TBTK::Property::EnergyResolvedProperty< SpinMatrix >, TBTK::Property::EnergyResolvedProperty< double >, TBTK::Property::EnergyResolvedProperty< std::complex< double > >, TBTK::SourceAmplitude, TBTK::BoundaryCondition, TBTK::HoppingAmplitudeList, TBTK::AnnotatedArray< DataType, AxesType >, TBTK::Array< DataType >, TBTK::Array< double >, TBTK::HoppingAmplitudeTree, TBTK::HoppingAmplitudeSet, TBTK::Property::AbstractProperty< DataType >, TBTK::Property::AbstractProperty< SpinMatrix >, TBTK::Property::AbstractProperty< double >, TBTK::Property::AbstractProperty< std::complex< double > >, TBTK::IndexTree, TBTK::Model, TBTK::SourceAmplitudeSet, TBTK::OverlapAmplitudeSet, TBTK::Property::LDOS, TBTK::IndexDescriptor, TBTK::Property::Density, TBTK::Property::DOS, TBTK::SingleParticleContext, TBTK::Property::SpinPolarizedLDOS, TBTK::Property::EigenValues, TBTK::Property::WaveFunctions, TBTK::IndexedDataTree< Data >, TBTK::IndexedDataTree< unsigned int >, TBTK::IndexedDataTree< SerializableVector< TBTK::SourceAmplitude > >, TBTK::IndexedDataTree< TBTK::OverlapAmplitude >, TBTK::IndexedDataTree< SerializableVector< double > >, TBTK::Range, TBTK::Property::Magnetization, and TBTK::Geometry.
◆ split()
static std::vector<std::string> TBTK::Serializable::split |
( |
const std::string & |
content, |
|
|
Mode |
mode |
|
) |
| |
|
staticprotected |
◆ validate()
static bool TBTK::Serializable::validate |
( |
const std::string & |
serialization, |
|
|
const std::string & |
id, |
|
|
Mode |
mode |
|
) |
| |
|
staticprotected |
Validate serialization string.
◆ Index
Friend classes (Classes that are psudo-Serializable because they are so small and often used that a virtual function would have a non-negligible performance penalty).
The documentation for this class was generated from the following file: