Fixed is_nil() method on ConfigOptions.

PlaceholderParser was extended to support external config.
The external config has a lowest priority when looking up a variable.
This commit is contained in:
bubnikv 2019-07-24 12:39:01 +02:00
parent 6ea3a8e2b4
commit 42c8940795
4 changed files with 20 additions and 12 deletions

View file

@ -378,7 +378,7 @@ public:
static double nil_value() { return std::numeric_limits<double>::quiet_NaN(); }
// A scalar is nil, or all values of a vector are nil.
bool is_nil() const override { for (auto v : this->values) if (! std::isnan(v)) return false; return true; }
bool is_nil(size_t idx) const override { return std::isnan(v->values[idx]); }
bool is_nil(size_t idx) const override { return std::isnan(this->values[idx]); }
std::string serialize() const override
{
@ -524,7 +524,7 @@ public:
static int nil_value() { return std::numeric_limits<int>::max(); }
// A scalar is nil, or all values of a vector are nil.
bool is_nil() const override { for (auto v : this->values) if (v != nil_value()) return false; return true; }
bool is_nil(size_t idx) const override { return v->values[idx] == nil_value(); }
bool is_nil(size_t idx) const override { return this->values[idx] == nil_value(); }
std::string serialize() const override
{
@ -633,6 +633,7 @@ public:
ConfigOption* clone() const override { return new ConfigOptionStrings(*this); }
ConfigOptionStrings& operator=(const ConfigOption *opt) { this->set(opt); return *this; }
bool operator==(const ConfigOptionStrings &rhs) const { return this->values == rhs.values; }
bool is_nil(size_t idx) const override { return false; }
std::string serialize() const override
{
@ -847,6 +848,7 @@ public:
ConfigOption* clone() const override { return new ConfigOptionPoints(*this); }
ConfigOptionPoints& operator=(const ConfigOption *opt) { this->set(opt); return *this; }
bool operator==(const ConfigOptionPoints &rhs) const { return this->values == rhs.values; }
bool is_nil(size_t idx) const override { return false; }
std::string serialize() const override
{
@ -994,7 +996,7 @@ public:
static unsigned char nil_value() { return std::numeric_limits<unsigned char>::max(); }
// A scalar is nil, or all values of a vector are nil.
bool is_nil() const override { for (auto v : this->values) if (v != nil_value()) return false; return true; }
bool is_nil(size_t idx) const override { return v->values[idx] == nil_value(); }
bool is_nil(size_t idx) const override { return this->values[idx] == nil_value(); }
bool& get_at(size_t i) {
assert(! this->values.empty());