takes a string of hex and resolves it to an integer
| 337 | |
| 338 | //takes a string of hex and resolves it to an integer |
| 339 | unsigned int ThemeComponent::resolveColor(std::string str, unsigned int defaultColor) |
| 340 | { |
| 341 | if(str.empty()) |
| 342 | return defaultColor; |
| 343 | |
| 344 | if(str.length() != 6 && str.length() != 8) |
| 345 | { |
| 346 | LOG(LogError) << "Color \"" << str << "\" is not a valid hex color! Must be 6 or 8 characters."; |
| 347 | return defaultColor; |
| 348 | } |
| 349 | |
| 350 | //if there's no alpha specified, assume FF |
| 351 | if(str.length() == 6) |
| 352 | str += "FF"; |
| 353 | |
| 354 | unsigned int ret; |
| 355 | std::stringstream ss; |
| 356 | ss << std::hex << str; |
| 357 | ss >> ret; |
| 358 | |
| 359 | return ret; |
| 360 | } |
| 361 | |
| 362 | //splits a string in two at the first instance of the delimiter |
| 363 | void ThemeComponent::splitString(std::string str, char delim, std::string* before, std::string* after) |