20 #include <unordered_map>
22 #include "rapidjson/document.h"
23 #include "rapidjson/stringbuffer.h"
24 #include "rapidjson/writer.h"
29 namespace foreign_storage {
30 using OptionsMap = std::map<std::string, std::string, std::less<>>;
52 CHECK(ddl_options.IsObject());
56 for (
auto itr = ddl_options.MemberBegin(); itr != ddl_options.MemberEnd(); ++itr) {
57 std::string key =
to_upper(itr->name.GetString());
58 options[key] = itr->value.GetString();
63 CHECK(!options_json.empty());
65 options.Parse(options_json);
70 rapidjson::Document document;
73 for (
const auto& [key, value] :
options) {
74 document.AddMember(rapidjson::Value().SetString(
75 key.c_str(), key.length(), document.GetAllocator()),
76 rapidjson::Value().SetString(
77 value.c_str(), value.length(), document.GetAllocator()),
78 document.GetAllocator());
81 rapidjson::StringBuffer buffer;
82 rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
83 document.Accept(writer);
84 return buffer.GetString();
87 std::optional<std::string>
getOption(
const std::string_view& key)
const {
97 return option.has_value() && option.value() ==
"TRUE";
void populateOptionsMap(const rapidjson::Value &ddl_options, bool clear=false)
void populateOptionsMap(const std::string &options_json, bool clear=false)
std::string getOptionsAsJsonString() const
OptionsContainer(const std::string &options_str)
void populateOptionsMap(OptionsMap &&options_map, bool clear=false)
std::optional< std::string > getOption(const std::string_view &key) const
OptionsContainer(const OptionsMap &options)
std::map< std::string, std::string, std::less<>> OptionsMap
bool getOptionAsBool(const std::string_view &key) const