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

Public Member Functions

virtual ~XmlModifierParser ()=default
 
 XmlModifierParser (const std::string &sModifierName)
 Constructor. More...
 
const std::string & getModifierName () const
 The modifier name. More...
 
virtual unique_ptr< StdThemeModifierparseModifier (ThemeCtx &oCtx, const xmlpp::Element *p0Element)=0
 Parse a tile modifier element. More...
 

Protected Member Functions

std::vector< unique_ptr< StdThemeModifier > > parseSubModifiers (ThemeCtx &oCtx, const xmlpp::Element *p0ParentElement)
 Parse all children as modifiers. More...
 
std::vector< unique_ptr< StdThemeModifier > > parseSubModifiers (ThemeCtx &oCtx, const xmlpp::Element *p0ParentElement, const std::vector< std::string const *> &aSkipChildNames)
 Parse all children as modifiers. More...
 
unique_ptr< StdThemeModifierparseSubModifier (ThemeCtx &oCtx, const xmlpp::Element *p0ModifierElement)
 Parses a submodifier. More...
 
void parseBaseModifier (ThemeCtx &oCtx, const xmlpp::Element *p0Element, StdThemeModifier::Init &oInit)
 Parse the base class attributes. More...
 
shared_ptr< TileAniparseModifierTileAniId (ThemeCtx &oCtx, const xmlpp::Element *p0Element, bool bMandatory)
 Parse tile ani id. More...
 
int32_t parseModifierTileAniName (ThemeCtx &oCtx, const xmlpp::Element *p0Element, bool bMandatory)
 Parse tile ani name. More...
 
double parseModifierElapsedDefault (ThemeCtx &oCtx, const xmlpp::Element *p0Element)
 Parse elapsed default. More...
 
bool parseModifierInvert (ThemeCtx &oCtx, const xmlpp::Element *p0Element)
 Parse invert. More...
 
std::tuple< int32_t, double, bool > parseTileAniNameDefault (ThemeCtx &oCtx, const xmlpp::Element *p0Element, bool bMandatory)
 Parse tile ani name, default elapsed and invert. More...
 
std::tuple< int32_t, double, bool, shared_ptr< Image >, shared_ptr< TileAni > > parseTileAniIdNameImgDefault (ThemeCtx &oCtx, const xmlpp::Element *p0Element)
 Parse tile ani id, name, default image or elapsed and invert. More...
 
XmlConditionalParsergetXmlConditionalParser ()
 
XmlTraitsParsergetXmlTraitsParser ()
 
XmlThemeImageParsergetXmlThemeImageParser ()
 

Constructor & Destructor Documentation

◆ ~XmlModifierParser()

virtual stmg::XmlModifierParser::~XmlModifierParser ( )
virtualdefault

◆ XmlModifierParser()

stmg::XmlModifierParser::XmlModifierParser ( const std::string &  sModifierName)

Constructor.

Parameters
sModifierNameThe modifier name. Cannot be empty.

Member Function Documentation

◆ getModifierName()

const std::string& stmg::XmlModifierParser::getModifierName ( ) const

The modifier name.

Returns
The modifier name. Is not empty.

◆ getXmlConditionalParser()

XmlConditionalParser* stmg::XmlModifierParser::getXmlConditionalParser ( )
protected

◆ getXmlThemeImageParser()

XmlThemeImageParser* stmg::XmlModifierParser::getXmlThemeImageParser ( )
protected

◆ getXmlTraitsParser()

XmlTraitsParser* stmg::XmlModifierParser::getXmlTraitsParser ( )
protected

◆ parseBaseModifier()

void stmg::XmlModifierParser::parseBaseModifier ( ThemeCtx oCtx,
const xmlpp::Element *  p0Element,
StdThemeModifier::Init oInit 
)
protected

Parse the base class attributes.

Parameters
oCtxThe theme context.
p0ElementThe element. Cannot be null.
oInitThe initialization data to fill.

◆ parseModifier()

virtual unique_ptr<StdThemeModifier> stmg::XmlModifierParser::parseModifier ( ThemeCtx oCtx,
const xmlpp::Element *  p0Element 
)
pure virtual

◆ parseModifierElapsedDefault()

double stmg::XmlModifierParser::parseModifierElapsedDefault ( ThemeCtx oCtx,
const xmlpp::Element *  p0Element 
)
protected

Parse elapsed default.

If not defined as attribute default is -1.0.

Parameters
oCtxThe theme context.
p0ElementThe element. Cannot be null.
Returns
The elapsed default (0.0 to 1.0) or -1.0 if not defined.

◆ parseModifierInvert()

bool stmg::XmlModifierParser::parseModifierInvert ( ThemeCtx oCtx,
const xmlpp::Element *  p0Element 
)
protected

Parse invert.

If not defined as attribute default is false.

Parameters
oCtxThe theme context.
p0ElementThe element. Cannot be null.
Returns
The invert value.

◆ parseModifierTileAniId()

shared_ptr<TileAni> stmg::XmlModifierParser::parseModifierTileAniId ( ThemeCtx oCtx,
const xmlpp::Element *  p0Element,
bool  bMandatory 
)
protected

Parse tile ani id.

Parameters
oCtxThe theme context.
p0ElementThe element. Cannot be null.
bMandatoryWhether tile ani id must be defined.
Returns
The tile ani or null if not defined.

◆ parseModifierTileAniName()

int32_t stmg::XmlModifierParser::parseModifierTileAniName ( ThemeCtx oCtx,
const xmlpp::Element *  p0Element,
bool  bMandatory 
)
protected

Parse tile ani name.

Parameters
oCtxThe theme context.
p0ElementThe element. Cannot be null.
bMandatoryWhether tile ani name must be defined.
Returns
The index into Named::tileAnis() or -1 if not defined.

◆ parseSubModifier()

unique_ptr<StdThemeModifier> stmg::XmlModifierParser::parseSubModifier ( ThemeCtx oCtx,
const xmlpp::Element *  p0ModifierElement 
)
protected

Parses a submodifier.

If the element is not a modifier it throws.

Parameters
oCtxThe theme context.
p0ModifierElementThe submodifier element. Cannot be null.
Returns
The parsed submodifier. Is not null.
Exceptions
std::runtime_error.

◆ parseSubModifiers() [1/2]

std::vector< unique_ptr<StdThemeModifier> > stmg::XmlModifierParser::parseSubModifiers ( ThemeCtx oCtx,
const xmlpp::Element *  p0ParentElement 
)
protected

Parse all children as modifiers.

Use this if the child Elements are all Modifiers, if one isn't an error is thrown. Alternatively use parseSubModifier(), to parse them one by one.

Parameters
oCtxThe theme context.
p0ParentElementThe parent element. Cannot be null.
Returns
The created submodifiers. All values are not null.
Exceptions
std::runtime_error.

◆ parseSubModifiers() [2/2]

std::vector< unique_ptr<StdThemeModifier> > stmg::XmlModifierParser::parseSubModifiers ( ThemeCtx oCtx,
const xmlpp::Element *  p0ParentElement,
const std::vector< std::string const *> &  aSkipChildNames 
)
protected

Parse all children as modifiers.

Use this if the child Elements are all Modifiers, if one isn't an error is thrown. Alternatively use parseSubModifier(), to parse them one by one.

Parameters
oCtxThe theme context.
p0ParentElementThe parent element. Cannot be null.
aSkipChildNamesThe child names that should be ignored.
Returns
The created submodifiers. All values are not null.
Exceptions
std::runtime_error.

◆ parseTileAniIdNameImgDefault()

std::tuple<int32_t, double, bool, shared_ptr<Image>, shared_ptr<TileAni> > stmg::XmlModifierParser::parseTileAniIdNameImgDefault ( ThemeCtx oCtx,
const xmlpp::Element *  p0Element 
)
protected

Parse tile ani id, name, default image or elapsed and invert.

Used by MaskModifier, TileAniModifier.

Parameters
oCtxThe theme context.
p0ElementThe element. Cannot be null.
Returns
Tuple (tileAniIdx, fDefaultElapsed, bInvert, refDefaultImage, refTileAni).

◆ parseTileAniNameDefault()

std::tuple<int32_t, double, bool> stmg::XmlModifierParser::parseTileAniNameDefault ( ThemeCtx oCtx,
const xmlpp::Element *  p0Element,
bool  bMandatory 
)
protected

Parse tile ani name, default elapsed and invert.

Used by RotateModifier, FadeModifier.

Parameters
oCtxThe theme context.
p0ElementThe element. Cannot be null.
bMandatoryWhether either tile ani name or default elapsed must be defined.
Returns
Tuple (tileAniIdx, fDefaultElapsed, bInvert).