OmniSciDB  bf83d84833
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
foreign_storage::OptionsContainer Struct Reference

#include <OptionsContainer.h>

+ Inheritance diagram for foreign_storage::OptionsContainer:

Public Member Functions

 OptionsContainer ()
 
 OptionsContainer (const OptionsMap &options)
 
 OptionsContainer (const std::string &options_str)
 
void populateOptionsMap (OptionsMap &&options_map, bool clear=false)
 
void populateOptionsMap (const rapidjson::Value &ddl_options, bool clear=false)
 
void populateOptionsMap (const std::string &options_json, bool clear=false)
 
std::string getOptionsAsJsonString () const
 
std::optional< std::string > getOption (const std::string_view &key) const
 

Public Attributes

OptionsMap options
 

Detailed Description

Definition at line 31 of file OptionsContainer.h.

Constructor & Destructor Documentation

foreign_storage::OptionsContainer::OptionsContainer ( )
inline

Definition at line 34 of file OptionsContainer.h.

34 {}
foreign_storage::OptionsContainer::OptionsContainer ( const OptionsMap options)
inline

Definition at line 36 of file OptionsContainer.h.

foreign_storage::OptionsContainer::OptionsContainer ( const std::string &  options_str)
inline

Definition at line 38 of file OptionsContainer.h.

References populateOptionsMap().

38 { populateOptionsMap(options_str); }
void populateOptionsMap(OptionsMap &&options_map, bool clear=false)

+ Here is the call graph for this function:

Member Function Documentation

std::optional<std::string> foreign_storage::OptionsContainer::getOption ( const std::string_view &  key) const
inline

Definition at line 87 of file OptionsContainer.h.

References options.

87  {
88  if (auto it = options.find(key); it != options.end()) {
89  return it->second;
90  } else {
91  return {};
92  }
93  }
std::string foreign_storage::OptionsContainer::getOptionsAsJsonString ( ) const
inline

Definition at line 69 of file OptionsContainer.h.

References options.

Referenced by AlterForeignServerCommand::setForeignServerOptions().

69  {
70  rapidjson::Document document;
71  document.SetObject();
72 
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());
79  }
80 
81  rapidjson::StringBuffer buffer;
82  rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
83  document.Accept(writer);
84  return buffer.GetString();
85  }

+ Here is the caller graph for this function:

void foreign_storage::OptionsContainer::populateOptionsMap ( OptionsMap &&  options_map,
bool  clear = false 
)
inline

Definition at line 40 of file OptionsContainer.h.

References options.

Referenced by RefreshForeignTablesCommand::execute(), OptionsContainer(), populateOptionsMap(), AlterForeignServerCommand::setForeignServerOptions(), and Catalog_Namespace::Catalog::setForeignServerOptions().

40  {
41  if (clear) {
42  options = options_map;
43  } else {
44  // The merge order here is to make sure we overwrite duplicates in options. If we
45  // used options.merge(options_map) we would preserve existing entries.
46  options_map.merge(options);
47  options = options_map;
48  }
49  }

+ Here is the caller graph for this function:

void foreign_storage::OptionsContainer::populateOptionsMap ( const rapidjson::Value &  ddl_options,
bool  clear = false 
)
inline

Definition at line 51 of file OptionsContainer.h.

References CHECK, options, and to_upper().

51  {
52  CHECK(ddl_options.IsObject());
53  if (clear) {
54  options.clear();
55  }
56  for (const auto& member : ddl_options.GetObject()) {
57  std::string key = to_upper(member.name.GetString());
58  options[key] = member.value.GetString();
59  }
60  }
std::string to_upper(const std::string &str)
#define CHECK(condition)
Definition: Logger.h:197

+ Here is the call graph for this function:

void foreign_storage::OptionsContainer::populateOptionsMap ( const std::string &  options_json,
bool  clear = false 
)
inline

Definition at line 62 of file OptionsContainer.h.

References CHECK, options, and populateOptionsMap().

62  {
63  CHECK(!options_json.empty());
64  rapidjson::Document options;
65  options.Parse(options_json);
66  populateOptionsMap(options);
67  }
void populateOptionsMap(OptionsMap &&options_map, bool clear=false)
#define CHECK(condition)
Definition: Logger.h:197

+ Here is the call graph for this function:

Member Data Documentation


The documentation for this struct was generated from the following file: