Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Zolotarev <alex@maps.me>2016-01-09 21:59:18 +0300
committerSergey Yershov <yershov@corp.mail.ru>2016-03-23 16:04:25 +0300
commit9965e0757e629c1530d9e7c6f58be4798013ebb0 (patch)
tree86520f3e2f178d71e0dd3ca330ab1ca76e2deb66 /editor/xml_feature.cpp
parentc29a7615bf958d91f0fc88bf09734395a0aac3f9 (diff)
Split way and node validation for XMLFeature.
Diffstat (limited to 'editor/xml_feature.cpp')
-rw-r--r--editor/xml_feature.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/editor/xml_feature.cpp b/editor/xml_feature.cpp
index 610311f64b..3705e82a7b 100644
--- a/editor/xml_feature.cpp
+++ b/editor/xml_feature.cpp
@@ -57,6 +57,16 @@ void ValidateNode(pugi::xml_node const & node)
if (!node.attribute(kTimestamp))
MYTHROW(editor::XMLFeatureNoTimestampError, ("Node has no timestamp attribute"));
}
+
+void ValidateWay(pugi::xml_node const & way)
+{
+ if (!way)
+ MYTHROW(editor::XMLFeatureNoNodeError, ("Document has no node"));
+
+ if (!way.attribute(kTimestamp))
+ MYTHROW(editor::XMLFeatureNoTimestampError, ("Way has no timestamp attribute"));
+}
+
} // namespace
namespace editor
@@ -73,20 +83,23 @@ XMLFeature::XMLFeature(Type const type)
XMLFeature::XMLFeature(string const & xml)
{
m_document.load(xml.data());
- ValidateNode(GetRootNode());
+ auto const r = GetRootNode();
+ r.name() == kNodeType ? ValidateNode(r) : ValidateWay(r);
}
XMLFeature::XMLFeature(pugi::xml_document const & xml)
{
m_document.reset(xml);
- ValidateNode(GetRootNode());
+ auto const r = GetRootNode();
+ r.name() == kNodeType ? ValidateNode(r) : ValidateWay(r);
}
XMLFeature::XMLFeature(pugi::xml_node const & xml)
{
m_document.reset();
m_document.append_copy(xml);
- ValidateNode(GetRootNode());
+ auto const r = GetRootNode();
+ r.name() == kNodeType ? ValidateNode(r) : ValidateWay(r);
}
XMLFeature::Type XMLFeature::GetType() const