00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00023
00048
00049
00050 #ifndef _CTTL_XTL_IDENTITY_FUNCTORS_H_INCLUDED_
00051 #define _CTTL_XTL_IDENTITY_FUNCTORS_H_INCLUDED_
00052
00053 namespace cttl_impl {
00054
00056 class xtl_identity_adjust_base {
00057 protected:
00058
00060 size_t m_insertion_point_offset;
00061
00063 int m_delta_offset;
00064
00065 public:
00066
00068 xtl_identity_adjust_base( size_t insertion_point_offset_, int delta_offset_ )
00069 :
00070 m_insertion_point_offset( insertion_point_offset_ ),
00071 m_delta_offset( delta_offset_ )
00072 {}
00073
00074 };
00075
00083 template< typename StringT >
00084 class xtl_identity_collapse : public xtl_identity_adjust_base {
00085 public:
00087 xtl_identity_collapse( size_t insertion_point_offset_, int delta_offset_ )
00088 :
00089 xtl_identity_adjust_base( insertion_point_offset_, delta_offset_ )
00090 {}
00091
00114 void adjust( size_t& target_offset_ ) const
00115 {
00116
00117 if ( target_offset_ == StringT::npos )
00118 return;
00119
00120 if ( target_offset_ < m_insertion_point_offset ) {
00121 if ( ( m_insertion_point_offset + m_delta_offset ) < target_offset_ )
00122 target_offset_ = m_insertion_point_offset + m_delta_offset;
00123
00124 return;
00125 }
00126 target_offset_ += m_delta_offset;
00127 }
00128 };
00129
00130
00138 template< typename StringT >
00139 class xtl_identity_insert_go : public xtl_identity_adjust_base {
00140 public:
00141
00143 xtl_identity_insert_go( size_t insertion_point_offset_, int delta_offset_ )
00144 :
00145 xtl_identity_adjust_base( insertion_point_offset_, delta_offset_ )
00146 {}
00147
00154 void adjust( size_t& target_offset_ ) const
00155 {
00156 if ( target_offset_ == StringT::npos )
00157 return;
00158
00159 if ( target_offset_ >= m_insertion_point_offset )
00160 target_offset_ += m_delta_offset;
00161 }
00162 };
00163
00164
00172 template< typename StringT >
00173 class xtl_identity_insert_stay : public xtl_identity_adjust_base {
00174 public:
00175
00177 xtl_identity_insert_stay( size_t insertion_point_offset_, int delta_offset_ )
00178 :
00179 xtl_identity_adjust_base( insertion_point_offset_, delta_offset_ )
00180 {}
00181
00188 void adjust( size_t& target_offset_ ) const
00189 {
00190 if ( target_offset_ == StringT::npos )
00191 return;
00192
00193 if ( target_offset_ > m_insertion_point_offset )
00194 target_offset_ += m_delta_offset;
00195 }
00196 };
00197
00198 }
00199
00200 #endif // _CTTL_XTL_IDENTITY_FUNCTORS_H_INCLUDED_