Codechange: String parameters can now be explicitly not initialised.
As the visitor is now more complex this requires an unspecialised GetNextParameter() to avoid it being repeated for each return type.
This commit is contained in:
committed by
Peter Nelson
parent
0c0e7606d9
commit
4010313180
@@ -83,6 +83,7 @@ public:
|
||||
uint64_t GetNextParameter()
|
||||
{
|
||||
struct visitor {
|
||||
uint64_t operator()(const std::monostate &) { throw std::out_of_range("Attempt to read uninitialised parameter as integer"); }
|
||||
uint64_t operator()(const uint64_t &arg) { return arg; }
|
||||
uint64_t operator()(const std::string &) { throw std::out_of_range("Attempt to read string parameter as integer"); }
|
||||
};
|
||||
@@ -113,11 +114,12 @@ public:
|
||||
const char *GetNextParameterString()
|
||||
{
|
||||
struct visitor {
|
||||
const char *operator()(const std::monostate &) { throw std::out_of_range("Attempt to read uninitialised parameter as string"); }
|
||||
const char *operator()(const uint64_t &) { throw std::out_of_range("Attempt to read integer parameter as string"); }
|
||||
const char *operator()(const std::string &arg) { return arg.c_str(); }
|
||||
};
|
||||
|
||||
const auto ¶m = GetNextParameterReference();
|
||||
const auto ¶m = this->GetNextParameterReference();
|
||||
return std::visit(visitor{}, param.data);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user