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

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

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

// already have a Window variable named win
OstreamWidgetSerializer out(std::cout);
out.add(&win);
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,
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]

OstreamWidgetSerializer& operator= ( const OstreamWidgetSerializer )
delete

◆ operator=() [2/2]

OstreamWidgetSerializer& operator= ( OstreamWidgetSerializer &&  )
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()

void write ( std::ostream &  out)
overridevirtual

Write to the specified ostream.

Implements Serializer.