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

Method ReadXML

cpp/src/NotificationCCTypes.cpp:45–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45void NotificationCCTypes::ReadXML
46(
47)
48{
49 // Parse the Z-Wave manufacturer and product XML file.
50 string configPath;
51 Options::Get()->GetOptionAsString( "ConfigPath", &configPath );
52
53 string path = configPath + "NotificationCCTypes.xml";
54 TiXmlDocument* pDoc = new TiXmlDocument();
55 if( !pDoc->LoadFile( path.c_str(), TIXML_ENCODING_UTF8 ) )
56 {
57 delete pDoc;
58 Log::Write( LogLevel_Warning, "Unable to load NotificationCCTypes file %s", path.c_str());
59 return;
60 }
61 pDoc->SetUserData((void*)path.c_str());
62 Log::Write( LogLevel_Info, "Loading NotificationCCTypes File %s", path.c_str() );
63
64 TiXmlElement const* root = pDoc->RootElement();
65 char const *str = root->Value();
66 if( str && !strcmp( str, "NotificationTypes" ) )
67 {
68 // Read in the revision attributes
69 str = root->Attribute( "Revision" );
70 if( !str )
71 {
72 Log::Write( LogLevel_Info, "Error in Product Config file at line %d - missing Revision attribute", root->Row() );
73 delete pDoc;
74 return;
75 }
76 m_revision = atol(str);
77 }
78 TiXmlElement const* AlarmTypeElement = root->FirstChildElement();
79 while( AlarmTypeElement )
80 {
81 char const* str = AlarmTypeElement->Value();
82 char* pStopChar;
83 if( str && !strcmp( str, "AlarmType" ) )
84 {
85 NotificationTypes *nt = new NotificationTypes;
86
87 str = AlarmTypeElement->Attribute( "id" );
88 if( !str )
89 {
90 Log::Write( LogLevel_Warning, "NotificationCCTypes::ReadXML: Error in %s at line %d - missing AlarmType ID attribute", AlarmTypeElement->GetDocument()->GetUserData(), AlarmTypeElement->Row() );
91 AlarmTypeElement = AlarmTypeElement->NextSiblingElement();
92 delete nt;
93 continue;
94 }
95 nt->id = (uint32)strtol( str, &pStopChar, 10 );
96 str = AlarmTypeElement->Attribute( "name" );
97 if ( !str )
98 {
99 Log::Write( LogLevel_Warning, "NotificationCCTypes::ReadXML: Error in %s at line %d - missing AlarmType name attribute", AlarmTypeElement->GetDocument()->GetUserData(), AlarmTypeElement->Row() );
100 AlarmTypeElement = AlarmTypeElement->NextSiblingElement();
101 delete nt;
102 continue;

Callers

nothing calls this directly

Calls 15

WriteFunction · 0.85
GetOptionAsStringMethod · 0.80
SetUserDataMethod · 0.80
RootElementMethod · 0.80
AttributeMethod · 0.80
RowMethod · 0.80
GetUserDataMethod · 0.80
findMethod · 0.80
GetFunction · 0.70
LoadFileMethod · 0.45
c_strMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected