BazisLib::Win32::RegistryKey Class Reference

Provides extremely easy and fast registry access. More...

#include <registry.h>

List of all members.

Classes

class  accessor
 Represents an internal object used to read or write registry values. More...

Public Member Functions

 RegistryKey (HKEY hRootKey, const TCHAR *ptszSubkey)
 RegistryKey (const RegistryKey &rootKey, const TCHAR *ptszSubkey)
 ~RegistryKey ()
accessor operator[] (const TCHAR *ptszValue)
template<class _Type >
bool _SerializerEntry (const TCHAR *ptszValue, _Type *ref, bool Save)
 This method is called by serializer subsystem to read/write a field of a serialized structure.

Public Attributes

 IMPLEMENT_STD_SERIALIZE_METHOD
 IMPLEMENT_STD_DESERIALIZE_METHOD

Private Member Functions

 RegistryKey (const RegistryKey &key)
void operator= (const RegistryKey &key)

Private Attributes

HKEY m_hKey
 IMPLEMENT_EMPTY_SERIALIZE_WRAPPER
 IMPLEMENT_EMPTY_DESERIALIZE_WRAPPER


Detailed Description

Provides extremely easy and fast registry access.

The RegistryKey class allows accessing registry keys according to the following scenario:

	RegistryKey key(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion"));
	String str = key[_T("ProgramFilesDir")];
	str[0] = 'C';
	key[_T("ProgramFilesDir")] = str;

	...
	RegistryKey subKey(key, "Run");
	...
Remarks:
The RegistryKey and the RegistryKey::accessor classes are highly optimized for inline usage. Using these classes according to the scenario presented above guarantees NO EXTRA instructions compared with classical C approach, except for two cases:
  • Querying integer value reads it first to stack variable, and then - to the resulting variable
  • Reading strings directly causes one extra allocation operation to be performed
To ensure maximum efficiency, the following inline methods can be used: Example:
	...
	TCHAR tsz[256];
	key[_T("SomeValuename")].ReadToCharArray(tsz, sizeof(tsz));
	...

Constructor & Destructor Documentation

BazisLib::Win32::RegistryKey::RegistryKey ( const RegistryKey key  )  [inline, private]

BazisLib::Win32::RegistryKey::RegistryKey ( HKEY  hRootKey,
const TCHAR *  ptszSubkey 
) [inline]

BazisLib::Win32::RegistryKey::RegistryKey ( const RegistryKey rootKey,
const TCHAR *  ptszSubkey 
) [inline]

BazisLib::Win32::RegistryKey::~RegistryKey (  )  [inline]


Member Function Documentation

template<class _Type >
bool BazisLib::Win32::RegistryKey::_SerializerEntry ( const TCHAR *  ptszValue,
_Type *  ref,
bool  Save 
) [inline]

This method is called by serializer subsystem to read/write a field of a serialized structure.

This template method does basically save or load a field of a serialized structure.

Parameters:
ptszValue Specifies the field name. RegistryKey class uses this name as a registry value name.
ref Points to the field to save/load.
Save If this parameter is true, the save operation is required, of false - load operation should be performed.
Returns:
The method returns true on success and false on error.
Remarks:
As this method is declared as a template method, it can handle any type compatible with RegistryKey::accessor operators. When developing your own serialization methods, be sure to provide support for all basic types defined in serializer.h

void BazisLib::Win32::RegistryKey::operator= ( const RegistryKey key  )  [inline, private]

accessor BazisLib::Win32::RegistryKey::operator[] ( const TCHAR *  ptszValue  )  [inline]


Member Data Documentation


The documentation for this class was generated from the following file:
SourceForge.net Logo