|
|
|
|
|
|
|
|
|
|
|
|||||||
00001 /* 00002 * File: rangelib/adaptors.hpp 00003 * 00004 * Purpose: Adaptors. 00005 * 00006 * Created: 4th November 2003 00007 * Updated: 12th 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 00041 #error This file is not ready for release. 00042 00044 00045 #ifndef STLSOFT_INCL_RANGELIB_HPP_ADAPTORS 00046 #define STLSOFT_INCL_RANGELIB_HPP_ADAPTORS 00047 00048 #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION 00049 # define STLSOFT_VER_RANGELIB_HPP_ADAPTORS_MAJOR 1 00050 # define STLSOFT_VER_RANGELIB_HPP_ADAPTORS_MINOR 0 00051 # define STLSOFT_VER_RANGELIB_HPP_ADAPTORS_REVISION 4 00052 # define STLSOFT_VER_RANGELIB_HPP_ADAPTORS_EDIT 6 00053 #endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ 00054 00055 /* 00056 * Includes 00057 */ 00058 00059 #ifndef STLSOFT_INCL_H_STLSOFT 00060 # include <stlsoft.h> // Include the STLSoft root header 00061 #endif /* !STLSOFT_INCL_H_STLSOFT */ 00062 #include <iterator> 00063 00064 /* 00065 * Namespace 00066 */ 00067 00068 #ifndef _STLSOFT_NO_NAMESPACE 00069 namespace stlsoft 00070 { 00071 #endif /* _STLSOFT_NO_NAMESPACE */ 00072 00073 /* 00074 00079 00080 /* 00081 * Classes 00082 */ 00083 00085 template <class R> 00086 class r_back_insert_range 00087 { 00088 public: 00090 typedef R range_type; 00092 typedef ss_typename_type_k R::iterator iterator; 00094 typedef ss_typename_type_k R::value_type value_type; 00096 typedef r_back_insert_range<R> class_type; 00097 00098 public: 00100 r_back_insert_range(R &r); 00101 00102 // operator =( 00103 00105 operator bool() const; 00107 value_type operator *(); 00109 class_type &operator ++(); 00112 class_type operator ++(int) 00113 { 00114 class_type ret(*this); 00115 00116 operator ++(); 00117 00118 return ret; 00119 } 00120 00122 iterator begin(); 00124 iterator end(); 00125 00126 // Members 00127 private: 00128 }; 00129 00131 template <class R> 00132 inline r_back_insert_range<R> r_back_inserter(R &r) 00133 { 00134 return r_back_insert_range<R>(r); 00135 } 00136 00138 // Unit-testing 00139 00140 #ifdef STLSOFT_UNITTEST 00141 00142 namespace unittest 00143 { 00144 ss_bool_t test_rangelib_adaptors(unittest_reporter *r) 00145 { 00146 using stlsoft::unittest::unittest_initialiser; 00147 00148 ss_bool_t bSuccess = true; 00149 00150 unittest_initialiser init(r, "RangeLib", "adaptors", __FILE__); 00151 00152 adaptors vi1("USER32"); 00153 00154 #if 0 00155 if(NULL != pi1) 00156 { 00157 ator1.construct(pi1, 1968); 00158 00159 if(1968 != *pi1) 00160 { 00161 r->report("construct() failed ", __LINE__); 00162 bSuccess = false; 00163 } 00164 } 00165 #endif /* 0 */ 00166 00167 return bSuccess; 00168 } 00169 00170 unittest_registrar unittest_rangelib_adaptors(test_rangelib_adaptors); 00171 00172 } // namespace unittest 00173 00174 #endif /* STLSOFT_UNITTEST */ 00175 00176 /* 00177 00179 00180 /* 00181 00182 #ifndef _STLSOFT_NO_NAMESPACE 00183 } // namespace stlsoft 00184 #endif /* _STLSOFT_NO_NAMESPACE */ 00185 00186 /* 00187 00188 #endif /* !STLSOFT_INCL_RANGELIB_HPP_ADAPTORS */ 00189 00190 /*
|
|
| STLSoft Libraries documentation © Synesis Software Pty Ltd, 2001-2004 |