----------------------------------------------------------------------------- Write ourselves to an XML document -----------------------------------------------------------------------------
| 84 | // Write ourselves to an XML document |
| 85 | //----------------------------------------------------------------------------- |
| 86 | void Scene::WriteXML |
| 87 | ( |
| 88 | string const& _name |
| 89 | ) |
| 90 | { |
| 91 | char str[16]; |
| 92 | |
| 93 | // Create a new XML document to contain the driver configuration |
| 94 | TiXmlDocument doc; |
| 95 | TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "utf-8", "" ); |
| 96 | TiXmlElement* scenesElement = new TiXmlElement( "Scenes" ); |
| 97 | doc.LinkEndChild( decl ); |
| 98 | doc.LinkEndChild( scenesElement ); |
| 99 | |
| 100 | scenesElement->SetAttribute( "xmlns", "http://code.google.com/p/open-zwave/" ); |
| 101 | |
| 102 | snprintf( str, sizeof(str), "%d", c_sceneVersion ); |
| 103 | scenesElement->SetAttribute( "version", str); |
| 104 | |
| 105 | for( int i = 1; i < 256; i++ ) |
| 106 | { |
| 107 | if( s_scenes[i] == NULL ) |
| 108 | { |
| 109 | continue; |
| 110 | } |
| 111 | |
| 112 | TiXmlElement* sceneElement = new TiXmlElement( "Scene" ); |
| 113 | |
| 114 | snprintf( str, sizeof(str), "%d", i ); |
| 115 | sceneElement->SetAttribute( "id", str ); |
| 116 | sceneElement->SetAttribute( "label", s_scenes[i]->m_label.c_str() ); |
| 117 | |
| 118 | for( vector<SceneStorage*>::iterator vt = s_scenes[i]->m_values.begin(); vt != s_scenes[i]->m_values.end(); ++vt ) |
| 119 | { |
| 120 | TiXmlElement* valueElement = new TiXmlElement( "Value" ); |
| 121 | |
| 122 | snprintf( str, sizeof(str), "0x%.8x", (*vt)->m_id.GetHomeId() ); |
| 123 | valueElement->SetAttribute( "homeId", str ); |
| 124 | |
| 125 | snprintf( str, sizeof(str), "%d", (*vt)->m_id.GetNodeId() ); |
| 126 | valueElement->SetAttribute( "nodeId", str ); |
| 127 | |
| 128 | valueElement->SetAttribute( "genre", Value::GetGenreNameFromEnum((*vt)->m_id.GetGenre()) ); |
| 129 | |
| 130 | snprintf( str, sizeof(str), "%d", (*vt)->m_id.GetCommandClassId() ); |
| 131 | valueElement->SetAttribute( "commandClassId", str ); |
| 132 | |
| 133 | snprintf( str, sizeof(str), "%d", (*vt)->m_id.GetInstance() ); |
| 134 | valueElement->SetAttribute( "instance", str ); |
| 135 | |
| 136 | snprintf( str, sizeof(str), "%d", (*vt)->m_id.GetIndex() ); |
| 137 | valueElement->SetAttribute( "index", str ); |
| 138 | |
| 139 | valueElement->SetAttribute( "type", Value::GetTypeNameFromEnum((*vt)->m_id.GetType()) ); |
| 140 | |
| 141 | TiXmlText* textElement = new TiXmlText( (*vt)->m_value.c_str() ); |
| 142 | valueElement->LinkEndChild( textElement ); |
| 143 |
nothing calls this directly
no test coverage detected