26#ifndef ROUTER_SRC_MYSQL_REST_SERVICE_INCLUDE_MRS_DATABASE_JSON_MAPPER_VIEW_JSON_INPUT_H_
27#define ROUTER_SRC_MYSQL_REST_SERVICE_INCLUDE_MRS_DATABASE_JSON_MAPPER_VIEW_JSON_INPUT_H_
29#ifdef RAPIDJSON_NO_SIZETYPEDEFINE
33#include <rapidjson/document.h>
54 virtual bool has_new()
const {
return false; }
55 virtual bool has_old()
const {
return false; }
66 std::string_view
new_name()
const {
return (*new_)->name.GetString(); }
67 std::string_view
old_name()
const {
return (*old_)->name.GetString(); }
69 const rapidjson::Value &
new_value()
const {
return (*new_)->value; }
70 const rapidjson::Value &
old_value()
const {
return (*old_)->value; }
73 return new_.has_value() &&
74 *
new_ != rapidjson::Value::ConstMemberIterator();
78 return old_.has_value() &&
79 *
old_ != rapidjson::Value::ConstMemberIterator();
89 rapidjson::Value::ConstMemberIterator aold)
92 std::optional<rapidjson::Value::ConstMemberIterator>
new_;
93 std::optional<rapidjson::Value::ConstMemberIterator>
old_;
108 template <
typename S>
118 : rapidjson::Value::ConstMemberIterator(),
121 : rapidjson::Value::ConstMemberIterator());
125 : rapidjson::Value::ConstMemberIterator());
174 const rapidjson::Value *
new_ =
nullptr;
175 const rapidjson::Value *
old_ =
nullptr;
184 const rapidjson::Value &old_value)
200 throw std::logic_error(
"sort_old() must be called first");
202 if (i >=
new_value_->Size())
throw std::range_error(
"invalid array index");
221 template <
typename KeyType>
222 void sort_old(
const std::function<KeyType(
const rapidjson::Value &)> &get_key,
223 std::vector<KeyType> &out_missing_from_old) {
225 std::vector<std::tuple<KeyType, int>> old_array;
227 auto index_in_old_array = [&](
const rapidjson::Value &
value) ->
int {
231 for (
auto iter = old_array.begin(); iter != old_array.end(); ++iter) {
232 if (std::get<0>(*iter) ==
key) {
233 int i = std::get<1>(*iter);
234 old_array.erase(iter);
244 old_array.emplace_back(get_key(
ov),
index++);
246 for (
const auto &obj :
new_value_->GetArray()) {
250 for (
const auto &elem : old_array) {
251 out_missing_from_old.push_back(std::get<0>(elem));
263 const std::string &
table,
264 const std::string &field =
"");
267 const std::string &
table,
268 const std::string &field =
"");
271 const std::string &
table,
272 const std::string &field =
"");
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:247
Define rapidjson::SizeType to be std::uint64_t.
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
PT & ref(PT *tp)
Definition: tablespace_impl.cc:359
bool index(const std::string &value, const String &search_for, uint32_t *idx)
Definition: contains.h:75
JSONInputObject make_input_object(const JSONInputArray::ValueReference &ref, const std::string &table, const std::string &field="")
Definition: json_input.cc:33
JSONInputArray make_input_array(const JSONInputObject::MemberReference &ref, const std::string &table, const std::string &field="")
Definition: json_input.cc:54
ValueType value(const std::optional< ValueType > &v)
Definition: gtid.h:83
Definition: authorize_manager.h:48
Definition: gcs_xcom_synode.h:64
static struct plugin_options_variables ov
Definition: plugin.cc:77
required string key
Definition: replication_asynchronous_connection_failover.proto:60
case opt name
Definition: sslopt-case.h:29