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

Method SetValueFromString

cpp/src/Options.cpp:593–636  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Find an option by name -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

591// Find an option by name
592//-----------------------------------------------------------------------------
593bool Options::Option::SetValueFromString
594(
595 string const& _value
596)
597{
598 if( OptionType_Bool == m_type )
599 {
600 string lowerValue = ToLower( _value );
601 if( ( lowerValue == "true" ) || ( lowerValue == "1" ) )
602 {
603 m_valueBool = true;
604 return true;
605 }
606
607 if( ( lowerValue == "false" ) || ( lowerValue == "0" ) )
608 {
609 m_valueBool = false;
610 return true;
611 }
612
613 return false;
614 }
615
616 if( OptionType_Int == m_type )
617 {
618 m_valueInt = (int32)atol( _value.c_str() );
619 return true;
620 }
621
622 if( OptionType_String == m_type )
623 {
624 if( m_append && ( m_valueString.size() > 0 ) )
625 {
626 m_valueString += ( string(",") + _value );
627 }
628 else
629 {
630 m_valueString = _value;
631 }
632 return true;
633 }
634
635 return false;
636}

Callers 2

ParseOptionsStringMethod · 0.80
ParseOptionsXMLMethod · 0.80

Calls 3

ToLowerFunction · 0.85
c_strMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected