20#ifndef RIPPLE_PROTOCOL_APIVERSION_H_INCLUDED
21#define RIPPLE_PROTOCOL_APIVERSION_H_INCLUDED
23#include <xrpl/beast/core/SemanticVersion.h>
24#include <xrpl/beast/utility/instrumentation.h>
25#include <xrpl/json/json_value.h>
26#include <xrpl/protocol/jss.h>
57template <
unsigned int Version>
80template <
class JsonObject>
86 "ripple::RPC::setVersion : input is valid");
87 auto& retObj = addObject(parent, jss::version);
96 retObj[jss::first] = firstVersion.
print();
97 retObj[jss::good] = goodVersion.print();
98 retObj[jss::last] = lastVersion.print();
133 auto const specifiedVersion = jv[jss::api_version];
134 if (!specifiedVersion.isInt() && !specifiedVersion.isUInt())
138 auto const specifiedVersionInt = specifiedVersion.
asInt();
139 if (specifiedVersionInt < minVersion ||
140 specifiedVersionInt > maxVersion)
144 return specifiedVersionInt;
153template <
unsigned minVer,
unsigned maxVer,
typename Fn,
typename... Args>
157 (maxVer >= minVer) &&
166 constexpr auto size = maxVer + 1 - minVer;
175template <
typename Fn,
typename... Args>
bool isMember(char const *key) const
Return true if the object has a member named key.
A Semantic Version number.
std::string print() const
Produce a string from semantic version components.
void setVersion(JsonObject &parent, unsigned int apiVersion, bool betaEnabled)
static constexpr auto apiMaximumSupportedVersion
static constexpr std::integral_constant< unsigned, Version > apiVersion
static constexpr auto apiMaximumValidVersion
static constexpr auto apiCommandLineVersion
static constexpr auto apiBetaVersion
static constexpr auto apiVersionIfUnspecified
static constexpr auto apiInvalidVersion
unsigned int getAPIVersionNumber(Json::Value const &jv, bool betaEnabled)
Retrieve the api version number from the json value.
static constexpr auto apiMinimumSupportedVersion
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
void forAllApiVersions(Fn const &fn, Args &&... args)
void forApiVersions(Fn const &fn, Args &&... args)