Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/server.cpp
Show All 12 Lines | |||||
#include "sync.h" | #include "sync.h" | ||||
#include "ui_interface.h" | #include "ui_interface.h" | ||||
#include "util.h" | #include "util.h" | ||||
#include "utilstrencodings.h" | #include "utilstrencodings.h" | ||||
#include <univalue.h> | #include <univalue.h> | ||||
#include <boost/algorithm/string/case_conv.hpp> // for to_upper() | #include <boost/algorithm/string/case_conv.hpp> // for to_upper() | ||||
#include <boost/algorithm/string/classification.hpp> | |||||
#include <boost/algorithm/string/split.hpp> | |||||
#include <boost/bind.hpp> | #include <boost/bind.hpp> | ||||
#include <boost/signals2/signal.hpp> | #include <boost/signals2/signal.hpp> | ||||
#include <memory> // for unique_ptr | #include <memory> // for unique_ptr | ||||
#include <set> | #include <set> | ||||
#include <unordered_map> | #include <unordered_map> | ||||
static bool fRPCRunning = false; | static bool fRPCRunning = false; | ||||
▲ Show 20 Lines • Show All 427 Lines • ▼ Show 20 Lines | transformNamedArguments(const JSONRPCRequest &in, | ||||
const std::vector<std::string> &keys = in.params.getKeys(); | const std::vector<std::string> &keys = in.params.getKeys(); | ||||
const std::vector<UniValue> &values = in.params.getValues(); | const std::vector<UniValue> &values = in.params.getValues(); | ||||
std::unordered_map<std::string, const UniValue *> argsIn; | std::unordered_map<std::string, const UniValue *> argsIn; | ||||
for (size_t i = 0; i < keys.size(); ++i) { | for (size_t i = 0; i < keys.size(); ++i) { | ||||
argsIn[keys[i]] = &values[i]; | argsIn[keys[i]] = &values[i]; | ||||
} | } | ||||
// Process expected parameters. | // Process expected parameters. | ||||
int hole = 0; | int hole = 0; | ||||
for (const std::string &argName : argNames) { | for (const std::string &argNamePattern : argNames) { | ||||
auto fr = argsIn.find(argName); | std::vector<std::string> vargNames; | ||||
boost::algorithm::split(vargNames, argNamePattern, | |||||
boost::algorithm::is_any_of("|")); | |||||
auto fr = argsIn.end(); | |||||
for (const std::string &argName : vargNames) { | |||||
fr = argsIn.find(argName); | |||||
if (fr != argsIn.end()) { | |||||
break; | |||||
} | |||||
} | |||||
if (fr != argsIn.end()) { | if (fr != argsIn.end()) { | ||||
for (int i = 0; i < hole; ++i) { | for (int i = 0; i < hole; ++i) { | ||||
// Fill hole between specified parameters with JSON nulls, but | // Fill hole between specified parameters with JSON nulls, but | ||||
// not at the end (for backwards compatibility with calls that | // not at the end (for backwards compatibility with calls that | ||||
// act based on number of specified parameters). | // act based on number of specified parameters). | ||||
out.params.push_back(UniValue()); | out.params.push_back(UniValue()); | ||||
} | } | ||||
hole = 0; | hole = 0; | ||||
▲ Show 20 Lines • Show All 106 Lines • Show Last 20 Lines |