40 #ifndef _uimarkupparser_cpp
41 #define _uimarkupparser_cpp
43 #include "UI/markupparser.h"
44 #include "UI/character.h"
46 #include "UI/sprite.h"
47 #include "UI/texttoken.h"
50 #include "exception.h"
75 const Integer TextSize = Text.size();
77 UInt32 SlashPos = Text.find_first_of(
'/');
81 String TagName = Text.substr(SlashPos + 1,Text.find_first_of(this->GetMarkupTagEnd()) - SlashPos - 1);
83 }
else if( SlashPos == String::npos ) {
87 String SeparatorChars(
" =");
91 Position = Text.find_first_of(SeparatorChars);
92 String TagName = Text.substr(1,Position - 1);
96 if( TagIt != this->
Tags.end() ) {
98 if( (*TagIt).second->IsRangeTag() ) {
112 if( Text[Position] ==
'=' ) {
113 TagParams[
"Value"] = Text.substr(Position + 1,TextSize - Position - 1);
114 }
else if( Text[Position] ==
' ' ) {
116 String ParamEndChars(
" ");
118 while( Position < TextSize - 1 )
120 String ParamName, ParamValue;
122 UInt32 SeparatorPos = Text.find_first_of(
'=');
123 if( SeparatorPos != String::npos ) ParamName = Text.substr(Position + 1,SeparatorPos - Position - 1);
126 UInt32 PairEndPos = Text.find_first_of(ParamEndChars);
127 if( SeparatorPos != String::npos ) ParamValue = Text.substr(SeparatorPos + 1,PairEndPos - SeparatorPos - 1);
130 TagParams[ParamName] = ParamValue;
131 Position = PairEndPos;
135 CastedTag->
Params.swap(TagParams);
149 Int32 BytesAdvance = 0;
150 const char* StrBuf = Token->
Text.data();
152 while( static_cast<UInt32>(Position) < Token->
Text.size() )
161 if( TheGlyph == NULL )
164 ExceptionStream <<
"Attempting to parse unknown Glyph ID: " << GlyphID <<
". Provided font (" << Traits.
CharFont->
GetName() <<
") does not contain that Glyph.";
171 Characters.push_back(NewChar);
173 Position += BytesAdvance;
179 for(
ConstTagVecIterator TagIt = ActiveTags.begin() ; TagIt != ActiveTags.end() ; ++TagIt )
182 (*TagIt).second->Process( (*TagIt).first->Params, Traits, Layer );
201 return GeneratedCharacters;
217 switch( (*TokIt)->Type )
227 GeneratedCharacters.splice(GeneratedCharacters.end(),CharacterSegment);
228 CurrToken->
RenderSize = CharacterSegment.size();
236 if( TagIt !=
Tags.end() ) {
238 if( (*TagIt).second->IsRangeTag() ) {
246 CharacterSegment.push_back(Res.second);
249 ActiveTags.push_back(
TokenTagPair( CurrToken,(*TagIt).second ) );
264 if( !CharacterSegment.empty() )
266 GeneratedCharacters.splice(GeneratedCharacters.end(),CharacterSegment);
267 CurrToken->
RenderSize = CharacterSegment.size();
277 for( TagVector::reverse_iterator TagIt = ActiveTags.rbegin() ; TagIt != ActiveTags.rend() ; ++TagIt )
281 ActiveTags.erase( --(TagIt.base()) );
284 CurrentTraits = InitialTraits;
289 GeneratedCharacters.splice(GeneratedCharacters.end(),CharacterSegment);
290 CurrToken->
RenderSize = CharacterSegment.size();
299 if( TagIt !=
Tags.end() ) {
303 CharacterSegment.push_back(Res.second);
310 GeneratedCharacters.splice(GeneratedCharacters.end(),CharacterSegment);
311 CurrToken->
RenderSize = CharacterSegment.size();
316 return GeneratedCharacters;
326 while( Position < Source.size() )
329 size_t TagStartPos = Source.find_first_of( this->
GetMarkupTagStart(), Position );
332 if( TagStartPos == String::npos )
338 else if( TagStartPos - Position > 0 )
345 size_t TagEndPos = Source.find_first_of( this->
GetMarkupTagEnd(), TagStartPos );
348 if( TagEndPos == String::npos )
375 Position = TagEndPos + 1;