1.2
Public Member Functions | List of all members
XmlWidgetSerializer Class Reference

Serialize a widget tree to an XML document. More...

Inheritance diagram for XmlWidgetSerializer:
Inheritance graph
[legend]

Public Member Functions

 XmlWidgetSerializer ()
 
 XmlWidgetSerializer (const XmlWidgetSerializer &)=delete
 
 XmlWidgetSerializer (XmlWidgetSerializer &&) noexcept=default
 
 ~XmlWidgetSerializer () noexcept override
 
bool add (const Widget *widget, int level=0) override
 Add a widget to the serializer. More...
 
void add_node (std::string nodename) override
 Add a node to the serializer. More...
 
void add_property (const std::string &name, bool value, const Attributes &attrs={})
 Add a property. More...
 
void add_property (const std::string &name, const AlignFlags &value, const Attributes &attrs={})
 Add a property. More...
 
void add_property (const std::string &name, const char *value, const Attributes &attrs={})
 Add a property. More...
 
void add_property (const std::string &name, const Pattern &value, const Attributes &attrs={}) override
 Add a property. More...
 
virtual void add_property (const std::string &name, const Pattern &value, const Attributes &attrs={})=0
 Add a property. More...
 
void add_property (const std::string &name, const std::string &value, const Attributes &attrs={}) override
 Add a property. More...
 
virtual void add_property (const std::string &name, const std::string &value, const Attributes &attrs={})=0
 Add a property. More...
 
void add_property (const std::string &name, double value, const Attributes &attrs={})
 Add a property. More...
 
void add_property (const std::string &name, float value, const Attributes &attrs={})
 Add a property. More...
 
void add_property (const std::string &name, int value, const Attributes &attrs={})
 Add a property. More...
 
void add_property (const std::string &name, unsigned int value, const Attributes &attrs={})
 Add a property. More...
 
XmlWidgetSerializeroperator= (const XmlWidgetSerializer &)=delete
 
XmlWidgetSerializeroperator= (XmlWidgetSerializer &&) noexcept=default
 
void previous_node () override
 Go to previous node. More...
 
void reset ()
 Clear or reset, the serializer for re-use. More...
 
void write (const std::string &filename)
 Write to the specified file path. More...
 
void write (std::ostream &out) override
 Write to the specified ostream. More...
 
- Public Member Functions inherited from Serializer
 Serializer () noexcept=default
 
 Serializer (const Serializer &)=default
 
 Serializer (Serializer &&) noexcept=default
 
virtual ~Serializer () noexcept=default
 
void add_property (const std::string &name, bool value, const Attributes &attrs={})
 Add a property. More...
 
void add_property (const std::string &name, const AlignFlags &value, const Attributes &attrs={})
 Add a property. More...
 
void add_property (const std::string &name, const char *value, const Attributes &attrs={})
 Add a property. More...
 
void add_property (const std::string &name, double value, const Attributes &attrs={})
 Add a property. More...
 
void add_property (const std::string &name, float value, const Attributes &attrs={})
 Add a property. More...
 
void add_property (const std::string &name, int value, const Attributes &attrs={})
 Add a property. More...
 
void add_property (const std::string &name, unsigned int value, const Attributes &attrs={})
 Add a property. More...
 
EGT_NODISCARD int level () const
 Get the current level. More...
 
Serializeroperator= (const Serializer &)=default
 
Serializeroperator= (Serializer &&) noexcept=default
 

Additional Inherited Members

- Public Types inherited from Serializer
using Attributes = std::vector< std::pair< std::string, std::string > >
 Attributes array type. More...
 
using Properties = std::vector< std::tuple< std::string, std::string, Serializer::Attributes > >
 
- Protected Attributes inherited from Serializer
int m_level {0}
 Current serialize tree level. More...
 

Detailed Description

Serialize a widget tree to an XML document.

// already have a Window variable named win
xml.add(&win);
// write the result
xml.write("output.xml");
// or
xml.write(std::cout);
See also
Widget::walk()

Constructor & Destructor Documentation

◆ XmlWidgetSerializer() [1/3]

◆ XmlWidgetSerializer() [2/3]

◆ XmlWidgetSerializer() [3/3]

XmlWidgetSerializer ( XmlWidgetSerializer &&  )
defaultnoexcept

◆ ~XmlWidgetSerializer()

~XmlWidgetSerializer ( )
overridenoexcept

Member Function Documentation

◆ add()

bool add ( const Widget widget,
int  level = 0 
)
overridevirtual

Add a widget to the serializer.

Implements Serializer.

◆ add_node()

void add_node ( std::string  nodename)
overridevirtual

Add a node to the serializer.

Implements Serializer.

◆ add_property() [1/11]

void add_property

Add a property.

◆ add_property() [2/11]

void add_property

Add a property.

◆ add_property() [3/11]

void add_property
inline

Add a property.

◆ add_property() [4/11]

void add_property ( const std::string &  name,
const Pattern value,
const Attributes attrs = {} 
)
overridevirtual

Add a property.

Implements Serializer.

◆ add_property() [5/11]

virtual void add_property

Add a property.

◆ add_property() [6/11]

void add_property ( const std::string &  name,
const std::string &  value,
const Attributes attrs = {} 
)
overridevirtual

Add a property.

Implements Serializer.

◆ add_property() [7/11]

virtual void add_property

Add a property.

◆ add_property() [8/11]

void add_property

Add a property.

◆ add_property() [9/11]

void add_property

Add a property.

◆ add_property() [10/11]

void add_property

Add a property.

◆ add_property() [11/11]

void add_property

Add a property.

◆ operator=() [1/2]

XmlWidgetSerializer& operator= ( const XmlWidgetSerializer )
delete

◆ operator=() [2/2]

XmlWidgetSerializer& operator= ( XmlWidgetSerializer &&  )
defaultnoexcept

◆ previous_node()

void previous_node ( )
overridevirtual

Go to previous node.

Implements Serializer.

◆ reset()

void reset ( )

Clear or reset, the serializer for re-use.

◆ write() [1/2]

void write ( const std::string &  filename)

Write to the specified file path.

◆ write() [2/2]

void write ( std::ostream &  out)
overridevirtual

Write to the specified ostream.

Implements Serializer.