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_ITERATORS_HPP_CSTRING_CONCATENATOR_ITERATOR
00049 #define STLSOFT_INCL_STLSOFT_ITERATORS_HPP_CSTRING_CONCATENATOR_ITERATOR
00050
00051 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00052 # define STLSOFT_VER_STLSOFT_ITERATORS_HPP_CSTRING_CONCATENATOR_ITERATOR_MAJOR 2
00053 # define STLSOFT_VER_STLSOFT_ITERATORS_HPP_CSTRING_CONCATENATOR_ITERATOR_MINOR 1
00054 # define STLSOFT_VER_STLSOFT_ITERATORS_HPP_CSTRING_CONCATENATOR_ITERATOR_REVISION 2
00055 # define STLSOFT_VER_STLSOFT_ITERATORS_HPP_CSTRING_CONCATENATOR_ITERATOR_EDIT 28
00056 #endif
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
00073 # include <stlsoft/stlsoft.h>
00074 #endif
00075 #ifndef STLSOFT_INCL_STLSOFT_UTIL_STD_HPP_ITERATOR_HELPER
00076 # include <stlsoft/util/std/iterator_helper.hpp>
00077 #endif
00078 #ifndef STLSOFT_INCL_STLSOFT_ALGORITHMS_HPP_POD
00079 # include <stlsoft/algorithms/pod.hpp>
00080 #endif
00081 #ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_HPP_STRING
00082 # include <stlsoft/shims/access/string.hpp>
00083 #endif
00084
00085
00086
00087
00088
00089 #ifndef _STLSOFT_NO_NAMESPACE
00090 namespace stlsoft
00091 {
00092 #endif
00093
00094
00095
00096
00097
00106 template <ss_typename_param_k C>
00107
00108 class cstring_concatenator_iterator
00109 : public stlsoft_ns_qual(iterator_base)<stlsoft_ns_qual_std(output_iterator_tag), void, void, void, void>
00110 {
00113 public:
00114 typedef C char_type;
00115 typedef ss_size_t size_type;
00116 typedef cstring_concatenator_iterator<C> class_type;
00117 private:
00118 typedef cstring_concatenator_iterator<C> concatenator_iterator_type;
00119 private:
00120 class deref_proxy;
00121 friend class deref_proxy;
00123
00126 public:
00138 ss_explicit_k cstring_concatenator_iterator(char_type *dest, size_type *pNumWritten = NULL)
00139 : m_dest(dest)
00140 , m_numWritten((NULL != pNumWritten) ? pNumWritten : dummy_())
00141 {
00142
00143
00144 STLSOFT_ASSERT(NULL != m_dest);
00145 }
00147
00150 public:
00152 class_type& operator ++()
00153 {
00154 return *this;
00155 }
00157 class_type& operator ++(int)
00158 {
00159 return *this;
00160 }
00161
00163 deref_proxy operator *()
00164 {
00165 return deref_proxy(this);
00166 }
00168
00171 private:
00172 class deref_proxy
00173 {
00174 public:
00175 deref_proxy(concatenator_iterator_type *it)
00176 : m_it(it)
00177 {}
00178
00179 public:
00180 template <ss_typename_param_k S>
00181 void operator =(S const& s)
00182 {
00183 m_it->invoke_(s);
00184 }
00185
00186 private:
00187 concatenator_iterator_type *const m_it;
00188
00189
00190 private:
00191 void operator =(deref_proxy const&);
00192 };
00194
00197 private:
00198 void concat_(char_type const* s, size_type len)
00199 {
00200 pod_copy_n(m_dest, s, len);
00201
00202 m_dest += len;
00203 *m_numWritten += len;
00204 }
00205 template <ss_typename_param_k S>
00206 void invoke_(S const& s)
00207 {
00208
00209 this->concat_(::stlsoft::c_str_data(s), ::stlsoft::c_str_len(s));
00210 }
00211
00212 static size_type *dummy_()
00213 {
00214 static size_type s_dummy;
00215
00216 return &s_dummy;
00217 }
00219
00222 private:
00223 char_type *m_dest;
00224 size_type *m_numWritten;
00226 };
00227
00228 #if 0
00229
00241 template <ss_typename_param_k C>
00242 inline cstring_concatenator_iterator<C> cstring_concatenator(C *s, ss_size_t &numWritten)
00243 {
00244 return cstring_concatenator_iterator<C>(s, &numWritten);
00245 }
00246
00255 template <ss_typename_param_k C>
00256 inline cstring_concatenator_iterator<C> cstring_concatenator(C *s)
00257 {
00258 return cstring_concatenator_iterator<C>(s, NULL);
00259 }
00260
00261 #else
00262
00272 template <ss_typename_param_k C>
00273 inline cstring_concatenator_iterator<C> make_cstring_concatenator_iterator(C *s, ss_size_t *pNumWritten = NULL)
00274 {
00275 return cstring_concatenator_iterator<C>(s, pNumWritten);
00276 }
00277
00292 template <ss_typename_param_k C>
00293 inline cstring_concatenator_iterator<C> cstring_concatenator(C *s, ss_size_t *pNumWritten = NULL)
00294 {
00295 return make_cstring_concatenator_iterator(s, pNumWritten);
00296 }
00297
00298 #endif
00299
00301
00302
00303 #ifdef STLSOFT_UNITTEST
00304 # include "./unittest/cstring_concatenator_iterator_unittest_.h"
00305 #endif
00306
00307
00308
00309 #ifndef _STLSOFT_NO_NAMESPACE
00310 }
00311 #endif
00312
00313
00314
00315 #endif
00316
00317