+ // Points the next free position in the vector of runs.
+ RunIndex colorRunIndex = 0u;
+ RunIndex fontRunIndex = 0u;
+ RunIndex underlinedCharacterRunIndex = 0u;
+ RunIndex backgroundRunIndex = 0u;
+ RunIndex strikethroughCharacterRunIndex = 0u;
+
+ // check tag reference
+ int colorTagReference = 0u;
+ int fontTagReference = 0u;
+ int iTagReference = 0u;
+ int bTagReference = 0u;
+ int uTagReference = 0u;
+ int backgroundTagReference = 0u;
+ int spanTagReference = 0u;
+ int sTagReference = 0u;
+
+ // Give an initial default value to the model's vectors.
+ markupProcessData.colorRuns.Reserve(DEFAULT_VECTOR_SIZE);
+ markupProcessData.fontRuns.Reserve(DEFAULT_VECTOR_SIZE);
+ markupProcessData.underlinedCharacterRuns.Reserve(DEFAULT_VECTOR_SIZE);
+ markupProcessData.backgroundColorRuns.Reserve(DEFAULT_VECTOR_SIZE);
+
+ // Get the mark-up string buffer.
+ const char* markupStringBuffer = markupString.c_str();
+ const char* const markupStringEndBuffer = markupStringBuffer + markupStringSize;
+
+ Tag tag;
+ CharacterIndex characterIndex = 0u;
+ for(; markupStringBuffer < markupStringEndBuffer;)
+ {
+ tag.attributes.Clear();
+ if(IsTag(markupStringBuffer,
+ markupStringEndBuffer,
+ tag))
+ {
+ if(TokenComparison(XHTML_COLOR_TAG, tag.buffer, tag.length))
+ {
+ ProcessTagForRun<ColorRun>(
+ markupProcessData.colorRuns, styleStack, tag, characterIndex, colorRunIndex, colorTagReference, [](const Tag& tag, ColorRun& run) { ProcessColorTag(tag, run); });
+ } // <color></color>
+ else if(TokenComparison(XHTML_I_TAG, tag.buffer, tag.length))
+ {
+ ProcessTagForRun<FontDescriptionRun>(
+ markupProcessData.fontRuns, styleStack, tag, characterIndex, fontRunIndex, iTagReference, [](const Tag&, FontDescriptionRun& fontRun) {
+ fontRun.slant = TextAbstraction::FontSlant::ITALIC;
+ fontRun.slantDefined = true;
+ });
+ } // <i></i>
+ else if(TokenComparison(XHTML_U_TAG, tag.buffer, tag.length))
+ {
+ ProcessTagForRun<UnderlinedCharacterRun>(
+ markupProcessData.underlinedCharacterRuns, styleStack, tag, characterIndex, underlinedCharacterRunIndex, uTagReference, [](const Tag& tag, UnderlinedCharacterRun& run) {});
+ } // <u></u>
+ else if(TokenComparison(XHTML_B_TAG, tag.buffer, tag.length))
+ {
+ ProcessTagForRun<FontDescriptionRun>(
+ markupProcessData.fontRuns, styleStack, tag, characterIndex, fontRunIndex, bTagReference, [](const Tag&, FontDescriptionRun& fontRun) {
+ fontRun.weight = TextAbstraction::FontWeight::BOLD;
+ fontRun.weightDefined = true;
+ });
+ } // <b></b>
+ else if(TokenComparison(XHTML_FONT_TAG, tag.buffer, tag.length))
+ {
+ ProcessTagForRun<FontDescriptionRun>(
+ markupProcessData.fontRuns, styleStack, tag, characterIndex, fontRunIndex, fontTagReference, [](const Tag& tag, FontDescriptionRun& fontRun) { ProcessFontTag(tag, fontRun); });