1
mirror of https://github.com/bitcoin/bitcoin synced 2024-08-01 10:10:06 +02:00

rpc: Assert named arguments are unique in RPCHelpMan

This commit is contained in:
João Barbosa 2018-12-06 15:37:39 +00:00
parent e2c473ff75
commit e09a5875ca
2 changed files with 11 additions and 4 deletions

View File

@ -242,6 +242,16 @@ struct Sections {
}
};
RPCHelpMan::RPCHelpMan(const std::string& name, const std::string& description, const std::vector<RPCArg>& args)
: m_name{name}, m_description{description}, m_args{args}
{
std::set<std::string> named_args;
for (const auto& arg : m_args) {
// Should have unique named arguments
assert(named_args.insert(arg.m_name).second);
}
}
std::string RPCHelpMan::ToString() const
{
std::string ret;

View File

@ -109,10 +109,7 @@ struct RPCArg {
class RPCHelpMan
{
public:
RPCHelpMan(const std::string& name, const std::string& description, const std::vector<RPCArg>& args)
: m_name{name}, m_description{description}, m_args{args}
{
}
RPCHelpMan(const std::string& name, const std::string& description, const std::vector<RPCArg>& args);
std::string ToString() const;