dxd - dynax driver framework 3.0.1d223
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:

Classes

struct  property

Public Types

typedef std::set< std::string > keys
enum class  type : ::DWORD {
  undefined = REG_NONE , uint32 = REG_DWORD , uint64 = REG_QWORD , string = REG_SZ ,
  vendor = REG_BINARY
}
 the value types this store keeps - a scalar rides as REG_DWORD/REG_QWORD rather than as a byte copy, so a value written here reads like any other in the registry editor More...

Public Member Functions

 catch (...)
 catch (...)
registry & erase (const char *subkey=nullptr) noexcept
template<typename value_t>
value_t get () const
template<typename value_t>
bool get (value_t &value) const
registry & initialize (::HKEY root, ::REGSAM rights=KEY_ALL_ACCESS)
registry & initialize (::REGSAM rights=KEY_ALL_ACCESS, ::HKEY root=HKEY_CURRENT_USER)
registry & initialize (const std::string &key, ::HKEY root=HKEY_CURRENT_USER, ::REGSAM rights=KEY_ALL_ACCESS)
 operator::HKEY () const noexcept
registry & operator= (const char *value)
registry & operator= (const registry &registry)
registry & operator= (const std::string &value)
template<typename value_t, typename = typename std::enable_if< !std::is_pointer_v<value_t> && std::is_trivially_copyable_v<value_t>, value_t>::type>
registry & operator= (const value_t &value)
registry & operator= (uint32_t value)
registry & operator= (uint64_t value)
 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)
registry & run ()
registry & set (::DWORD typetype, const void *value, size_t size)
size_t size () const noexcept
type type () const noexcept
 ~registry () noexcept

Static Public Member Functions

template<typename value_t, typename self_t>
static void assign (const self_t &self, const value_t &value)
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
template<typename value_t, typename self_t>
static bool fetch (const self_t &self, value_t &value)
template<typename self_t>
static bool nested (const self_t &self) noexcept
template<typename self_t>
static void purge (const self_t &self) noexcept
template<typename self_t>
static size_t size (const self_t &self) noexcept

Public Attributes

std::string key
std::deque< std::function< void()> > listen
bool schedule_erase {}

Protected Member Functions

std::string canonical (const std::string &name) const
registry & initialize (const std::string &key, ::REGSAM rights, ::HKEY root, const char *path=nullptr)
 registry (::REGSAM rights, ::HKEY root, const char *path)
 registry (const registry &registry, const std::string &key)

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(::REGSAM rights, ::HKEY root, const char *path)
    Definition dx_registry.h:208
    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 Typedef Documentation

◆ keys

typedef std::set<std::string> dx::registry::keys

Member Enumeration Documentation

◆ type

enum class dx::registry::type : ::DWORD
strong

the value types this store keeps - a scalar rides as REG_DWORD/REG_QWORD rather than as a byte copy, so a value written here reads like any other in the registry editor

Enumerator
undefined 
uint32 
uint64 
string 
vendor 

Constructor & Destructor Documentation

◆ registry() [1/7]

dx::registry::registry ( ::REGSAM rights,
::HKEY root,
const char * path )
inlineprotected
Here is the call graph for this function:
Here is the caller graph for this function:

◆ registry() [2/7]

dx::registry::registry ( const registry & registry,
const std::string & key )
inlineprotected

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

Here is the call graph for this function:

◆ registry() [3/7]

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

◆ registry() [4/7]

dx::registry::registry ( const std::string & key,
::HKEY root,
::REGSAM rights = KEY_ALL_ACCESS,
const decltype(listen)& listen = {} )
inline
Here is the call graph for this function:

◆ registry() [5/7]

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

◆ registry() [6/7]

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

◆ registry() [7/7]

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

◆ ~registry()

dx::registry::~registry ( )
inlinenoexcept

Member Function Documentation

◆ assign()

template<typename value_t, typename self_t>
void dx::registry::assign ( const self_t & self,
const value_t & value )
inlinestatic
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)
inlinestatic

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 ( ...)
inline

◆ catch() [2/2]

dx::registry::catch ( ...)
inline

◆ children()

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

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:

◆ erase()

registry & dx::registry::erase ( const char * subkey = nullptr)
inlinenoexcept
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 )
inlinestatic

a value that serializes itself into a tree node recurses through its own named children; only what has no such serialization reaches the flat position below, where a struct would become one opaque REG_BINARY of its layout

Here is the call graph for this function:

◆ get() [1/2]

template<typename value_t>
value_t dx::registry::get ( ) const
inline

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.

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

◆ get() [2/2]

template<typename value_t>
bool dx::registry::get ( value_t & value) const
inline

like get<value_t>() but returns false for ERROR_FILE_NOT_FOUND, from either RegQueryValueExA or value_of() itself; any other failure throws.

Here is the call graph for this function:

◆ initialize() [1/4]

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

◆ initialize() [2/4]

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

◆ initialize() [3/4]

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

◆ initialize() [4/4]

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)
inlinestaticnoexcept
Here is the call graph for this function:

◆ operator::HKEY()

dx::registry::operator::HKEY ( ) const
inlinenoexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [1/6]

registry & dx::registry::operator= ( const char * value)
inline
Here is the call graph for this function:

◆ operator=() [2/6]

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

◆ operator=() [3/6]

registry & dx::registry::operator= ( const std::string & value)
inline
Here is the call graph for this function:

◆ operator=() [4/6]

template<typename value_t, typename = typename std::enable_if< !std::is_pointer_v<value_t> && std::is_trivially_copyable_v<value_t>, value_t>::type>
registry & dx::registry::operator= ( const value_t & value)
inline
Here is the call graph for this function:

◆ operator=() [5/6]

registry & dx::registry::operator= ( uint32_t value)
inline
Here is the call graph for this function:

◆ operator=() [6/6]

registry & dx::registry::operator= ( uint64_t value)
inline
Here is the call graph for this function:

◆ purge()

template<typename self_t>
void dx::registry::purge ( const self_t & self)
inlinestaticnoexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

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

◆ set()

registry & dx::registry::set ( ::DWORD type,
const void * value,
size_t size )
inline

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

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

◆ size() [1/2]

size_t dx::registry::size ( ) const
inlinenoexcept

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)
inlinestaticnoexcept
Here is the call graph for this function:

◆ type()

type dx::registry::type ( ) const
inlinenoexcept

Member Data Documentation

◆ key

std::string dx::registry::key

◆ listen

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

◆ schedule_erase

bool dx::registry::schedule_erase {}

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.