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
00048 #ifndef STLSOFT_INCL_STLSOFT_STRING_HPP_CHARSET_TOKENISER
00049 #define STLSOFT_INCL_STLSOFT_STRING_HPP_CHARSET_TOKENISER
00050
00051 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00052 # define STLSOFT_VER_STLSOFT_STRING_HPP_CHARSET_TOKENISER_MAJOR 2
00053 # define STLSOFT_VER_STLSOFT_STRING_HPP_CHARSET_TOKENISER_MINOR 0
00054 # define STLSOFT_VER_STLSOFT_STRING_HPP_CHARSET_TOKENISER_REVISION 4
00055 # define STLSOFT_VER_STLSOFT_STRING_HPP_CHARSET_TOKENISER_EDIT 25
00056 #endif
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
00075 # include <stlsoft/stlsoft.h>
00076 #endif
00077
00078 #if defined(STLSOFT_COMPILER_IS_MSVC) && \
00079 _MSC_VER < 1200
00080 # error stlsoft/string/charset_tokeniser.hpp is not compatible with Visual C++ 5.0 or earlier
00081 #endif
00082
00083 #ifndef STLSOFT_INCL_STLSOFT_STRING_HPP_STRING_TOKENISER
00084 # include <stlsoft/string/string_tokeniser.hpp>
00085 #endif
00086
00087 #ifndef STLSOFT_INCL_ALGORITHM
00088 # define STLSOFT_INCL_ALGORITHM
00089 # include <algorithm>
00090 #endif
00091
00092 #ifdef STLSOFT_UNITTEST
00093 # ifndef STLSOFT_INCL_STLSOFT_STRING_HPP_SIMPLE_STRING
00094 # include <stlsoft/string/simple_string.hpp>
00095 # endif
00096 # ifndef STLSOFT_INCL_STLSOFT_STRING_HPP_STRING_VIEW
00097 # include <stlsoft/string/string_view.hpp>
00098 # endif
00099 # include <algorithm>
00100 # include <string>
00101 #endif
00102
00103
00104
00105
00106
00107 #ifndef _STLSOFT_NO_NAMESPACE
00108 namespace stlsoft
00109 {
00110 #endif
00111
00112
00113
00114
00115
00120 template <ss_typename_param_k S>
00121 struct charset_comparator
00122 {
00123 public:
00124 typedef S delimiter_type;
00125
00126 private:
00127 template <ss_typename_param_k const_iterator>
00128 static bool equal_(delimiter_type const& delimiter, const_iterator &it)
00129 {
00130 return delimiter.end() != stlsoft_ns_qual_std(find)(delimiter.begin(), delimiter.end(), *it);
00131 }
00132
00133 template <ss_typename_param_k const_iterator>
00134 static const_iterator advance_(const_iterator it, delimiter_type const& delimiter)
00135 {
00136 return it + 1;
00137 }
00138
00139 public:
00143 template <ss_typename_param_k const_iterator>
00144 static bool not_equal(delimiter_type const& delimiter, const_iterator &it)
00145 {
00146 return !equal_(delimiter, it);
00147 }
00148
00149 static ss_size_t length(delimiter_type const& )
00150 {
00151 return 1;
00152 }
00153
00154 template <ss_typename_param_k const_iterator>
00155 static bool test_start_token_advance(const_iterator &it, const_iterator end, delimiter_type const& delimiter)
00156 {
00157 return equal_(delimiter, it) ? (it = advance_(it, delimiter), true) : false;
00158 }
00159
00160 template <ss_typename_param_k const_iterator>
00161 static bool test_end_token_advance(const_iterator &it, const_iterator end, delimiter_type const& delimiter)
00162 {
00163 return equal_(delimiter, it) ? (it = advance_(it, delimiter), true) : false;
00164 }
00165
00166 template <ss_typename_param_k const_iterator>
00167 static const_iterator nonskip_move_to_start(const_iterator it, const_iterator end, delimiter_type const& delimiter)
00168 {
00169 return it;
00170 }
00171
00172 template <ss_typename_param_k const_iterator>
00173 static bool test_end_token(const_iterator it, const_iterator end, delimiter_type const& delimiter)
00174 {
00175 return equal_(delimiter, it);
00176 }
00177
00178 template <ss_typename_param_k const_iterator>
00179 static const_iterator find_next_start(const_iterator it, const_iterator end, delimiter_type const& delimiter)
00180 {
00181 return advance_(it, delimiter);
00182 }
00183 };
00184
00204 template< ss_typename_param_k S
00205 #ifdef STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT
00206 , ss_typename_param_k B = skip_blank_tokens<true>
00207 , ss_typename_param_k V = S
00208 , ss_typename_param_k T = string_tokeniser_type_traits<S, V>
00209 , ss_typename_param_k D = S
00210 , ss_typename_param_k P = charset_comparator<S>
00211 #else
00212 , ss_typename_param_k B
00213 , ss_typename_param_k V
00214 , ss_typename_param_k T
00215 , ss_typename_param_k D
00216 , ss_typename_param_k P
00217 #endif
00218 >
00219 class charset_tokeniser
00220 : public string_tokeniser<S, D, B, V, T, P>
00221 {
00224 private:
00225 typedef string_tokeniser<S, D, B, V, T, P> parent_class_type;
00226 public:
00228 typedef charset_tokeniser<S, B, V, T, D, P> class_type;
00230 typedef ss_typename_type_k parent_class_type::string_type string_type;
00232 typedef ss_typename_type_k parent_class_type::delimiter_type delimiter_type;
00234 typedef ss_typename_type_k parent_class_type::blanks_policy_type blanks_policy_type;
00236 typedef ss_typename_type_k parent_class_type::value_type value_type;
00238 typedef ss_typename_type_k parent_class_type::traits_type traits_type;
00240 typedef ss_typename_type_k parent_class_type::comparator_type comparator_type;
00242 typedef ss_typename_type_k parent_class_type::char_type char_type;
00244 typedef ss_typename_type_k parent_class_type::size_type size_type;
00245 #if 0
00247 typedef ss_typename_type_k parent_class_type::difference_type difference_type;
00248 #endif
00250 typedef ss_typename_type_k parent_class_type::const_reference const_reference;
00252 typedef ss_typename_type_k parent_class_type::const_iterator const_iterator;
00254
00255 public:
00258 public:
00265 charset_tokeniser(char_type const* psz, delimiter_type const& charSet)
00266 : parent_class_type(psz, charSet)
00267 {}
00268
00269
00270
00271 #if !defined(STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT) || \
00272 defined(STLSOFT_CF_MEMBER_TEMPLATE_CTOR_OVERLOAD_DISCRIMINATED)
00279 charset_tokeniser(string_type const& str, delimiter_type const& charSet)
00280 : parent_class_type(str, charSet)
00281 {}
00282 #endif
00283
00284
00285 #if defined(STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT)
00292 template <ss_typename_param_k S1>
00293 charset_tokeniser(S1 const& str, delimiter_type const& charSet)
00294 : parent_class_type(str, charSet)
00295 {}
00296 #endif
00297
00305 charset_tokeniser(char_type const* psz, size_type cch, delimiter_type const& charSet)
00306 : parent_class_type(psz, cch, charSet)
00307 {}
00308
00309 #if !defined(STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT) || \
00310 defined(STLSOFT_CF_MEMBER_TEMPLATE_CTOR_OVERLOAD_DISCRIMINATED)
00316 charset_tokeniser(char_type const* from, char_type const* to, delimiter_type const& charSet)
00317 : parent_class_type(from, to, charSet)
00318 {}
00319 #endif
00320
00321 #if defined(STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT)
00327 template <ss_typename_param_k I>
00328 charset_tokeniser(I from, I to, delimiter_type const& charSet)
00329 : parent_class_type(from, to, charSet)
00330 {}
00331 #endif
00333 };
00334
00335
00336
00337
00338
00339 #ifdef STLSOFT_UNITTEST
00340 # include "./unittest/charset_tokeniser_unittest_.h"
00341 #endif
00342
00343
00344
00345 #ifndef _STLSOFT_NO_NAMESPACE
00346 }
00347 #endif
00348
00349
00350
00351 #endif
00352
00353