⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stlsoft_proxy_iterator.h

📁 用STL的方式封装了WindowsAPI、COM调用、ACE、ATL、MFC、WTL等多种组件
💻 H
📖 第 1 页 / 共 2 页
字号:
/* /////////////////////////////////////////////////////////////////////////
 * File:        stlsoft_proxy_iterator.h (Formerly part of stlsoft_proxy_sequence.h)
 *
 * Purpose:     proxy_iterator template class.
 *
 * Created:     28th June 2004
 * Updated:     18th June 2006
 *
 * Home:        http://stlsoft.org/
 *
 * Copyright (c) 2004-2006, 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 stlsoft_proxy_iterator.h
///
/// proxy_iterator template class.

#ifndef STLSOFT_INCL_H_STLSOFT_PROXY_ITERATOR
#define STLSOFT_INCL_H_STLSOFT_PROXY_ITERATOR

#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
# define STLSOFT_VER_H_STLSOFT_PROXY_ITERATOR_MAJOR       2
# define STLSOFT_VER_H_STLSOFT_PROXY_ITERATOR_MINOR       5
# define STLSOFT_VER_H_STLSOFT_PROXY_ITERATOR_REVISION    2
# define STLSOFT_VER_H_STLSOFT_PROXY_ITERATOR_EDIT        43
#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */

/* /////////////////////////////////////////////////////////////////////////
 * Compatibility
 */

/*
[Incompatibilies-start]
STLSOFT_COMPILER_IS_WATCOM:
[Incompatibilies-end]
 */

/* /////////////////////////////////////////////////////////////////////////
 * Includes
 */

#ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
# include <stlsoft/stlsoft.h>
#endif /* !STLSOFT_INCL_STLSOFT_H_STLSOFT */
#ifndef STLSOFT_INCL_STLSOFT_HPP_ITERATOR
# include <stlsoft/iterator.hpp>
#endif /* !STLSOFT_INCL_STLSOFT_HPP_ITERATOR */

/* /////////////////////////////////////////////////////////////////////////
 * Namespace
 */

#ifndef _STLSOFT_NO_NAMESPACE
namespace stlsoft
{
#endif /* _STLSOFT_NO_NAMESPACE */

/* /////////////////////////////////////////////////////////////////////////
 * Warnings
 */

#if defined(STLSOFT_COMPILER_IS_MSVC)
# if _MSC_VER >= 1200
#  pragma warning(push)
# endif /* compiler */
# pragma warning(disable : 4355)
#endif /* compiler */

/* /////////////////////////////////////////////////////////////////////////
 * Classes
 */

/** \brief Provides translation between the elements in a range and a different value type
 *
 * \param R The element type. This type is the element in the underlying sequence
 * \param V The value type. This is the type to which the element type is translated
 * \param T The traits_type. This type provides a static method \c make_value(), which
 * converts the element type to the value type
 * \param C The iterator category
 * \param R The reference type
 * \param P The pointer type
 */
/// Iterator for proxy_sequence
template<   ss_typename_param_k E
        ,   ss_typename_param_k V
        ,   ss_typename_param_k T
        ,   ss_typename_param_k C
        ,   ss_typename_param_k R = T&
        ,   ss_typename_param_k P = T*
        >
class proxy_iterator
    : public iterator_base<C, V, ss_ptrdiff_t, P, R>
{
/// \name Types
/// @{
private:
    typedef iterator_base<C, V, ss_ptrdiff_t, P, R>                 parent_class_type;
    typedef ss_typename_type_k parent_class_type::value_type        raw_value_type;
public:
    typedef E                                                       element_type;
    typedef raw_value_type                                          value_type;
    typedef ss_typename_type_k parent_class_type::reference         reference;
    typedef value_type const                                        &const_reference;
    typedef T                                                       traits_type;
    typedef ss_typename_type_k parent_class_type::iterator_category iterator_category;
    typedef ss_typename_type_k parent_class_type::pointer           pointer;
    typedef proxy_iterator<E, V, T, C, R, P>                        class_type;
    typedef ss_size_t                                               size_type;
    typedef ss_typename_type_k parent_class_type::difference_type   difference_type;
/// @}

/// \name Construction
/// @{
public:
    /// Default constructor
    proxy_iterator()
        : m_begin(NULL)
        , m_end(NULL)
        , m_value(value_type())
        , m_modified(true)
    {}

#if !defined(STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT) || \
    defined(STLSOFT_CF_MEMBER_TEMPLATE_CTOR_OVERLOAD_DISCRIMINATED)
    proxy_iterator(element_type *from, element_type *to)
        : m_begin(from)
        , m_end(to)
        , m_value(value_type())
        , m_modified(true)
    {}
    proxy_iterator(element_type *p, size_type n)
        : m_begin(p)
        , m_end(p + n)
        , m_value(value_type())
        , m_modified(true)
    {}
#endif /* !STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT || STLSOFT_CF_MEMBER_TEMPLATE_CTOR_OVERLOAD_DISCRIMINATED */

#if defined(STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT)
    template <ss_typename_param_k P2>
    proxy_iterator(P2 *from, P2 *to)
        : m_begin(from)
        , m_end(to)
        , m_value(value_type())
        , m_modified(true)
    {}
    template <ss_typename_param_k P2>
    proxy_iterator(P2 *p, size_type n)
        : m_begin(p)
        , m_end(p + n)
        , m_value(value_type())
        , m_modified(true)
    {}
#endif /* STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT */

    proxy_iterator(class_type const &rhs)
        : m_begin(rhs.begin())
        , m_end(rhs.end())
        , m_value(value_type())
        , m_modified(true)
    {}

#if defined(STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT) && \
    (   !defined(STLSOFT_COMPILER_IS_MSVC) || \
        _MSC_VER >= 1310)
    template <ss_typename_param_k I>
    /* ss_explicit_k */ proxy_iterator(I &i)
        : m_begin(i.begin())
        , m_end(i.end())
        , m_value(value_type())
        , m_modified(true)
    {}
#endif /* STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT && compiler */

    class_type &operator =(class_type const &rhs)
    {
        m_begin     =   rhs.begin();
        m_end       =   rhs.end();
        m_modified  =   true;

        return *this;
    }

#if defined(STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT)
    template <ss_typename_param_k I>
    class_type &operator =(I &rhs)
    {
        m_begin     =   rhs.begin();
        m_end       =   rhs.end();
        m_modified  =   true;

        return *this;
    }
#endif /* STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT */
/// @}

/// \name Helper functions
/// @{
public:
    /// The proxy iterator begin-point
    ///
    /// \return A pointer to the current position of the proxy iterator
    element_type    *begin()
    {
        return m_begin;
    }
    /// The proxy iterator end-point
    ///
    /// \return A pointer to the end point of the proxy iterator
    element_type    *end()
    {
        return m_end;
    }
    /// The proxy iterator begin-point
    ///
    /// \return A pointer to the current position of the proxy iterator
    element_type const  *begin() const
    {
        return m_begin;
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -