| 124 | //============================================================================// |
| 125 | |
| 126 | static bool parseNamedFormat(const char* str, fvec4& color) { |
| 127 | const char* end = TextUtils::skipNonWhitespace(str); |
| 128 | const size_t nameLen = (end - str); |
| 129 | if (nameLen <= 0) { |
| 130 | return false; |
| 131 | } |
| 132 | const std::string name(str, nameLen); |
| 133 | |
| 134 | const ColorMap& colorMap = getColorMap(); |
| 135 | ColorMap::const_iterator it = colorMap.find(TextUtils::tolower(name)); |
| 136 | if (it == colorMap.end()) { |
| 137 | return false; |
| 138 | } |
| 139 | |
| 140 | color = it->second; |
| 141 | |
| 142 | str = TextUtils::skipWhitespace(end); |
| 143 | if (*str == 0) { |
| 144 | return true; |
| 145 | } |
| 146 | |
| 147 | float alpha; |
| 148 | if (sscanf(str, "%f", &alpha) > 0) { |
| 149 | color.a = alpha; |
| 150 | } |
| 151 | |
| 152 | return true; |
| 153 | } |
| 154 | |
| 155 | |
| 156 | //============================================================================// |
no test coverage detected