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
00043 #ifndef RANGELIB_INCL_RANGELIB_HPP_CSTRING_RANGE
00044 #define RANGELIB_INCL_RANGELIB_HPP_CSTRING_RANGE
00045
00046 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00047 # define RANGELIB_VER_RANGELIB_HPP_CSTRING_RANGE_MAJOR 2
00048 # define RANGELIB_VER_RANGELIB_HPP_CSTRING_RANGE_MINOR 3
00049 # define RANGELIB_VER_RANGELIB_HPP_CSTRING_RANGE_REVISION 3
00050 # define RANGELIB_VER_RANGELIB_HPP_CSTRING_RANGE_EDIT 37
00051 #endif
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 #ifndef RANGELIB_INCL_RANGELIB_HPP_RANGELIB
00069 # include <rangelib/rangelib.hpp>
00070 #endif
00071 #ifndef RANGELIB_INCL_RANGELIB_HPP_RANGE_CATEGORIES
00072 # include <rangelib/range_categories.hpp>
00073 #endif
00074 #ifndef RANGELIB_INCL_RANGELIB_HPP_OPERATOR_ADAPTORS
00075 # include <rangelib/operator_adaptors.hpp>
00076 #endif
00077 #ifndef STLSOFT_INCL_STLSOFT_META_HPP_CAPABILITIES
00078 # include <stlsoft/meta/capabilities.hpp>
00079 #endif
00080 #ifndef STLSOFT_INCL_STLSOFT_META_HPP_IS_BOOL_TYPE
00081 # include <stlsoft/meta/is_bool_type.hpp>
00082 #endif
00083 #ifndef STLSOFT_INCL_STLSOFT_META_HPP_IS_INTEGRAL_TYPE
00084 # include <stlsoft/meta/is_integral_type.hpp>
00085 #endif
00086 #ifndef STLSOFT_INCL_STLSOFT_META_HPP_IS_NUMERIC_TYPE
00087 # include <stlsoft/meta/is_numeric_type.hpp>
00088 #endif
00089 #ifndef STLSOFT_INCL_STLSOFT_UTIL_HPP_CONSTRAINTS
00090 # include <stlsoft/util/constraints.hpp>
00091 #endif
00092
00093
00094
00095
00096
00097 #ifndef RANGELIB_NO_NAMESPACE
00098 # if defined(_STLSOFT_NO_NAMESPACE) || \
00099 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00100
00101 namespace rangelib
00102 {
00103 # else
00104
00105
00106 namespace stlsoft
00107 {
00108
00109 namespace rangelib_project
00110 {
00111
00112 # endif
00113 #endif
00114
00115
00116
00117
00118
00123 template <ss_typename_param_k C>
00124 struct cstring_range_traits
00125 {
00128 public:
00130 typedef C value_type;
00132 typedef C const& const_reference;
00134 };
00135
00136
00152 template <ss_typename_param_k C>
00153 class cstring_range
00154 : public non_mutating_operator_adaptor< cstring_range<C>
00155 , cstring_range_traits<C>
00156 >
00157 , public notional_range_tag
00158 {
00161 public:
00163 typedef C value_type;
00165 typedef notional_range_tag range_tag_type;
00167 typedef cstring_range<C> class_type;
00169 typedef value_type const& const_reference;
00171
00174 public:
00178 cstring_range(value_type const* s)
00179 : m_s(s)
00180 {
00181 STLSOFT_MESSAGE_ASSERT("NULL string passed to cstring_range constructor", NULL != s);
00182 }
00184 ~cstring_range() stlsoft_throw_0()
00185 {
00186
00187
00188 STLSOFT_STATIC_ASSERT(0 != is_integral_type<value_type>::value);
00189 STLSOFT_STATIC_ASSERT(0 == is_numeric_type<value_type>::value);
00190 STLSOFT_STATIC_ASSERT(0 == is_bool_type<value_type>::value);
00191 }
00193
00196 public:
00198 ss_bool_t is_open() const
00199 {
00200 STLSOFT_ASSERT(NULL != m_s);
00201
00202 return '\0' != *m_s;
00203 }
00205 const_reference current() const
00206 {
00207 STLSOFT_MESSAGE_ASSERT("Attempting to access the value of a closed range", is_open());
00208
00209 return *m_s;
00210 }
00212 class_type& advance()
00213 {
00214 STLSOFT_MESSAGE_ASSERT("Attempting to advance a closed range", is_open());
00215
00216 ++m_s;
00217
00218 return *this;
00219 }
00221
00222
00223 private:
00224 value_type const *m_s;
00225 };
00226
00228
00229
00230 #ifdef STLSOFT_UNITTEST
00231 # include "./unittest/cstring_range_unittest_.h"
00232 #endif
00233
00234
00235
00236 #ifndef RANGELIB_NO_NAMESPACE
00237 # if defined(_STLSOFT_NO_NAMESPACE) || \
00238 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00239 }
00240 # else
00241 }
00242 }
00243 # endif
00244 #endif
00245
00246
00247
00248 #endif
00249
00250