----------------------------------------------------------------------------- Creates a string representation of the value, regardless of type -----------------------------------------------------------------------------
| 2367 | // Creates a string representation of the value, regardless of type |
| 2368 | //----------------------------------------------------------------------------- |
| 2369 | bool Manager::GetValueAsString |
| 2370 | ( |
| 2371 | ValueID const& _id, |
| 2372 | string* o_value |
| 2373 | ) |
| 2374 | { |
| 2375 | bool res = false; |
| 2376 | char str[256] = {0}; |
| 2377 | |
| 2378 | if( o_value ) |
| 2379 | { |
| 2380 | if( Driver* driver = GetDriver( _id.GetHomeId() ) ) |
| 2381 | { |
| 2382 | LockGuard LG(driver->m_nodeMutex); |
| 2383 | |
| 2384 | switch( _id.GetType() ) |
| 2385 | { |
| 2386 | case ValueID::ValueType_BitSet: |
| 2387 | { |
| 2388 | if( ValueBitSet* value = static_cast<ValueBitSet*>( driver->GetValue( _id ) ) ) |
| 2389 | { |
| 2390 | *o_value = value->GetAsString(); |
| 2391 | value->Release(); |
| 2392 | res = true; |
| 2393 | } else { |
| 2394 | OZW_ERROR(OZWException::OZWEXCEPTION_INVALID_VALUEID, "Invalid ValueID passed to GetValueAsString"); |
| 2395 | } |
| 2396 | break; |
| 2397 | } |
| 2398 | case ValueID::ValueType_Bool: |
| 2399 | { |
| 2400 | if( ValueBool* value = static_cast<ValueBool*>( driver->GetValue( _id ) ) ) |
| 2401 | { |
| 2402 | *o_value = value->GetValue() ? "True" : "False"; |
| 2403 | value->Release(); |
| 2404 | res = true; |
| 2405 | } else { |
| 2406 | OZW_ERROR(OZWException::OZWEXCEPTION_INVALID_VALUEID, "Invalid ValueID passed to GetValueAsString"); |
| 2407 | } |
| 2408 | break; |
| 2409 | } |
| 2410 | case ValueID::ValueType_Byte: |
| 2411 | { |
| 2412 | if( ValueByte* value = static_cast<ValueByte*>( driver->GetValue( _id ) ) ) |
| 2413 | { |
| 2414 | snprintf( str, sizeof(str), "%u", value->GetValue() ); |
| 2415 | *o_value = str; |
| 2416 | value->Release(); |
| 2417 | res = true; |
| 2418 | } else { |
| 2419 | OZW_ERROR(OZWException::OZWEXCEPTION_INVALID_VALUEID, "Invalid ValueID passed to GetValueAsString"); |
| 2420 | } |
| 2421 | break; |
| 2422 | } |
| 2423 | case ValueID::ValueType_Decimal: |
| 2424 | { |
| 2425 | if( ValueDecimal* value = static_cast<ValueDecimal*>( driver->GetValue( _id ) ) ) |
| 2426 | { |
nothing calls this directly
no test coverage detected