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 Member Functions

 Serializer (const std::filesystem::path &fileName)
 Initializes serializer with a file name that will be used to set relative paths to data.
 
virtual void writeFile ()
 Writes serialized data to the file specified by the currently set file name.
 
virtual void writeFile (std::ostream &stream, bool format=false)
 Writes serialized data to stream.
 
template<typename T , typename Pred = util::alwaysTrue, typename Proj = util::identity>
void serialize (std::string_view key, const std::vector< T > &sVector, std::string_view itemKey="item", Pred pred={}, Proj proj={})
 
template<typename T >
void serialize (std::string_view key, const std::unordered_set< T > &sSet, std::string_view itemKey="item")
 
template<typename T >
void serialize (std::string_view key, const std::list< T > &container, std::string_view itemKey="item")
 
template<typename T , size_t N>
void serialize (std::string_view key, const std::array< T, N > &container, std::string_view itemKey="item")
 
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")
 
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={})
 
void serialize (std::string_view key, const signed char &data, const SerializationTarget &target=SerializationTarget::Node)
 
void serialize (std::string_view key, const char &data, const SerializationTarget &target=SerializationTarget::Node)
 
void serialize (std::string_view key, const unsigned char &data, const SerializationTarget &target=SerializationTarget::Node)
 
template<typename T , typename std::enable_if< std::is_integral< T >::value||util::is_floating_point< T >::value||util::is_string< T >::value, int >::type = 0>
void serialize (std::string_view key, const T &data, const SerializationTarget &target=SerializationTarget::Node)
 
template<typename T , typename std::enable_if< std::is_enum< T >::value, int >::type = 0>
void serialize (std::string_view key, const T &data, const SerializationTarget &target=SerializationTarget::Node)
 
template<typename T >
void serialize (std::string_view key, const flags::flags< T > &data, const 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)
 
template<typename Mat , typename std::enable_if< util::rank< Mat >::value==2, int >::type = 0>
void serialize (std::string_view key, const Mat &data)
 
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, const SerializationTarget &target=SerializationTarget::Node)
 
void serialize (std::string_view key, const Serializable &sObj)
 
template<class T >
void serialize (std::string_view key, const T *const &data)
 
template<class T , class D >
void serialize (std::string_view key, const std::unique_ptr< T, D > &data)
 
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)
 
- Public Member Functions inherited from inviwo::SerializeBase
 SerializeBase ()
 Base class for Serializer and Deserializer.
 
 SerializeBase (const std::filesystem::path &fileName)
 Base class for Serializer and Deserializer.
 
 SerializeBase (std::istream &stream, const std::filesystem::path &path)
 Base class for Serializer and Deserializer.
 
 SerializeBase (const SerializeBase &rhs)=delete
 
 SerializeBase (SerializeBase &&rhs) noexcept
 
SerializeBaseoperator= (const SerializeBase &)=delete
 
SerializeBaseoperator= (SerializeBase &&) noexcept
 
virtual const std::filesystem::path & getFileName () const
 gets the xml file name.
 

Protected Member Functions

NodeSwitch switchToNewNode (std::string_view key)
 
TxElement * getLastChild () const
 
void linkEndChild (TxElement *child)
 

Static Protected Member Functions

static void setAttribute (TxElement *node, std::string_view key, std::string_view val)
 
static void setValue (TxElement *node, std::string_view val)
 

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.
 
static std::string nodeToString (const TxElement &node)
 
- Protected Attributes inherited from inviwo::SerializeBase
std::filesystem::path fileName_
 
std::unique_ptr< TxDocument > doc_
 
TxElement * rootElement_
 
bool retrieveChild_
 

Constructor & Destructor Documentation

◆ Serializer()

inviwo::Serializer::Serializer ( const std::filesystem::path & fileName)

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.
Exceptions
SerializationException

Member Function Documentation

◆ writeFile() [1/2]

virtual void inviwo::Serializer::writeFile ( )
virtual

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

Exceptions
SerializationException

◆ writeFile() [2/2]

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

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: