📄 reg_value_sequence.hpp
字号:
/* /////////////////////////////////////////////////////////////////////////
* File: winstl/registry/reg_value_sequence.hpp
*
* Purpose: Contains the basic_reg_value_sequence class template, and ANSI
* and Unicode specialisations thereof.
*
* Notes: The original implementation of the class had the iterator
* and value_type as nested classes. Unfortunately, Visual C++ 5 &
* 6 both had either compilation or linking problems so these are
* regretably now implemented as independent classes.
*
* Thanks: To Allan McLellan, for pointing out some inadequacies in the
* basic_reg_key_sequence class interface (that equally applied to.
* basic_reg_value_sequence).
*
* Created: 19th January 2002
* Updated: 7th April 2007
*
* Home: http://stlsoft.org/
*
* Copyright (c) 2002-2007, Matthew Wilson and Synesis Software
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
* any contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* ////////////////////////////////////////////////////////////////////// */
/** \file winstl/registry/reg_value_sequence.hpp
*
* \brief [C++ only] Definition of the winstl::basic_reg_value_sequence
* class template
* (\ref group__library__windows_registry "Windows Registry" Library).
*/
#ifndef WINSTL_INCL_WINSTL_REGISTRY_HPP_REG_VALUE_SEQUENCE
#define WINSTL_INCL_WINSTL_REGISTRY_HPP_REG_VALUE_SEQUENCE
#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
# define WINSTL_VER_WINSTL_REGISTRY_HPP_REG_VALUE_SEQUENCE_MAJOR 3
# define WINSTL_VER_WINSTL_REGISTRY_HPP_REG_VALUE_SEQUENCE_MINOR 5
# define WINSTL_VER_WINSTL_REGISTRY_HPP_REG_VALUE_SEQUENCE_REVISION 1
# define WINSTL_VER_WINSTL_REGISTRY_HPP_REG_VALUE_SEQUENCE_EDIT 117
#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
/* /////////////////////////////////////////////////////////////////////////
* Includes
*/
#ifndef WINSTL_INCL_WINSTL_H_WINSTL
# include <winstl/winstl.h>
#endif /* !WINSTL_INCL_WINSTL_H_WINSTL */
#ifndef WINSTL_INCL_WINSTL_REGISTRY_HPP_REGFWD
# include <winstl/registry/regfwd.hpp>
#endif /* !WINSTL_INCL_WINSTL_REGISTRY_HPP_REGFWD */
#ifndef WINSTL_INCL_WINSTL_REGISTRY_UTIL_HPP_DEFS
# include <winstl/registry/util/defs.hpp>
#endif /* !WINSTL_INCL_WINSTL_REGISTRY_UTIL_HPP_DEFS */
#ifndef WINSTL_INCL_WINSTL_REGISTRY_HPP_REG_TRAITS
# include <winstl/registry/reg_traits.hpp>
#endif /* !WINSTL_INCL_WINSTL_REGISTRY_HPP_REG_TRAITS */
#ifndef WINSTL_INCL_WINSTL_REGISTRY_HPP_REG_VALUE
# include <winstl/registry/reg_value.hpp>
#endif /* !WINSTL_INCL_WINSTL_REGISTRY_HPP_REG_VALUE */
#ifndef WINSTL_INCL_WINSTL_REGISTRY_UTIL_HPP_SHARED_HANDLES
# include <winstl/registry/util/shared_handles.hpp>
#endif /* !WINSTL_INCL_WINSTL_REGISTRY_UTIL_HPP_SHARED_HANDLES */
#ifndef STLSOFT_INCL_STLSOFT_MEMORY_HPP_AUTO_BUFFER
# include <stlsoft/memory/auto_buffer.hpp>
#endif /* !STLSOFT_INCL_STLSOFT_MEMORY_HPP_AUTO_BUFFER */
#ifndef WINSTL_INCL_WINSTL_MEMORY_HPP_PROCESSHEAP_ALLOCATOR
# include <winstl/memory/processheap_allocator.hpp>
#endif /* !WINSTL_INCL_WINSTL_MEMORY_HPP_PROCESSHEAP_ALLOCATOR */
#ifndef STLSOFT_INCL_STLSOFT_UTIL_STD_HPP_ITERATOR_HELPER
# include <stlsoft/util/std/iterator_helper.hpp>
#endif /* !STLSOFT_INCL_STLSOFT_UTIL_STD_HPP_ITERATOR_HELPER */
#ifndef STLSOFT_INCL_STLSOFT_COLLECTIONS_UTIL_HPP_COLLECTIONS
# include <stlsoft/collections/util/collections.hpp>
#endif /* !STLSOFT_INCL_STLSOFT_COLLECTIONS_UTIL_HPP_COLLECTIONS */
#ifndef STLSOFT_INCL_STLSOFT_SMARTPTR_HPP_REF_PTR
# include <stlsoft/smartptr/ref_ptr.hpp>
#endif /* !STLSOFT_INCL_STLSOFT_SMARTPTR_HPP_REF_PTR */
#ifndef STLSOFT_INCL_STLSOFT_SMARTPTR_HPP_SCOPED_HANDLE
# include <stlsoft/smartptr/scoped_handle.hpp>
#endif /* !STLSOFT_INCL_STLSOFT_SMARTPTR_HPP_SCOPED_HANDLE */
/* /////////////////////////////////////////////////////////////////////////
* Namespace
*/
#ifndef _WINSTL_NO_NAMESPACE
# if defined(_STLSOFT_NO_NAMESPACE) || \
defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
/* There is no stlsoft namespace, so must define ::winstl */
namespace winstl
{
# else
/* Define stlsoft::winstl_project */
namespace stlsoft
{
namespace winstl_project
{
# endif /* _STLSOFT_NO_NAMESPACE */
#endif /* !_WINSTL_NO_NAMESPACE */
/* ////////////////////////////////////////////////////////////////////// */
// class basic_reg_value_sequence
/** \brief Presents an STL-like sequence interface over the values of a given registry key
*
* \ingroup group__library__windows_registry
*
* \param C The character type
* \param T The traits type. On translators that support default template arguments this defaults to reg_traits<C>
* \param A The allocator type. On translators that support default template arguments this defaults to processheap_allocator<C>
*/
template< ss_typename_param_k C
#ifdef STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT
, ss_typename_param_k T = reg_traits<C>
, ss_typename_param_k A = processheap_allocator<C>
#else /* ? STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */
, ss_typename_param_k T /* = reg_traits<C> */
, ss_typename_param_k A /* = processheap_allocator<C> */
#endif /* STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */
>
class basic_reg_value_sequence
: public stlsoft_ns_qual(stl_collection_tag)
{
/// \name Member Types
/// @{
public:
/// \brief The character type
typedef C char_type;
/// \brief The traits type
typedef T traits_type;
/// \brief The allocator type
typedef A allocator_type;
/// \brief The current parameterisation of the type
typedef basic_reg_value_sequence<C, T, A> class_type;
/// \brief The value type
typedef basic_reg_value<C, T, A> value_type;
/// \brief The size type
typedef ss_typename_type_k traits_type::size_type size_type;
/// \brief The get key type
typedef basic_reg_key<C, T, A> reg_key_type;
/// \brief The non-mutating (const) iterator type
typedef basic_reg_value_sequence_iterator<C, T, value_type, A> iterator;
/// \brief The non-mutating (const) iterator type
///
/// \note This is retained for backwards compatibility
typedef iterator const_iterator;
/// \brief The reference type
typedef value_type &reference;
/// \brief The non-mutable (const) reference type
typedef value_type const &const_reference;
/// \brief The hkey type
#if defined(STLSOFT_COMPILER_IS_MSVC) && \
_MSC_VER == 1100
/* WSCB: VC5 has an unresolved external linker error if use traits_type::hkey_type */
typedef HKEY hkey_type;
#else /* ? compiler */
typedef ss_typename_type_k traits_type::hkey_type hkey_type;
#endif /* compiler */
/// \brief The difference type
typedef ws_ptrdiff_t difference_type;
/// \brief The non-mutating (const) reverse iterator type
#if defined(STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT)
typedef stlsoft_ns_qual(reverse_bidirectional_iterator_base) < iterator
, value_type
, value_type // By-Value Temporary reference category
, void // By-Value Temporary reference category
, difference_type
> reverse_iterator;
#endif /* STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT */
/// \brief The Boolean type
typedef ws_bool_t bool_type;
private:
/// \brief The results type of the Registry API
typedef ss_typename_type_k traits_type::result_type result_type;
private:
typedef stlsoft_ns_qual(auto_buffer_old)< char_type
, allocator_type
, CCH_REG_API_AUTO_BUFFER
> buffer_type_;
public:
typedef hkey_type resource_type;
/// @}
/// \name Construction
/// @{
public:
/// \brief Creates an instance which provides access to the values of the named sub-key of \c hkey
///
/// \param hkey A registry key handle representing the parent of \c subKeyName
/// \param subKeyName The name of the sub-key whose values will be enumerated. If subKeyName is NULL or the empty string, then
/// the values of \c hkey will be enumerated
/// \param accessMask The security access mask with which the key (hkey + subKeyName) will be opened. Defaults to KEY_READ.
///
/// \note If accessMask contains KEY_NOTIFY, this method will construct a sequence whose iterators monitor for external iterator
/// invalidation. Use the alternative (four-parameter) constructor form to explicitly suppress monitoring.
basic_reg_value_sequence( hkey_type hkey
, char_type const *subKeyName
, REGSAM accessMask = KEY_READ);
/// \brief Creates an instance which provides access to the values of the named sub-key of \c hkey
///
/// \param hkey A registry key handle representing the parent of \c subKeyName
/// \param subKeyName The name of the sub-key whose values will be enumerated. If subKeyName is NULL or the empty string, then
/// the values of \c hkey will be enumerated
/// \param accessMask The security access mask with which the key (hkey + subKeyName) will be opened. Defaults to KEY_READ
/// \param bMonitorExternalInvalidation If non-zero, the iterators will monitor for external iterator invalidation, throwing
/// an instance of registry_exception (or a derived class) when any values are added or removed
///
/// \note The bMonitorExternalInvalidation parameter overrides the accessMask parameter. i.e. if bMonitorExternalInvalidation is
/// non-zero then accessMask is combined with KEY_NOTIFY. If not, then KEY_NOTIFY is stripped from accessMask.
basic_reg_value_sequence( hkey_type hkey
, char_type const *subKeyName
, REGSAM accessMask
, bool_type bMonitorExternalInvalidation);
/// \brief Creates an instance which provides access to the values of of \c key
///
/// \param key A registry key handle representing the parent of \c subKeyName
///
/// \note If the key's access mask contains KEY_NOTIFY, this method will construct a sequence whose iterators monitor for external iterator
/// invalidation. Use the alternative (three-parameter) constructor form to explicitly suppress monitoring.
ss_explicit_k basic_reg_value_sequence(reg_key_type const& key);
/// \brief Creates an instance which provides access to the values of of \c key
///
/// \param key A registry key handle representing the parent of \c subKeyName
/// \param accessMask The security access mask with which the key will be used. Defaults to KEY_READ
///
/// \note If accessMask contains KEY_NOTIFY, this method will construct a sequence whose iterators monitor for external iterator
/// invalidation. Use the alternative (three-parameter) constructor form to explicitly suppress monitoring.
basic_reg_value_sequence( reg_key_type const &key
, REGSAM accessMask);
/// \brief Creates an instance which provides access to the values of of \c key
///
/// \param key A registry key handle representing the parent of \c subKeyName
/// \param accessMask The security access mask with which the key will be used. Defaults to KEY_READ
/// \param bMonitorExternalInvalidation If non-zero, the iterators will monitor for external iterator invalidation, throwing
/// an instance of registry_exception (or a derived class) when any values are added or removed
///
/// \note The bMonitorExternalInvalidation parameter overrides the accessMask parameter. i.e. if bMonitorExternalInvalidation is
/// non-zero then accessMask is combined with KEY_NOTIFY. If not, then KEY_NOTIFY is stripped from accessMask.
basic_reg_value_sequence( reg_key_type const &key
, REGSAM accessMask
, bool_type bMonitorExternalInvalidation);
/// \brief Destructor
~basic_reg_value_sequence() stlsoft_throw_0();
/// @}
/// \name Iteration
/// @{
public:
/// \brief Begins the iteration
///
/// \return An iterator representing the start of the sequence
iterator begin();
/// \brief Ends the iteration
///
/// \return An iterator representing the end of the sequence
iterator end();
#if defined(STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT)
/// \brief Begins the reverse iteration
///
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -