summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYifan Hong2018-08-07 19:41:56 -0500
committerYifan Hong2018-08-08 12:07:39 -0500
commit250b55c08e84951c0a615857f2bba46b6888d818 (patch)
treee7f0e2eea12191d26552c0c27ccfba9af232c0ac /parse_xml.cpp
parente6a770a85d60c756fcee5c33c6722e5592b5bb8b (diff)
downloadplatform-system-libvintf-250b55c08e84951c0a615857f2bba46b6888d818.tar.gz
platform-system-libvintf-250b55c08e84951c0a615857f2bba46b6888d818.tar.xz
platform-system-libvintf-250b55c08e84951c0a615857f2bba46b6888d818.zip
SerializeFlag => SerializeFlags
This is a straightforward refactoring to remove the SerializeFlag enum. They are combined into one class because SerializeFlag is the old negative bitfields and is confusing. SerializeFlags will contain positive bitfields. Bug: 110711640 Test: libvintf_test Change-Id: I46070db674955add4971b0dc5736a43436f54ddf
Diffstat (limited to 'parse_xml.cpp')
-rw-r--r--parse_xml.cpp42
1 files changed, 21 insertions, 21 deletions
diff --git a/parse_xml.cpp b/parse_xml.cpp
index 7947fc3..fba8dfd 100644
--- a/parse_xml.cpp
+++ b/parse_xml.cpp
@@ -150,7 +150,7 @@ struct XmlNodeConverter : public XmlConverter<Object> {
150 // convenience methods for user 150 // convenience methods for user
151 inline const std::string& lastError() const override { return mLastError; } 151 inline const std::string& lastError() const override { return mLastError; }
152 inline NodeType* serialize(const Object& o, DocType* d, 152 inline NodeType* serialize(const Object& o, DocType* d,
153 SerializeFlags flags = EVERYTHING) const { 153 SerializeFlags flags = SerializeFlags::EVERYTHING) const {
154 NodeType *root = createNode(this->elementName(), d); 154 NodeType *root = createNode(this->elementName(), d);
155 this->mutateNode(o, root, d, flags); 155 this->mutateNode(o, root, d, flags);
156 return root; 156 return root;
@@ -234,7 +234,7 @@ struct XmlNodeConverter : public XmlConverter<Object> {
234 template <typename T, typename Array> 234 template <typename T, typename Array>
235 inline void appendChildren(NodeType* parent, const XmlNodeConverter<T>& conv, 235 inline void appendChildren(NodeType* parent, const XmlNodeConverter<T>& conv,
236 const Array& array, DocType* d, 236 const Array& array, DocType* d,
237 SerializeFlags flags = SerializeFlag::EVERYTHING) const { 237 SerializeFlags flags = SerializeFlags::EVERYTHING) const {
238 for (const T &t : array) { 238 for (const T &t : array) {
239 appendChild(parent, conv.serialize(t, d, flags)); 239 appendChild(parent, conv.serialize(t, d, flags));
240 } 240 }
@@ -602,12 +602,12 @@ MatrixKernelConditionsConverter matrixKernelConditionsConverter{};
602struct MatrixKernelConverter : public XmlNodeConverter<MatrixKernel> { 602struct MatrixKernelConverter : public XmlNodeConverter<MatrixKernel> {
603 std::string elementName() const override { return "kernel"; } 603 std::string elementName() const override { return "kernel"; }
604 void mutateNode(const MatrixKernel& kernel, NodeType* root, DocType* d) const override { 604 void mutateNode(const MatrixKernel& kernel, NodeType* root, DocType* d) const override {
605 mutateNode(kernel, root, d, SerializeFlag::EVERYTHING); 605 mutateNode(kernel, root, d, SerializeFlags::EVERYTHING);
606 } 606 }
607 void mutateNode(const MatrixKernel& kernel, NodeType* root, DocType* d, 607 void mutateNode(const MatrixKernel& kernel, NodeType* root, DocType* d,
608 SerializeFlags flags) const override { 608 SerializeFlags flags) const override {
609 KernelVersion kv = kernel.mMinLts; 609 KernelVersion kv = kernel.mMinLts;
610 if (flags & SerializeFlag::NO_KERNEL_MINOR_REVISION) { 610 if (flags & SerializeFlags::NO_KERNEL_MINOR_REVISION) {
611 kv.minorRev = 0u; 611 kv.minorRev = 0u;
612 } 612 }
613 appendAttr(root, "version", kv); 613 appendAttr(root, "version", kv);
@@ -615,7 +615,7 @@ struct MatrixKernelConverter : public XmlNodeConverter<MatrixKernel> {
615 if (!kernel.mConditions.empty()) { 615 if (!kernel.mConditions.empty()) {
616 appendChild(root, matrixKernelConditionsConverter(kernel.mConditions, d)); 616 appendChild(root, matrixKernelConditionsConverter(kernel.mConditions, d));
617 } 617 }
618 if (!(flags & SerializeFlag::NO_KERNEL_CONFIGS)) { 618 if (!(flags & SerializeFlags::NO_KERNEL_CONFIGS)) {
619 appendChildren(root, kernelConfigConverter, kernel.mConfigs, d); 619 appendChildren(root, kernelConfigConverter, kernel.mConfigs, d);
620 } 620 }
621 } 621 }
@@ -637,7 +637,7 @@ XmlTextConverter<FqInstance> fqInstanceConverter{"fqname"};
637struct ManifestHalConverter : public XmlNodeConverter<ManifestHal> { 637struct ManifestHalConverter : public XmlNodeConverter<ManifestHal> {
638 std::string elementName() const override { return "hal"; } 638 std::string elementName() const override { return "hal"; }
639 void mutateNode(const ManifestHal& m, NodeType* root, DocType* d) const override { 639 void mutateNode(const ManifestHal& m, NodeType* root, DocType* d) const override {
640 mutateNode(m, root, d, SerializeFlag::EVERYTHING); 640 mutateNode(m, root, d, SerializeFlags::EVERYTHING);
641 } 641 }
642 void mutateNode(const ManifestHal& hal, NodeType* root, DocType* d, 642 void mutateNode(const ManifestHal& hal, NodeType* root, DocType* d,
643 SerializeFlags flags) const override { 643 SerializeFlags flags) const override {
@@ -650,7 +650,7 @@ struct ManifestHalConverter : public XmlNodeConverter<ManifestHal> {
650 appendAttr(root, "override", hal.isOverride()); 650 appendAttr(root, "override", hal.isOverride());
651 } 651 }
652 652
653 if (!(flags & SerializeFlag::NO_FQNAME)) { 653 if (!(flags & SerializeFlags::NO_FQNAME)) {
654 std::set<FqInstance> fqInstances; 654 std::set<FqInstance> fqInstances;
655 hal.forEachInstance([&fqInstances](const auto& manifestInstance) { 655 hal.forEachInstance([&fqInstances](const auto& manifestInstance) {
656 fqInstances.emplace(manifestInstance.getFqInstanceNoPackage()); 656 fqInstances.emplace(manifestInstance.getFqInstanceNoPackage());
@@ -861,25 +861,25 @@ ManifestXmlFileConverter manifestXmlFileConverter{};
861struct HalManifestConverter : public XmlNodeConverter<HalManifest> { 861struct HalManifestConverter : public XmlNodeConverter<HalManifest> {
862 std::string elementName() const override { return "manifest"; } 862 std::string elementName() const override { return "manifest"; }
863 void mutateNode(const HalManifest &m, NodeType *root, DocType *d) const override { 863 void mutateNode(const HalManifest &m, NodeType *root, DocType *d) const override {
864 mutateNode(m, root, d, SerializeFlag::EVERYTHING); 864 mutateNode(m, root, d, SerializeFlags::EVERYTHING);
865 } 865 }
866 void mutateNode(const HalManifest& m, NodeType* root, DocType* d, 866 void mutateNode(const HalManifest& m, NodeType* root, DocType* d,
867 SerializeFlags flags) const override { 867 SerializeFlags flags) const override {
868 appendAttr(root, "version", m.getMetaVersion()); 868 appendAttr(root, "version", m.getMetaVersion());
869 appendAttr(root, "type", m.mType); 869 appendAttr(root, "type", m.mType);
870 870
871 if (!(flags & SerializeFlag::NO_HALS)) { 871 if (!(flags & SerializeFlags::NO_HALS)) {
872 appendChildren(root, manifestHalConverter, m.getHals(), d, flags); 872 appendChildren(root, manifestHalConverter, m.getHals(), d, flags);
873 } 873 }
874 if (m.mType == SchemaType::DEVICE) { 874 if (m.mType == SchemaType::DEVICE) {
875 if (!(flags & SerializeFlag::NO_SEPOLICY)) { 875 if (!(flags & SerializeFlags::NO_SEPOLICY)) {
876 appendChild(root, halManifestSepolicyConverter(m.device.mSepolicyVersion, d)); 876 appendChild(root, halManifestSepolicyConverter(m.device.mSepolicyVersion, d));
877 } 877 }
878 if (m.mLevel != Level::UNSPECIFIED) { 878 if (m.mLevel != Level::UNSPECIFIED) {
879 this->appendAttr(root, "target-level", m.mLevel); 879 this->appendAttr(root, "target-level", m.mLevel);
880 } 880 }
881 } else if (m.mType == SchemaType::FRAMEWORK) { 881 } else if (m.mType == SchemaType::FRAMEWORK) {
882 if (!(flags & SerializeFlag::NO_VNDK)) { 882 if (!(flags & SerializeFlags::NO_VNDK)) {
883#pragma clang diagnostic push 883#pragma clang diagnostic push
884#pragma clang diagnostic ignored "-Wdeprecated-declarations" 884#pragma clang diagnostic ignored "-Wdeprecated-declarations"
885 appendChildren(root, vndkConverter, m.framework.mVndks, d); 885 appendChildren(root, vndkConverter, m.framework.mVndks, d);
@@ -887,14 +887,14 @@ struct HalManifestConverter : public XmlNodeConverter<HalManifest> {
887 887
888 appendChildren(root, vendorNdkConverter, m.framework.mVendorNdks, d); 888 appendChildren(root, vendorNdkConverter, m.framework.mVendorNdks, d);
889 } 889 }
890 if (!(flags & SerializeFlag::NO_SSDK)) { 890 if (!(flags & SerializeFlags::NO_SSDK)) {
891 if (!m.framework.mSystemSdk.empty()) { 891 if (!m.framework.mSystemSdk.empty()) {
892 appendChild(root, systemSdkConverter(m.framework.mSystemSdk, d)); 892 appendChild(root, systemSdkConverter(m.framework.mSystemSdk, d));
893 } 893 }
894 } 894 }
895 } 895 }
896 896
897 if (!(flags & SerializeFlag::NO_XMLFILES)) { 897 if (!(flags & SerializeFlags::NO_XMLFILES)) {
898 appendChildren(root, manifestXmlFileConverter, m.getXmlFiles(), d); 898 appendChildren(root, manifestXmlFileConverter, m.getXmlFiles(), d);
899 } 899 }
900 } 900 }
@@ -1022,26 +1022,26 @@ MatrixXmlFileConverter matrixXmlFileConverter{};
1022struct CompatibilityMatrixConverter : public XmlNodeConverter<CompatibilityMatrix> { 1022struct CompatibilityMatrixConverter : public XmlNodeConverter<CompatibilityMatrix> {
1023 std::string elementName() const override { return "compatibility-matrix"; } 1023 std::string elementName() const override { return "compatibility-matrix"; }
1024 void mutateNode(const CompatibilityMatrix &m, NodeType *root, DocType *d) const override { 1024 void mutateNode(const CompatibilityMatrix &m, NodeType *root, DocType *d) const override {
1025 mutateNode(m, root, d, SerializeFlag::EVERYTHING); 1025 mutateNode(m, root, d, SerializeFlags::EVERYTHING);
1026 } 1026 }
1027 void mutateNode(const CompatibilityMatrix& m, NodeType* root, DocType* d, 1027 void mutateNode(const CompatibilityMatrix& m, NodeType* root, DocType* d,
1028 SerializeFlags flags) const override { 1028 SerializeFlags flags) const override {
1029 appendAttr(root, "version", m.getMinimumMetaVersion()); 1029 appendAttr(root, "version", m.getMinimumMetaVersion());
1030 appendAttr(root, "type", m.mType); 1030 appendAttr(root, "type", m.mType);
1031 1031
1032 if (!(flags & SerializeFlag::NO_HALS)) { 1032 if (!(flags & SerializeFlags::NO_HALS)) {
1033 appendChildren(root, matrixHalConverter, iterateValues(m.mHals), d); 1033 appendChildren(root, matrixHalConverter, iterateValues(m.mHals), d);
1034 } 1034 }
1035 if (m.mType == SchemaType::FRAMEWORK) { 1035 if (m.mType == SchemaType::FRAMEWORK) {
1036 if (!(flags & SerializeFlag::NO_KERNEL)) { 1036 if (!(flags & SerializeFlags::NO_KERNEL)) {
1037 appendChildren(root, matrixKernelConverter, m.framework.mKernels, d, flags); 1037 appendChildren(root, matrixKernelConverter, m.framework.mKernels, d, flags);
1038 } 1038 }
1039 if (!(flags & SerializeFlag::NO_SEPOLICY)) { 1039 if (!(flags & SerializeFlags::NO_SEPOLICY)) {
1040 if (!(m.framework.mSepolicy == Sepolicy{})) { 1040 if (!(m.framework.mSepolicy == Sepolicy{})) {
1041 appendChild(root, sepolicyConverter(m.framework.mSepolicy, d)); 1041 appendChild(root, sepolicyConverter(m.framework.mSepolicy, d));
1042 } 1042 }
1043 } 1043 }
1044 if (!(flags & SerializeFlag::NO_AVB)) { 1044 if (!(flags & SerializeFlags::NO_AVB)) {
1045 if (!(m.framework.mAvbMetaVersion == Version{})) { 1045 if (!(m.framework.mAvbMetaVersion == Version{})) {
1046 appendChild(root, avbConverter(m.framework.mAvbMetaVersion, d)); 1046 appendChild(root, avbConverter(m.framework.mAvbMetaVersion, d));
1047 } 1047 }
@@ -1050,7 +1050,7 @@ struct CompatibilityMatrixConverter : public XmlNodeConverter<CompatibilityMatri
1050 this->appendAttr(root, "level", m.mLevel); 1050 this->appendAttr(root, "level", m.mLevel);
1051 } 1051 }
1052 } else if (m.mType == SchemaType::DEVICE) { 1052 } else if (m.mType == SchemaType::DEVICE) {
1053 if (!(flags & SerializeFlag::NO_VNDK)) { 1053 if (!(flags & SerializeFlags::NO_VNDK)) {
1054#pragma clang diagnostic push 1054#pragma clang diagnostic push
1055#pragma clang diagnostic ignored "-Wdeprecated-declarations" 1055#pragma clang diagnostic ignored "-Wdeprecated-declarations"
1056 if (!(m.device.mVndk == Vndk{})) { 1056 if (!(m.device.mVndk == Vndk{})) {
@@ -1063,14 +1063,14 @@ struct CompatibilityMatrixConverter : public XmlNodeConverter<CompatibilityMatri
1063 } 1063 }
1064 } 1064 }
1065 1065
1066 if (!(flags & SerializeFlag::NO_SSDK)) { 1066 if (!(flags & SerializeFlags::NO_SSDK)) {
1067 if (!m.device.mSystemSdk.empty()) { 1067 if (!m.device.mSystemSdk.empty()) {
1068 appendChild(root, systemSdkConverter(m.device.mSystemSdk, d)); 1068 appendChild(root, systemSdkConverter(m.device.mSystemSdk, d));
1069 } 1069 }
1070 } 1070 }
1071 } 1071 }
1072 1072
1073 if (!(flags & SerializeFlag::NO_XMLFILES)) { 1073 if (!(flags & SerializeFlags::NO_XMLFILES)) {
1074 appendChildren(root, matrixXmlFileConverter, m.getXmlFiles(), d); 1074 appendChildren(root, matrixXmlFileConverter, m.getXmlFiles(), d);
1075 } 1075 }
1076 } 1076 }