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 WINSTL_INCL_WINSTL_CONTROLS_HPP_EDIT_LINE_SEQUENCE
00049 #define WINSTL_INCL_WINSTL_CONTROLS_HPP_EDIT_LINE_SEQUENCE
00050
00051 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00052 # define WINSTL_VER_WINSTL_CONTROLS_HPP_EDIT_LINE_SEQUENCE_MAJOR 1
00053 # define WINSTL_VER_WINSTL_CONTROLS_HPP_EDIT_LINE_SEQUENCE_MINOR 0
00054 # define WINSTL_VER_WINSTL_CONTROLS_HPP_EDIT_LINE_SEQUENCE_REVISION 7
00055 # define WINSTL_VER_WINSTL_CONTROLS_HPP_EDIT_LINE_SEQUENCE_EDIT 14
00056 #endif
00057
00058
00059
00060
00061
00062 #ifndef WINSTL_INCL_WINSTL_H_WINSTL
00063 # include <winstl/winstl.h>
00064 #endif
00065 #ifndef WINSTL_INCL_WINSTL_CONTROLS_H_FUNCTIONS
00066 # include <winstl/controls/functions.h>
00067 #endif
00068 #ifndef WINSTL_INCL_WINSTL_MEMORY_HPP_PROCESSHEAP_ALLOCATOR
00069 # include <winstl/memory/processheap_allocator.hpp>
00070 #endif
00071 #ifndef STLSOFT_INCL_STLSOFT_COLLECTIONS_UTIL_HPP_COLLECTIONS
00072 # include <stlsoft/collections/util/collections.hpp>
00073 #endif
00074 #ifndef STLSOFT_INCL_STLSOFT_MEMORY_HPP_AUTO_BUFFER
00075 # include <stlsoft/memory/auto_buffer.hpp>
00076 #endif
00077 #ifndef STLSOFT_INCL_STLSOFT_STRING_HPP_SIMPLE_STRING
00078 # include <stlsoft/string/simple_string.hpp>
00079 #endif
00080 #ifndef STLSOFT_INCL_STLSOFT_UTIL_STD_HPP_ITERATOR_HELPER
00081 # include <stlsoft/util/std/iterator_helper.hpp>
00082 #endif
00083
00084 #ifndef STLSOFT_INCL_VECTOR
00085 # define STLSOFT_INCL_VECTOR
00086 # include <vector>
00087 #endif
00088
00089
00090
00091
00092
00093 #ifndef _WINSTL_NO_NAMESPACE
00094 # if defined(_STLSOFT_NO_NAMESPACE) || \
00095 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00096
00097 namespace winstl
00098 {
00099 # else
00100
00101
00102 namespace stlsoft
00103 {
00104
00105 namespace winstl_project
00106 {
00107
00108 # endif
00109 #endif
00110
00111
00112
00113
00114
00126 template< ss_typename_param_k C
00127 , ss_typename_param_k A = processheap_allocator<C>
00128 , ss_typename_param_k S = stlsoft_ns_qual(basic_simple_string)<C, stlsoft_ns_qual(char_traits)<C>, A>
00129 , ss_typename_param_k Q = stlsoft_ns_qual_std(vector)<S>
00130 >
00131 class edit_line_sequence
00132 : public stlsoft_ns_qual(stl_collection_tag)
00133 {
00136 public:
00138 typedef C char_type;
00140 typedef A allocator_type;
00142 typedef S string_type;
00144 typedef string_type value_type;
00146 typedef Q queue_type;
00148 typedef edit_line_sequence<S> class_type;
00150 typedef ss_typename_type_k queue_type::const_iterator const_iterator;
00152 typedef ss_typename_type_k queue_type::const_reverse_iterator const_reverse_iterator;
00154 typedef ss_typename_type_k const_iterator::const_reference const_reference;
00156
00159 public:
00161 ss_explicit_k edit_line_sequence(HWND hwndEdit, unsigned = 0);
00163
00166 public:
00167 const_iterator begin() const;
00168 const_iterator end() const;
00169 const_reverse_iterator rbegin() const;
00170 const_reverse_iterator rend() const;
00172
00175 private:
00176 HWND m_hwndEdit;
00177 queue_type m_queue;
00179 };
00180
00181
00182 template<ss_typename_param_k C, ss_typename_param_k A, ss_typename_param_k S, ss_typename_param_k Q>
00183 inline ws_bool_t operator ==(ss_typename_type_k edit_line_sequence<C, A, S, Q>::const_iterator const& lhs, ss_typename_type_k edit_line_sequence<C, A, S, Q>::const_iterator const& rhs)
00184 {
00185 return lhs.equal(rhs);
00186 }
00187
00188 template<ss_typename_param_k C, ss_typename_param_k A, ss_typename_param_k S, ss_typename_param_k Q>
00189 inline ws_bool_t operator !=(ss_typename_type_k edit_line_sequence<C, A, S, Q>::const_iterator const& lhs, ss_typename_type_k edit_line_sequence<C, A, S, Q>::const_iterator const& rhs)
00190 {
00191 return !lhs.equal(rhs);
00192 }
00193
00195
00196
00197 #ifdef STLSOFT_UNITTEST
00198 # include "./unittest/edit_line_sequence_unittest_.h"
00199 #endif
00200
00201
00202
00203
00204
00205 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00206
00207 template<ss_typename_param_k C, ss_typename_param_k A, ss_typename_param_k S, ss_typename_param_k Q>
00208 inline edit_line_sequence<C, A, S, Q>::edit_line_sequence(HWND hwndEdit, unsigned )
00209 : m_hwndEdit(hwndEdit)
00210 {
00211 WINSTL_ASSERT(NULL != hwndEdit);
00212 WINSTL_ASSERT(::IsWindow(hwndEdit));
00213 WINSTL_MESSAGE_ASSERT("Edit control must have both ES_MULTILINE and ES_AUTOHSCROLL styles", (ES_MULTILINE | ES_AUTOHSCROLL) == ((ES_MULTILINE | ES_AUTOHSCROLL) & ::GetWindowLong(hwndEdit, GWL_STYLE)));
00214
00215 queue_type queue;
00216 int numLines = edit_getcount(hwndEdit);
00217
00218 { int charTotal = 0;
00219 for(int i = 0; i < numLines; ++i)
00220 {
00221 int charIndex = charTotal + i;
00222 int lineLength = edit_linelength(hwndEdit, charIndex);
00223 stlsoft_ns_qual(auto_buffer)<char> line(1 + lineLength);
00224
00225 lineLength = edit_getline(hwndEdit, i, &line[0], line.size());
00226
00227 line[lineLength] = '\0';
00228
00229 queue.push_back(line.data());
00230
00231 charTotal += lineLength + 2;
00232 }}
00233
00234 m_queue.swap(queue);
00235 }
00236
00237 template<ss_typename_param_k C, ss_typename_param_k A, ss_typename_param_k S, ss_typename_param_k Q>
00238 inline ss_typename_type_ret_k edit_line_sequence<C, A, S, Q>::const_iterator edit_line_sequence<C, A, S, Q>::begin() const
00239 {
00240 return m_queue.begin();
00241 }
00242
00243 template<ss_typename_param_k C, ss_typename_param_k A, ss_typename_param_k S, ss_typename_param_k Q>
00244 inline ss_typename_type_ret_k edit_line_sequence<C, A, S, Q>::const_iterator edit_line_sequence<C, A, S, Q>::end() const
00245 {
00246 return m_queue.end();
00247 }
00248
00249 template<ss_typename_param_k C, ss_typename_param_k A, ss_typename_param_k S, ss_typename_param_k Q>
00250 inline ss_typename_type_ret_k edit_line_sequence<C, A, S, Q>::const_reverse_iterator edit_line_sequence<C, A, S, Q>::rbegin() const
00251 {
00252 return const_reverse_iterator(end());
00253 }
00254
00255 template<ss_typename_param_k C, ss_typename_param_k A, ss_typename_param_k S, ss_typename_param_k Q>
00256 inline ss_typename_type_ret_k edit_line_sequence<C, A, S, Q>::const_reverse_iterator edit_line_sequence<C, A, S, Q>::rend() const
00257 {
00258 return const_reverse_iterator(begin());
00259 }
00260
00261 #endif
00262
00263
00264
00265 #ifndef _WINSTL_NO_NAMESPACE
00266 # if defined(_STLSOFT_NO_NAMESPACE) || \
00267 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00268 }
00269 # else
00270 }
00271 }
00272 # endif
00273 #endif
00274
00275
00276
00277 #endif
00278
00279