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  

comstl_enumerator_policies.h

Go to the documentation of this file.
00001 /* 
00002  * File:        comstl_enumerator_policies.h (originally part of comstl_enum_sequence.h)
00003  *
00004  * Purpose:     Policies for enumerator interface handling.
00005  *
00006  * Created:     20th December 2003
00007  * Updated:     11th September 2004
00008  *
00009  * Home:        http://stlsoft.org/
00010  *
00011  * Copyright (c) 2003-2004, Matthew Wilson and Synesis Software
00012  * All rights reserved.
00013  *
00014  * Redistribution and use in source and binary forms, with or without
00015  * modification, are permitted provided that the following conditions are met:
00016  *
00017  * - Redistributions of source code must retain the above copyright notice, this
00018  *   list of conditions and the following disclaimer.
00019  * - Redistributions in binary form must reproduce the above copyright notice,
00020  *   this list of conditions and the following disclaimer in the documentation
00021  *   and/or other materials provided with the distribution.
00022  * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
00023  *   any contributors may be used to endorse or promote products derived from
00024  *   this software without specific prior written permission.
00025  *
00026  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00027  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00029  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00030  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00031  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00032  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00033  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00034  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00035  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00036  * POSSIBILITY OF SUCH DAMAGE.
00037  *
00038  * 
00039 
00040 
00044 
00045 #ifndef COMSTL_INCL_H_COMSTL_ENUMERATOR_POLICIES
00046 #define COMSTL_INCL_H_COMSTL_ENUMERATOR_POLICIES
00047 
00048 #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION
00049 # define COMSTL_VER_H_COMSTL_ENUMERATOR_POLICIES_MAJOR      3
00050 # define COMSTL_VER_H_COMSTL_ENUMERATOR_POLICIES_MINOR      0
00051 # define COMSTL_VER_H_COMSTL_ENUMERATOR_POLICIES_REVISION   1
00052 # define COMSTL_VER_H_COMSTL_ENUMERATOR_POLICIES_EDIT       8
00053 #endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */
00054 
00055 /* 
00056  * Includes
00057  */
00058 
00059 #ifndef COMSTL_INCL_H_COMSTL
00060 # include "comstl.h"                    // Include the COMSTL root header
00061 #endif /* !COMSTL_INCL_H_COMSTL */
00062 #ifndef COMSTL_INCL_H_COMSTL_REFCOUNT_FUNCTIONS
00063 # include "comstl_refcount_functions.h" // safe_release, release_set_null
00064 #endif /* !COMSTL_INCL_H_COMSTL_REFCOUNT_FUNCTIONS */
00065 #ifndef STLSOFT_INCL_H_STLSOFT_ITERATOR
00066 # include "stlsoft_iterator.h"
00067 #endif /* !STLSOFT_INCL_H_STLSOFT_ITERATOR */
00068 
00069 /* 
00070  * Namespace
00071  *
00072  * The COMSTL components are contained within the comstl namespace. This is
00073  * actually an alias for stlsoft::comstl_project,
00074  *
00075  * The definition matrix is as follows:
00076  *
00077  * _STLSOFT_NO_NAMESPACE    _COMSTL_NO_NAMESPACE    comstl definition
00078  * ---------------------    --------------------    -----------------
00079  *  not defined              not defined             = stlsoft::comstl_project
00080  *  not defined              defined                 not defined
00081  *  defined                  not defined             comstl
00082  *  defined                  defined                 not defined
00083  *
00084  */
00085 
00086 #ifndef _COMSTL_NO_NAMESPACE
00087 # if defined(_STLSOFT_NO_NAMESPACE) || \
00088      defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION)
00089 /* There is no stlsoft namespace, so must define ::comstl */
00090 namespace comstl
00091 {
00092 # else
00093 /* Define stlsoft::comstl_project */
00094 
00095 namespace stlsoft
00096 {
00097 
00098 namespace comstl_project
00099 {
00100 
00101 # endif /* _STLSOFT_NO_NAMESPACE */
00102 #endif /* !_COMSTL_NO_NAMESPACE */
00103 
00104 /* 
00105 
00110 
00111 /* 
00112  * Classes
00113  */
00114 
00118 template<ss_typename_param_k I>
00119 struct input_cloning_policy
00120 {
00121 public:
00122     typedef I                                       interface_type;
00123     typedef comstl_ns_qual_std(input_iterator_tag)  iterator_tag_type;
00124 
00125 public:
00127     static interface_type *clone(interface_type *&src)
00128     {
00129         interface_type *ret =   src;
00130 
00131         safe_addref(ret);
00132 
00133         return ret;
00134     }
00135 };
00136 
00140 template<ss_typename_param_k I>
00141 struct forward_cloning_policy
00142 {
00143 public:
00144     typedef I                                           interface_type;
00145     typedef comstl_ns_qual_std(forward_iterator_tag)    iterator_tag_type;
00146 
00147 public:
00149     static interface_type *clone(interface_type const *src)
00150     {
00151         interface_type  *ret;
00152 
00153         if( src == 0 ||
00154             FAILED(const_cast<interface_type*>(src)->Clone(&ret)))
00155         {
00156             ret = 0;
00157         }
00158 
00159         return ret;
00160     }
00161 };
00162 
00166 template<ss_typename_param_k I>
00167 struct degenerate_cloning_policy
00168 {
00169 public:
00170     typedef I                                       interface_type;
00171     typedef comstl_ns_qual_std(input_iterator_tag)  iterator_tag_type;
00172 
00173 public:
00175     static interface_type *clone(interface_type *&src)
00176     {
00177         interface_type  *ret;
00178 
00179         if(src == 0)
00180         {
00181             ret = 0;
00182         }
00183         else if(FAILED(src->Clone(&ret)))
00184         {
00185             ret = src;
00186 
00187             safe_addref(ret);
00188         }
00189 
00190         return ret;
00191     }
00192 };
00193 
00197 template <ss_typename_param_k P>
00198 struct policy_adaptor
00199     : public P
00200 {
00201 public:
00202     typedef ss_typename_type_k P::value_type    value_type;
00203 
00204 public:
00206     struct _init
00207     {
00209         void operator ()(value_type &v) const
00210         {
00211             P::init(&v);
00212         }
00213     };
00215     struct _copy
00216     {
00218         void operator ()(value_type &dest, value_type const &src) const
00219         {
00220             P::copy(&dest, &src);
00221         }
00222     };
00224     struct _clear
00225     {
00227         void operator ()(value_type &v) const
00228         {
00229             P::clear(&v);
00230         }
00231     };
00232 };
00233 
00234 
00235 /* 
00236 
00238 
00239 /* 
00240 
00241 #ifndef _COMSTL_NO_NAMESPACE
00242 # if defined(_STLSOFT_NO_NAMESPACE) || \
00243      defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION)
00244 } // namespace comstl
00245 # else
00246 } // namespace stlsoft::comstl_project
00247 } // namespace stlsoft
00248 # endif /* _STLSOFT_NO_NAMESPACE */
00249 #endif /* !_COMSTL_NO_NAMESPACE */
00250 
00251 /* 
00252 
00253 #endif /* !COMSTL_INCL_H_COMSTL_ENUMERATOR_POLICIES */
00254 
00255 /* 

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