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

Public Member Functions

 ConditionalCtx (const shared_ptr< AppPreferences > &refAppPreferences, Named &oNamed)
 
 ConditionalCtx (const shared_ptr< AppConfig > &refAppConfig, Named &oNamed)
 
virtual int32_t getContextTeam () const
 The context team. More...
 
virtual int32_t getContextMate () const
 The context mate. More...
 
void addChecker (const xmlpp::Element *p0Element) override
 Adds a checker for the element. More...
 
void removeChecker (const xmlpp::Element *p0Element, bool bCheckChildElements, bool bCheckAttrs) override
 Removes a checker for the element. More...
 
- Public Member Functions inherited from stmg::ParserCtx
 ParserCtx (const shared_ptr< AppConfig > &refAppConfig, Named &oNamed)
 Constructor. More...
 
 ParserCtx (const shared_ptr< AppPreferences > &refAppPreferences, Named &oNamed)
 Constructor. More...
 
virtual ~ParserCtx ()
 
const shared_ptr< AppConfig > & appConfig ()
 The app config. More...
 
const shared_ptr< AppPreferences > & appPreferences ()
 The app preferences. More...
 
Namednamed ()
 The named assets. More...
 
void pushCtx (const std::string &sStr)
 Push a context. More...
 
void popCtx ()
 Pop a context. More...
 
void addValidChildElementName (const xmlpp::Element *p0Element, const std::string &sChildElementName)
 Declares a child element name as valid. More...
 
void addValidChildElementNames (const xmlpp::Element *p0Element, const std::string &sChildElementName)
 Declares a child element name as valid. More...
 
template<typename ... Names>
void addValidChildElementNames (const xmlpp::Element *p0Element, const std::string &sChildElementName, const Names &... oNames)
 Declares multiple child element names as valid. More...
 
void addValidAttrName (const xmlpp::Element *p0Element, const std::string &sAttrName)
 Declares an attribute name as valid. More...
 
void addValidAttrNames (const xmlpp::Element *p0Element, const std::string &sAttrName)
 Declares an attribute name as valid. More...
 
template<typename ... Names>
void addValidAttrNames (const xmlpp::Element *p0Element, const std::string &sAttrName, const Names &... oNames)
 Declares attribute names as valid. More...
 
void removeChecker (const xmlpp::Element *p0Element, bool bCheck)
 Removes a checker for the element. More...
 
std::runtime_error error (const std::string &sErr)
 Creates an exception for the current context. More...
 
void dump () const
 

Additional Inherited Members

- Static Public Member Functions inherited from stmg::ParserCtx
static int32_t getLine (const xmlpp::Element *p0Element, const std::string &sAttr)
 The line number within a document of an element or attribute. More...
 
- Protected Member Functions inherited from stmg::ParserCtx
virtual std::string err (const std::string &s)
 Builds complete error string from context. More...
 
std::vector< Checker >::iterator getChecker (const xmlpp::Element *p0Element)
 
- Protected Attributes inherited from stmg::ParserCtx
const shared_ptr< AppConfigm_refAppConfig
 
shared_ptr< AppPreferencesm_refAppPreferences
 
Namedm_oNamed
 
std::vector< std::string > m_oStack
 
std::vector< Checkerm_aCheckers
 

Constructor & Destructor Documentation

◆ ConditionalCtx() [1/2]

stmg::ConditionalCtx::ConditionalCtx ( const shared_ptr< AppPreferences > &  refAppPreferences,
Named oNamed 
)

◆ ConditionalCtx() [2/2]

stmg::ConditionalCtx::ConditionalCtx ( const shared_ptr< AppConfig > &  refAppConfig,
Named oNamed 
)

Member Function Documentation

◆ addChecker()

void stmg::ConditionalCtx::addChecker ( const xmlpp::Element *  p0Element)
overridevirtual

Adds a checker for the element.

A checker is used to make sure all attributes and child elements of an element are expected.

If an element already has a checker a reference count is increased.

The check happens (if requested) in the corresponding removeChecker() function.

Parameters
p0ElementThe element. Cannot be null.

Reimplemented from stmg::ParserCtx.

◆ getContextMate()

virtual int32_t stmg::ConditionalCtx::getContextMate ( ) const
inlinevirtual

The context mate.

Default implementation returns -1.

Returns
The context mate or -1.

Reimplemented in stmg::LayoutCtx.

◆ getContextTeam()

virtual int32_t stmg::ConditionalCtx::getContextTeam ( ) const
inlinevirtual

The context team.

The preferences team number (not the level team number).

Default implementation returns -1.

Returns
The context team or -1.

Reimplemented in stmg::GameCtx, and stmg::LayoutCtx.

◆ removeChecker()

void stmg::ConditionalCtx::removeChecker ( const xmlpp::Element *  p0Element,
bool  bCheckChildElements,
bool  bCheckAttrs 
)
overridevirtual

Removes a checker for the element.

This should always be paired with a addChecker() call.

If an element has multiple checkers, the check is only performed when the last checker is removed.

The bCheckChildElements parameter should be set to false if you are iterating over all child elements and checking their validity explicitely. Same for bCheckAttrs.

Parameters
p0ElementThe element. Cannot be null.
bCheckChildElementsWhether to check child element names.
bCheckAttrsWhether to check attributes.

Reimplemented from stmg::ParserCtx.