+void SkipWhiteSpace(const char*& stringBuffer,
+ const char* const stringEndBuffer)
+{
+ for(; (WHITE_SPACE >= *stringBuffer) && (stringBuffer < stringEndBuffer); ++stringBuffer)
+ ;
+}
+
+void JumpToWhiteSpace(const char*& stringBuffer,
+ const char* const stringEndBuffer)
+{
+ for(; (WHITE_SPACE != *stringBuffer) && (stringBuffer < stringEndBuffer); ++stringBuffer)
+ ;
+}
+
+unsigned int StringToUint(const char* const uintStr)
+{
+ return static_cast<unsigned int>(strtoul(uintStr, NULL, 10));
+}
+
+unsigned int StringToHex(const char* const uintStr)
+{
+ return static_cast<unsigned int>(strtoul(uintStr, NULL, 16));
+}
+
+float StringToFloat(const char* const floatStr)
+{
+ return static_cast<float>(strtod(floatStr, NULL));
+}
+
+void FloatToString(float value, std::string& floatStr)
+{
+ std::stringstream ss;
+ ss << value;
+ floatStr = ss.str();
+}
+
+void UintToString(unsigned int value, std::string& uIntStr)
+{
+ std::stringstream ss;
+ ss << value;
+ uIntStr = ss.str();
+}
+
+void UintColorToVector4(unsigned int color, Vector4& retColor)
+{
+ retColor.a = static_cast<float>((color & 0xFF000000) >> 24u) / 255.f;
+ retColor.r = static_cast<float>((color & 0x00FF0000) >> 16u) / 255.f;
+ retColor.g = static_cast<float>((color & 0x0000FF00) >> 8u) / 255.f;
+ retColor.b = static_cast<float>(color & 0x000000FF) / 255.f;
+}
+
+void ColorStringToVector4(const char* const colorStr, Length length, Vector4& retColor)
+{
+ if(WEB_COLOR_TOKEN == *colorStr)
+ {
+ std::string webColor(colorStr + 1u, length - 1u);
+ if(4u == length) // 3 component web color #F00 (red)
+ {
+ webColor.insert(2u, &(webColor[2]), 1u);
+ webColor.insert(1u, &(webColor[1]), 1u);
+ webColor.insert(0u, &(webColor[0]), 1u);
+ webColor.insert(0u, ALPHA_ONE);
+ }
+ else if(7u == length) // 6 component web color #FF0000 (red)
+ {
+ webColor.insert(0u, ALPHA_ONE);
+ }
+
+ UintColorToVector4(StringToHex(webColor.c_str()), retColor);
+ }
+ else if(TokenComparison(HEX_COLOR_TOKEN, colorStr, 2u))
+ {
+ UintColorToVector4(StringToHex(colorStr + 2u), retColor);
+ }
+ else if(TokenComparison(BLACK_COLOR, colorStr, length))
+ {
+ retColor = Color::BLACK;
+ }
+ else if(TokenComparison(WHITE_COLOR, colorStr, length))
+ {
+ retColor = Color::WHITE;
+ }
+ else if(TokenComparison(RED_COLOR, colorStr, length))
+ {
+ retColor = Color::RED;
+ }
+ else if(TokenComparison(GREEN_COLOR, colorStr, length))
+ {
+ retColor = Color::GREEN;
+ }
+ else if(TokenComparison(BLUE_COLOR, colorStr, length))
+ {
+ retColor = Color::BLUE;
+ }
+ else if(TokenComparison(YELLOW_COLOR, colorStr, length))
+ {
+ retColor = Color::YELLOW;
+ }
+ else if(TokenComparison(MAGENTA_COLOR, colorStr, length))
+ {
+ retColor = Color::MAGENTA;
+ }
+ else if(TokenComparison(CYAN_COLOR, colorStr, length))
+ {
+ retColor = Color::CYAN;
+ }
+ else if(TokenComparison(TRANSPARENT_COLOR, colorStr, length))
+ {
+ retColor = Color::TRANSPARENT;
+ }
+}
+
+void Vector4ToColorString(const Vector4& value, std::string& vector2Str)
+{
+ if(Color::BLACK == value)
+ {
+ vector2Str = BLACK_COLOR;
+ return;
+ }
+
+ if(Color::WHITE == value)
+ {
+ vector2Str = WHITE_COLOR;
+ return;
+ }
+
+ if(Color::RED == value)
+ {
+ vector2Str = RED_COLOR;
+ return;
+ }
+
+ if(Color::GREEN == value)
+ {
+ vector2Str = GREEN_COLOR;
+ return;
+ }
+
+ if(Color::BLUE == value)
+ {
+ vector2Str = BLUE_COLOR;
+ return;
+ }
+
+ if(Color::YELLOW == value)
+ {
+ vector2Str = YELLOW_COLOR;
+ return;
+ }
+
+ if(Color::MAGENTA == value)
+ {
+ vector2Str = MAGENTA_COLOR;
+ return;
+ }
+
+ if(Color::CYAN == value)
+ {
+ vector2Str = CYAN_COLOR;
+ return;
+ }
+
+ if(Color::TRANSPARENT == value)
+ {
+ vector2Str = TRANSPARENT_COLOR;
+ return;
+ }
+
+ const unsigned int alpha = static_cast<unsigned int>(255.f * value.a);
+ const unsigned int red = static_cast<unsigned int>(255.f * value.r);
+ const unsigned int green = static_cast<unsigned int>(255.f * value.g);
+ const unsigned int blue = static_cast<unsigned int>(255.f * value.b);
+
+ std::stringstream ss;
+ const unsigned int size = 2u * sizeof(unsigned char);
+
+ ss << "0x"
+ << std::setfill('0') << std::setw(size)
+ << std::hex << alpha
+ << std::setfill('0') << std::setw(size)
+ << std::hex << red
+ << std::setfill('0') << std::setw(size)
+ << std::hex << green
+ << std::setfill('0') << std::setw(size)
+ << std::hex << blue;
+ vector2Str = ss.str();
+}
+
+void StringToVector2(const char* const vectorStr, Length length, Vector2& vector2)
+{
+ // Points to the first character of the string.
+ const char* strBuffer = vectorStr;
+
+ // Points to the first character of the 'x' value.
+ const char* const xBuffer = strBuffer;
+
+ // Jumps to the next white space.
+ JumpToWhiteSpace(strBuffer, strBuffer + length);
+
+ // Points to the first character of the 'y' value.
+ const char* const yBuffer = strBuffer;
+
+ // Converts the shadow's offset to float.
+ vector2.x = StringToFloat(xBuffer);
+ vector2.y = StringToFloat(yBuffer);
+}
+
+void Vector2ToString(const Vector2& value, std::string& vector2Str)
+{
+ FloatToString(value.x, vector2Str);
+ vector2Str += " ";
+
+ std::string yStr;
+ FloatToString(value.y, yStr);
+
+ vector2Str += yStr;
+}
+
+void UnderlineTypeStringToTypeValue(const char* const typeStr, Length length, Text::Underline::Type& retType)