Spinning Topp Logo BlackTopp Studios
inc
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Mezzanine::UI::TextToken Class Reference

This class represents a normal text segment from the source string. More...

#include <texttoken.h>

+ Inheritance diagram for Mezzanine::UI::TextToken:
+ Collaboration diagram for Mezzanine::UI::TextToken:

Public Types

enum  TokenType {
  TT_Error = 0, TT_Text = 1, TT_TagInvalid = 2, TT_RangeTagStart = 3,
  TT_RangeTagEnd = 4, TT_InsertTag = 5
}
 The type of token this class represents. More...
 

Public Member Functions

 TextToken ()
 Class constructor. More...
 
 TextToken (const String &RawText, const TokenType TType)
 Descriptive constructor. More...
 
 TextToken (const Char8 *Characters, const UInt32 Size)
 Char8 constructor. More...
 
 TextToken (const UInt32 *Characters, const UInt32 Size)
 Char8 constructor. More...
 
virtual ~TextToken ()
 Class destructor.
 
virtual UInt32 ClearAllCharacters ()
 Removes all the rendered characters from this token. More...
 
virtual UInt32 GetRawCharacterSize () const
 Gets the number of Char8's that comprise the source text for this tag. More...
 
virtual const StringGetRawCharacterString () const
 Gets the raw string for this token used to render or manipulate characters. More...
 
virtual UInt32 GetRenderCharacterSize () const
 Gets the number of rendered characters this token generates. More...
 
virtual TextToken::TokenType GetTokenType () const
 Gets the type of token this is. More...
 
virtual UInt32 InsertCharacter (const UInt32 Index, UInt32 UChar)
 Inserts a single UTF-32 size character into this token. More...
 
virtual UInt32 InsertCharacters (const UInt32 Index, const Char8 *Characters, const UInt32 Size)
 Inserts multiple characters into this token. More...
 
virtual UInt32 InsertCharacters (const UInt32 Index, const UInt32 *Characters, const UInt32 Size)
 Inserts multiple characters into this token. More...
 
virtual UInt32 RemoveCharacter (const UInt32 Index)
 Removes a single rendered character from this token. More...
 
virtual UInt32 RemoveCharacters (const UInt32 Index, const UInt32 Length)
 Removes rendered characters from this token. More...
 

Protected Member Functions

UInt32 ConvertRenderIndexToRawIndex (const UInt32 Index)
 Takes a position of a renderable char and converts it to the respective position in the raw string. More...
 

Protected Attributes

UInt32 RenderSize
 The number of rendered characters this token produced. More...
 
String Text
 Container for the converted text. More...
 
TokenType Type
 Type of token this is. More...
 

Friends

class MarkupParser
 

Detailed Description

This class represents a normal text segment from the source string.

Text tokens are intended for the generation of segments of regular glyphs provided by an atlas or font file. They have no special behaviors of their own and will almost always have their render size match their text size.

Definition at line 56 of file texttoken.h.

Member Enumeration Documentation

The type of token this class represents.

Enumerator
TT_Error 

Used to describe any generic error with a token.

TT_Text 

Used to describe a normal text token with plain text.

TT_TagInvalid 

Used to describe a tag token that is syntactically correct, but has another error, such as a range tag missing a partner, or the tag name isn't found.

TT_RangeTagStart 

Used to describe either a tag token inserting a character, or the start of a range tag.

TT_RangeTagEnd 

Used to describe the end of a range tag.

TT_InsertTag 

Used to describe a single tag used to insert a special character (such as s sprite).

Definition at line 60 of file texttoken.h.

Constructor & Destructor Documentation

Mezzanine::UI::TextToken::TextToken ( )

Class constructor.

Note
This is mostly used for inheritence purposes.

Definition at line 55 of file texttoken.cpp.

Mezzanine::UI::TextToken::TextToken ( const String RawText,
const TokenType  TType 
)

Descriptive constructor.

Parameters
RawTextA string containing the raw text of this token.
TTypeThe type of text token to be created.

Definition at line 60 of file texttoken.cpp.

Mezzanine::UI::TextToken::TextToken ( const Char8 Characters,
const UInt32  Size 
)

Char8 constructor.

Parameters
CharactersA buffer of UTF-8 characters to populate this TextToken with.
SizeThe number of characters that exist in the provided buffer.

Definition at line 66 of file texttoken.cpp.

Mezzanine::UI::TextToken::TextToken ( const UInt32 Characters,
const UInt32  Size 
)

Char8 constructor.

Parameters
CharactersA buffer of UTF-32 characters to populate this TextToken with.
SizeThe number of characters that exist in the provided buffer.

Definition at line 71 of file texttoken.cpp.

Member Function Documentation

UInt32 Mezzanine::UI::TextToken::ClearAllCharacters ( )
virtual

Removes all the rendered characters from this token.

Returns
Returns the number of rendered characters that were actually removed.

Reimplemented in Mezzanine::UI::InsertTagToken, and Mezzanine::UI::RangeTagToken.

Definition at line 222 of file texttoken.cpp.

UInt32 Mezzanine::UI::TextToken::ConvertRenderIndexToRawIndex ( const UInt32  Index)
protected

Takes a position of a renderable char and converts it to the respective position in the raw string.

Note
In cases where ASCII is used, this will always return the same number, this exists for when more exotic unicode characters/glyphs are used.
Parameters
IndexThe index to be converted.
Returns
Returns a UInt32 representing the Raw character index of the first character corresponding to the rendered character at the provided index.

Definition at line 79 of file texttoken.cpp.

UInt32 Mezzanine::UI::TextToken::GetRawCharacterSize ( ) const
virtual

Gets the number of Char8's that comprise the source text for this tag.

Returns
Returns a UInt32 containing the size of the source string for this token.

Definition at line 102 of file texttoken.cpp.

const String & Mezzanine::UI::TextToken::GetRawCharacterString ( ) const
virtual

Gets the raw string for this token used to render or manipulate characters.

Returns
Returns a reference to the source string stored by this token.

Definition at line 96 of file texttoken.cpp.

UInt32 Mezzanine::UI::TextToken::GetRenderCharacterSize ( ) const
virtual

Gets the number of rendered characters this token generates.

Note
This number is initially generated when the tokens are parsed and the actual characters are generated. Methods that modify the source text try to keep this in sync appropriately.
Returns
Returns a UInt32 containing the number of characters are being rendered via the text from this token.

Definition at line 105 of file texttoken.cpp.

TextToken::TokenType Mezzanine::UI::TextToken::GetTokenType ( ) const
virtual

Gets the type of token this is.

Returns
Returns a TokenType enum value describing the type of token this is.

Definition at line 99 of file texttoken.cpp.

UInt32 Mezzanine::UI::TextToken::InsertCharacter ( const UInt32  Index,
UInt32  UChar 
)
virtual

Inserts a single UTF-32 size character into this token.

Parameters
IndexThe index at which the character will be inserted.
UCharThe unicode character to be inserted. This will be converted to UTF-8 prior to insertion.
Returns
Returns 1 if the character was successfully inserted, otherwise returns 0. Note: This is not rendered characters, as they don't get generated until the tokens are re-parsed.

Reimplemented in Mezzanine::UI::InsertTagToken, and Mezzanine::UI::RangeTagToken.

Definition at line 108 of file texttoken.cpp.

UInt32 Mezzanine::UI::TextToken::InsertCharacters ( const UInt32  Index,
const Char8 Characters,
const UInt32  Size 
)
virtual

Inserts multiple characters into this token.

Parameters
IndexThe index at which the characters will be inserted.
CharactersAn array of Char8's encoded in UTF-8 to be inserted.
SizeThe size of the array of Char8's passed in.
Returns
Returns the number of characters successfully inserted. Note: This is not rendered characters, as they don't get generated until the tokens are re-parsed.

Reimplemented in Mezzanine::UI::InsertTagToken, and Mezzanine::UI::RangeTagToken.

Definition at line 113 of file texttoken.cpp.

UInt32 Mezzanine::UI::TextToken::InsertCharacters ( const UInt32  Index,
const UInt32 Characters,
const UInt32  Size 
)
virtual

Inserts multiple characters into this token.

Parameters
IndexThe index at which the characters will be inserted.
CharactersAn array of UInt32's encoded in UTF-32 to be inserted.
SizeThe size of the array of UInt32's passed in.
Returns
Returns the number of characters successfully inserted. Note: This is not rendered characters, as they don't get generated until the tokens are re-parsed.

Reimplemented in Mezzanine::UI::InsertTagToken, and Mezzanine::UI::RangeTagToken.

Definition at line 141 of file texttoken.cpp.

UInt32 Mezzanine::UI::TextToken::RemoveCharacter ( const UInt32  Index)
virtual

Removes a single rendered character from this token.

Parameters
IndexThe index at which the rendered character will be removed.
Returns
Returns 1 if the character was successfully removed, otherwise returns 0.

Reimplemented in Mezzanine::UI::InsertTagToken, and Mezzanine::UI::RangeTagToken.

Definition at line 173 of file texttoken.cpp.

UInt32 Mezzanine::UI::TextToken::RemoveCharacters ( const UInt32  Index,
const UInt32  Length 
)
virtual

Removes rendered characters from this token.

Parameters
IndexThe index at which to start removing characters from this token.
LengthThe number of characters to try and remove from this token.
Returns
Returns the number of rendered characters that were actually removed.

Reimplemented in Mezzanine::UI::InsertTagToken, and Mezzanine::UI::RangeTagToken.

Definition at line 194 of file texttoken.cpp.

Member Data Documentation

UInt32 Mezzanine::UI::TextToken::RenderSize
protected

The number of rendered characters this token produced.

Definition at line 76 of file texttoken.h.

String Mezzanine::UI::TextToken::Text
protected

Container for the converted text.

Definition at line 79 of file texttoken.h.

TokenType Mezzanine::UI::TextToken::Type
protected

Type of token this is.

Definition at line 73 of file texttoken.h.


The documentation for this class was generated from the following files: