MySQL  8.0.17
Source Code Documentation
dd::Properties_impl Class Reference

The Properties_impl class implements the Properties interface. More...

#include <properties_impl.h>

Inheritance diagram for dd::Properties_impl:
dd::Properties

Public Member Functions

 Properties_impl ()=default
 
 Properties_impl (const std::set< String_type > &keys)
 
virtual const Properties_implimpl () const
 
virtual iterator begin ()
 
virtual const_iterator begin () const
 
virtual iterator end ()
 
virtual const_iterator end () const
 
virtual size_type size () const
 Get the number of key=value pairs. More...
 
virtual bool empty () const
 Are there any key=value pairs? More...
 
virtual void clear ()
 Remove all key=value pairs. More...
 
virtual bool valid_key (const String_type &key) const
 Check if the submitted key is valid. More...
 
virtual bool exists (const String_type &key) const
 Check for the existence of a key=value pair given the key. More...
 
virtual bool remove (const String_type &key)
 Remove the key=value pair for the given key if it exists. More...
 
virtual const String_type raw_string () const
 Iterate over all entries in the private hash table. More...
 
virtual bool get (const String_type &key, String_type *value) const
 Get the string value for a given key. More...
 
virtual bool set (const String_type &key, const String_type &value)
 Set the key/value. More...
 
virtual bool insert_values (const Properties &properties)
 Insert key/value pairs from a different property object. More...
 
virtual bool insert_values (const String_type &raw_string)
 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
 
Propertiesoperator= (const Properties &)=delete
 
virtual ~Properties ()
 

Private Attributes

Properties::Map m_map
 
std::set< String_typem_keys
 

Additional Inherited Members

- Public Types inherited from dd::Properties
typedef std::map< String_type, String_typeMap
 
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 Propertiesparse_properties (const String_type &raw_properties)
 Parse the submitted string for properties on the format "key=value;key=value;...". More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Properties_impl() [1/2]

dd::Properties_impl::Properties_impl ( )
default

◆ Properties_impl() [2/2]

dd::Properties_impl::Properties_impl ( const std::set< String_type > &  keys)
inline

Member Function Documentation

◆ begin() [1/2]

virtual iterator dd::Properties_impl::begin ( void  )
inlinevirtual

Implements dd::Properties.

◆ begin() [2/2]

virtual const_iterator dd::Properties_impl::begin ( void  ) const
inlinevirtual

Implements dd::Properties.

◆ clear()

virtual void dd::Properties_impl::clear ( )
inlinevirtual

Remove all key=value pairs.

Implements dd::Properties.

◆ empty()

virtual bool dd::Properties_impl::empty ( ) const
inlinevirtual

Are there any key=value pairs?

Returns
true if there is no key=value pair, else false.

Implements dd::Properties.

◆ end() [1/2]

virtual iterator dd::Properties_impl::end ( void  )
inlinevirtual

Implements dd::Properties.

◆ end() [2/2]

virtual const_iterator dd::Properties_impl::end ( void  ) const
inlinevirtual

Implements dd::Properties.

◆ exists()

virtual bool dd::Properties_impl::exists ( const String_type key) const
inlinevirtual

Check for the existence of a key=value pair given the key.

Parameters
keyKey to be checked.
Returns
true if the given key exists, false otherwise.

Implements dd::Properties.

◆ get()

bool dd::Properties_impl::get ( const String_type key,
String_type value 
) const
virtual

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.

Parameters
keykey to lookup the value for
[out]valuestring value
Returns
Operation outcome, false if success, otherwise true

Implements dd::Properties.

◆ impl()

virtual const Properties_impl* dd::Properties_impl::impl ( ) const
inlinevirtual

◆ insert_values() [1/2]

bool dd::Properties_impl::insert_values ( const Properties properties)
virtual

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.

Parameters
propertiesSource object.
Return values
Operationoutcome, false if no error, otherwise true.

Implements dd::Properties.

◆ insert_values() [2/2]

bool dd::Properties_impl::insert_values ( const String_type raw_string)
virtual

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.

Parameters
raw_stringString to be parsed.
Return values
Operationoutcome, false if no error, otherwise true.

Implements dd::Properties.

◆ raw_string()

const String_type dd::Properties_impl::raw_string ( ) const
virtual

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.

Returns
string containing all escaped key value pairs

Implements dd::Properties.

◆ remove()

virtual bool dd::Properties_impl::remove ( const String_type key)
inlinevirtual

Remove the key=value pair for the given key if it exists.

Otherwise, do nothing.

Parameters
keykey to lookup.
Returns
false if the given key existed, true otherwise.

Implements dd::Properties.

◆ set()

bool dd::Properties_impl::set ( const String_type key,
const String_type value 
)
virtual

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.

Parameters
keyKey to set.
valueValue to set.
Returns
Operation outcome, false if success, otherwise true

Implements dd::Properties.

◆ size()

virtual size_type dd::Properties_impl::size ( ) const
inlinevirtual

Get the number of key=value pairs.

Note
Invalid keys that are present will also be reflected in the count.
Returns
number of key=value pairs

Implements dd::Properties.

◆ valid_key()

virtual bool dd::Properties_impl::valid_key ( const String_type key) const
inlinevirtual

Check if the submitted key is valid.

Parameters
keyKey to be checked.
Return values
trueif the key is valid, otherwise false.

Implements dd::Properties.

Member Data Documentation

◆ m_keys

std::set<String_type> dd::Properties_impl::m_keys
private

◆ m_map

Properties::Map dd::Properties_impl::m_map
private

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