1#ifndef XRPL_PROTOCOL_APIVERSION_H_INCLUDED
2#define XRPL_PROTOCOL_APIVERSION_H_INCLUDED
4#include <xrpl/beast/core/SemanticVersion.h>
5#include <xrpl/beast/utility/instrumentation.h>
6#include <xrpl/json/json_value.h>
7#include <xrpl/protocol/jss.h>
38template <
unsigned int Version>
61template <
class JsonObject>
67 "ripple::RPC::setVersion : input is valid");
68 auto& retObj = addObject(parent, jss::version);
77 retObj[jss::first] = firstVersion.
print();
78 retObj[jss::good] = goodVersion.print();
79 retObj[jss::last] = lastVersion.print();
114 auto const specifiedVersion = jv[jss::api_version];
115 if (!specifiedVersion.isInt() && !specifiedVersion.isUInt())
119 auto const specifiedVersionInt = specifiedVersion.
asInt();
120 if (specifiedVersionInt < minVersion ||
121 specifiedVersionInt > maxVersion)
125 return specifiedVersionInt;
134template <
unsigned minVer,
unsigned maxVer,
typename Fn,
typename... Args>
138 (maxVer >= minVer) &&
147 constexpr auto size = maxVer + 1 - minVer;
156template <
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)