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

Method ReadScenes

cpp/src/Scene.cpp:162–265  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Read scene configuration from an XML document -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

160// Read scene configuration from an XML document
161//-----------------------------------------------------------------------------
162bool Scene::ReadScenes
163(
164)
165{
166 int32 intVal;
167 char const* str;
168
169 // Load the XML document that contains the driver configuration
170 string userPath;
171 Options::Get()->GetOptionAsString( "UserPath", &userPath );
172
173 string filename = userPath + "zwscene.xml";
174
175 TiXmlDocument doc;
176 if( !doc.LoadFile( filename.c_str(), TIXML_ENCODING_UTF8 ) )
177 {
178 return false;
179 }
180
181 TiXmlElement const* scenesElement = doc.RootElement();
182
183 // Version
184 if( TIXML_SUCCESS == scenesElement->QueryIntAttribute( "version", &intVal ) )
185 {
186 if( (uint32)intVal != c_sceneVersion )
187 {
188 Log::Write( LogLevel_Alert, "Driver::ReadScenes - %s is from an older version of OpenZWave and cannot be loaded.", filename.c_str() );
189 return false;
190 }
191 }
192 else
193 {
194 Log::Write( LogLevel_Alert, "Driver::ReadScenes - %s is from an older version of OpenZWave and cannot be loaded.", filename.c_str() );
195 return false;
196 }
197
198 TiXmlElement const* sceneElement = scenesElement->FirstChildElement();
199 while( sceneElement )
200 {
201 Scene* scene = NULL;
202
203 if( TIXML_SUCCESS == sceneElement->QueryIntAttribute( "id", &intVal ) )
204 {
205 scene = new Scene( (uint8)intVal );
206 }
207
208 if( scene == NULL )
209 {
210 continue;
211 }
212
213 str = sceneElement->Attribute( "label" );
214 if( str )
215 {
216 scene->m_label = str;
217 }
218
219 // Read the ValueId for this scene

Callers

nothing calls this directly

Calls 13

WriteFunction · 0.85
GetOptionAsStringMethod · 0.80
RootElementMethod · 0.80
QueryIntAttributeMethod · 0.80
AttributeMethod · 0.80
GetTextMethod · 0.80
GetFunction · 0.70
ValueIDClass · 0.70
LoadFileMethod · 0.45
c_strMethod · 0.45
FirstChildElementMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected