This is a base class for the parsing of markup texts contained in text layers. More...
#include <markupparser.h>
Public Types | |
typedef std::list< Character * > | CharacterContainer |
Basic container type for the storage of Character instances used during processing by this class. | |
typedef CharacterContainer::iterator | CharacterIterator |
Iterator type for Character instances being processed by this class. | |
typedef CharacterContainer::const_iterator | ConstCharacterIterator |
Const Iterator type for Character instances being processed by this class. | |
typedef TagContainer::const_iterator | ConstTagIterator |
Const Iterator type for MarkupTag instances stored by this class. | |
typedef TagVector::const_iterator | ConstTagVecIterator |
Const Iterator type for TokenTagPair instances being processed by this class. | |
typedef TokenContainer::const_iterator | ConstTokenIterator |
Const Iterator type for TextToken instances being processed by this class. | |
typedef std::map< String, MarkupTag * > | TagContainer |
Basic container type for the storage of MarkupTag instances by this class. | |
typedef TagContainer::iterator | TagIterator |
Iterator type for MarkupTag instances stored by this class. | |
typedef TagVector::iterator | TagVecIterator |
Iterator type for TokenTagPair instances being processed by this class. | |
typedef std::vector< TokenTagPair > | TagVector |
Basic container type for the storage of TokenTagPair instances used during processing by this class. | |
typedef std::vector< TextToken * > | TokenContainer |
Basic container type for the storage of TextToken instances used during processing by this class. | |
typedef TokenContainer::iterator | TokenIterator |
Iterator type for TextToken instances being processed by this class. | |
typedef std::pair< TagToken *, MarkupTag * > | TokenTagPair |
An std::pair type used to map a TagToken to the MarkupTag implementation it is calling. | |
Public Member Functions | |
MarkupParser () | |
Class constructor. | |
virtual | ~MarkupParser () |
Class destructor. | |
virtual Char8 | GetMarkupTagEnd () const =0 |
Gets the ID for the character that marks the end of a markup section. More... | |
virtual Char8 | GetMarkupTagStart () const =0 |
Gets the ID for the character that marks the start of a markup section. More... | |
virtual String | GetName () const =0 |
Gets the name of this parser implementation. More... | |
virtual TokenString * | Lex (const String &Source) const |
Converts a string into a series of tokens that can be parsed more readily. More... | |
virtual CharacterContainer | Parse (const String &Source, const CharacterTraits &InitialTraits, TextLayer *CallingLayer) const |
Processes a string encoded in UTF8 into a list of renderable characters. More... | |
virtual CharacterContainer | ParseTextTokens (TokenString *Tokens, const CharacterTraits &InitialTraits, TextLayer *CallingLayer) const |
Processes a collection of text tokens into a list of renderable characters. More... | |
Protected Member Functions | |
virtual TextToken * | CreateTagToken (const String &Text) const |
Helper method for creating tag tokens. More... | |
virtual TextToken * | CreateTextToken (const String &Text) const |
Helper method for creating text tokens. More... | |
virtual void | GenerateCharactersFromToken (const TextToken *Token, TextLayer *Layer, const CharacterTraits &Traits, CharacterContainer &Characters) const |
Helper method for converting text tokens into characters. More... | |
virtual void | Initialize ()=0 |
Populates the tag map with the tags recognized by this parser. | |
virtual void | RegenerateTraits (CharacterTraits &Traits, const TagVector &ActiveTags, TextLayer *Layer) const |
Helper method for regenerating current traits after a tag is disabled. More... | |
Protected Attributes | |
TagContainer | Tags |
Map of tags recognized by this parser. | |
This is a base class for the parsing of markup texts contained in text layers.
This class implements every aspect of the markup language except for the tags and their functionality. It is expected that tags can be broken down into one of two processes, either they will generate a character, or they will alter the styling used to render an existing range of characters.
The styling and syntax of the markup language is similar (but not identical) to BBCode. Developers can set which glyphs are to be used to mark the start and end of a markup tag. Tags can be start tags, end tags, and individual tags. Individual tags are the character generators. They make the character and are done with influencing any other characters. Start tags and end tags together define a range of characters they are to influence. Use of the forward slash '/' is prohibited unless you are noting an end tag, in which case the slash is to be followed by the tag name (this is case sensitive) and nothing else, within the markup start and end glyphs. An end tag cannot have parameters defined in it, and if any are included they will be parsed as a part of the tag name. A start tag cannot have a forward slash '/'. Instead it must start with the tag name, then a space, and then list the parameter names and values linked by an equals sign '=', and separated by spaces. Spaces between the markup tag start and end glyphs and tag names should be avoided.
Relevant parameters and their possibile values are based on the tag being used, and you should check the markup implemenation for that information. Depending on the number of parameters needed for the tag this markup system supports both short notation, and long notation. Short notation is only supported when there is one parameter, and is implemented as "{tagname}{equals}{value}". For example a sprite could be implemented as "[Sprite=Awesome]" where everything after the equals to the end tag is treated as the value to set, in this case the name of the sprite to be set. In situations like this the value is always given the name "Value" in the NameValuePairMap of parameters that is passed around during parsing. Long notation involves being explicit with the names of values, and is necessary for tags that require multiple parameters. In long notation there should be minimal spaces, used only to separate the tag name and each parameter from each other.
Definition at line 126 of file markupparser.h.
|
protectedvirtual |
Helper method for creating tag tokens.
Text | The text to generate a token for. |
Definition at line 71 of file markupparser.cpp.
|
protectedvirtual |
Helper method for creating text tokens.
Text | The text to generate a token for. |
Definition at line 65 of file markupparser.cpp.
|
protectedvirtual |
Helper method for converting text tokens into characters.
Token | The token to be converted into renderable characters. |
Layer | A pointer to the layer this is parsing for. |
Traits | The character properties to use when generating characters. |
Characters | The character container to append any generated characters to. |
Definition at line 144 of file markupparser.cpp.
|
pure virtual |
Gets the ID for the character that marks the end of a markup section.
Implemented in Mezzanine::UI::DefaultMarkupParser.
|
pure virtual |
Gets the ID for the character that marks the start of a markup section.
Implemented in Mezzanine::UI::DefaultMarkupParser.
|
pure virtual |
Gets the name of this parser implementation.
Implemented in Mezzanine::UI::DefaultMarkupParser.
|
virtual |
Converts a string into a series of tokens that can be parsed more readily.
Source | The source string containing raw text and (maybe) markup tags to convert into tokens. |
Definition at line 315 of file markupparser.cpp.
|
virtual |
Processes a string encoded in UTF8 into a list of renderable characters.
Source | The source string containing raw text and (maybe) markup tags to convert into characters. |
InitialTraits | The colour, highlight colour, and font characters are to have by default without otherwise being set via markup. |
CallingLayer | The TextLayer instance calling this method. |
Definition at line 186 of file markupparser.cpp.
|
virtual |
Processes a collection of text tokens into a list of renderable characters.
Tokens | A TokenString storing all the lex'd text that is to be parsed. |
InitialTraits | The colour, highlight colour, and font characters are to have by default without otherwise being set via markup. |
CallingLayer | The TextLayer instance calling this method. |
Definition at line 201 of file markupparser.cpp.
|
protectedvirtual |
Helper method for regenerating current traits after a tag is disabled.
Traits | The character properties to use when generating characters. |
ActiveTags | A container of the tags that are to be applied to characters. |
Layer | A pointer to the layer this is parsing for. |
Definition at line 174 of file markupparser.cpp.