00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00023
00038
00039
00040 #ifndef _CTTL_XTL_EDGE_TRAIT_H_INCLUDED_
00041 #define _CTTL_XTL_EDGE_TRAIT_H_INCLUDED_
00042
00043 #include "xtl_container_impl.h"
00044
00045 namespace cttl_impl {
00046
00051 class xtl_const_offset_manager
00052 {
00054 size_t m_offset;
00055 public:
00063 template< typename StringT >
00064 xtl_const_offset_manager( xtl_text_container< StringT >&, size_t offset_ )
00065 :
00066 m_offset( offset_ )
00067 {
00068 }
00069
00071 xtl_const_offset_manager& operator=( size_t offset_ )
00072 {
00073 m_offset = offset_;
00074 return *this;
00075 }
00076
00078 operator size_t() const
00079 {
00080 return m_offset;
00081 }
00082 };
00083
00095 template< typename StringT >
00096 class xtl_mutable_offset_manager
00097 {
00099 xtl_text_container< StringT >& m_container;
00100
00105 size_t m_stack_identity;
00106
00107 public:
00108
00115 xtl_mutable_offset_manager( xtl_text_container< StringT >& container_, size_t offset_ )
00116 :
00117 m_container( container_ )
00118 {
00119 m_stack_identity = m_container.stack_size();
00120 m_container.push_offset( offset_ );
00121 }
00122
00129 ~xtl_mutable_offset_manager()
00130 {
00131 m_container.pop_offset();
00132 }
00133
00135 xtl_mutable_offset_manager< StringT >& operator=( size_t offset_ )
00136 {
00137 m_container.stack_offset( m_stack_identity, offset_ );
00138 return *this;
00139 }
00140
00142 xtl_mutable_offset_manager< StringT >& operator=( xtl_mutable_offset_manager< StringT > const& other_ )
00143 {
00144 m_container.stack_offset( m_stack_identity, size_t( other_ ) );
00145 return *this;
00146 }
00147
00149 operator size_t() const
00150 {
00151 return m_container.stack_offset( m_stack_identity );
00152 }
00153
00155 size_t stack_identity() const
00156 {
00157 return m_stack_identity;
00158 }
00159 };
00160
00161
00173 template< typename EdgeT >
00174 struct xtl_edge_offset_manager
00175 {
00180 typename EdgeT::offset_manager_T first;
00181
00186 typename EdgeT::offset_manager_T second;
00187
00197 xtl_edge_offset_manager( EdgeT& edge_ )
00198 :
00199 first( edge_.parent().container(), edge_.first.offset() ),
00200 second( edge_.parent().container(), edge_.second.offset() )
00201 {
00202 }
00203
00212 void save( EdgeT& edge_ )
00213 {
00214 first = edge_.first.offset();
00215 second = edge_.second.offset();
00216 }
00217
00226 void swap( EdgeT& edge_ )
00227 {
00228 size_t temp = first;
00229 first = edge_.first.offset();
00230 edge_.first.offset( temp );
00231
00232 temp = second;
00233 second = edge_.second.offset();
00234 edge_.second.offset( temp );
00235 }
00236
00245 void restore( EdgeT& edge_ )
00246 {
00247 edge_.first.offset( first );
00248 edge_.second.offset( second );
00249 }
00250 };
00251
00252 }
00253
00254 #endif // _CTTL_XTL_EDGE_TRAIT_H_INCLUDED_