ValidatorJsonSPtr create_anyof_validator(const json::Value& value) { if (value["anyof"].is_array() && value.is_member("type")) { const auto type = value["type"].as_string(); if ("string" == type) { return create_anyof_string(value); } if ("int" == type) { return create_anyof_int(value); } } return nullptr; }
void Port::read_configuration(const json::Value& port_configuration) { try { log_debug(GET_LOGGER("module"), "Reading ports configuration."); set_id(port_configuration["id"].as_uint()); if (port_configuration.is_member("link_state")) { set_link_state(m_state_string_to_enum( port_configuration["link_state"].as_string())); } // Optional parameters if (port_configuration.is_member("ethmod")) { set_iface_mode(port_configuration["ethmod"].as_string()); } else { set_iface_mode("default"); } if (port_configuration.is_member("type")) { set_type(port_configuration["type"].as_string()); } if (port_configuration.is_member("autoneg")) { set_autoneg_mode(port_configuration["autoneg"].as_string()); } else { set_autoneg_mode("default"); } } catch (const json::Value::Exception& e) { log_warning(GET_LOGGER("module"), "Invalid/missing submodule configuration member: " << e.what()); } catch (...) { log_alert(GET_LOGGER("module"), "Unknown error in submodule section"); } }
bool is_validator_object(const json::Value& value) { return value.is_object() && value.is_member("validator") && (value.is_member("max") || value.is_member("min") || value.is_member("type") || value.is_member("addrV") || value.is_member("url") || value.is_member("anyof")); }