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

Serialize a widget tree to an std::ostream. More...

#include <serialize.h>

Inheritance diagram for OstreamWidgetSerializer:
Inheritance graph
[legend]

Public Member Functions

 OstreamWidgetSerializer ()
 
 OstreamWidgetSerializer (const OstreamWidgetSerializer &)=delete
 
 OstreamWidgetSerializer (OstreamWidgetSerializer &&) noexcept=default
 
 ~OstreamWidgetSerializer () 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.
 
OstreamWidgetSerializeroperator= (const OstreamWidgetSerializer &)=delete
 
OstreamWidgetSerializeroperator= (OstreamWidgetSerializer &&) noexcept=default
 
void reset ()
 Clear or reset, the serializer for re-use.
 
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 std::ostream.

// already have a Window variable named win
OstreamWidgetSerializer out(std::cout);
out.add(&win);
Serialize a widget tree to an std::ostream.
Definition serialize.h:109
See also
Widget::walk()

Constructor & Destructor Documentation

◆ OstreamWidgetSerializer() [1/3]

◆ OstreamWidgetSerializer() [2/3]

◆ OstreamWidgetSerializer() [3/3]

◆ ~OstreamWidgetSerializer()

~OstreamWidgetSerializer ( )
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]

OstreamWidgetSerializer & operator= ( const OstreamWidgetSerializer )
delete

◆ operator=() [2/2]

OstreamWidgetSerializer & operator= ( OstreamWidgetSerializer &&  )
defaultnoexcept

◆ reset()

void reset ( )

Clear or reset, the serializer for re-use.

◆ write()

void write ( std::ostream &  out)
overridevirtual

Write to the specified ostream.

Implements Serializer.