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

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

#include <serialize.h>

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) override
 Add a widget to the serializer.
 
void add_property (const std::string &name, bool value, const Attributes &attrs={})
 Add a property.
 
void add_property (const std::string &name, const AlignFlags &value, const Attributes &attrs={})
 Add a property.
 
void add_property (const std::string &name, const char *value, const Attributes &attrs={})
 Add a property.
 
void add_property (const std::string &name, const Pattern &value, const Attributes &attrs={}) override
 Add a property.
 
virtual void add_property (const std::string &name, const Pattern &value, const Attributes &attrs={})=0
 Add a property.
 
void add_property (const std::string &name, const std::string &value, const Attributes &attrs={}) override
 Add a property.
 
virtual void add_property (const std::string &name, const std::string &value, const Attributes &attrs={})=0
 Add a property.
 
void add_property (const std::string &name, double value, const Attributes &attrs={})
 Add a property.
 
void add_property (const std::string &name, float value, const Attributes &attrs={})
 Add a property.
 
void add_property (const std::string &name, int value, const Attributes &attrs={})
 Add a property.
 
void add_property (const std::string &name, unsigned int value, const Attributes &attrs={})
 Add a property.
 
Contextbegin_child (const std::string &nodename) override
 Create a new child.
 
void end_child (Context *context) override
 Complete a child.
 
XmlWidgetSerializeroperator= (const XmlWidgetSerializer &)=delete
 
XmlWidgetSerializeroperator= (XmlWidgetSerializer &&) noexcept=default
 
void reset ()
 Clear or reset, the serializer for re-use.
 
void write (const std::string &filename)
 Write to the specified file path.
 
void write (std::ostream &out) override
 Write to the specified ostream.
 
- 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.
 
void add_property (const std::string &name, const AlignFlags &value, const Attributes &attrs={})
 Add a property.
 
void add_property (const std::string &name, const char *value, const Attributes &attrs={})
 Add a property.
 
void add_property (const std::string &name, double value, const Attributes &attrs={})
 Add a property.
 
void add_property (const std::string &name, float value, const Attributes &attrs={})
 Add a property.
 
void add_property (const std::string &name, int value, const Attributes &attrs={})
 Add a property.
 
void add_property (const std::string &name, unsigned int value, const Attributes &attrs={})
 Add a property.
 
Serializeroperator= (const Serializer &)=default
 
Serializeroperator= (Serializer &&) noexcept=default
 

Additional Inherited Members

- Public Types inherited from Serializer
using Attributes = std::list< std::pair< std::string, std::string > >
 Attributes array type.
 
using Context = void
 
using Properties = std::list< std::tuple< std::string, std::string, Serializer::Attributes > >
 

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);
Serialize a widget tree to an XML document.
Definition serialize.h:160
void write(const std::string &filename)
Write to the specified file path.
bool add(const Widget *widget) override
Add a widget to the serializer.
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)
overridevirtual

Add a widget to the serializer.

Implements Serializer.

◆ add_property() [1/11]

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

Add a property.

◆ add_property() [2/11]

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

Add a property.

◆ add_property() [3/11]

void add_property ( const std::string &  name,
const char *  value,
const Attributes attrs = {} 
)
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 ( const std::string &  name,
const Pattern value,
const Attributes attrs = {} 
)
virtual

Add a property.

Implements Serializer.

◆ 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 ( const std::string &  name,
const std::string &  value,
const Attributes attrs = {} 
)
virtual

Add a property.

Implements Serializer.

◆ add_property() [8/11]

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

Add a property.

◆ add_property() [9/11]

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

Add a property.

◆ add_property() [10/11]

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

Add a property.

◆ add_property() [11/11]

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

Add a property.

◆ begin_child()

Context * begin_child ( const std::string &  nodename)
overridevirtual

Create a new child.

Implements Serializer.

◆ end_child()

void end_child ( Context context)
overridevirtual

Complete a child.

Implements Serializer.

◆ operator=() [1/2]

XmlWidgetSerializer & operator= ( const XmlWidgetSerializer )
delete

◆ operator=() [2/2]

XmlWidgetSerializer & operator= ( XmlWidgetSerializer &&  )
defaultnoexcept

◆ 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.