OmniSciDB  2e3a973ef4
foreign_storage::OptionsContainer Struct Reference

#include <OptionsContainer.h>

+ Inheritance diagram for foreign_storage::OptionsContainer:

Public Member Functions

 OptionsContainer ()
 
 OptionsContainer (const std::map< std::string, std::string, std::less<>> &options)
 
 OptionsContainer (const std::string &options_str)
 
void populateOptionsMap (const rapidjson::Value &ddl_options)
 
void populateOptionsMap (const std::string &options_json, bool clear=false)
 
std::string getOptionsAsJsonString () const
 

Public Attributes

std::map< std::string, std::string, std::less<> > options
 

Detailed Description

Definition at line 30 of file OptionsContainer.h.

Constructor & Destructor Documentation

◆ OptionsContainer() [1/3]

foreign_storage::OptionsContainer::OptionsContainer ( )
inline

Definition at line 33 of file OptionsContainer.h.

33 {}

◆ OptionsContainer() [2/3]

foreign_storage::OptionsContainer::OptionsContainer ( const std::map< std::string, std::string, std::less<>> &  options)
inline

Definition at line 35 of file OptionsContainer.h.

36  : options(options) {}
std::map< std::string, std::string, std::less<> > options

◆ OptionsContainer() [3/3]

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(const rapidjson::Value &ddl_options)
+ Here is the call graph for this function:

Member Function Documentation

◆ getOptionsAsJsonString()

std::string foreign_storage::OptionsContainer::getOptionsAsJsonString ( ) const
inline

Definition at line 59 of file OptionsContainer.h.

Referenced by AlterForeignServerCommand::setForeignServerOptions(), and Catalog_Namespace::Catalog::setForeignServerOptions().

59  {
60  rapidjson::Document document;
61  document.SetObject();
62 
63  for (const auto& [key, value] : options) {
64  document.AddMember(rapidjson::Value().SetString(
65  key.c_str(), key.length(), document.GetAllocator()),
66  rapidjson::Value().SetString(
67  value.c_str(), value.length(), document.GetAllocator()),
68  document.GetAllocator());
69  }
70 
71  rapidjson::StringBuffer buffer;
72  rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
73  document.Accept(writer);
74  return buffer.GetString();
75  }
std::map< std::string, std::string, std::less<> > options
+ Here is the caller graph for this function:

◆ populateOptionsMap() [1/2]

void foreign_storage::OptionsContainer::populateOptionsMap ( const rapidjson::Value &  ddl_options)
inline

Definition at line 40 of file OptionsContainer.h.

References CHECK, and to_upper().

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

40  {
41  CHECK(ddl_options.IsObject());
42  for (const auto& member : ddl_options.GetObject()) {
43  std::string key = to_upper(member.name.GetString());
44  std::string value = member.value.GetString();
45  options[key] = value;
46  }
47  }
std::map< std::string, std::string, std::less<> > options
std::string to_upper(const std::string &str)
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateOptionsMap() [2/2]

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

Definition at line 49 of file OptionsContainer.h.

References CHECK, options, and populateOptionsMap().

49  {
50  CHECK(!options_json.empty());
51  if (clear) {
52  options.clear();
53  }
54  rapidjson::Document options;
55  options.Parse(options_json);
56  populateOptionsMap(options);
57  }
std::map< std::string, std::string, std::less<> > options
void populateOptionsMap(const rapidjson::Value &ddl_options)
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the call graph for this function:

Member Data Documentation

◆ options


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