19 BackendSelector::BackendSelector()
25 : backend_type_(backend_type),
32 host_(host), port_(port) {
39 if (access_map->getType() != Element::map) {
45 if (t->getType() != Element::string) {
53 if (h->getType() != Element::string) {
56 host_ = h->stringValue();
61 if ((p->getType() != Element::integer) ||
62 (p->intValue() < 0) ||
63 (p->intValue() > std::numeric_limits<uint16_t>::max())) {
65 "to " << std::numeric_limits<uint16_t>::max());
67 port_ =
static_cast<uint16_t
>(p->intValue());
98 s <<
"host=" << host_ <<
",";
101 s <<
"port=" << port_ <<
",";
106 std::string text = s.str();
107 if ((!text.empty() && (text.back() ==
','))) {
121 if (!host_.empty()) {
122 result->set(
"host", Element::create(host_));
124 result->set(
"port", Element::create(static_cast<long int>(port_)));
132 if (type ==
"mysql") {
135 }
else if (type ==
"pgsql") {
138 }
else if (type ==
"cql") {
159 return (std::string());
163 BackendSelector::validate()
const {
164 if ((port_ != 0) && (host_.empty())) {
static const BackendSelector & UNSPEC()
Returns instance of the "unspecified" backend selector.
static Type stringToBackendType(const std::string &type)
Converts string to backend type.
static std::string backendTypeToString(const Type &type)
Converts backend type to string.
bool amUnspecified() const
Checks if selector is "unspecified".
boost::shared_ptr< Element > ElementPtr
std::string toText() const
Returns selections as text.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
boost::shared_ptr< const Element > ConstElementPtr
BackendSelector()
Default constructor.
Defines the logger used by the top-level component of kea-dhcp-ddns.
Type
Supported database types.
virtual data::ElementPtr toElement() const
Unparse a backend selector object.