fixed some potential issues with MAC addresses
added corresponding test-cases switched to newer version of tinyxml due to some issues adjusted affected code-parts accordingly for better re-use, moved ceiling-calculation to a new class some minor fixes new helper methods worked on wifi-opt
This commit is contained in:
@@ -35,11 +35,12 @@ namespace Floorplan {
|
||||
if (res != tinyxml2::XMLError::XML_SUCCESS) {
|
||||
throw Exception(
|
||||
std::string() + "error while loading XML " + file + "\n" +
|
||||
((doc.GetErrorStr1()) ? (doc.GetErrorStr1()) : ("")) + "\n" +
|
||||
((doc.GetErrorStr2()) ? (doc.GetErrorStr2()) : (""))
|
||||
((doc.GetErrorStr1()) ? (doc.GetErrorStr1()) : ("")) + "\n" +
|
||||
((doc.GetErrorStr2()) ? (doc.GetErrorStr2()) : (""))
|
||||
);
|
||||
}
|
||||
return parse(doc);
|
||||
IndoorMap* map = parse(doc);
|
||||
return map;
|
||||
}
|
||||
|
||||
/** read an IndoorMap from the given XMl-string */
|
||||
@@ -51,16 +52,17 @@ namespace Floorplan {
|
||||
if (res != tinyxml2::XMLError::XML_SUCCESS) {
|
||||
throw Exception(
|
||||
std::string() + "error while parsing XML\n" +
|
||||
((doc.GetErrorStr1()) ? (doc.GetErrorStr1()) : ("")) + "\n" +
|
||||
((doc.GetErrorStr2()) ? (doc.GetErrorStr2()) : (""))
|
||||
((doc.GetErrorStr1()) ? (doc.GetErrorStr1()) : ("")) + "\n" +
|
||||
((doc.GetErrorStr2()) ? (doc.GetErrorStr2()) : (""))
|
||||
);
|
||||
}
|
||||
return parse(doc);
|
||||
IndoorMap* map = parse(doc);
|
||||
return map;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
#define FOREACH_NODE(out, in) for( const XMLElem* out = (XMLElem*) in->FirstChild(); out; out = (XMLElem*) out->NextSibling() )
|
||||
#define FOREACH_NODE(out, in) for( const XMLElem* out = in->FirstChildElement(); out; out = out->NextSiblingElement() )
|
||||
|
||||
static void assertNode(const std::string& node, const XMLElem* el) {
|
||||
std::string err = std::string("unexpected node '") + el->Name() + "' expected '" + node + "'";
|
||||
@@ -69,7 +71,7 @@ namespace Floorplan {
|
||||
|
||||
/** parse the complete document */
|
||||
static IndoorMap* parse(tinyxml2::XMLDocument& doc) {
|
||||
return parseMap((XMLElem*)doc.FirstChild());
|
||||
return parseMap(doc.FirstChildElement());
|
||||
}
|
||||
|
||||
/** parse the <map> node */
|
||||
@@ -266,7 +268,9 @@ namespace Floorplan {
|
||||
const XMLElem* sub = n->FirstChildElement();
|
||||
while(sub) {
|
||||
// <entry key="123">abc</entry>
|
||||
elem->add(sub->Attribute("key"), sub->FirstChild()->Value());
|
||||
const std::string key = sub->Attribute("key");
|
||||
const std::string val = sub->GetText();
|
||||
elem->add(key, val);
|
||||
sub = sub->NextSiblingElement();
|
||||
}
|
||||
return elem;
|
||||
@@ -402,7 +406,7 @@ namespace Floorplan {
|
||||
FloorOutline outline;
|
||||
FOREACH_NODE(n, el) {
|
||||
if (std::string("polygon") == n->Name()) {
|
||||
outline.push_back(parseFloorPolygon(n)); // TODO
|
||||
outline.push_back(parseFloorPolygon(n));
|
||||
}
|
||||
}
|
||||
return outline;
|
||||
@@ -427,6 +431,9 @@ namespace Floorplan {
|
||||
poly.points.push_back(p2);
|
||||
}
|
||||
}
|
||||
if (poly.points.size() < 4 || poly.points.size() > 1024) {
|
||||
throw Exception("detected invalid outline-polygon during XML parsing");
|
||||
}
|
||||
return poly;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user