-// Copyright (C) 2010-2022 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2010-2023 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
return b.boolValue() || !a.boolValue();
case Element::string:
return std::strcmp(a.stringValue().c_str(), b.stringValue().c_str()) < 0;
+ default:
+ isc_throw(BadValue, "cannot compare Elements of type " << to_string(a.getType()));
}
- isc_throw(BadValue, "cannot compare Elements of type " <<
- std::to_string(a.getType()));
}
//
-// Copyright (C) 2010-2022 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2010-2023 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
return (position);
}
+ // any is a special type used in list specifications, specifying
+ // that the elements can be of any type
+ enum types { integer, real, boolean, null, string, list, map, any };
+
private:
// technically the type could be omitted; is it useful?
// should we remove it or replace it with a pure virtual
// function getType?
- int type_;
+ types type_;
/// @brief Position of the element in the configuration string.
Position position_;
/// @param pos Structure holding position of the value of the data element.
/// It comprises the line number and the position within this line. The values
/// held in this structure are used for error logging purposes.
- Element(int t, const Position& pos = ZERO_POSITION())
+ Element(types t, const Position& pos = ZERO_POSITION())
: type_(t), position_(pos) {
}
public:
-
- // any is a special type used in list specifications, specifying
- // that the elements can be of any type
- enum types { integer, real, boolean, null, string, list, map, any };
// base class; make dtor virtual
virtual ~Element() {};
/// @return the type of this element
- int getType() const { return (type_); }
+ types getType() const { return (type_); }
/// @brief Returns position where the data element's value starts in a
/// configuration string.
-// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2023 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
(value_->getType() != Element::real)) {
isc_throw(TypeError, "StampedValue: provided value of the '"
<< name_ << "' parameter has invalid type: "
- << Element::typeToName(static_cast<Element::types>(value_->getType())));
+ << Element::typeToName(value_->getType()));
}
}
isc_throw(TypeError, "StampedValue: attempt to access a '"
<< name_ << "' parameter as " << Element::typeToName(type)
<< ", but this parameter has "
- << Element::typeToName(static_cast<Element::types>(value_->getType()))
+ << Element::typeToName(value_->getType())
<< " type");
}
}