Inviwo 0.9.12-pre
Inviwo documentation
Loading...
Searching...
No Matches
inviwo::Serializer Class Reference
Inheritance diagram for inviwo::Serializer:

Public Types

template<typename T>
using HasSerialize = decltype(std::declval<const T>().serialize(std::declval<Serializer&>()))
Public Types inherited from inviwo::SerializeBase
using allocator_type = std::pmr::polymorphic_allocator<std::byte>

Public Member Functions

std::pmr::string & addAttribute (std::string_view key)
WorkspaceSaveMode getWorkspaceSaveMode () const
Serializeroperator= (const Serializer &)=delete
Serializeroperator= (Serializer &&) noexcept=default
void serialize (std::string_view key, const char &data, SerializationTarget target=SerializationTarget::Node)
template<typename T>
void serialize (std::string_view key, const flags::flags< T > &data, SerializationTarget target=SerializationTarget::Node)
template<typename Mat, typename std::enable_if< util::rank< Mat >::value==2, int >::type = 0>
void serialize (std::string_view key, const Mat &data)
void serialize (std::string_view key, const Serializable &sObj)
void serialize (std::string_view key, const signed char &data, SerializationTarget target=SerializationTarget::Node)
template<typename T, size_t N>
void serialize (std::string_view key, const std::array< T, N > &container, std::string_view itemKey="item")
template<size_t N>
void serialize (std::string_view key, const std::bitset< N > &bits)
void serialize (std::string_view key, const std::filesystem::path &path, SerializationTarget target=SerializationTarget::Node)
template<typename K, typename V, typename C, typename A>
void serialize (std::string_view key, const std::map< K, V, C, A > &map, std::string_view itemKey="item")
void serialize (std::string_view key, const std::pmr::string &data, SerializationTarget target=SerializationTarget::Node)
void serialize (std::string_view key, const std::string &data, SerializationTarget target=SerializationTarget::Node)
template<class T, class D>
void serialize (std::string_view key, const std::unique_ptr< T, D > &data)
template<typename K, typename V, typename H, typename C, typename A, typename Pred = util::alwaysTrue, typename KProj = util::identity, typename VProj = util::identity>
void serialize (std::string_view key, const std::unordered_map< K, V, H, C, A > &map, std::string_view itemKey="item", Pred pred={}, KProj kproj={}, VProj vproj={})
template<typename T, typename Alloc, typename Pred = util::alwaysTrue, typename Proj = util::identity>
void serialize (std::string_view key, const std::vector< T, Alloc > &sVector, std::string_view itemKey="item", Pred pred={}, Proj proj={})
template<typename T, typename std::enable_if< std::is_enum< T >::value, int >::type = 0>
void serialize (std::string_view key, const T &data, SerializationTarget target=SerializationTarget::Node)
template<typename T>
requires (std::is_integral_v<T> || std::is_floating_point_v<T>)
void serialize (std::string_view key, const T &data, SerializationTarget target=SerializationTarget::Node)
template<typename T, typename = std::enable_if_t<util::is_detected_exact_v<void, HasSerialize, T>>>
void serialize (std::string_view key, const T &sObj)
template<class T>
void serialize (std::string_view key, const T *const &data)
void serialize (std::string_view key, const unsigned char &data, SerializationTarget target=SerializationTarget::Node)
template<typename Vec, typename std::enable_if< util::rank< Vec >::value==1, int >::type = 0>
void serialize (std::string_view key, const Vec &data)
void serialize (std::string_view key, std::string_view data, SerializationTarget target=SerializationTarget::Node)
 Serializer (allocator_type alloc={})
 Serializer (const Serializer &rhs)=delete
 Serializer (const std::filesystem::path &fileName, std::string_view rootElement, int version, allocator_type alloc={})
 Serializer (const std::filesystem::path &fileName, std::string_view rootElement=SerializeConstants::InviwoWorkspace, allocator_type alloc={})
 Initializes serializer with a file name that will be used to set relative paths to data.
 Serializer (Serializer &&rhs) noexcept=default
template<typename Range, typename SerializeFunction>
void serializeRange (std::string_view key, Range &&range, SerializeFunction serializeFunction={})
void setWorkspaceSaveMode (WorkspaceSaveMode mode)
NodeSwitch switchToNewNode (std::string_view key)
void write (std::pmr::string &xml, bool format=false)
void writeFile ()
 Writes serialized data to the file specified by the currently set file name.
void writeFile (std::ostream &stream, bool format=false)
 Writes serialized data to stream.
Public Member Functions inherited from inviwo::SerializeBase
TiXmlDocument & doc ()
allocator_type getAllocator () const
const std::filesystem::path & getFileDir () const
 Gets the workspace file directory.
const std::filesystem::path & getFileName () const
 Gets the workspace file name.
SerializeBaseoperator= (const SerializeBase &)=delete
SerializeBaseoperator= (SerializeBase &&) noexcept
 SerializeBase (const SerializeBase &rhs)=delete
 SerializeBase (const std::filesystem::path &fileName, allocator_type alloc={})
 Base class for Serializer and Deserializer.
 SerializeBase (SerializeBase &&rhs) noexcept

Protected Member Functions

TiXmlElement * getLastChild () const

Static Protected Member Functions

static std::pmr::string & addAttribute (TiXmlElement *node, std::string_view key)

Protected Attributes

WorkspaceSaveMode workspaceSaveMode_ = WorkspaceSaveMode::Disk
Protected Attributes inherited from inviwo::SerializeBase
std::unique_ptr< TiXmlDocument > doc_
std::filesystem::path fileDir_
std::filesystem::path fileName_
bool retrieveChild_
TiXmlElement * rootElement_

Friends

class NodeSwitch

Additional Inherited Members

Static Public Member Functions inherited from inviwo::SerializeBase
template<typename U>
static constexpr bool isPrimitiveType ()
 Checks whether the given type is a primitive type.

Constructor & Destructor Documentation

◆ Serializer()

inviwo::Serializer::Serializer ( const std::filesystem::path & fileName,
std::string_view rootElement = SerializeConstants::InviwoWorkspace,
allocator_type alloc = {} )
explicit

Initializes serializer with a file name that will be used to set relative paths to data.

The specified file name will not be used to write any content until writeFile() is called.

Parameters
fileNamefull path to xml file.
rootElementName of the root element to use (default: InviwoWorkspace).
allocAllocator to use for memory resources.
Exceptions
SerializationException

Member Function Documentation

◆ writeFile() [1/2]

void inviwo::Serializer::writeFile ( )

Writes serialized data to the file specified by the currently set file name.

Exceptions
SerializationException

◆ writeFile() [2/2]

void inviwo::Serializer::writeFile ( std::ostream & stream,
bool format = false )

Writes serialized data to stream.

Parameters
streamStream to be written to.
formatFormat the output, i.e. insert line breaks and tabs.
Exceptions
SerializationException

The documentation for this class was generated from the following file:
  • include/inviwo/core/io/serialization/serializer.h