ReactOS 0.4.15-dev-7660-g0086d05
_Rope_iterator_base< _CharT, _Alloc > Class Template Reference

#include <_rope.h>

Inheritance diagram for _Rope_iterator_base< _CharT, _Alloc >:
Collaboration diagram for _Rope_iterator_base< _CharT, _Alloc >:

Public Types

enum  { _S_path_cache_len = 4 }
 
enum  { _S_iterator_buf_len = 15 }
 
typedef _Rope_RopeRep< _CharT, _Alloc_RopeRep
 

Public Member Functions

 _Rope_iterator_base ()
 
 _Rope_iterator_base (_RopeRep *__root, size_t __pos)
 
void _M_incr (size_t __n)
 
void _M_decr (size_t __n)
 
size_t index () const
 
 _Rope_iterator_base (const _Self &__x)
 
_Selfoperator= (const _Self &__x)
 

Static Public Member Functions

static void _S_setbuf (_Rope_iterator_base< _CharT, _Alloc > &__x)
 
static void _S_setcache (_Rope_iterator_base< _CharT, _Alloc > &__x)
 
static void _S_setcache_for_incr (_Rope_iterator_base< _CharT, _Alloc > &__x)
 

Public Attributes

size_t _M_current_pos
 
_RopeRep_M_root
 
size_t _M_leaf_pos
 
_CharT * _M_buf_start
 
_CharT * _M_buf_ptr
 
_CharT * _M_buf_end
 
struct {
   _RopeRep const *   _M_data [_S_path_cache_len]
 
_M_path_end
 
int _M_leaf_index
 
unsigned char _M_path_directions
 
struct {
   _CharT   _M_data [_S_iterator_buf_len]
 
_M_tmp_buf
 

Private Types

typedef _Rope_iterator_base< _CharT, _Alloc_Self
 
typedef _Rope_RopeConcatenation< _CharT, _Alloc_RopeConcat
 

Private Member Functions

void _M_copy_buf (const _Self &__x)
 

Friends

class rope< _CharT, _Alloc >
 

Detailed Description

template<class _CharT, class _Alloc>
class _Rope_iterator_base< _CharT, _Alloc >

Definition at line 753 of file _rope.h.

Member Typedef Documentation

◆ _RopeConcat

template<class _CharT , class _Alloc >
typedef _Rope_RopeConcatenation<_CharT,_Alloc> _Rope_iterator_base< _CharT, _Alloc >::_RopeConcat
private

Definition at line 758 of file _rope.h.

◆ _RopeRep

template<class _CharT , class _Alloc >
typedef _Rope_RopeRep<_CharT,_Alloc> _Rope_iterator_base< _CharT, _Alloc >::_RopeRep

Definition at line 760 of file _rope.h.

◆ _Self

template<class _CharT , class _Alloc >
typedef _Rope_iterator_base<_CharT, _Alloc> _Rope_iterator_base< _CharT, _Alloc >::_Self
private

Definition at line 757 of file _rope.h.

Member Enumeration Documentation

◆ anonymous enum

template<class _CharT , class _Alloc >
anonymous enum
Enumerator
_S_path_cache_len 

Definition at line 762 of file _rope.h.

762{ _S_path_cache_len = 4 }; // Must be <= 9 because of _M_path_direction.

◆ anonymous enum

template<class _CharT , class _Alloc >
anonymous enum
Enumerator
_S_iterator_buf_len 

Definition at line 763 of file _rope.h.

763{ _S_iterator_buf_len = 15 };

Constructor & Destructor Documentation

◆ _Rope_iterator_base() [1/3]

template<class _CharT , class _Alloc >
_Rope_iterator_base< _CharT, _Alloc >::_Rope_iterator_base ( )
inline

Definition at line 817 of file _rope.h.

817{}

◆ _Rope_iterator_base() [2/3]

template<class _CharT , class _Alloc >
_Rope_iterator_base< _CharT, _Alloc >::_Rope_iterator_base ( _RopeRep __root,
size_t  __pos 
)
inline

Definition at line 818 of file _rope.h.

819 : _M_current_pos(__pos),_M_root(__root), _M_buf_ptr(0) {}
size_t _M_current_pos
Definition: _rope.h:764
_RopeRep * _M_root
Definition: _rope.h:766
_CharT * _M_buf_ptr
Definition: _rope.h:772

◆ _Rope_iterator_base() [3/3]

template<class _CharT , class _Alloc >
_Rope_iterator_base< _CharT, _Alloc >::_Rope_iterator_base ( const _Self __x)
inline

Definition at line 837 of file _rope.h.

837 :
838 _M_current_pos(__x._M_current_pos),
839 _M_root(__x._M_root),
840 _M_leaf_pos( __x._M_leaf_pos ),
841 _M_buf_start(__x._M_buf_start),
842 _M_buf_ptr(__x._M_buf_ptr),
843 _M_path_end(__x._M_path_end),
844 _M_leaf_index(__x._M_leaf_index),
845 _M_path_directions(__x._M_path_directions)
846 {
847 if (0 != __x._M_buf_ptr) {
848 _M_copy_buf(__x);
849 }
850 }
size_t _M_leaf_pos
Definition: _rope.h:768
_CharT * _M_buf_start
Definition: _rope.h:770
unsigned char _M_path_directions
Definition: _rope.h:795
void _M_copy_buf(const _Self &__x)
Definition: _rope.h:825
struct _Rope_iterator_base::@1843 _M_path_end

Member Function Documentation

◆ _M_copy_buf()

template<class _CharT , class _Alloc >
void _Rope_iterator_base< _CharT, _Alloc >::_M_copy_buf ( const _Self __x)
inlineprivate

Definition at line 825 of file _rope.h.

825 {
826 _M_tmp_buf = __x._M_tmp_buf;
827 if (__x._M_buf_start == __x._M_tmp_buf._M_data) {
828 _M_buf_start = _M_tmp_buf._M_data;
829 _M_buf_end = _M_buf_start + (__x._M_buf_end - __x._M_buf_start);
830 _M_buf_ptr = _M_buf_start + (__x._M_buf_ptr - __x._M_buf_start);
831 } else {
832 _M_buf_end = __x._M_buf_end;
833 }
834 }
_CharT * _M_buf_end
Definition: _rope.h:774
struct _Rope_iterator_base::@1844 _M_tmp_buf

Referenced by _Rope_iterator_base< _CharT, _Alloc >::_Rope_iterator_base(), and _Rope_iterator_base< _CharT, _Alloc >::operator=().

◆ _M_decr()

◆ _M_incr()

template<class _CharT , class _Alloc >
void _Rope_iterator_base< _CharT, _Alloc >::_M_incr ( size_t  __n)

Definition at line 270 of file _rope.c.

270 {
272 if (0 != _M_buf_ptr) {
273 size_t __chars_left = _M_buf_end - _M_buf_ptr;
274 if (__chars_left > __n) {
275 _M_buf_ptr += __n;
276 } else if (__chars_left == __n) {
277 _M_buf_ptr += __n;
279 } else {
280 _M_buf_ptr = 0;
281 }
282 }
283}
static void _S_setcache_for_incr(_Rope_iterator_base< _CharT, _Alloc > &__x)
Definition: _rope.c:208

Referenced by _Rope_const_iterator< _CharT, _Alloc >::operator++(), _Rope_iterator< _CharT, _Alloc >::operator++(), _Rope_const_iterator< _CharT, _Alloc >::operator+=(), _Rope_iterator< _CharT, _Alloc >::operator+=(), _Rope_const_iterator< _CharT, _Alloc >::operator-=(), and _Rope_iterator< _CharT, _Alloc >::operator-=().

◆ _S_setbuf()

template<class _CharT , class _Alloc >
void _Rope_iterator_base< _CharT, _Alloc >::_S_setbuf ( _Rope_iterator_base< _CharT, _Alloc > &  __x)
static

Definition at line 90 of file _rope.c.

91 {
92 const _RopeRep* __leaf = __x._M_path_end._M_data[__x._M_leaf_index];
93 size_t __leaf_pos = __x._M_leaf_pos;
94 size_t __pos = __x._M_current_pos;
95
96 switch(__leaf->_M_tag) {
98 typedef _Rope_RopeLeaf<_CharT, _Alloc> _RopeLeaf;
99 __x._M_buf_start = __STATIC_CAST(const _RopeLeaf*, __leaf)->_M_data;
100 __x._M_buf_ptr = __x._M_buf_start + (__pos - __leaf_pos);
101 __x._M_buf_end = __x._M_buf_start + __leaf->_M_size._M_data;
102 break;
105 {
106 size_t __len = _S_iterator_buf_len;
107 size_t __buf_start_pos = __leaf_pos;
108 size_t __leaf_end = __leaf_pos + __leaf->_M_size._M_data;
109 typedef _Rope_RopeFunction<_CharT, _Alloc> _RopeFunction;
110 char_producer<_CharT>* __fn = __STATIC_CAST(const _RopeFunction*, __leaf)->_M_fn;
111
112 if (__buf_start_pos + __len <= __pos) {
113 __buf_start_pos = __pos - __len/4;
114 if (__buf_start_pos + __len > __leaf_end) {
115 __buf_start_pos = __leaf_end - __len;
116 }
117 }
118 if (__buf_start_pos + __len > __leaf_end) {
119 __len = __leaf_end - __buf_start_pos;
120 }
121 (*__fn)(__buf_start_pos - __leaf_pos, __len, __x._M_tmp_buf._M_data);
122 __x._M_buf_ptr = __x._M_tmp_buf._M_data + (__pos - __buf_start_pos);
123 __x._M_buf_start = __x._M_tmp_buf._M_data;
124 __x._M_buf_end = __x._M_tmp_buf._M_data + __len;
125 }
126 break;
127 default:
128 _STLP_ASSERT(0)
129 ;
130 }
131}
#define _STLP_ASSERT(expr)
Definition: _debug.h:165
_Rope_RopeRep< _CharT, _Alloc > _RopeRep
Definition: _rope.h:760
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
@ _S_function
Definition: _rope.h:345
@ _S_substringfn
Definition: _rope.h:345

◆ _S_setcache()

template<class _CharT , class _Alloc >
void _Rope_iterator_base< _CharT, _Alloc >::_S_setcache ( _Rope_iterator_base< _CharT, _Alloc > &  __x)
static

Definition at line 136 of file _rope.c.

137 {
138 const _RopeRep* __path[_RopeRep::_S_max_rope_depth+1];
139 const _RopeRep* __curr_rope;
140 int __curr_depth = -1; /* index into path */
141 size_t __curr_start_pos = 0;
142 size_t __pos = __x._M_current_pos;
143 unsigned char __dirns = 0; // Bit vector marking right turns in the path
144
145 _STLP_ASSERT(__pos <= __x._M_root->_M_size._M_data)
146 if (__pos >= __x._M_root->_M_size._M_data) {
147 __x._M_buf_ptr = 0;
148 return;
149 }
150 __curr_rope = __x._M_root;
151 if (0 != __curr_rope->_M_c_string) {
152 /* Treat the root as a leaf. */
153 __x._M_buf_start = __curr_rope->_M_c_string;
154 __x._M_buf_end = __curr_rope->_M_c_string + __curr_rope->_M_size._M_data;
155 __x._M_buf_ptr = __curr_rope->_M_c_string + __pos;
156 __x._M_path_end._M_data[0] = __curr_rope;
157 __x._M_leaf_index = 0;
158 __x._M_leaf_pos = 0;
159 return;
160 }
161 for(;;) {
162 ++__curr_depth;
164 __path[__curr_depth] = __curr_rope;
165 switch(__curr_rope->_M_tag) {
169 __x._M_leaf_pos = __curr_start_pos;
170 goto done;
172 {
173 const _RopeConcat* __c = __STATIC_CAST(const _RopeConcat*, __curr_rope);
174 _RopeRep* __left = __c->_M_left;
175 size_t __left_len = __left->_M_size._M_data;
176
177 __dirns <<= 1;
178 if (__pos >= __curr_start_pos + __left_len) {
179 __dirns |= 1;
180 __curr_rope = __c->_M_right;
181 __curr_start_pos += __left_len;
182 } else {
183 __curr_rope = __left;
184 }
185 }
186 break;
187 }
188 }
189done:
190 // Copy last section of path into _M_path_end.
191 {
192 int __i = -1;
193 int __j = __curr_depth + 1 - _S_path_cache_len;
194
195 if (__j < 0) __j = 0;
196 while (__j <= __curr_depth) {
197 __x._M_path_end._M_data[++__i] = __path[__j++];
198 }
199 __x._M_leaf_index = __i;
200 }
201 __x._M_path_directions = __dirns;
202 _S_setbuf(__x);
203}
static void _S_setbuf(_Rope_iterator_base< _CharT, _Alloc > &__x)
Definition: _rope.c:90
_Rope_RopeConcatenation< _CharT, _Alloc > _RopeConcat
Definition: _rope.h:758
_Value _M_data
Definition: _alloc.h:478
#define __c
Definition: schilyio.h:209
@ _S_max_rope_depth
Definition: _rope.h:344
_STLP_PRIV _STLP_alloc_proxy< size_t, _CharT, allocator_type > _M_size
Definition: _rope.h:362

Referenced by _Rope_iterator< _CharT, _Alloc >::_Rope_iterator(), and _Rope_const_iterator< _CharT, _Alloc >::operator*().

◆ _S_setcache_for_incr()

template<class _CharT , class _Alloc >
void _Rope_iterator_base< _CharT, _Alloc >::_S_setcache_for_incr ( _Rope_iterator_base< _CharT, _Alloc > &  __x)
static

Definition at line 208 of file _rope.c.

209 {
210 int __current_index = __x._M_leaf_index;
211 const _RopeRep* __current_node = __x._M_path_end._M_data[__current_index];
212 size_t __len = __current_node->_M_size._M_data;
213 size_t __node_start_pos = __x._M_leaf_pos;
214 unsigned char __dirns = __x._M_path_directions;
215 const _RopeConcat* __c;
216
218 if (__x._M_current_pos - __node_start_pos < __len) {
219 /* More stuff in this leaf, we just didn't cache it. */
220 _S_setbuf(__x);
221 return;
222 }
223 _STLP_ASSERT(__node_start_pos + __len == __x._M_current_pos)
224 // node_start_pos is starting position of last_node.
225 while (--__current_index >= 0) {
226 if (!(__dirns & 1) /* Path turned left */)
227 break;
228 __current_node = __x._M_path_end._M_data[__current_index];
229 __c = __STATIC_CAST(const _RopeConcat*, __current_node);
230 // Otherwise we were in the right child. Thus we should pop
231 // the concatenation node.
232 __node_start_pos -= __c->_M_left->_M_size._M_data;
233 __dirns >>= 1;
234 }
235 if (__current_index < 0) {
236 // We underflowed the cache. Punt.
237 _S_setcache(__x);
238 return;
239 }
240 __current_node = __x._M_path_end._M_data[__current_index];
241 __c = __STATIC_CAST(const _RopeConcat*, __current_node);
242 // current_node is a concatenation node. We are positioned on the first
243 // character in its right child.
244 // node_start_pos is starting position of current_node.
245 __node_start_pos += __c->_M_left->_M_size._M_data;
246 __current_node = __c->_M_right;
247 __x._M_path_end._M_data[++__current_index] = __current_node;
248 __dirns |= 1;
249 while (_RopeRep::_S_concat == __current_node->_M_tag) {
250 ++__current_index;
251 if (_S_path_cache_len == __current_index) {
252 int __i;
253 for (__i = 0; __i < _S_path_cache_len-1; ++__i) {
254 __x._M_path_end._M_data[__i] = __x._M_path_end._M_data[__i+1];
255 }
256 --__current_index;
257 }
258 __current_node = __STATIC_CAST(const _RopeConcat*, __current_node)->_M_left;
259 __x._M_path_end._M_data[__current_index] = __current_node;
260 __dirns <<= 1;
261 // node_start_pos is unchanged.
262 }
263 __x._M_leaf_index = __current_index;
264 __x._M_leaf_pos = __node_start_pos;
265 __x._M_path_directions = __dirns;
266 _S_setbuf(__x);
267}
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
static void _S_setcache(_Rope_iterator_base< _CharT, _Alloc > &__x)
Definition: _rope.c:136
if(dx< 0)
Definition: linetemp.h:194

◆ index()

◆ operator=()

template<class _CharT , class _Alloc >
_Self & _Rope_iterator_base< _CharT, _Alloc >::operator= ( const _Self __x)
inline

Definition at line 851 of file _rope.h.

852 {
853 _M_current_pos = __x._M_current_pos;
854 _M_root = __x._M_root;
855 _M_buf_start = __x._M_buf_start;
856 _M_buf_ptr = __x._M_buf_ptr;
857 _M_path_end = __x._M_path_end;
858 _M_leaf_index = __x._M_leaf_index;
859 _M_path_directions = __x._M_path_directions;
860 _M_leaf_pos = __x._M_leaf_pos;
861 if (0 != __x._M_buf_ptr) {
862 _M_copy_buf(__x);
863 }
864 return *this;
865 }

Referenced by _Rope_const_iterator< _CharT, _Alloc >::operator=(), and _Rope_iterator< _CharT, _Alloc >::operator=().

Friends And Related Function Documentation

◆ rope< _CharT, _Alloc >

template<class _CharT , class _Alloc >
friend class rope< _CharT, _Alloc >
friend

Definition at line 736 of file _rope.h.

Member Data Documentation

◆ _M_buf_end

◆ _M_buf_ptr

◆ _M_buf_start

◆ _M_current_pos

◆ _M_data [1/2]

template<class _CharT , class _Alloc >
_CharT _Rope_iterator_base< _CharT, _Alloc >::_M_data[_S_iterator_buf_len]

Definition at line 807 of file _rope.h.

◆ _M_data [2/2]

template<class _CharT , class _Alloc >
_RopeRep const* _Rope_iterator_base< _CharT, _Alloc >::_M_data[_S_path_cache_len]

Definition at line 784 of file _rope.h.

◆ _M_leaf_index

◆ _M_leaf_pos

◆ _M_path_directions

◆ 

◆ _M_root

◆ 


The documentation for this class was generated from the following files: