dxd - dynax driver framework 2.7.0d222
cross platform open source driver development framework
Loading...
Searching...
No Matches
dx::registry Class Reference

flat, non-hierarchical Windows registry access to one real key More...

#include <dx_registry.h>

Inheritance diagram for dx::registry:
Collaboration diagram for dx::registry:

Protected Types

enum class  type : ::DWORD {
  undefined = REG_NONE , uint32 = REG_DWORD , uint64 = REG_QWORD , string = REG_SZ ,
  vendor = REG_BINARY
}

Protected Member Functions

std::string canonical (const std::string &name) const try
 catch (...)
 catch (...)
 dx_catchall_rethrow () registry(
 dx_catchall_rethrow () registry(const registry &registry
 dx_catchall_rethrow () template< typename self_t > static void purge(const self_t &self) noexcept try
 dx_catchall_rethrow () template< typename value_t
 dx_catchall_rethrow () ~registry() noexcept
registryerase (const char *subkey=nullptr) noexcept
registryinitialize (const std::string &key, ::HKEY root=HKEY_CURRENT_USER, ::REGSAM rights=KEY_ALL_ACCESS) try
registryinitialize (const std::string &key, ::REGSAM rights, ::HKEY root, const char *path=nullptr) try
registryoperator= (const registry &registry) try
 registry (::HKEY root, ::REGSAM rights=KEY_ALL_ACCESS)
 registry (::REGSAM rights, ::HKEY root=HKEY_CURRENT_USER)
 registry (const registry &registry)
 registry (const std::string &key, ::HKEY root, ::REGSAM rights=KEY_ALL_ACCESS, const decltype(listen)&listen={})
 registry (const std::string &key=property::root, ::REGSAM rights=KEY_ALL_ACCESS, ::HKEY root=HKEY_CURRENT_USER)
registryrun ()
dx_catchall_rethrow() registry &initialize(size_t size () const noexcept

Static Protected Member Functions

static self_t void assign (const self_t &self, const value_t &value) try
template<typename self_t>
static registry at (const self_t &self)
template<typename container_t, typename self_t>
static container_t children (const self_t &self) noexcept try
template<typename value_t, typename self_t>
static bool fetch (const self_t &self, value_t &value) try
template<typename self_t>
static bool nested (const self_t &self) noexcept
template<typename self_t>
static size_t size (const self_t &self) noexcept

Protected Attributes

std::string key
const std::string & key: rights{registry.rights}
std::deque< std::function< void()> > listen
const std::string owns_root
const std::string root {registry.root}
bool schedule_erase {}

Detailed Description

flat, non-hierarchical Windows registry access to one real key

  • usage:
    registry= value;
    value= registry.get<value_t>();
    registry.erase();
    registry.erase(subkey);
    registry(const std::string &key=property::root, ::REGSAM rights=KEY_ALL_ACCESS, ::HKEY root=HKEY_CURRENT_USER)
    Definition dx_registry.h:249
    dx::registry itself has no operator[] and never opens more than the one real HKey it was constructed with (a single RegCreateKeyExA/RegOpenKeyExA call, same as today - the given path may itself be a multi-segment string, Windows resolves/creates the whole chain natively in that one call). It's the right tool where code only ever needs that one real key directly - e.g. watching it for change notification (run()/listen), or a single erase(subkey) - never where code indexes into it with []. On copy construction it generates a new HKey for the same root key to circumvent missing reference counting.
See also
dx::key_value_tree (dxd/interface/dx_key_value_tree.h - shared, platform- agnostic template, not part of this file), dx::preference for hierarchical registry[key1][key2]..[keyN] navigation.

/////////////////////////////////////////////////////////////////////////////

design note: registry vs. key_value_tree

registry[k1][k2]..[kN] navigation stays purely in memory until a leaf is actually read/written/erased/enumerated - operator[] never touches the OS. A parent pointer chain holds each level's own bare key name, mirroring cf::key_value_tree's structure (macOS/cf_key_value_tree.h), though not its storage mechanism: Windows has no CFPropertyListRef-like nesting value.

registry's own fetch/assign/purge (below) join the chain's bare names into one "level0\..\levelN" path and issue exactly one real RegCreateKeyExA/ RegOpenKeyExA call, resolving/creating every intermediate real key atomically (capped at Windows' 32-levels-created-per-call limit). purge() walks that same path back up, deleting each now-empty ancestor real key - auto-prune, mirroring cf::key_value_tree's upward erase cascade.

The persisted registry layout for every consumer (COM registration, ASIO enumeration, preference storage, ...) is real, separate, externally-readable subkeys and values. Each node's .key holds its own bare segment name, so code reading .key directly (enumeration, printing, building a further real path from a child's name) works directly. A node's type is decided dynamically at first write, like CFPropertyListRef's own dynamic typing.

Member Enumeration Documentation

◆ type

enum class dx::registry::type : ::DWORD
strongprotected
Enumerator
undefined 
uint32 
uint64 
string 
vendor 

Constructor & Destructor Documentation

◆ registry() [1/5]

dx::registry::registry ( const std::string & key = property::root,
::REGSAM rights = KEY_ALL_ACCESS,
::HKEY root = HKEY_CURRENT_USER )
inlineprotected
Here is the call graph for this function:
Here is the caller graph for this function:

◆ registry() [2/5]

dx::registry::registry ( const std::string & key,
::HKEY root,
::REGSAM rights = KEY_ALL_ACCESS,
const decltype(listen)& listen = {} )
inlineprotected

◆ registry() [3/5]

dx::registry::registry ( ::REGSAM rights,
::HKEY root = HKEY_CURRENT_USER )
inlineprotected
Here is the call graph for this function:

◆ registry() [4/5]

dx::registry::registry ( ::HKEY root,
::REGSAM rights = KEY_ALL_ACCESS )
inlineprotected
Here is the call graph for this function:

◆ registry() [5/5]

dx::registry::registry ( const registry & registry)
inlineprotected
Here is the call graph for this function:

Member Function Documentation

◆ assign()

self_t void dx::registry::assign ( const self_t & self,
const value_t & value )
inlinestaticprotected
Here is the call graph for this function:
Here is the caller graph for this function:

◆ at()

template<typename self_t>
registry dx::registry::at ( const self_t & self)
inlinestaticprotected

dx::key_value_tree<registry> contract: resolves self's parent chain into one real key/value position, then delegates below - the only place a registry[k1][k2]..[kN] chain becomes real subkeys/values.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ canonical()

std::string dx::registry::canonical ( const std::string & name) const
inlineprotected
Here is the caller graph for this function:

◆ catch() [1/2]

dx::registry::catch ( ...)
inlineprotected

◆ catch() [2/2]

dx::registry::catch ( ...)
inlineprotected

◆ children()

template<typename container_t, typename self_t>
container_t dx::registry::children ( const self_t & self)
inlinestaticprotectednoexcept

self's own child names as any string container, yielding an empty one when the key is absent or inaccessible. Stays a static, not a dx::key_value_tree-style operator container_t(): registry is a dependent base of key_value_tree<registry> (inherited via the tree_t template parameter), and key_value_tree's own operator value_t() becomes entirely unreachable once a dependent base declares a same-shaped operator container_t() template of its own.

Here is the call graph for this function:

◆ dx_catchall_rethrow() [1/5]

dx::registry::dx_catchall_rethrow ( )
inlineprotected

◆ dx_catchall_rethrow() [2/5]

dx::registry::dx_catchall_rethrow ( ) const &
protected

cheap: purely in-memory identity extension with a bare child name - what dx::key_value_tree::operator[] builds on.

◆ dx_catchall_rethrow() [3/5]

dx::registry::dx_catchall_rethrow ( ) const &
inlineprotectednoexcept

◆ dx_catchall_rethrow() [4/5]

dx::registry::dx_catchall_rethrow ( )
protected

◆ dx_catchall_rethrow() [5/5]

dx::registry::dx_catchall_rethrow ( )
inlineprotectednoexcept

◆ erase()

registry & dx::registry::erase ( const char * subkey = nullptr)
inlineprotectednoexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fetch()

template<typename value_t, typename self_t>
bool dx::registry::fetch ( const self_t & self,
value_t & value )
inlinestaticprotected
Here is the call graph for this function:

◆ initialize() [1/2]

registry & dx::registry::initialize ( const std::string & key,
::HKEY root = HKEY_CURRENT_USER,
::REGSAM rights = KEY_ALL_ACCESS )
inlineprotected
Here is the call graph for this function:

◆ initialize() [2/2]

registry & dx::registry::initialize ( const std::string & key,
::REGSAM rights,
::HKEY root,
const char * path = nullptr )
inlineprotected
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nested()

template<typename self_t>
bool dx::registry::nested ( const self_t & self)
inlinestaticprotectednoexcept
Here is the call graph for this function:

◆ operator=()

registry & dx::registry::operator= ( const registry & registry)
inlineprotected
Here is the call graph for this function:

◆ run()

registry & dx::registry::run ( )
inlineprotected
Here is the call graph for this function:

◆ size() [1/2]

dx_catchall_rethrow() registry &initialize(size_t dx::registry::size ( ) const
inlineprotectednoexcept

stays a named method: base and derived conversion function templates are simultaneous overload candidates, so an operator value_t() here would compete with dx::key_value_tree's own. like get<value_t>() but returns false for ERROR_FILE_NOT_FOUND, from either RegQueryValueExA or value_of() itself; any other failure throws. a sibling thread/process may delete the containing key between value_of()'s create and the set - retry recreates the whole chain in that case subkey+value count, 0 if the key doesn't exist (key_of()'s non-throwing overload - an ordinary, expected outcome here, not a genuine error).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ size() [2/2]

template<typename self_t>
size_t dx::registry::size ( const self_t & self)
inlinestaticprotectednoexcept
Here is the call graph for this function:

Member Data Documentation

◆ key [1/2]

std::string dx::registry::key
protected

◆ key [2/2]

const std::string& dx::registry::key
protected

◆ listen

std::deque<std::function<void()> > dx::registry::listen
protected

◆ owns_root

const std::string dx::registry::owns_root
protected
Initial value:
{false}{
this->key= key;
}
public:
struct property{
static constexpr auto software= "SOFTWARE";
static constexpr auto root= software;
}
const std::string & key
Definition dx_registry.h:227

◆ root

const std::string dx::registry::root {registry.root}
protected

◆ schedule_erase

bool dx::registry::schedule_erase {}
protected

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

(c) copyright 2009 dynamic acoustics e.U. generated on

a closed source license may be obtained by requesting a written permission from dynamic acoustics e.U.
however - governmental use generally and military use especially is strictly prohibited though.