40 #ifndef _uitexttoken_cpp
41 #define _uitexttoken_cpp
43 #include "UI/texttoken.h"
81 Int32 BytesAdvance = 0;
83 UInt32 CurrRenderIndex = 0;
84 while( CurrRawIndex < this->
Text.size() && CurrRenderIndex < Index )
89 CurrRawIndex += BytesAdvance;
97 {
return this->
Text; }
100 {
return this->
Type; }
103 {
return this->
Text.size(); }
125 Int32 BytesAdvance = 0;
127 while( BufPos < Size )
132 BufPos +=
static_cast<UInt32>(BytesAdvance);
135 this->
Text.insert(RawIndex,Characters[0],Size);
150 Int32 BytesAdvance = 0;
153 UInt32 ConvBufSize = Size * 4;
154 Char8* ConversionBuffer =
new Char8[ConvBufSize];
155 while( SourceBufPos < Size )
158 if( BytesAdvance < 0 ) {
162 ConvBufPos +=
static_cast<UInt32>(BytesAdvance);
166 this->
Text.insert(RawIndex,ConversionBuffer,ConvBufPos);
167 delete[] ConversionBuffer;
182 Int32 BytesAdvance = 0;
183 if( RawIndex < this->
Text.size() ) {
187 this->
Text.erase(RawIndex,BytesAdvance);
204 Int32 BytesAdvance = 0;
206 UInt32 CurrRenderLength = 0;
207 while( RawIndex + CurrRawLength < this->
Text.size() && CurrRenderLength < Length )
212 CurrRawLength +=
static_cast<UInt32>(BytesAdvance);
216 this->
Text.erase(RawIndex,CurrRawLength);
217 return CurrRenderLength;
249 NameValuePairMap::const_iterator ParamIt = this->
Params.find(Param);
250 if( ParamIt != this->
Params.end() )
return (*ParamIt).second;
375 if( this->
RenderSize != 0 && Index == 0 && Length > 0 ) {
409 if( IndexCount + (*TokIt)->GetRenderCharacterSize() < Index ) {
410 IndexCount += (*TokIt)->GetRenderCharacterSize();
414 Ret.second = Index - IndexCount;
424 Ret.first = --(this->
Tokens.end());
425 Ret.second = (*Ret.first)->GetRenderCharacterSize();
437 Ret.append( (*TokIt)->GetRawCharacterString() );
447 Ret += (*TokIt)->GetRenderCharacterSize();
454 return this->
Tokens.size();
458 {
return this->
Tokens.begin(); }
461 {
return this->
Tokens.end(); }
464 {
return this->
Tokens.begin(); }
467 {
return this->
Tokens.end(); }
470 {
return this->
Tokens.rbegin(); }
473 {
return this->
Tokens.rend(); }
476 {
return this->
Tokens.rbegin(); }
479 {
return this->
Tokens.rend(); }
485 { this->
Tokens.push_back(ToBePushed); }
488 { this->
Tokens.insert(this->
Tokens.end(),ToBePushed.begin(),ToBePushed.end()); }
510 this->
Tokens.insert(Result.first,NewToken);
524 this->
Tokens.insert(Result.first,NewToken);
538 this->
Tokens.insert(Result.first,NewToken);
547 return (*Result.first)->RemoveCharacter(Result.second);
554 while( Removed < Length ) {
556 if( Result.first == this->Tokens.end() )
559 Removed += (*Result.first)->
RemoveCharacters(Result.second,Length - Removed);
569 Ret += (*TokIt)->ClearAllCharacters();
TokenContainer Tokens
Container for TextToken storage.
int32_t Int32
An 32-bit integer.
This contains simple tools for indexing with UTF8 characters swiftly.
This class represents a normal text segment from the source string.
TokenString()
Class constructor.
NameValuePairMap Params
The parameters provided for this tag, if any.
TokenIndexPair GetTokenIndex(const UInt32 Index)
Gets the token at the string index, and it's local index.
String TagName
Unconverted version of the tag name.
virtual UInt32 RemoveCharacters(const UInt32 Index, const UInt32 Length)
Removes rendered characters from this string.
virtual UInt32 RemoveCharacter(const UInt32 Index)
Removes a single rendered character from this token.
virtual ~TextToken()
Class destructor.
virtual UInt32 ClearAllCharacters()
Removes all the rendered characters from this token.
virtual UInt32 RemoveCharacters(const UInt32 Index, const UInt32 Length)
Removes rendered characters from this token.
virtual UInt32 ClearAllCharacters()
Removes all the rendered characters from this string.
UInt32 RenderSize
The number of rendered characters this token produced.
UInt32 ConvertRenderIndexToRawIndex(const UInt32 Index)
Takes a position of a renderable char and converts it to the respective position in the raw string...
virtual UInt32 InsertCharacters(const UInt32 Index, const Char8 *Characters, const UInt32 Size)
virtual UInt32 InsertCharacter(const UInt32 Index, UInt32 UChar)
Inserts a single UTF-32 size character into this string.
ReverseTokenIterator ReverseBeginToken()
Gets a reverse iterator to the last TextToken.
const String & GetTagName() const
Gets the name of the tag this token represents.
virtual ~RangeTagToken()
Class destructor.
std::pair< TokenIterator, UInt32 > TokenIndexPair
An std::pair used to report the result of a TextToken and it's local index.
virtual const String & GetRawCharacterString() const
Gets the raw string for this token used to render or manipulate characters.
RangeTagToken()
Class constructor.
This implements the exception hiearchy for Mezzanine.
virtual ~TokenString()
Class destructor.
RangeTagToken * GetPartnerTag() const
Gets the partner tag to this RangeTag.
virtual UInt32 RemoveCharacter(const UInt32 Index)
Removes a single rendered character from this token.
virtual void PushToken(TextToken *ToBePushed)
Appends a new token to the end of this string.
char Char8
A datatype to represent one character.
Whole GetNumCharacters() const
Gets the number of renderable characters that exist in this string.
TokenContainer::reverse_iterator ReverseTokenIterator
Reverse Iterator type for TextToken instances being stored by this class.
InsertTagToken()
Class constructor.
virtual UInt32 RemoveCharacters(const UInt32 Index, const UInt32 Length)
Removes rendered characters from this token.
TextToken()
Class constructor.
virtual UInt32 InsertCharacter(const UInt32 Index, UInt32 UChar)
Inserts a single UTF-32 size character into this token.
virtual UInt32 InsertCharacters(const UInt32 Index, const Char8 *Characters, const UInt32 Size)
Inserts multiple characters into this token.
virtual UInt32 RemoveCharacter(const UInt32 Index)
Removes a single rendered character from this token.
uint32_t UInt32
An 32-bit unsigned integer.
String GetParameter(const String &Param) const
Gets a parameter specified in this token by name.
virtual void PushTokens(const TokenContainer &ToBePushed)
Appends a group of tokens to the end of this string.
virtual UInt32 RemoveCharacter(const UInt32 Index)
Removes a single rendered character from this string.
std::vector< TextToken * > TokenContainer
Basic container type for the storage of TextToken instances by this class.
virtual TextToken::TokenType GetTokenType() const
Gets the type of token this is.
virtual UInt32 GetRenderCharacterSize() const
Gets the number of rendered characters this token generates.
virtual UInt32 ClearAllCharacters()
Removes all the rendered characters from this token.
TokenType
The type of token this class represents.
TokenIterator EndToken()
Gets an iterator to one passed the last TextToken.
TokenIterator BeginToken()
Gets an iterator to the first TextToken.
Int32 GetIntFromCharacter(Int32 &BytesUsed, const char *CurrentCharacter)
Get a number suitable for using in an index from a character string.
This struct represents a markup tag segment from the source string.
This struct represents a markup tag segment from the source string.
virtual ~TagToken()
Class destructor.
virtual ~InsertTagToken()
Class destructor.
RangeTagToken * PartnerTag
Pointer to the opening/closing tag for this tag.
virtual UInt32 GetRawCharacterSize() const
Gets the number of Char8's that comprise the source text for this tag.
The bulk of the engine components go in this namspace.
TokenContainer::iterator TokenIterator
Iterator type for TextToken instances being stored by this class.
virtual UInt32 InsertCharacters(const UInt32 Index, const Char8 *Characters, const UInt32 Size)
Inserts multiple characters into this token.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
ReverseTokenIterator ReverseEndToken()
Gets a reverse iterator to one before the first TextToken.
TokenContainer::const_iterator ConstTokenIterator
Const Iterator type for TextToken instances being stored by this class.
virtual UInt32 InsertCharacters(const UInt32 Index, const Char8 *Characters, const UInt32 Size)
Inserts multiple characters into this string.
virtual UInt32 InsertCharacter(const UInt32 Index, UInt32 UChar)
Inserts a single UTF-32 size character into this token.
Used to describe a normal text token with plain text.
virtual UInt32 InsertCharacter(const UInt32 Index, UInt32 UChar)
Inserts a single UTF-32 size character into this token.
virtual UInt32 ClearAllCharacters()
Removes all the rendered characters from this token.
virtual void DestroyAllTokens()
Destroys all tokens currently in this string.
TokenType Type
Type of token this is.
TagToken()
Class constructor.
Whole GetNumTokens() const
Gets the number of text tokens in this string.
String Text
Container for the converted text.
virtual UInt32 RemoveCharacters(const UInt32 Index, const UInt32 Length)
Removes rendered characters from this token.
std::string String
A datatype used to a series of characters.
virtual String GetRawString() const
Gets a string containing all the raw characters of the tokens in this string.
Int32 GetCharacterFromInt(char *Destination, Int32 BytesUsable, Int32 ByteSequence)
Convert a number that represents any valid unicode value into its UTF8 representation.
TokenContainer::const_reverse_iterator ConstReverseTokenIterator
Const Reverse Iterator type for TextToken instances being stored by this class.