00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00047 #ifndef WINSTL_INCL_WINSTL_MEMORY_HPP_NETAPI_ALLOCATOR
00048 #define WINSTL_INCL_WINSTL_MEMORY_HPP_NETAPI_ALLOCATOR
00049
00050 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00051 # define WINSTL_VER_WINSTL_MEMORY_HPP_NETAPI_ALLOCATOR_MAJOR 1
00052 # define WINSTL_VER_WINSTL_MEMORY_HPP_NETAPI_ALLOCATOR_MINOR 1
00053 # define WINSTL_VER_WINSTL_MEMORY_HPP_NETAPI_ALLOCATOR_REVISION 4
00054 # define WINSTL_VER_WINSTL_MEMORY_HPP_NETAPI_ALLOCATOR_EDIT 14
00055 #endif
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 #ifndef WINSTL_INCL_WINSTL_H_WINSTL
00070 # include <winstl/winstl.h>
00071 #endif
00072 #ifndef STLSOFT_INCL_STLSOFT_MEMORY_HPP_ALLOCATOR_BASE
00073 # include <stlsoft/memory/allocator_base.hpp>
00074 #endif
00075
00076 #ifndef STLSOFT_INCL_H_LM
00077 # define STLSOFT_INCL_H_LM
00078 # include <lm.h>
00079 #endif
00080
00081
00082
00083
00084
00085 #ifndef _WINSTL_NO_NAMESPACE
00086 # if defined(_STLSOFT_NO_NAMESPACE) || \
00087 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00088
00089 namespace winstl
00090 {
00091 # else
00092
00093
00094 namespace stlsoft
00095 {
00096
00097 namespace winstl_project
00098 {
00099
00100 # endif
00101 #endif
00102
00103
00104
00105
00106
00113 template <ss_typename_param_k T>
00114 class netapi_allocator
00115 : public allocator_base<T, netapi_allocator<T> >
00116 {
00117 private:
00118 typedef allocator_base<T, netapi_allocator<T> > parent_class_type;
00119 public:
00121 typedef netapi_allocator<T> class_type;
00123 typedef ss_typename_type_k parent_class_type::value_type value_type;
00125 typedef ss_typename_type_k parent_class_type::pointer pointer;
00127 typedef ss_typename_type_k parent_class_type::const_pointer const_pointer;
00129 typedef ss_typename_type_k parent_class_type::reference reference;
00131 typedef ss_typename_type_k parent_class_type::const_reference const_reference;
00133 typedef ss_typename_type_k parent_class_type::difference_type difference_type;
00135 typedef ss_typename_type_k parent_class_type::size_type size_type;
00136
00137 public:
00138 #ifdef STLSOFT_CF_ALLOCATOR_REBIND_SUPPORT
00140 template <ss_typename_param_k U>
00141 struct rebind
00142 {
00143 typedef netapi_allocator<U> other;
00144 };
00145 #endif
00146
00149 public:
00151 netapi_allocator()
00152 {}
00154 #ifdef STLSOFT_CF_ALLOCATOR_REBIND_SUPPORT
00155 template <ss_typename_param_k U>
00156 netapi_allocator(netapi_allocator<U> const&)
00157 {}
00158 #else
00159 netapi_allocator(class_type const&)
00160 {}
00161 #endif
00163
00164 private:
00165 friend class allocator_base<T, netapi_allocator<T> >;
00166
00167 void *do_allocate(size_type n, void const* hint)
00168 {
00169 STLSOFT_SUPPRESS_UNUSED(hint);
00170
00171 LPVOID pv;
00172 NET_API_STATUS status = ::NetApiBufferAllocate(n * sizeof(value_type), &pv);
00173
00174 return (NERR_Success == status) ? static_cast<void*>(pv) : NULL;
00175 }
00176 void do_deallocate(void *pv, size_type n)
00177 {
00178 STLSOFT_SUPPRESS_UNUSED(n);
00179
00180 ::NetApiBufferFree(static_cast<LPVOID>(pv));
00181 }
00182 void do_deallocate(void *pv)
00183 {
00184 ::NetApiBufferFree(static_cast<LPVOID>(pv));
00185 }
00186 };
00187
00188
00189
00190 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00191
00192
00193 STLSOFT_TEMPLATE_SPECIALISATION
00194 class netapi_allocator<void>
00195 {
00196 public:
00197 typedef void value_type;
00198 typedef netapi_allocator<void> class_type;
00199 typedef void* pointer;
00200 typedef void const* const_pointer;
00201 typedef ws_ptrdiff_t difference_type;
00202 typedef ws_size_t size_type;
00203
00204 #ifdef STLSOFT_CF_ALLOCATOR_REBIND_SUPPORT
00206 template <ss_typename_param_k U>
00207 struct rebind
00208 {
00209 typedef netapi_allocator<U> other;
00210 };
00211 #endif
00212 };
00213
00214 #endif
00215
00216 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00217
00218 template <ss_typename_param_k T>
00219 inline ws_bool_t operator ==(const netapi_allocator<T> &, const netapi_allocator<T> &)
00220 {
00221 return ws_true_v;
00222 }
00223
00224 template <ss_typename_param_k T>
00225 inline ws_bool_t operator !=(const netapi_allocator<T> &, const netapi_allocator<T> &)
00226 {
00227 return ws_false_v;
00228 }
00229
00230 #endif
00231
00233
00234
00235 #ifdef STLSOFT_UNITTEST
00236 # include "./unittest/netapi_allocator_unittest_.h"
00237 #endif
00238
00239
00240
00241 #ifndef _WINSTL_NO_NAMESPACE
00242 # if defined(_STLSOFT_NO_NAMESPACE) || \
00243 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00244 }
00245 # else
00246 }
00247 }
00248 # endif
00249 #endif
00250
00251
00252
00253 #endif
00254
00255