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
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00056
00057
00058
00059
00060 #ifndef RECLS_INCL_RECLS_STL_HPP_RECLS
00061 # include <recls/stl/recls.hpp>
00062 #endif
00063 #ifndef RECLS_INCL_RECLS_STL_HPP_TRAITS
00064 # include <recls/stl/traits.hpp>
00065 #endif
00066 #include <stlsoft/new_allocator.hpp>
00067 #include <stlsoft/proxy_sequence.hpp>
00068
00069
00070
00071
00072
00073 #if !defined(RECLS_NO_NAMESPACE)
00074 namespace recls
00075 {
00076
00077 namespace stl
00078 {
00079 #endif
00080
00081
00082
00083
00084
00085
00092
00093 #ifdef __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT
00094 , typename T = reclstl_traits<C>
00095 , typename A = stlsoft::new_allocator<C>
00096 #else
00097 , typename T
00098 , typename A
00099 #endif
00100 >
00101 class basic_root_sequence
00102 {
00105 public:
00107 typedef C char_type;
00109 typedef T traits_type;
00111 typedef A allocator_type;
00113 typedef basic_root_sequence<C, T, A> class_type;
00115 typedef char_type const *value_type;
00116 private:
00117 struct proxy_traits_type
00118 {
00119 static recls_char_t const *make_value(recls_root_t const &root)
00120 {
00121 return root.name;
00122 }
00123 };
00124
00125 typedef stlsoft::proxy_sequence< const recls_root_t
00126 , recls_char_t const*
00127 , proxy_traits_type
00128 > sequence_type;
00129 public:
00131 typedef typename sequence_type::const_iterator const_iterator;
00133 typedef value_type &reference;
00135 typedef value_type const &const_reference;
00137 typedef size_t size_type;
00139
00142 public:
00144 basic_root_sequence();
00146 ~basic_root_sequence();
00148
00151 public:
00155 const_iterator begin() const;
00159 const_iterator end() const;
00161
00164 public:
00166 size_type size() const;
00168 recls_bool_t empty() const;
00170 static size_type max_size();
00172
00175 private:
00176 recls_root_t *m_roots;
00177 size_type m_cRoots;
00179
00180
00181 private:
00182 basic_root_sequence(class_type const &);
00183 basic_root_sequence const &operator =(class_type const &);
00184 };
00185
00186
00187
00188
00189
00191 typedef basic_root_sequence<recls_char_a_t, reclstl_traits<recls_char_a_t>, stlsoft::new_allocator<recls_char_a_t> > root_sequence_a;
00193 typedef basic_root_sequence<recls_char_w_t, reclstl_traits<recls_char_w_t>, stlsoft::new_allocator<recls_char_w_t> > root_sequence_w;
00195 typedef basic_root_sequence<recls_char_t, reclstl_traits<recls_char_t>, stlsoft::new_allocator<recls_char_t> > root_sequence;
00196
00198
00199
00210 template <typename C, typename T, typename A>
00211 inline recls_bool_t is_empty(basic_root_sequence<C, T, A> const &s)
00212 {
00213 return s.empty();
00214 }
00215
00217
00218
00219 #ifndef RECLS_DOCUMENTATION_SKIP_SECTION
00220
00221
00222
00223
00224
00225 template <typename C, typename T, typename A>
00226 inline basic_root_sequence<C, T, A>::basic_root_sequence()
00227 #ifdef RECLS_COMPILER_IS_BORLAND
00228 : m_cRoots(26)
00229 #else
00230 : m_cRoots(Recls_GetRoots(NULL, 0))
00231 #endif
00232 {
00233 m_roots = new recls_root_t[m_cRoots];
00234
00235 m_cRoots = Recls_GetRoots(m_roots, m_cRoots);
00236 }
00237
00238 template <typename C, typename T, typename A>
00239 inline basic_root_sequence<C, T, A>::~basic_root_sequence()
00240 {
00241 delete [] m_roots;
00242 }
00243
00244
00245
00246 template <typename C, typename T, typename A>
00247 inline typename basic_root_sequence<C, T, A>::const_iterator basic_root_sequence<C, T, A>::begin() const
00248 {
00249 return const_iterator(&m_roots[0], &m_roots[m_cRoots]);
00250 }
00251
00252 template <typename C, typename T, typename A>
00253 inline typename basic_root_sequence<C, T, A>::const_iterator basic_root_sequence<C, T, A>::end() const
00254 {
00255 return const_iterator();
00256 }
00257
00258
00259
00260 template <typename C, typename T, typename A>
00261 inline typename basic_root_sequence<C, T, A>::size_type basic_root_sequence<C, T, A>::size() const
00262 {
00263 return m_cRoots;
00264 }
00265
00266 template <typename C, typename T, typename A>
00267 inline recls_bool_t basic_root_sequence<C, T, A>::empty() const
00268 {
00269 return 0 == m_cRoots;
00270 }
00271
00272 template <typename C, typename T, typename A>
00273 inline typename basic_root_sequence<C, T, A>::size_type basic_root_sequence<C, T, A>::max_size()
00274 {
00275 return static_cast<size_type>(-1) / sizeof(value_type);
00276 }
00277
00278 #endif
00279
00280
00281
00282
00283
00284 }
00285 #endif
00286
00287
00288
00289
00290
00291