----------------------------------------------------------------------------- Find an option by name -----------------------------------------------------------------------------
| 591 | // Find an option by name |
| 592 | //----------------------------------------------------------------------------- |
| 593 | bool 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 | } |
no test coverage detected