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

Method ParseOptionsXML

cpp/src/Options.cpp:500–543  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Parse an XML file containing program options -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

498// Parse an XML file containing program options
499//-----------------------------------------------------------------------------
500bool Options::ParseOptionsXML
501(
502 string const& _filename
503)
504{
505 TiXmlDocument doc;
506 if( !doc.LoadFile( _filename.c_str(), TIXML_ENCODING_UTF8 ) )
507 {
508 Log::Write(LogLevel_Warning, "Failed to Parse %s: %s", _filename.c_str(), doc.ErrorDesc());
509 return false;
510 }
511 doc.SetUserData((void *)_filename.c_str());
512 Log::Write(LogLevel_Info, "Reading %s for Options", _filename.c_str());
513
514 TiXmlElement const* optionsElement = doc.RootElement();
515
516 // Read the options
517 TiXmlElement const* optionElement = optionsElement->FirstChildElement();
518 while( optionElement )
519 {
520 char const* str = optionElement->Value();
521 if( str && !strcmp( str, "Option" ) )
522 {
523 char const* name = optionElement->Attribute( "name" );
524 if( name )
525 {
526 Option* option = Find( name );
527 if( option )
528 {
529 char const* value = optionElement->Attribute( "value" );
530 if( value )
531 {
532 // Set the value
533 option->SetValueFromString( value );
534 }
535 }
536 }
537 }
538
539 optionElement = optionElement->NextSiblingElement();
540 }
541
542 return true;
543}
544
545//-----------------------------------------------------------------------------
546// <Options::AddOption>

Callers

nothing calls this directly

Calls 11

WriteFunction · 0.85
ErrorDescMethod · 0.80
SetUserDataMethod · 0.80
RootElementMethod · 0.80
AttributeMethod · 0.80
SetValueFromStringMethod · 0.80
LoadFileMethod · 0.45
c_strMethod · 0.45
FirstChildElementMethod · 0.45
ValueMethod · 0.45
NextSiblingElementMethod · 0.45

Tested by

no test coverage detected