stmm-games-doc  0.32.0
Public Member Functions | Protected Member Functions | List of all members
stmg::XmlGameWidgetParser Class Referenceabstract
Inheritance diagram for stmg::XmlGameWidgetParser:
Inheritance graph
[legend]

Public Member Functions

virtual ~XmlGameWidgetParser ()=default
 
 XmlGameWidgetParser (const std::string &sGameWidgetName)
 Constructor. More...
 
const std::string & getGameWidgetName () const
 The game widget name. More...
 
virtual shared_ptr< GameWidgetparseGameWidget (LayoutCtx &oCtx, const xmlpp::Element *p0Element)=0
 Parses a game widget element. More...
 

Protected Member Functions

XmlConditionalParsergetXmlConditionalParser ()
 
XmlTraitsParsergetXmlTraitsParser ()
 
XmlImageParsergetXmlImageParser ()
 
void parseGameWidget (GameWidget::Init &oInit, LayoutCtx &oCtx, const xmlpp::Element *p0Element)
 Parse the base class attributes of GameWidget. More...
 
void parseRelSizedGameWidget (RelSizedGameWidget::Init &oInit, LayoutCtx &oCtx, const xmlpp::Element *p0Element)
 Parse the base class attributes of RelSizedGameWidget. More...
 
void parseContainerWidget (ContainerWidget::Init &oInit, LayoutCtx &oCtx, const xmlpp::Element *p0WidgetElement)
 Parse the base class attributes of ContainerWidget. More...
 
void parseContainerWidget (ContainerWidget::Init &oInit, LayoutCtx &oCtx, const xmlpp::Element *p0WidgetElement, const std::vector< std::string const *> &aSkipChildNames)
 Parse the base class attributes of ContainerWidget. More...
 
std::vector< shared_ptr< GameWidget > > parseChildWidgets (LayoutCtx &oCtx, const xmlpp::Element *p0Parent)
 Parse the child game widgets. More...
 
std::vector< shared_ptr< GameWidget > > parseChildWidgets (LayoutCtx &oCtx, const xmlpp::Element *p0Parent, const std::vector< std::string const *> &aSkipChildNames)
 Parse the child game widgets with exceptions. More...
 
std::pair< std::string, int32_t > parseEvIdMessage (ConditionalCtx &oCtx, const xmlpp::Element *p0Element, bool bMandatory, const std::string &sEvIdAttrName, const std::string &sMsgNameAttrName, const std::string &sMsgAttrName)
 Get event and message id for an event, given message name. More...
 
std::pair< int32_t, OwnerTypeparseVariable (LayoutCtx &oCtx, const xmlpp::Element *p0Element, const std::string &sVarNameAttrName, bool bMandatory)
 

Constructor & Destructor Documentation

◆ ~XmlGameWidgetParser()

virtual stmg::XmlGameWidgetParser::~XmlGameWidgetParser ( )
virtualdefault

◆ XmlGameWidgetParser()

stmg::XmlGameWidgetParser::XmlGameWidgetParser ( const std::string &  sGameWidgetName)

Constructor.

Parameters
sGameWidgetNameThe game widget element name. Cannot be empty.

Member Function Documentation

◆ getGameWidgetName()

const std::string& stmg::XmlGameWidgetParser::getGameWidgetName ( ) const

The game widget name.

Returns
The game widget name. Is not empty.

◆ getXmlConditionalParser()

XmlConditionalParser& stmg::XmlGameWidgetParser::getXmlConditionalParser ( )
protected

◆ getXmlImageParser()

XmlImageParser& stmg::XmlGameWidgetParser::getXmlImageParser ( )
protected

◆ getXmlTraitsParser()

XmlTraitsParser& stmg::XmlGameWidgetParser::getXmlTraitsParser ( )
protected

◆ parseChildWidgets() [1/2]

std::vector<shared_ptr<GameWidget> > stmg::XmlGameWidgetParser::parseChildWidgets ( LayoutCtx oCtx,
const xmlpp::Element *  p0Parent 
)
protected

Parse the child game widgets.

This is used by container widgets.

Parameters
oCtxThe context.
p0ParentThe parent element. Cannot be null.
Returns
The widget instances.

◆ parseChildWidgets() [2/2]

std::vector<shared_ptr<GameWidget> > stmg::XmlGameWidgetParser::parseChildWidgets ( LayoutCtx oCtx,
const xmlpp::Element *  p0Parent,
const std::vector< std::string const *> &  aSkipChildNames 
)
protected

Parse the child game widgets with exceptions.

Even the child names that are skipped are added as valid child names with oCtx.addValidChildElementName(). There is therefore no need to check the valid names when oCtx.removeChecker() is called.

Parameters
oCtxThe context.
p0ParentThe parent element. Cannot be null.
aSkipChildNamesThe child element names that shouldn't be parsed.
Returns
The widget instances.

◆ parseContainerWidget() [1/2]

void stmg::XmlGameWidgetParser::parseContainerWidget ( ContainerWidget::Init oInit,
LayoutCtx oCtx,
const xmlpp::Element *  p0WidgetElement 
)
protected

Parse the base class attributes of ContainerWidget.

Call this method if your widget is a container.

Parameters
oInitThe init structure to fill.
oCtxThe context.
p0WidgetElementThe element. Cannot be null.

◆ parseContainerWidget() [2/2]

void stmg::XmlGameWidgetParser::parseContainerWidget ( ContainerWidget::Init oInit,
LayoutCtx oCtx,
const xmlpp::Element *  p0WidgetElement,
const std::vector< std::string const *> &  aSkipChildNames 
)
protected

Parse the base class attributes of ContainerWidget.

Call this method if your widget is a container and some child widget element names must be ignored.

Parameters
oInitThe init structure to fill.
oCtxThe context.
p0WidgetElementThe element. Cannot be null.
aSkipChildNamesThe child names ti skip.

◆ parseEvIdMessage()

std::pair<std::string, int32_t> stmg::XmlGameWidgetParser::parseEvIdMessage ( ConditionalCtx oCtx,
const xmlpp::Element *  p0Element,
bool  bMandatory,
const std::string &  sEvIdAttrName,
const std::string &  sMsgNameAttrName,
const std::string &  sMsgAttrName 
)
protected

Get event and message id for an event, given message name.

The event must have been added to the level with its id.

Parameters
oCtxThe context.
p0ElementThe element containing the attributes. Cannot be null.
bMandatoryWhether event id and message must be defined.
sEvIdAttrNameThe attribute name containing the event id. Cannot be empty.
sMsgNameAttrNameThe attribute name containing the message. Cannot be empty.
sMsgAttrNameThe attribute name containing the message name. Cannot be empty.
Returns
The event id and the message or empty string and -1 if none of the attributes is defined.
Exceptions
std::runtime_errorIf the event with given id doesn't exist or the message name isn't an input to said event or the attributes are not defined and mandatory is true, etc.

◆ parseGameWidget() [1/2]

virtual shared_ptr<GameWidget> stmg::XmlGameWidgetParser::parseGameWidget ( LayoutCtx oCtx,
const xmlpp::Element *  p0Element 
)
pure virtual

◆ parseGameWidget() [2/2]

void stmg::XmlGameWidgetParser::parseGameWidget ( GameWidget::Init oInit,
LayoutCtx oCtx,
const xmlpp::Element *  p0Element 
)
protected

Parse the base class attributes of GameWidget.

Call this method if your widget derives directly from GameWidget.

Parameters
oInitThe init structure to fill.
oCtxThe context.
p0ElementThe element. Cannot be null.

◆ parseRelSizedGameWidget()

void stmg::XmlGameWidgetParser::parseRelSizedGameWidget ( RelSizedGameWidget::Init oInit,
LayoutCtx oCtx,
const xmlpp::Element *  p0Element 
)
protected

Parse the base class attributes of RelSizedGameWidget.

Call this method if your widget derives directly from RelSizedGameWidget.

Parameters
oInitThe init structure to fill.
oCtxThe context.
p0ElementThe element. Cannot be null.

◆ parseVariable()

std::pair<int32_t, OwnerType> stmg::XmlGameWidgetParser::parseVariable ( LayoutCtx oCtx,
const xmlpp::Element *  p0Element,
const std::string &  sVarNameAttrName,
bool  bMandatory 
)
protected