MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / GetColor

Function GetColor

cpp/src/command_classes/Color.cpp:252–264  ·  view source on GitHub ↗

----------------------------------------------------------------------------- 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 -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

250// throws a exception when position is out of bounds
251//-----------------------------------------------------------------------------
252uint16 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>

Callers 1

SetValueMethod · 0.85

Calls 3

WriteFunction · 0.85
lengthMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected