----------------------------------------------------------------------------- Get a Specific Color Value from a position in a RGB String its assumed the string is formated such as #RRGGBB[WWCWAMCYPR] where the color values in [] are optional. throws a exception when position is out of bounds -----------------------------------------------------------------------------
| 250 | // throws a exception when position is out of bounds |
| 251 | //----------------------------------------------------------------------------- |
| 252 | uint16 GetColor(string rgbstring, uint8 const position) { |
| 253 | |
| 254 | /* check the length of the string based on position value we passed in including the #*/ |
| 255 | if (rgbstring.length() < (size_t)(position *2)+1) { |
| 256 | Log::Write( LogLevel_Warning, "Request for Color Position %d exceeds String Length: %s", position, rgbstring.c_str()); |
| 257 | throw; |
| 258 | } |
| 259 | string result = rgbstring.substr(((position - 1) * 2) +1, 2); |
| 260 | std::stringstream ss(result); |
| 261 | uint16 rawresult; |
| 262 | ss >> std::hex >> rawresult; |
| 263 | return rawresult; |
| 264 | } |
| 265 | |
| 266 | //----------------------------------------------------------------------------- |
| 267 | // <Color::HandleMsg> |