STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ... ATLSTL - Template Software for the Active Template Library COMSTL - The Standard Template Library meets the Component Object Model .netSTL - Standard Template Library meets the Microsoft.NET Common Language Runtime InetSTL - The Standard Template Library meets WinInet MFCSTL - Template Software for the Microsoft Foundation Classes UNIXSTL - Template Software for the UNIX Operating System WinSTL - where the Standard Template Library meets the Win32 API

Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

winstl_reg_value_sequence.h

Go to the documentation of this file.
00001 /* 
00002  * File:        winstl_reg_value_sequence.h
00003  *
00004  * Purpose:     Contains the basic_reg_value_sequence template class, and ANSI
00005  *              and Unicode specialisations thereof.
00006  *
00007  * Notes:       The original implementation of the class had the const_iterator
00008  *              and value_type as nested classes. Unfortunately, Visual C++ 5 &
00009  *              6 both had either compilation or linking problems so these are
00010  *              regretably now implemented as independent classes.
00011  *
00012  * Created:     19th January 2002
00013  * Updated:     11th September 2004
00014  *
00015  * Home:        http://stlsoft.org/
00016  *
00017  * Copyright (c) 2002-2004, Matthew Wilson and Synesis Software
00018  * All rights reserved.
00019  *
00020  * Redistribution and use in source and binary forms, with or without
00021  * modification, are permitted provided that the following conditions are met:
00022  *
00023  * - Redistributions of source code must retain the above copyright notice, this
00024  *   list of conditions and the following disclaimer.
00025  * - Redistributions in binary form must reproduce the above copyright notice,
00026  *   this list of conditions and the following disclaimer in the documentation
00027  *   and/or other materials provided with the distribution.
00028  * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
00029  *   any contributors may be used to endorse or promote products derived from
00030  *   this software without specific prior written permission.
00031  *
00032  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00033  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00034  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00035  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00036  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00037  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00038  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00039  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00040  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00041  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00042  * POSSIBILITY OF SUCH DAMAGE.
00043  *
00044  * 
00045 
00046 
00050 
00051 #ifndef WINSTL_INCL_H_WINSTL_REG_VALUE_SEQUENCE
00052 #define WINSTL_INCL_H_WINSTL_REG_VALUE_SEQUENCE
00053 
00054 #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION
00055 # define WINSTL_VER_H_WINSTL_REG_VALUE_SEQUENCE_MAJOR        2
00056 # define WINSTL_VER_H_WINSTL_REG_VALUE_SEQUENCE_MINOR        0
00057 # define WINSTL_VER_H_WINSTL_REG_VALUE_SEQUENCE_REVISION     1
00058 # define WINSTL_VER_H_WINSTL_REG_VALUE_SEQUENCE_EDIT         57
00059 #endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */
00060 
00061 /* 
00062  * Includes
00063  */
00064 
00065 #ifndef WINSTL_INCL_H_WINSTL
00066 # include "winstl.h"                        // Include the WinSTL root header
00067 #endif /* !WINSTL_INCL_H_WINSTL */
00068 #ifndef WINSTL_INCL_H_WINSTL_REG_DEFS
00069 # include "winstl_reg_defs.h"               // The WinSTL reg API standard types
00070 #endif /* WINSTL_INCL_H_WINSTL_REG_DEFS */
00071 #ifndef WINSTL_INCL_H_WINSTL_REG_TRAITS
00072 # include "winstl_reg_traits.h"             // The WinSTL reg API reg_traits class
00073 #endif /* WINSTL_INCL_H_WINSTL_REG_TRAITS */
00074 #ifndef WINSTL_INCL_H_WINSTL_REG_KEY
00075 # include "winstl_reg_key.h"                // The WinSTL reg API reg_key class
00076 #endif /* WINSTL_INCL_H_WINSTL_REG_KEY */
00077 #ifndef WINSTL_INCL_H_WINSTL_REG_VALUE
00078 # include "winstl_reg_value.h"              // The WinSTL reg API reg_value class
00079 #endif /* WINSTL_INCL_H_WINSTL_REG_VALUE */
00080 #ifndef STLSOFT_INCL_H_STLSOFT_AUTO_DESTRUCTOR
00081 # include "stlsoft_auto_buffer.h"           // Include the STLSoft auto_buffer
00082 #endif /* STLSOFT_INCL_H_STLSOFT_AUTO_DESTRUCTOR */
00083 #ifndef WINSTL_INCL_H_WINSTL_AUTO_DESTRUCTOR
00084 # include "winstl_processheap_allocator.h"  // winstl::processheap_allocator
00085 #endif /* WINSTL_INCL_H_WINSTL_AUTO_DESTRUCTOR */
00086 #ifndef STLSOFT_INCL_H_STLSOFT_ITERATOR
00087 # include "stlsoft_iterator.h"              // stlsoft::iterator, stlsoft::reverse_iterator
00088 #endif /* STLSOFT_INCL_H_STLSOFT_ITERATOR */
00089 
00090 /* 
00091  * Namespace
00092  */
00093 
00094 #ifndef _WINSTL_NO_NAMESPACE
00095 # if defined(_STLSOFT_NO_NAMESPACE) || \
00096      defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION)
00097 /* There is no stlsoft namespace, so must define ::winstl */
00098 namespace winstl
00099 {
00100 # else
00101 /* Define stlsoft::winstl_project */
00102 
00103 namespace stlsoft
00104 {
00105 
00106 namespace winstl_project
00107 {
00108 
00109 # endif /* _STLSOFT_NO_NAMESPACE */
00110 #endif /* !_WINSTL_NO_NAMESPACE */
00111 
00112 /* 
00113 
00116 
00117 /* 
00118  * Forward declarations
00119  */
00120 
00121 #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION
00122 
00123 template<   ss_typename_param_k C
00124         ,   ss_typename_param_k T
00125         ,   ss_typename_param_k V
00126         ,   ss_typename_param_k A
00127         >
00128 class basic_reg_value_sequence_const_iterator;
00129 
00130 #endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */
00131 
00132 /* 
00133  * Classes
00134  */
00135 
00136 // class basic_reg_value_sequence
00142 template<   ss_typename_param_k C
00143 #ifdef __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT
00144         ,   ss_typename_param_k T = reg_traits<C>
00145         ,   ss_typename_param_k A = processheap_allocator<C>
00146 #else
00147         ,   ss_typename_param_k T /* = reg_traits<C> */
00148         ,   ss_typename_param_k A /* = processheap_allocator<C> */
00149 #endif /* __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */
00150         >
00151 class basic_reg_value_sequence
00152 {
00153 public:
00155     typedef C                                                                       char_type;
00157     typedef T                                                                       traits_type;
00159     typedef A                                                                       allocator_type;
00161     typedef basic_reg_value_sequence<C, T, A>                                       class_type;
00163     typedef basic_reg_value<C, T, A>                                                value_type;
00165     typedef ss_typename_type_k traits_type::size_type                               size_type;
00167     typedef basic_reg_key<C, T, A>                                                  reg_key_type;
00169     typedef basic_reg_value_sequence_const_iterator<C, T, value_type, A>            const_iterator;
00171     typedef value_type                                                              &reference;
00173     typedef value_type const                                                        &const_reference;
00175 #if defined(__STLSOFT_COMPILER_IS_MSVC) && \
00176     _MSC_VER == 1100
00177     /* WSCB: VC5 has an unresolved external linker error if use traits_type::hkey_type */
00178     typedef HKEY                                                                    hkey_type;
00179 #else
00180     typedef ss_typename_type_k traits_type::hkey_type                               hkey_type;
00181 #endif /* 0 */
00182 
00183     typedef ws_ptrdiff_t                                                            difference_type;
00185 #if defined(__STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT)
00186     typedef stlsoft_ns_qual(const_reverse_bidirectional_iterator_base)  <   const_iterator
00187                                                                         ,   value_type
00188                                                                         ,   value_type // Return by value!
00189                                                                         ,   void*
00190                                                                         ,   difference_type
00191                                                                         >           const_reverse_iterator;
00192 #endif /* __STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT */
00193 
00194 // Construction
00195 public:
00197     basic_reg_value_sequence(hkey_type hkey, char_type const * sub_key_name);
00199     basic_reg_value_sequence(reg_key_type const &key);
00201     ~basic_reg_value_sequence() winstl_throw_0();
00202 
00203 // Iteration
00204 public:
00208     const_iterator          begin() const;
00212     const_iterator          end() const;
00213 
00214 #if defined(__STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT)
00218     const_reverse_iterator  rbegin() const;
00222     const_reverse_iterator  rend() const;
00223 #endif /* __STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT */
00224 
00225 // State
00226 public:
00228     size_type               size() const;
00230     ws_bool_t               empty() const;
00232     static size_type        max_size();
00233 
00234 // Members
00235 private:
00236     ss_typename_type_k traits_type::hkey_type  m_hkey;
00237 
00238 // Not to be implemented
00239 private:
00240     basic_reg_value_sequence(class_type const &);
00241     basic_reg_value_sequence const &operator =(class_type const &);
00242 };
00243 
00244 /* Typedefs to commonly encountered types. */
00246 typedef basic_reg_value_sequence<ws_char_a_t, reg_traits<ws_char_a_t>, processheap_allocator<ws_char_a_t> >     reg_value_sequence_a;
00248 typedef basic_reg_value_sequence<ws_char_w_t, reg_traits<ws_char_w_t>, processheap_allocator<ws_char_w_t> >     reg_value_sequence_w;
00250 typedef basic_reg_value_sequence<TCHAR, reg_traits<TCHAR>, processheap_allocator<TCHAR> >                       reg_value_sequence;
00251 
00252 // class basic_reg_value_sequence_const_iterator
00259 template<   ss_typename_param_k C
00260         ,   ss_typename_param_k T
00261         ,   ss_typename_param_k V
00262         ,   ss_typename_param_k A
00263         >
00264 class basic_reg_value_sequence_const_iterator
00265     : public stlsoft_ns_qual(iterator_base) <   winstl_ns_qual_std(bidirectional_iterator_tag)
00266                                             ,   V
00267                                             ,   ws_ptrdiff_t
00268                                             ,   void *
00269                                             ,   V
00270                                             >
00271 {
00272 public:
00274     typedef C                                                   char_type;
00276     typedef T                                                   traits_type;
00278     typedef V                                                   value_type;
00280     typedef A                                                   allocator_type;
00282     typedef basic_reg_value_sequence_const_iterator<C, T, V, A> class_type;
00284     typedef ss_typename_type_k traits_type::size_type           size_type;
00286     typedef ss_typename_type_k traits_type::difference_type     difference_type;
00288     typedef ss_typename_type_k traits_type::string_type         string_type;
00290     typedef ws_sint32_t                                         index_type;
00292     typedef ss_typename_type_k traits_type::hkey_type           hkey_type;
00293 
00294 // Construction
00295 private:
00296     basic_reg_value_sequence_const_iterator(hkey_type hkey, index_type index, string_type const &value_name)
00297         : m_hkey(hkey)
00298         , m_index(index)
00299         , m_name(value_name)
00300     {} // Implementation is within class, otherwise VC5 will not link
00301     ss_explicit_k basic_reg_value_sequence_const_iterator(hkey_type hkey)
00302         : m_hkey(hkey)
00303         , m_index(sentinel_())
00304     {} // Implementation is within class, otherwise VC5 will not link
00305 public:
00307     basic_reg_value_sequence_const_iterator();
00309     basic_reg_value_sequence_const_iterator(class_type const &rhs);
00311     ~basic_reg_value_sequence_const_iterator() winstl_throw_0();
00312 
00314     basic_reg_value_sequence_const_iterator &operator =(class_type const &rhs);
00315 
00316 // Operators
00317 public:
00319     class_type &operator ++();
00321     class_type &operator --();
00323     const class_type operator ++(int);
00325     const class_type operator --(int);
00327     const value_type operator *() const;
00329     ws_bool_t operator ==(class_type const &rhs) const;
00331     ws_bool_t operator !=(class_type const &rhs) const;
00332 
00333 // Implementation
00334 private:
00335     static index_type sentinel_();
00336 
00337 // Members
00338 private:
00339     friend class basic_reg_value_sequence<C, T, A>;
00340 
00341     typedef basic_reg_value_sequence<C, T, A>      list_type;
00342 
00343     hkey_type   m_hkey;     // Parent container
00344     index_type  m_index;    // Iteration index
00345     string_type m_name;     // The value name
00346 };
00347 
00349 // Unit-testing
00350 
00351 #ifdef STLSOFT_UNITTEST
00352 
00353 namespace unittest
00354 {
00355     ss_bool_t test_winstl_reg_value_sequence(unittest_reporter *r)
00356     {
00357         using stlsoft::unittest::unittest_initialiser;
00358 
00359         ss_bool_t               bSuccess    =   true;
00360 
00361         unittest_initialiser    init(r, "WinSTL", "reg_value_sequence", __FILE__);
00362 
00363 #if 0
00364         if(<<TODO>>)
00365         {
00366             r->report("<<TODO>> failed ", __LINE__);
00367             bSuccess = false;
00368         }
00369 #endif /* 0 */
00370 
00371         return bSuccess;
00372     }
00373 
00374     unittest_registrar    unittest_winstl_reg_value_sequence(test_winstl_reg_value_sequence);
00375 
00376 } // namespace unittest
00377 
00378 #endif /* STLSOFT_UNITTEST */
00379 
00381 // Implementation
00382 
00383 #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION
00384 
00385 // basic_reg_value_sequence
00386 
00387 template<   ss_typename_param_k C
00388         ,   ss_typename_param_k T
00389         ,   ss_typename_param_k A
00390         >
00391 inline basic_reg_value_sequence<C, T, A>::basic_reg_value_sequence(ss_typename_type_k basic_reg_value_sequence<C, T, A>::hkey_type hkey, ss_typename_type_k basic_reg_value_sequence<C, T, A>::char_type const * sub_key_name)
00392     : m_hkey(NULL)
00393 {
00394     if(0 != traits_type::reg_open_key(hkey, sub_key_name, &m_hkey))
00395     {
00396         m_hkey = NULL;
00397     }
00398 }
00399 
00400 template<   ss_typename_param_k C
00401         ,   ss_typename_param_k T
00402         ,   ss_typename_param_k A
00403         >
00404 inline basic_reg_value_sequence<C, T, A>::basic_reg_value_sequence(reg_key_type const &key)
00405 //#ifdef __STLSOFT_CF_TYPENAME_TYPE_CIL_KEYWORD_SUPPORT
00406 //    : m_hkey(ss_typename_type_k traits_type::key_dup(key.m_hkey))
00407 //#else
00408     : m_hkey(traits_type::key_dup(key.m_hkey))
00409 //#endif /* __STLSOFT_COMPILER_IS_BORLAND */
00410 {}
00411 
00412 template<   ss_typename_param_k C
00413         ,   ss_typename_param_k T
00414         ,   ss_typename_param_k A
00415         >
00416 inline basic_reg_value_sequence<C, T, A>::~basic_reg_value_sequence() winstl_throw_0()
00417 {
00418     if(m_hkey != NULL)
00419     {
00420         ::RegCloseKey(m_hkey);
00421     }
00422 }
00423 
00424 template<   ss_typename_param_k C
00425         ,   ss_typename_param_k T
00426         ,   ss_typename_param_k A
00427         >
00428 inline ss_typename_type_k basic_reg_value_sequence<C, T, A>::const_iterator basic_reg_value_sequence<C, T, A>::begin() const
00429 {
00430     // Grab enough for the first item
00431     size_type   cch_value_name  =   0;
00432     ws_long_t   res             =   traits_type::reg_query_info(m_hkey, NULL, NULL, NULL, NULL, NULL, NULL, &cch_value_name, NULL, NULL, NULL);
00433 
00434     if(res == 0)
00435     {
00436         stlsoft_ns_qual(auto_buffer)<char_type, allocator_type, CCH_REG_API_AUTO_BUFFER>    buffer(++cch_value_name);
00437         size_type                                                                           cb_data = 0;
00438 
00439         res = traits_type::reg_enum_value(m_hkey, 0, buffer, &cch_value_name, NULL, NULL, cb_data);
00440 
00441         if(res == 0)
00442         {
00443             buffer[cch_value_name] = 0;
00444 
00445             return const_iterator(m_hkey, 0, static_cast<char_type const *>(buffer));
00446         }
00447     }
00448 
00449     return end();
00450 }
00451 
00452 template<   ss_typename_param_k C
00453         ,   ss_typename_param_k T
00454         ,   ss_typename_param_k A
00455         >
00456 inline ss_typename_type_k basic_reg_value_sequence<C, T, A>::const_iterator basic_reg_value_sequence<C, T, A>::end() const
00457 {
00458     return const_iterator(m_hkey);
00459 }
00460 
00461 #if defined(__STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT)
00462 template<   ss_typename_param_k C
00463         ,   ss_typename_param_k T
00464         ,   ss_typename_param_k A
00465         >
00466 inline ss_typename_type_k basic_reg_value_sequence<C, T, A>::const_reverse_iterator basic_reg_value_sequence<C, T, A>::rbegin() const
00467 {
00468     return const_reverse_iterator(end());
00469 }
00470 
00471 template<   ss_typename_param_k C
00472         ,   ss_typename_param_k T
00473         ,   ss_typename_param_k A
00474         >
00475 inline ss_typename_type_k basic_reg_value_sequence<C, T, A>::const_reverse_iterator basic_reg_value_sequence<C, T, A>::rend() const
00476 {
00477     return const_reverse_iterator(begin());
00478 }
00479 #endif /* __STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT */
00480 
00481 template<   ss_typename_param_k C
00482         ,   ss_typename_param_k T
00483         ,   ss_typename_param_k A
00484         >
00485 inline ss_typename_type_k basic_reg_value_sequence<C, T, A>::size_type basic_reg_value_sequence<C, T, A>::size() const
00486 {
00487     ws_uint_t   c_values;
00488     ws_long_t   res         =   traits_type::reg_query_info(m_hkey, NULL, NULL, NULL, NULL, NULL, &c_values, NULL, NULL, NULL, NULL);
00489 
00490     if(res != 0)
00491     {
00492         c_values = 0;
00493     }
00494 
00495     return static_cast<size_type>(c_values);
00496 }
00497 
00498 template<   ss_typename_param_k C
00499         ,   ss_typename_param_k T
00500         ,   ss_typename_param_k A
00501         >
00502 inline ws_bool_t basic_reg_value_sequence<C, T, A>::empty() const
00503 {
00504     return size() == 0;
00505 }
00506 
00507 template<   ss_typename_param_k C
00508         ,   ss_typename_param_k T
00509         ,   ss_typename_param_k A
00510         >
00511 inline /* static */ ss_typename_type_k basic_reg_value_sequence<C, T, A>::size_type basic_reg_value_sequence<C, T, A>::max_size()
00512 {
00513     return static_cast<size_type>(-1);
00514 }
00515 
00516 // basic_reg_value_sequence_const_iterator
00517 
00518 template<   ss_typename_param_k C
00519         ,   ss_typename_param_k T
00520         ,   ss_typename_param_k V
00521         ,   ss_typename_param_k A
00522         >
00523 inline /* static */ ss_typename_type_k basic_reg_value_sequence_const_iterator<C, T, V, A>::index_type basic_reg_value_sequence_const_iterator<C, T, V, A>::sentinel_()
00524 {
00525     return 0x7fffffff;
00526 }
00527 
00528 template<   ss_typename_param_k C
00529         ,   ss_typename_param_k T
00530         ,   ss_typename_param_k V
00531         ,   ss_typename_param_k A
00532         >
00533 inline basic_reg_value_sequence_const_iterator<C, T, V, A>::basic_reg_value_sequence_const_iterator()
00534     : m_hkey(NULL)
00535     , m_index(sentinel_())
00536 {
00537 }
00538 
00539 #if 0
00540 template<   ss_typename_param_k C
00541         ,   ss_typename_param_k T
00542         ,   ss_typename_param_k V
00543         ,   ss_typename_param_k A
00544         >
00545 inline basic_reg_value_sequence_const_iterator<C, T, V, A>::basic_reg_value_sequence_const_iterator(basic_reg_value_sequence_const_iterator<C, T, V, A>::hkey_type hkey, basic_reg_value_sequence_const_iterator<C, T, V, A>::index_type index, basic_reg_value_sequence_const_iterator<C, T, V, A>::string_type const &value_name)
00546     : m_hkey(hkey)
00547     , m_index(index)
00548     , m_name(value_name)
00549 {
00550 }
00551 
00552 template<   ss_typename_param_k C
00553         ,   ss_typename_param_k T
00554         ,   ss_typename_param_k V
00555         ,   ss_typename_param_k A
00556         >
00557 inline basic_reg_value_sequence_const_iterator<C, T, V, A>::basic_reg_value_sequence_const_iterator(basic_reg_value_sequence_const_iterator<C, T, V, A>::hkey_type hkey)
00558     : m_hkey(hkey)
00559     , m_index(sentinel_())
00560 {
00561 }
00562 #endif /* 0 */
00563 
00564 template<   ss_typename_param_k C
00565         ,   ss_typename_param_k T
00566         ,   ss_typename_param_k V
00567         ,   ss_typename_param_k A
00568         >
00569 inline basic_reg_value_sequence_const_iterator<C, T, V, A>::basic_reg_value_sequence_const_iterator(class_type const &rhs)
00570     : m_hkey(rhs.m_hkey)
00571     , m_index(rhs.m_index)
00572     , m_name(rhs.m_name)
00573 {
00574 }
00575 
00576 template<   ss_typename_param_k C
00577         ,   ss_typename_param_k T
00578         ,   ss_typename_param_k V
00579         ,   ss_typename_param_k A
00580         >
00581 inline ss_typename_type_k basic_reg_value_sequence_const_iterator<C, T, V, A>::class_type &basic_reg_value_sequence_const_iterator<C, T, V, A>::operator =(ss_typename_type_k basic_reg_value_sequence_const_iterator<C, T, V, A>::class_type const &rhs)
00582 {
00583     // For efficiency, we don't do self-assignment test, and assume (reasonably)
00584     // that m_name will be self-protecting
00585 
00586     m_hkey  =   rhs.m_hkey;
00587     m_index =   rhs.m_index;
00588     m_name  =   rhs.m_name;
00589 
00590     return *this;
00591 }
00592 
00593 template<   ss_typename_param_k C
00594         ,   ss_typename_param_k T
00595         ,   ss_typename_param_k V
00596         ,   ss_typename_param_k A
00597         >
00598 inline basic_reg_value_sequence_const_iterator<C, T, V, A>::~basic_reg_value_sequence_const_iterator() winstl_throw_0()
00599 {
00600 }
00601 
00602 template<   ss_typename_param_k C
00603         ,   ss_typename_param_k T
00604         ,   ss_typename_param_k V
00605         ,   ss_typename_param_k A
00606         >
00607 inline ss_typename_type_k basic_reg_value_sequence_const_iterator<C, T, V, A>::class_type &basic_reg_value_sequence_const_iterator<C, T, V, A>::operator ++()
00608 {
00609     // Grab enough for the first item
00610     size_type   cch_value_name  =   0;
00611     ws_long_t   res             =   traits_type::reg_query_info(m_hkey, NULL, NULL, NULL, NULL, NULL, NULL, &cch_value_name, NULL, NULL, NULL);
00612 
00613     if(res == 0)
00614     {
00615         stlsoft_ns_qual(auto_buffer)<char_type, allocator_type, CCH_REG_API_AUTO_BUFFER>    buffer(++cch_value_name);
00616         size_type                                                                           cb_data = 0;
00617 
00618         res = traits_type::reg_enum_value(m_hkey, ++m_index, buffer, &cch_value_name, NULL, NULL, cb_data);
00619 
00620         if(res == 0)
00621         {
00622             buffer[cch_value_name] = 0;
00623 
00624             m_name = buffer.data();
00625         }
00626         else
00627         {
00628             m_index = sentinel_();
00629         }
00630     }
00631     else
00632     {
00633         m_index = sentinel_();
00634     }
00635 
00636     return *this;
00637 }
00638 
00639 template<   ss_typename_param_k C
00640         ,   ss_typename_param_k T
00641         ,   ss_typename_param_k V
00642         ,   ss_typename_param_k A
00643         >
00644 inline ss_typename_type_k basic_reg_value_sequence_const_iterator<C, T, V, A>::class_type &basic_reg_value_sequence_const_iterator<C, T, V, A>::operator --()
00645 {
00646     // Grab enough for the first item
00647     size_type   cch_value_name  =   0;
00648     ws_uint_t   c_values;
00649     ws_long_t   res             =   traits_type::reg_query_info(m_hkey, NULL, NULL, NULL, NULL, NULL, &c_values, &cch_value_name, NULL, NULL, NULL);
00650 
00651     if(res == 0)
00652     {
00653         stlsoft_ns_qual(auto_buffer)<char_type, allocator_type, CCH_REG_API_AUTO_BUFFER>    buffer(++cch_value_name);
00654         size_type                                                                           cb_data = 0;
00655 
00656         // If the iterator is currently at the "end()", ...
00657         if(m_index == sentinel_())
00658         {
00659             // ... then set the index to be one past the end
00660             m_index = c_values;
00661         }
00662 
00663         // Move back one position, and get the key name
00664         res = traits_type::reg_enum_value(m_hkey, --m_index, buffer, &cch_value_name, NULL, NULL, cb_data);
00665 
00666         if(res == 0)
00667         {
00668             buffer[cch_value_name] = 0;
00669 
00670             m_name = buffer.data();
00671         }
00672         else
00673         {
00674             m_index = sentinel_();
00675         }
00676     }
00677     else
00678     {
00679         m_index = sentinel_();
00680     }
00681 
00682     return *this;
00683 }
00684 
00685 template<   ss_typename_param_k C
00686         ,   ss_typename_param_k T
00687         ,   ss_typename_param_k V
00688         ,   ss_typename_param_k A
00689         >
00690 inline const ss_typename_type_k basic_reg_value_sequence_const_iterator<C, T, V, A>::class_type basic_reg_value_sequence_const_iterator<C, T, V, A>::operator ++(int)
00691 {
00692     class_type  ret(*this);
00693 
00694     operator ++();
00695 
00696     return ret;
00697 }
00698 
00699 template<   ss_typename_param_k C
00700         ,   ss_typename_param_k T
00701         ,   ss_typename_param_k V
00702         ,   ss_typename_param_k A
00703         >
00704 inline const ss_typename_type_k basic_reg_value_sequence_const_iterator<C, T, V, A>::class_type basic_reg_value_sequence_const_iterator<C, T, V, A>::operator --(int)
00705 {
00706     class_type  ret(*this);
00707 
00708     operator --();
00709 
00710     return ret;
00711 }
00712 
00713 template<   ss_typename_param_k C
00714         ,   ss_typename_param_k T
00715         ,   ss_typename_param_k V
00716         ,   ss_typename_param_k A
00717         >
00718 inline const ss_typename_type_k basic_reg_value_sequence_const_iterator<C, T, V, A>::value_type basic_reg_value_sequence_const_iterator<C, T, V, A>::operator *() const
00719 {
00720     return value_type(m_hkey, m_name);
00721 }
00722 
00723 template<   ss_typename_param_k C
00724         ,   ss_typename_param_k T
00725         ,   ss_typename_param_k V
00726         ,   ss_typename_param_k A
00727         >
00728 inline ws_bool_t basic_reg_value_sequence_const_iterator<C, T, V, A>::operator ==(class_type const &rhs) const
00729 {
00730     winstl_message_assert("Comparing reg_value_sequence iterators from different sequences!", m_hkey == rhs.m_hkey);
00731 
00732     return m_index == rhs.m_index;
00733 }
00734 
00735 template<   ss_typename_param_k C
00736         ,   ss_typename_param_k T
00737         ,   ss_typename_param_k V
00738         ,   ss_typename_param_k A
00739         >
00740 inline ws_bool_t basic_reg_value_sequence_const_iterator<C, T, V, A>::operator !=(class_type const &rhs) const
00741 {
00742     return ! operator ==(rhs);
00743 }
00744 
00745 #endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */
00746 
00747 /* 
00748 
00750 
00751 /* 
00752 
00753 #ifndef _WINSTL_NO_NAMESPACE
00754 # if defined(_STLSOFT_NO_NAMESPACE) || \
00755      defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION)
00756 } // namespace winstl
00757 # else
00758 } // namespace winstl_project
00759 } // namespace stlsoft
00760 # endif /* _STLSOFT_NO_NAMESPACE */
00761 #endif /* !_WINSTL_NO_NAMESPACE */
00762 
00763 /* 
00764 
00765 #endif /* WINSTL_INCL_H_WINSTL_REG_VALUE_SEQUENCE */
00766 
00767 /* 

STLSoft Libraries documentation © Synesis Software Pty Ltd, 2001-2004