ConstElementPtr name = getItem(xpath + "/name");
ConstElementPtr type = getItem(xpath + "/type");
ConstElementPtr space = getItem(xpath + "/space");
- if (!code || !name || !type || !space) {
- return (ElementPtr());
+ if (!code || !space) {
+ // Can't happen as code and space are the keys.
+ isc_throw(Unexpected, "getOptionDefKea requires code and space: "
+ << xpath);
+ }
+ if (!name || !type) {
+ isc_throw(BadValue, "getOptionDefKea requires name and type: "
+ << xpath);
}
ElementPtr result = Element::createMap();
result->set("code", code);
void
TranslatorOptionDef::setOptionDefKea(const string& xpath,
ConstElementPtr elem) {
+ // Skip code and space as they are the keys.
ConstElementPtr name = elem->get("name");
if (!name) {
isc_throw(BadValue, "option definition with name: " << elem->str());
ElementPtr result = Element::createList();
S_Iter_Value iter = getIter(xpath + "/*");
if (!iter) {
- return (ConstElementPtr());
+ // Can't happen.
+ isc_throw(Unexpected, "getOptionDefListKea: can't get iterator: "
+ << xpath);
}
for (;;) {
const string& def = getNext(iter);
/// @param xpath The xpath of the option definition.
/// @return JSON representation of the option definition.
/// @throw SysrepoError when sysrepo raises an error.
+ /// @throw BadValue on option definition without name or type.
isc::data::ElementPtr getOptionDefKea(const std::string& xpath);
/// @brief setOptionDef for kea-dhcp[46].
///
/// @param xpath The xpath of the option definition.
/// @param elem The JSON element.
+ /// @throw BadValue on option definition without name or type.
void setOptionDefKea(const std::string& xpath,
isc::data::ConstElementPtr elem);
///
/// @param xpath The xpath of the option definition list.
/// @param elem The JSON element.
+ /// @throw BadValue on option definition without code or space.
void setOptionDefListKea(const std::string& xpath,
isc::data::ConstElementPtr elem);