Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

MNRopeIteratorBase.h

Go to the documentation of this file.
00001 /* 00002 * Copyright (c) 1997 00003 * Silicon Graphics Computer Systems, Inc. 00004 * 00005 * Permission to use, copy, modify, distribute and sell this software 00006 * and its documentation for any purpose is hereby granted without fee, 00007 * provided that the above copyright notice appear in all copies and 00008 * that both that copyright notice and this permission notice appear 00009 * in supporting documentation. Silicon Graphics makes no 00010 * representations about the suitability of this software for any 00011 * purpose. It is provided "as is" without express or implied warranty. 00012 * 00013 * Heavily modified by KOM/Darmstadt University of Technology, 2000 00014 */ 00015 #ifndef _R_ITERATOR_BASE_H 00016 #define _R_ITERATOR_BASE_H 00017 00018 #include <sys/types.h> 00019 00024 // Rope iterators: 00025 // Unlike in the C version, we cache only part of the stack 00026 // for rope iterators, since they must be efficiently copyable. 00027 // When we run out of cache, we have to reconstruct the iterator 00028 // value. 00029 // Pointers from iterators are not included in reference counts. 00030 // Iterators are assumed to be thread private. Ropes can 00031 // be shared. 00032 00033 class MNRopeRep; 00034 00035 class MNRopeIteratorBase 00036 { 00037 friend class MNRope; 00038 00039 protected: 00040 enum { _S_path_cache_len = 4 }; // Must be <= 9. 00041 00042 enum { _S_iterator_buf_len = 15 }; 00043 00044 size_t _M_current_pos; 00045 00046 MNRopeRep* _M_root; 00047 // The whole rope. 00048 00049 size_t _M_leaf_pos; 00050 // Starting position for current leaf 00051 uchar_t* _M_buf_start; 00052 // Buffer possibly 00053 // containing current char. 00054 uchar_t* _M_buf_ptr; 00055 // Pointer to current char in buffer. 00056 // != 0 ==> buffer valid. 00057 uchar_t* _M_buf_end; 00058 // One past __last valid char in buffer. 00059 00060 // What follows is the path cache. We go out of our 00061 // way to make this compact. 00062 // Path_end contains the bottom section of the path from 00063 // the root to the current leaf. 00064 const MNRopeRep* _M_path_end[_S_path_cache_len]; 00065 00066 int _M_leaf_index; 00067 // Last valid __pos in path_end; 00068 // _M_path_end[0] ... _M_path_end[leaf_index-1] 00069 // point to concatenation nodes. 00070 unsigned char _M_path_directions; 00071 // (path_directions >> __i) & 1 is 1 00072 // iff we got from _M_path_end[leaf_index - __i - 1] 00073 // to _M_path_end[leaf_index - __i] by going to the 00074 // __right. Assumes path_cache_len <= 9. 00075 uchar_t _M_tmp_buf[_S_iterator_buf_len]; 00076 // Short buffer for surrounding chars. 00077 // This is useful primarily for 00078 // RopeFunctions. We put the buffer 00079 // here to avoid locking in the 00080 // multithreaded case. 00081 00082 // The cached path is generally assumed to be valid 00083 // only if the buffer is valid. 00084 static void _S_setbuf(MNRopeIteratorBase& __x); 00085 // Set buffer contents given 00086 // path cache. 00087 static void _S_setcache(MNRopeIteratorBase& __x); 00088 // Set buffer contents and 00089 // path cache. 00090 static void _S_setcache_for_incr(MNRopeIteratorBase& __x); 00091 // As above, but assumes path 00092 // cache is valid for previous posn. 00093 MNRopeIteratorBase(); 00094 MNRopeIteratorBase(MNRopeRep* __root, size_t __pos); 00095 00096 void _M_incr(size_t __n); 00097 00098 void _M_decr(size_t __n); 00099 00100 public: 00101 size_t index() const; 00102 00103 MNRopeIteratorBase(const MNRopeIteratorBase& __x); 00104 }; 00105 00107 00108 #endif /* _R_ITERATOR_BASE_H */ 00109

Generated on Sun Mar 6 13:35:49 2005 for Komssys by doxygen 1.3.8