summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'parse_xml.cpp')
-rw-r--r--parse_xml.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/parse_xml.cpp b/parse_xml.cpp
index 38a09b4..3d67e1c 100644
--- a/parse_xml.cpp
+++ b/parse_xml.cpp
@@ -473,22 +473,24 @@ KernelConfigConverter kernelConfigConverter{};
473struct HalInterfaceConverter : public XmlNodeConverter<HalInterface> { 473struct HalInterfaceConverter : public XmlNodeConverter<HalInterface> {
474 std::string elementName() const override { return "interface"; } 474 std::string elementName() const override { return "interface"; }
475 void mutateNode(const HalInterface &intf, NodeType *root, DocType *d) const override { 475 void mutateNode(const HalInterface &intf, NodeType *root, DocType *d) const override {
476 appendTextElement(root, "name", intf.name, d); 476 appendTextElement(root, "name", intf.name(), d);
477 appendTextElements(root, "instance", intf.instances, d); 477 appendTextElements(root, "instance", intf.mInstances, d);
478 } 478 }
479 bool buildObject(HalInterface* intf, NodeType* root, std::string* error) const override { 479 bool buildObject(HalInterface* intf, NodeType* root, std::string* error) const override {
480 std::vector<std::string> instances; 480 std::vector<std::string> instances;
481 if (!parseTextElement(root, "name", &intf->name, error) || 481 if (!parseTextElement(root, "name", &intf->mName, error) ||
482 !parseTextElements(root, "instance", &instances, error)) { 482 !parseTextElements(root, "instance", &instances, error)) {
483 return false; 483 return false;
484 } 484 }
485 intf->instances.clear(); 485 bool success = true;
486 intf->instances.insert(instances.begin(), instances.end()); 486 for (const auto& e : instances) {
487 if (intf->instances.size() != instances.size()) { 487 if (!intf->insertInstance(e, false /* isRegex */)) {
488 *error = "Duplicated instances in " + intf->name; 488 if (!error->empty()) *error += "\n";
489 return false; 489 *error += "Duplicated instance '" + e + "' in " + intf->name();
490 success = false;
491 }
490 } 492 }
491 return true; 493 return success;
492 } 494 }
493}; 495};
494 496
@@ -514,7 +516,7 @@ struct MatrixHalConverter : public XmlNodeConverter<MatrixHal> {
514 return false; 516 return false;
515 } 517 }
516 for (auto&& interface : interfaces) { 518 for (auto&& interface : interfaces) {
517 std::string name{interface.name}; 519 std::string name{interface.name()};
518 auto res = object->interfaces.emplace(std::move(name), std::move(interface)); 520 auto res = object->interfaces.emplace(std::move(name), std::move(interface));
519 if (!res.second) { 521 if (!res.second) {
520 *error = "Duplicated interface entry \"" + res.first->first + 522 *error = "Duplicated interface entry \"" + res.first->first +
@@ -663,8 +665,7 @@ struct ManifestHalConverter : public XmlNodeConverter<ManifestHal> {
663 665
664 object->interfaces.clear(); 666 object->interfaces.clear();
665 for (auto &&interface : interfaces) { 667 for (auto &&interface : interfaces) {
666 auto res = object->interfaces.emplace(interface.name, 668 auto res = object->interfaces.emplace(interface.name(), std::move(interface));
667 std::move(interface));
668 if (!res.second) { 669 if (!res.second) {
669 *error = "Duplicated interface entry \"" + res.first->first + 670 *error = "Duplicated interface entry \"" + res.first->first +
670 "\"; if additional instances are needed, add them to the " 671 "\"; if additional instances are needed, add them to the "