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

Method ReadXML

cpp/src/CompatOptionManager.cpp:154–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152}
153
154void CompatOptionManager::ReadXML
155(
156 TiXmlElement const* _ccElement
157)
158{
159 TiXmlElement const *compatElement = _ccElement->FirstChildElement(GetXMLTagName().c_str());
160
161 map<string,CompatOptionFlags>::iterator it;
162 string value;
163 for ( it = m_enabledCompatFlags.begin(); it != m_enabledCompatFlags.end(); it++)
164 {
165 if (compatElement)
166 {
167 TiXmlElement const *valElement = compatElement->FirstChildElement(it->first.c_str());
168 if (valElement) value = valElement->GetText();
169 }
170 if (!value.empty()) {
171 char* pStopChar;
172 uint32_t val = strtol( value.c_str(), &pStopChar, 10 );;
173
174 switch (m_CompatVals[it->second].type) {
175 case COMPAT_FLAG_TYPE_BOOL:
176 m_CompatVals[it->second].valBool = !strcmp(value.c_str(), "true");
177 break;
178 case COMPAT_FLAG_TYPE_BYTE:
179 if (val > UINT8_MAX) {
180 Log::Write(LogLevel_Warning, m_owner->GetNodeId(), "ReadXML: (%s) - Value for %s is larger than a byte", m_owner->GetCommandClassName().c_str(), it->first.c_str());
181 val = 0;
182 }
183 m_CompatVals[it->second].valByte = val;
184 break;
185 case COMPAT_FLAG_TYPE_SHORT:
186 if (val > UINT16_MAX) {
187 Log::Write(LogLevel_Warning, m_owner->GetNodeId(), "ReadXML: (%s) - Value for %s is larger than a short", m_owner->GetCommandClassName().c_str(), it->first.c_str());
188 val = 0;
189 }
190 m_CompatVals[it->second].valShort = val;
191 break;
192 case COMPAT_FLAG_TYPE_INT:
193 if (val > UINT32_MAX) {
194 Log::Write(LogLevel_Warning, m_owner->GetNodeId(), "ReadXML: (%s) - Value for %s is larger than a int", m_owner->GetCommandClassName().c_str(), it->first.c_str());
195 val = 0;
196 }
197 m_CompatVals[it->second].valInt = val;
198 m_CompatVals[it->second].changed = true;
199 break;
200 }
201 }
202 }
203 {
204 map<string,CompatOptionFlags>::iterator it;
205 Log::Write(LogLevel_Info, m_owner->GetNodeId(), "(%s) - Compatibility Flags: (* = default)", m_owner->GetCommandClassName().c_str());
206 for ( it = m_enabledCompatFlags.begin(); it != m_enabledCompatFlags.end(); it++)
207 {
208 switch (m_CompatVals[it->second].type) {
209 case COMPAT_FLAG_TYPE_BOOL:
210 Log::Write(LogLevel_Info, m_owner->GetNodeId(), "\t %s: %s %s", it->first.c_str(), m_CompatVals[it->second].valBool ? "true": "false", m_CompatVals[it->second].changed ? "" : "*");
211 break;

Callers

nothing calls this directly

Calls 9

WriteFunction · 0.85
GetTextMethod · 0.80
GetNodeIdMethod · 0.80
FirstChildElementMethod · 0.45
c_strMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
GetCommandClassNameMethod · 0.45

Tested by

no test coverage detected