diff options
author | Adrian Szyndela <adrian.s@samsung.com> | 2020-10-27 10:12:22 +0100 |
---|---|---|
committer | Adrian Szyndela <adrian.s@samsung.com> | 2020-10-27 10:27:05 +0100 |
commit | 150ff53a07a3d1d94ea74c0c8a01a02fb00001a7 (patch) | |
tree | bae57cbe0617dc33a16d6fb235a0d8cef809f707 | |
parent | 4b97accaaf959355c477bf5bd10c2627d273e807 (diff) | |
download | libdbuspolicy-150ff53a07a3d1d94ea74c0c8a01a02fb00001a7.tar.gz libdbuspolicy-150ff53a07a3d1d94ea74c0c8a01a02fb00001a7.tar.bz2 libdbuspolicy-150ff53a07a3d1d94ea74c0c8a01a02fb00001a7.zip |
refactoring: generalize serialized enums conversion
Change-Id: Ia1fe8089c03605fe329bc3722bf7d99fe2117b21
-rw-r--r-- | src/internal/print_content.cpp | 10 | ||||
-rw-r--r-- | src/internal/serialized_convert.hpp | 17 |
2 files changed, 17 insertions, 10 deletions
diff --git a/src/internal/print_content.cpp b/src/internal/print_content.cpp index d65a433..cdded17 100644 --- a/src/internal/print_content.cpp +++ b/src/internal/print_content.cpp @@ -153,16 +153,16 @@ template <typename T> void printContentItem(std::ostream &stream, const T *item); template <> void printContentItem(std::ostream &stream, const FB::ItemAccess *item) { - print_content_item_access(stream, makeBusAccessType(item->type()), item->uid(), - item->gid(), makeDecisionItem(item->decision())); + print_content_item_access(stream, ldp_serialized::makeBusAccessType(item->type()), item->uid(), + item->gid(), ldp_serialized::makeDecisionItem(item->decision())); } template <typename T> void printContentItemSR(std::ostream &stream, const boost::string_ref &item_type, const T *item) { auto print_func = (print_content::xml_format ? print_content_item_sr_xml : print_content_item_sr); print_func(stream, item_type, item->name()->c_str(), item->interface()->c_str(), - item->member()->c_str(), item->path()->c_str(), makeMessageType(item->type()), - makeDecisionItem(item->decision()), item->is_name_prefix()); + item->member()->c_str(), item->path()->c_str(), ldp_serialized::makeMessageType(item->type()), + ldp_serialized::makeDecisionItem(item->decision()), item->is_name_prefix()); } template <> void printContentItem(std::ostream &stream, const FB::ItemSend *item) { @@ -182,7 +182,7 @@ void printContentPolicy(std::ostream &stream, const T *policy) { } void printDecisionItem(std::ostream &stream, const FB::DecisionItem *item) { - print_content_decision_item(stream, makeDecision(item->decision()), item->privilege()->c_str()); + print_content_decision_item(stream, ldp_serialized::makeDecision(item->decision()), item->privilege()->c_str()); } void printTreeLevel(std::ostream &stream, const FB::PolicyOwnNode *node, unsigned indent) { diff --git a/src/internal/serialized_convert.hpp b/src/internal/serialized_convert.hpp index f2c134b..de00f2f 100644 --- a/src/internal/serialized_convert.hpp +++ b/src/internal/serialized_convert.hpp @@ -15,21 +15,28 @@ */ #pragma once -#include "include/fb_generated.h" #include "policy.hpp" -inline ldp_xml_parser::Decision makeDecision(FB::Decision d) { +namespace ldp_serialized { + +template <typename D> +ldp_xml_parser::Decision makeDecision(D d) { return static_cast<ldp_xml_parser::Decision>(d); } -inline ldp_xml_parser::DecisionItem makeDecisionItem(const FB::DecisionItem *di) { +template <typename DI> +inline ldp_xml_parser::DecisionItem makeDecisionItem(const DI *di) { return ldp_xml_parser::DecisionItem(makeDecision(di->decision()), di->privilege()->c_str()); } -inline ldp_xml_parser::BusAccessType makeBusAccessType(FB::BusAccessType type) { +template <typename T> +ldp_xml_parser::BusAccessType makeBusAccessType(T type) { return static_cast<ldp_xml_parser::BusAccessType>(type); } -inline ldp_xml_parser::MessageType makeMessageType(FB::MessageType type) { +template <typename T> +ldp_xml_parser::MessageType makeMessageType(T type) { return static_cast<ldp_xml_parser::MessageType>(type); } + +} |