MySQL 8.4.3
Source Code Documentation
|
The Properties_impl class implements the Properties interface. More...
#include <properties_impl.h>
Public Member Functions | |
Properties_impl ()=default | |
Properties_impl (const std::set< String_type > &keys) | |
virtual const Properties_impl * | impl () const |
iterator | begin () override |
const_iterator | begin () const override |
iterator | end () override |
const_iterator | end () const override |
size_type | size () const override |
Get the number of key=value pairs. More... | |
bool | empty () const override |
Are there any key=value pairs? More... | |
void | clear () override |
Remove all key=value pairs. More... | |
bool | valid_key (const String_type &key) const override |
Check if the submitted key is valid. More... | |
bool | exists (const String_type &key) const override |
Check for the existence of a key=value pair given the key. More... | |
bool | remove (const String_type &key) override |
Remove the key=value pair for the given key if it exists. More... | |
const String_type | raw_string () const override |
Iterate over all entries in the private hash table. More... | |
bool | get (const String_type &key, String_type *value) const override |
Get the string value for a given key. More... | |
bool | set (const String_type &key, const String_type &value) override |
Set the key/value. More... | |
bool | insert_values (const Properties &properties) override |
Insert key/value pairs from a different property object. More... | |
bool | insert_values (const String_type &raw_string) override |
Insert key/value pairs from a string. More... | |
Public Member Functions inherited from dd::Properties | |
template<typename Lex_type > | |
bool | get (const String_type &key, Lex_type *value, MEM_ROOT *mem_root) const |
Get the lex string value for a given key. More... | |
template<typename Value_type > | |
bool | get (const String_type &key, Value_type *value) const |
Get the string value for the key and convert it to the appropriate type. More... | |
template<typename Value_type > | |
bool | set (const String_type &key, Value_type value) |
Convert the value to a string and set it for the given key. More... | |
Properties ()=default | |
Properties (const Properties &)=default | |
Properties & | operator= (const Properties &)=delete |
virtual | ~Properties ()=default |
Private Attributes | |
Properties::Map | m_map |
std::set< String_type > | m_keys |
Additional Inherited Members | |
Public Types inherited from dd::Properties | |
typedef std::map< String_type, String_type > | Map |
typedef std::map< String_type, String_type >::size_type | size_type |
typedef Map::iterator | iterator |
typedef Map::const_iterator | const_iterator |
Static Public Member Functions inherited from dd::Properties | |
template<typename T > | |
static bool | from_str (const String_type &number, T *value) |
Convert a string to a value of an integral type. More... | |
static bool | from_str (const String_type &bool_str, bool *value) |
Convert string to bool. More... | |
template<class T > | |
static String_type | to_str (T value) |
Convert a value of an integral type (including bool) to a string. More... | |
static Properties * | parse_properties (const String_type &raw_properties) |
Parse the submitted string for properties on the format "key=value;key=value;...". More... | |
The Properties_impl class implements the Properties interface.
The key=value pairs are stored in a std::map. An instance can be created either by means of the default constructor, which creates an object with an empty map, or alternatively, it can be created by means of the static parse_properties function with a String_type argument. The string is supposed to contain a semicolon separated list of key=value pairs, where the characters '=' and ';' also may be part of key or value by escaping using the '\' as an escape character. The escape character itself must also be escaped if being part of key or value. All characters between '=' and ';' are considered part of key or value, whitespace is not ignored.
Escaping is removed during parsing so the strings in the map are not escaped. Escaping is only relevant in the context of raw strings that are to be parsed, and raw strings that are returned containing all key=value pairs.
Example (note \ due to escaping of C string literals): parse_properties("a=b;b = c") -> ("a", "b"), ("b ", " c") parse_properties("a\\==b;b=\\;c") -> ("a=", "b"), ("b", ";c")
get("a=") == "b" get("b") == ";c"
Additional key=value pairs may be added by means of the set function, which takes a string argument that is assumed to be unescaped.
Please also refer to the comments in the file properties.h where the interface is defined; the functions in the interface are commented there.
|
default |
|
inline |
|
inlineoverridevirtual |
Implements dd::Properties.
|
inlineoverridevirtual |
Implements dd::Properties.
|
inlineoverridevirtual |
Remove all key=value pairs.
Implements dd::Properties.
|
inlineoverridevirtual |
Are there any key=value pairs?
Implements dd::Properties.
|
inlineoverridevirtual |
Implements dd::Properties.
|
inlineoverridevirtual |
Implements dd::Properties.
|
inlineoverridevirtual |
Check for the existence of a key=value pair given the key.
key | Key to be checked. |
Implements dd::Properties.
|
overridevirtual |
Get the string value for a given key.
Return true if the operation fails, i.e., if the key does not exist or if the key is invalid. Assert that the key exists in debug builds.
key | key to lookup the value for | |
[out] | value | string value |
Implements dd::Properties.
|
inlinevirtual |
|
overridevirtual |
Insert key/value pairs from a different property object.
The set of valid keys is not copied, instead, the existing set in the destination object is used to ignore all invalid keys.
properties | Source object. |
Operation | outcome, false if no error, otherwise true. |
Implements dd::Properties.
|
overridevirtual |
Insert key/value pairs from a string.
Parse the string and add key/value pairs to this object. The existing set of valid keys in the destination object is used to ignore all invalid keys.
raw_string | String to be parsed. |
Operation | outcome, false if no error, otherwise true. |
Implements dd::Properties.
|
overridevirtual |
Iterate over all entries in the private hash table.
For each key value pair, escape both key and value, and append the strings to the result. Use '=' to separate key and value, and use ';' to separate pairs.
Invalid keys are not included in the output. However, there should never be a situation where invalid keys are present, so we just assert that the keys are valid.
Implements dd::Properties.
|
inlineoverridevirtual |
Remove the key=value pair for the given key if it exists.
Otherwise, do nothing.
key | key to lookup. |
Implements dd::Properties.
|
overridevirtual |
Set the key/value.
If the key is invalid, a warning is written to the error log. Assert that the key exists in debug builds.
key | Key to set. |
value | Value to set. |
Implements dd::Properties.
|
inlineoverridevirtual |
Get the number of key=value pairs.
Implements dd::Properties.
|
inlineoverridevirtual |
Check if the submitted key is valid.
key | Key to be checked. |
true | if the key is valid, otherwise false. |
Implements dd::Properties.
|
private |
|
private |