#include "include/flatbuffers/flatbuffers.h"
#include "include/fb_generated.h"
-using namespace std;
-
namespace ldp_xml_parser {
-map<Decision, FB::Decision> decisions_map {
+std::map<Decision, FB::Decision> decisions_map {
{ Decision::ANY, FB::Decision_ANY },
{ Decision::DENY, FB::Decision_DENY },
{ Decision::ALLOW, FB::Decision_ALLOW },
{ Decision::CHECK, FB::Decision_CHECK }
};
-map<BusAccessType, FB::BusAccessType> bus_access_map {
+std::map<BusAccessType, FB::BusAccessType> bus_access_map {
{ BusAccessType::USER, FB::BusAccessType_USER },
{ BusAccessType::GROUP, FB::BusAccessType_GROUP },
{ BusAccessType::ALL_USERS, FB::BusAccessType_ALL_USERS },
{ BusAccessType::ALL_GROUPS, FB::BusAccessType_ALL_GROUPS },
};
-map<MessageType, FB::MessageType> message_type_map {
+std::map<MessageType, FB::MessageType> message_type_map {
{ MessageType::ANY, FB::MessageType_ANY },
{ MessageType::METHOD_CALL, FB::MessageType_METHOD_CALL },
{ MessageType::METHOD_RETURN, FB::MessageType_METHOD_RETURN },
ldp_xml::StorageBackendXML xmlStorage;
if (!xmlStorage.init(config_path.c_str())) {
- cout << "internal_init error" << endl;
+ std::cout << "internal_init error" << std::endl;
return nullptr;
}
return serialize(xmlStorage, size);
}
-void Serializer::serialize(const std::string config_path, ostream &output) {
+void Serializer::serialize(const std::string config_path, std::ostream &output) {
size_t size;
uint8_t *buf = serialize(config_path, size);
return policy;
}
-FbOff<FB::PolicyOwnNode> Serializer::serialize_tree(const shared_ptr<TreeNode> &node) {
+FbOff<FB::PolicyOwnNode> Serializer::serialize_tree(const std::shared_ptr<TreeNode> &node) {
auto prefix_decision_item = serialize_decision(node->getOwnPrefixDecisionItem());
auto decision_item = serialize_decision(node->getOwnDecisionItem());
}
template <typename T>
-auto Serializer::serialize_policy(const T &policy,
- const std::vector<FbOff<typename type_helper<T>::item>> items)
+auto Serializer::serialize_policy(const std::vector<FbOff<typename type_helper<T>::item>> items)
-> FbOff<typename type_helper<T>::policy> {
- (void)policy;
auto create_policy = get_create_policy<T>();
return create_policy(m_builder, m_builder.CreateVector(items));
}
template <>
-auto Serializer::serialize_policy(const PolicyAccess &policy,
- const std::vector<FbOff<FB::ItemAccess>> items)
- -> FbOff<FB::PolicyAccess> {
- (void)policy;
- auto create_policy = get_create_policy<PolicyAccess>();
- return create_policy(m_builder,
- m_builder.CreateVector(items));
-}
-
-template <>
auto Serializer::serialize_policy(const PolicyOwn &policy)
-> FbOff<FB::PolicyOwn> {
return serialize_tree(policy.getTree());
items.push_back(serialize_item<T>(item));
}
- return serialize_policy(policy, items);
+ return serialize_policy<T>(items);
}
template <typename T, typename P>
#include "storage_backend_xml.hpp"
#include "policy_containers.hpp"
-using namespace std;
-
namespace ldp_xml_parser
{
enum class SetType : uint8_t {
auto get_create_item() -> decltype(type_helper<T>::create_item);
FbOff<FB::PolicyOwn> serialize_tree(const OwnershipTree &tree);
- FbOff<FB::PolicyOwnNode> serialize_tree(const shared_ptr<TreeNode> &node);
+ FbOff<FB::PolicyOwnNode> serialize_tree(const std::shared_ptr<TreeNode> &node);
FbOff<FB::DecisionItem> serialize_decision(const DecisionItem &item);
template <typename T, typename P>
auto serialize_policy(const T &policy) -> FbOff<typename type_helper<T>::policy>;
template <typename T>
- auto serialize_policy(const T &policy,
- const std::vector<FbOff<typename type_helper<T>::item>> items)
+ auto serialize_policy(const std::vector<FbOff<typename type_helper<T>::item>> items)
-> FbOff<typename type_helper<T>::policy>;
template <typename T, typename P>
public:
uint8_t *serialize(const ldp_xml::StorageBackendXML &db, size_t &size);
uint8_t *serialize(const std::string config_path, size_t &size);
- void serialize(const std::string config_path, ostream &output);
+ void serialize(const std::string config_path, std::ostream &output);
friend class SerializerTests;
};
}
void run_tests(const char *conf_file, const char *conf_bin, size_t c, Choice ch) {
if (ch == Choice::ALL || ch == Choice::XML) {
if (!measure([&conf_file, c]() { return run_xml(conf_file); }, c, "XML")) {
- cout << "ERROR" << endl;
+ std::cout << "ERROR" << std::endl;
}
}
if (ch == Choice::ALL || ch == Choice::FB) {
if (!measure([&conf_bin, c]() { return run_fb(conf_bin); }, c, "FB")) {
- cout << "ERROR" << endl;
+ std::cout << "ERROR" << std::endl;
}
}
if (ch == Choice::ALL || ch == Choice::XMLplusFB)
if (!measure([&conf_file, c]() { return run_xml_plus_fb(conf_file); }, c, "FB after XML")) {
- cout << "ERROR" << endl;
+ std::cout << "ERROR" << std::endl;
}
}
void print_help(const char *name) {
- cout << endl;
- cout << "usage: " << name << " {-f <config_bin>|-x|-d|-a <config_bin>} {--system|--session|-c <config_xml>} <count>" << endl;
- cout << endl;
- cout << " -f <config_bin> - Flatbuffers" << endl;
- cout << " -x - XML" << endl;
- cout << " -d - FB after XML" << endl;
- cout << " -a <config_bin> - All tests" << endl;
- cout << endl;
+ std::cout << std::endl;
+ std::cout << "usage: " << name << " {-f <config_bin>|-x|-d|-a <config_bin>} {--system|--session|-c <config_xml>} <count>" << std::endl;
+ std::cout << std::endl;
+ std::cout << " -f <config_bin> - Flatbuffers" << std::endl;
+ std::cout << " -x - XML" << std::endl;
+ std::cout << " -d - FB after XML" << std::endl;
+ std::cout << " -a <config_bin> - All tests" << std::endl;
+ std::cout << std::endl;
}
static const struct option options[] {
}
if (optind < argc) {
- count = stoi(argv[optind]);
+ count = std::stoi(argv[optind]);
} else {
print_help(argv[0]);
return 1;
}
void print_help(const char *name) {
- cout << endl;
- cout << "usage: " << name << " {-f|-x|-a} {--system|--session|-c <config_xml>} <count>" << endl;
- cout << endl;
- cout << " -f - Flatbuffers" << endl;
- cout << " -x - XML" << endl;
- cout << " -a - Flatbuffers and XML" << endl;
- cout << endl;
+ std::cout << std::endl;
+ std::cout << "usage: " << name << " {-f|-x|-a} {--system|--session|-c <config_xml>} <count>" << std::endl;
+ std::cout << std::endl;
+ std::cout << " -f - Flatbuffers" << std::endl;
+ std::cout << " -x - XML" << std::endl;
+ std::cout << " -a - Flatbuffers and XML" << std::endl;
+ std::cout << std::endl;
}
static const struct option options[] {
}
if (optind < argc) {
- count = stoi(argv[optind]);
+ count = std::stoi(argv[optind]);
} else {
print_help(argv[0]);
return 1;