MCPcopy Create free account
hub / github.com/MyGUI/mygui / parse

Method parse

MyGUIEngine/src/MyGUI_Colour.cpp:63–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61 }
62
63 Colour Colour::parse(std::string_view _value)
64 {
65 if (!_value.empty())
66 {
67 if (_value[0] == '#')
68 {
69 std::stringstream stream;
70 stream << _value.substr(1);
71 int result = 0;
72 stream >> std::hex >> result;
73 if (!stream.fail())
74 {
75 return {
76 (unsigned char)(result >> 16) / 256.0f,
77 (unsigned char)(result >> 8) / 256.0f,
78 (unsigned char)(result) / 256.0f};
79 }
80 }
81 else
82 {
83 float red;
84 float green;
85 float blue;
86 std::stringstream stream;
87 stream << _value;
88 stream >> red >> green >> blue;
89 if (!stream.fail())
90 {
91 float alpha = ALPHA_MAX;
92 if (!stream.eof())
93 stream >> alpha;
94 return {red, green, blue, alpha};
95 }
96 }
97 }
98 return Colour::Zero;
99 }
100
101 std::ostream& Colour::operatorShiftLeft(std::ostream& _stream, const Colour& _value)
102 {

Callers

nothing calls this directly

Calls 3

substrMethod · 0.80
emptyMethod · 0.45
eofMethod · 0.45

Tested by

no test coverage detected