| Kea 3.0.2-git

isc::db::DbAccessParser Class Reference

Parse Database Parameters. More...

`#include <dbaccess_parser.h>`

Inheritance diagram for isc::db::DbAccessParser:
[legend]

## Public Member Functions
| DbAccessParser ()
| Constructor.
virtual | ~DbAccessParser ()
| The destructor.
const DatabaseConnection::ParameterMap & | getDbAccessParameters () const
| Get database access parameters.
void | parse (std::string &access_string, isc::data::ConstElementPtr database_config)
| Parse configuration value.
Public Member Functions inherited from isc::data::SimpleParser
uint16_t | getUint16 (isc::data::ConstElementPtr scope, const std::string &name)
| Returns a value converted to uint16_t.
uint32_t | getUint32 (isc::data::ConstElementPtr scope, const std::string &name)
| Returns a value converted to uint32_t.
uint8_t | getUint8 (ConstElementPtr scope, const std::string &name)
| Get an uint8_t value.
const isc::util::Triplet< uint32_t > | parseIntTriplet (const data::ConstElementPtr &scope, const std::string &name)
| Parses an integer triplet.

## Protected Member Functions
std::string | getDbAccessString () const
| Construct database access string.
Protected Member Functions inherited from isc::data::SimpleParser
template<typename target_type, target_type convert>
target_type | getAndConvert (isc::data::ConstElementPtr scope, const std::string &name, const std::string &type_name)
| Returns a converted value from a scope.
template<typename int_type>
int_type | getIntType (isc::data::ConstElementPtr scope, const std::string &name)
| Returns an integer value with range checking from a scope.

## Additional Inherited Members
Static Public Member Functions inherited from isc::data::SimpleParser
static void | checkKeywords (const SimpleKeywords &keywords, isc::data::ConstElementPtr scope)
| Checks acceptable keywords with their expected type.
static void | checkRequired (const SimpleRequiredKeywords &required, isc::data::ConstElementPtr scope)
| Checks that all required keywords are present.
static size_t | deriveParams (isc::data::ConstElementPtr parent, isc::data::ElementPtr child, const ParamsList &params)
| Derives (inherits) parameters from parent scope to a child.
static isc::asiolink::IOAddress | getAddress (const ConstElementPtr &scope, const std::string &name)
| Returns a IOAddress parameter from a scope.
static bool | getBoolean (isc::data::ConstElementPtr scope, const std::string &name)
| Returns a boolean parameter from a scope.
static double | getDouble (const ConstElementPtr &scope, const std::string &name)
| Returns a floating point parameter from a scope.
static int64_t | getInteger (isc::data::ConstElementPtr scope, const std::string &name)
| Returns an integer parameter from a scope.
static int64_t | getInteger (isc::data::ConstElementPtr scope, const std::string &name, int64_t min, int64_t max)
| Returns an integer parameter from a scope and checks its range.
static const data::Element::Position & | getPosition (const std::string &name, const data::ConstElementPtr parent)
| Utility method that returns position of an element.
static std::string | getString (isc::data::ConstElementPtr scope, const std::string &name)
| Returns a string parameter from a scope.
static size_t | setDefaults (isc::data::ElementPtr scope, const SimpleDefaults &default_values)
| Sets the default values.
static size_t | setListDefaults (isc::data::ConstElementPtr list, const SimpleDefaults &default_values)
| Sets the default values for all entries in a list.

## Detailed Description

Parse Database Parameters.

This class is the parser for the database configuration. This is a map under the top-level "lease-database", "hosts-database" and "config-database" elements, and comprises a map of strings.

Definition at line 25 of file dbaccess_parser.h.

## Constructor & Destructor Documentation

## ◆ DbAccessParser()

isc::db::DbAccessParser::DbAccessParser | ( |  | ) |

Constructor.

Definition at line 27 of file dbaccess_parser.cc.

## ◆ ~DbAccessParser()

virtual isc::db::DbAccessParser::~DbAccessParser | ( |  | ) |
| inline virtual

The destructor.

Definition at line 31 of file dbaccess_parser.h.

## Member Function Documentation

## ◆ getDbAccessParameters()

const DatabaseConnection::ParameterMap & isc::db::DbAccessParser::getDbAccessParameters | ( |  | ) | const
| inline

Get database access parameters.

Used in testing to check that the configuration information has been parsed correctly.

Returns
  Reference to the internal map of keyword/value pairs representing database access information. This is valid only for so long as the parser remains in existence.

Definition at line 63 of file dbaccess_parser.h.

## ◆ getDbAccessString()

std::string isc::db::DbAccessParser::getDbAccessString | ( |  | ) | const
| protected

Construct database access string.

Constructs the database access string from the stored parameters.

Returns
  Database access string

Definition at line 268 of file dbaccess_parser.cc.

Referenced by parse().

## ◆ parse()

void isc::db::DbAccessParser::parse | ( | std::string & | access_string,
|  | isc::data::ConstElementPtr | database_config )

Parse configuration value.

Parses the set of strings forming the database access specification and checks that all are OK. In particular it checks:

- "type" is "memfile", "mysql" or "postgresql"
- "lfc-interval" is a number from the range of 0 to 4294967295.
- "connect-timeout" is a number from the range of 0 to 4294967295.
- "port" is a number from the range of 0 to 65535.

Once all has been validated, constructs the database access string.

Parameters

  [out] | access_string | Generated database access string.
  | database_config | The configuration value for the "*-database" identifier.

Exceptions

  isc::dhcp::DbConfigError | The connection parameters or their combination is invalid.

Definition at line 33 of file dbaccess_parser.cc.

References getDbAccessString(), and isc_throw.

Referenced by isc::process::ConfigControlParser::parse(), isc::dhcp::processDhcp4Config(), and isc::dhcp::processDhcp6Config().

Here is the call graph for this function:

The documentation for this class was generated from the following files:

- dbaccess_parser.h
- dbaccess_parser.cc