cttl::edge< PolicyT, StringT > Class Template Reference

Implements mutable parseable substring. More...

#include <edge.h>

Inheritance diagram for cttl::edge< PolicyT, StringT >:

cttl::const_edge< PolicyT, StringT >

List of all members.

Public Types

typedef StringT::value_type char_T
 Defines type of referenced character.
typedef const_edge< PolicyT,
StringT >::node_T 
node_T
 Defines type of substring boundaries, represented by instances of two cttl::node objects.
typedef
xtl_mutable_offset_guard
< StringT > 
offset_guard_T
 Defines offset guard type for substring boundary.
typedef PolicyT policy_T
 Defines type of the space policy.
typedef StringT::size_type size_type
 Defines size type of substring.
typedef edge< strict_policy_T,
StringT > 
strict_edge_T
 Defines type of the substring specialized for strict grammar evaluation algorithm.
typedef PolicyT::strict_policy_T strict_policy_T
 Defines type of the strict space policy.

Public Member Functions

 edge (StringT &inp_, PolicyT &policy_)
 Constructor taking a string and a user-defined space policy.
template<typename Other_policyT >
 edge (const_edge< Other_policyT, StringT > const &other_, PolicyT &policy_)
 Constructor taking another substring and a user-defined space policy.
 edge (const_edge< PolicyT, StringT > const &other_, size_type start_, size_type finish_)
 Constructs copy of the existing substring with explicitly specified boundary positions.
 edge (const_edge< PolicyT, StringT > const &other_)
 Constructs exact copy of the existing substring.
template<typename Other_policyT >
 edge (const_edge< Other_policyT, StringT > const &other_)
 Constructor converting another cttl::edge or cttl::const_edge to a substring with a different space policy type.
 edge (node< StringT > &node_first_, node< StringT > &node_second_, size_type start_, size_type finish_)
 Constructor taking two cttl::node objects that specify substring boundaries and override specific boundary positions.
 edge (node< StringT > &node_first_, node< StringT > &node_second_)
 Constructor taking two cttl::node objects that specify substring boundaries.
 edge (StringT &inp_, size_type start_, size_type finish_)
 Constructor taking reference to a string and specific boundary positions.
 edge (StringT &inp_)
 Constructor taking reference to a string.
void erase ()
 Erases content of the substring.
void insert_go (node_T &node_)
 Inserts substring at the current position of the node.
void insert_stay (node_T &node_)
 Inserts substring at the current position of the node.
edge< PolicyT, StringT > & operator= (StringT const &str_)
 Assigns new content to the substring.
edge< PolicyT, StringT > & operator= (const_edge< PolicyT, StringT > const &other_)
 Substring assignment.
StringT text () const
 Returns content of the substring.
void text (edge< PolicyT, StringT > const &other_)
 Replaces content of the substring with the content of another substring.
void text (const_edge< PolicyT, StringT > const &other_)
 Replaces content of the substring with the content of another substring.
void text (StringT const &str_)
 Replaces content of the substring.
void text_swap (edge< PolicyT, StringT > &other_)
 Exchanges text content with another substring.


Detailed Description

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
class cttl::edge< PolicyT, StringT >

Implements mutable parseable substring.

Template Parameters:
PolicyT specifies space policy for the grammar evaluation algorithm of this substring. The default policy is cttl::policy_default.
StringT specifies the type of the referenced string. The default type is std::string.

Definition at line 61 of file edge.h.


Member Typedef Documentation

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
typedef StringT::value_type cttl::edge< PolicyT, StringT >::char_T

Defines type of referenced character.

Reimplemented from cttl::const_edge< PolicyT, StringT >.

Definition at line 75 of file edge.h.

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
typedef const_edge< PolicyT, StringT >::node_T cttl::edge< PolicyT, StringT >::node_T

Defines type of substring boundaries, represented by instances of two cttl::node objects.

Reimplemented from cttl::const_edge< PolicyT, StringT >.

Definition at line 98 of file edge.h.

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
typedef xtl_mutable_offset_guard< StringT > cttl::edge< PolicyT, StringT >::offset_guard_T

Defines offset guard type for substring boundary.

Reimplemented from cttl::const_edge< PolicyT, StringT >.

Definition at line 72 of file edge.h.

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
typedef PolicyT cttl::edge< PolicyT, StringT >::policy_T

Defines type of the space policy.

Reimplemented from cttl::const_edge< PolicyT, StringT >.

Definition at line 81 of file edge.h.

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
typedef StringT::size_type cttl::edge< PolicyT, StringT >::size_type

Defines size type of substring.

Reimplemented from cttl::const_edge< PolicyT, StringT >.

Definition at line 78 of file edge.h.

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
typedef edge< strict_policy_T, StringT > cttl::edge< PolicyT, StringT >::strict_edge_T

Defines type of the substring specialized for strict grammar evaluation algorithm.

Reimplemented from cttl::const_edge< PolicyT, StringT >.

Definition at line 92 of file edge.h.

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
typedef PolicyT::strict_policy_T cttl::edge< PolicyT, StringT >::strict_policy_T

Defines type of the strict space policy.

Reimplemented from cttl::const_edge< PolicyT, StringT >.

Definition at line 86 of file edge.h.


Constructor & Destructor Documentation

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
cttl::edge< PolicyT, StringT >::edge ( StringT &  inp_  )  [explicit]

Constructor taking reference to a string.

Parameters:
inp_ Mutable reference to a string.
Postcondition:
Substring boundaries are set to the positions corresponding to the beginning and the ending of the referenced string.

Definition at line 116 of file edge.h.

00117             :
00118         const_edge< PolicyT, StringT >( inp_ )
00119         {
00120         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
cttl::edge< PolicyT, StringT >::edge ( StringT &  inp_,
size_type  start_,
size_type  finish_ 
)

Constructor taking reference to a string and specific boundary positions.

Parameters:
inp_ Mutable reference to a string.
start_ Initial offset of the upper boundary (edge::first node.)
finish_ Initial offset of the lower boundary (edge::second node.)

Definition at line 135 of file edge.h.

00136             :
00137         const_edge< PolicyT, StringT >( inp_, start_, finish_ )
00138         {
00139         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
cttl::edge< PolicyT, StringT >::edge ( node< StringT > &  node_first_,
node< StringT > &  node_second_ 
)

Constructor taking two cttl::node objects that specify substring boundaries.

Parameters:
node_first_ Specifies initial offset of the upper boundary.
node_second_ Specifies initial offset of the lower boundary.
Precondition:
The nodes must belong to the same parent string;
the nodes must be part of the same list.

Definition at line 155 of file edge.h.

00156             :
00157         const_edge< PolicyT, StringT >( node_first_, node_second_ )
00158         {
00159         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
cttl::edge< PolicyT, StringT >::edge ( node< StringT > &  node_first_,
node< StringT > &  node_second_,
size_type  start_,
size_type  finish_ 
)

Constructor taking two cttl::node objects that specify substring boundaries and override specific boundary positions.

Parameters:
node_first_ Specifies initial offset of the upper boundary.
node_second_ Specifies initial offset of the lower boundary.
start_ Initial offset of the upper boundary (edge::first node.)
finish_ Initial offset of the lower boundary (edge::second node.)
Precondition:
The nodes must belong to the same parent string;
the nodes must be part of the same list.

Definition at line 181 of file edge.h.

00187             :
00188         const_edge< PolicyT, StringT >( node_first_, node_second_, start_, finish_ )
00189         {
00190         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
template<typename Other_policyT >
cttl::edge< PolicyT, StringT >::edge ( const_edge< Other_policyT, StringT > const &  other_  ) 

Constructor converting another cttl::edge or cttl::const_edge to a substring with a different space policy type.

Template Parameters:
Other_policyT space policy of another substring.
Parameters:
other_ reference to an instance of another substring.
Postcondition:
This constructor converts a "relaxed" substring with user-specified space policy to a "strict" substring, which is using the space policy obtained via call to const_edge::default_policy().

Definition at line 211 of file edge.h.

00212             :
00213         const_edge< PolicyT, StringT >( other_ )
00214         {
00215         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
cttl::edge< PolicyT, StringT >::edge ( const_edge< PolicyT, StringT > const &  other_  ) 

Constructs exact copy of the existing substring.

Definition at line 218 of file edge.h.

00219             :
00220         const_edge< PolicyT, StringT >( other_ )
00221         {
00222         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
cttl::edge< PolicyT, StringT >::edge ( const_edge< PolicyT, StringT > const &  other_,
size_type  start_,
size_type  finish_ 
)

Constructs copy of the existing substring with explicitly specified boundary positions.

Parameters:
other_ The reference to another substring.
start_ Initial offset of the upper boundary (edge::first node.)
finish_ Initial offset of the lower boundary (edge::second node.)

Definition at line 237 of file edge.h.

00242             :
00243         const_edge< PolicyT, StringT >( other_, start_, finish_ )
00244         {
00245         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
template<typename Other_policyT >
cttl::edge< PolicyT, StringT >::edge ( const_edge< Other_policyT, StringT > const &  other_,
PolicyT &  policy_ 
)

Constructor taking another substring and a user-defined space policy.

Template Parameters:
Other_policyT Type of space policy of another substring.
Parameters:
other_ reference to instance of another substring.
policy_ mutable reference to an instance of the user-defined space policy object.
Postcondition:
References to the string and the policy objects are retained for the lifetime of the substring. The program should never let those two objects go out of scope for as long as the corresponding substrings are in use.

Definition at line 270 of file edge.h.

00271             :
00272         const_edge< PolicyT, StringT >( other_, policy_ )
00273         {
00274         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
cttl::edge< PolicyT, StringT >::edge ( StringT &  inp_,
PolicyT &  policy_ 
)

Constructor taking a string and a user-defined space policy.

Parameters:
inp_ Mutable reference to string
policy_ mutable reference to an instance of the user-defined space policy object.
Postcondition:
References to the string and the policy objects are retained for the lifetime of the substring. The program should never let those two objects go out of scope for as long as the corresponding substrings are in use.

Definition at line 293 of file edge.h.

00294             :
00295         const_edge< PolicyT, StringT >( inp_, policy_ )
00296         {
00297         }


Member Function Documentation

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
void cttl::edge< PolicyT, StringT >::erase (  ) 

Erases content of the substring.

Warning:
Erase, like other mutating substring operations, are prohibited inside void regions.
Postcondition:
The function preserves logical positions of the substring boundaries before and after the operation. Client regions are adjusted accordingly: all offsets remain in sync with existing client regions.

Definition at line 404 of file edge.h.

00405         {
00406             size_t offset_from_i = this->first.offset();
00407             size_t offset_to_i = this->second.offset();
00408 
00409             // Compute negative length of the erased substring:
00410             int delta_offset = this->length();
00411             delta_offset = -delta_offset;
00412 
00413             if ( !delta_offset )
00414                 return; // nothing to do
00415 
00416             assert( offset_from_i <= offset_to_i );
00417             assert( offset_from_i <= this->parent().length() );
00418             assert( ( offset_to_i - offset_from_i ) <= this->parent().length() );
00419 
00420             this->parent().erase(
00421                 offset_from_i,
00422                 offset_to_i - offset_from_i
00423                 );
00424 
00425             this->space_policy().region_erase(
00426                 offset_from_i,
00427                 offset_to_i
00428                 );
00429 
00430             this->space_policy().region_adjust(
00431                 offset_from_i,
00432                 delta_offset
00433                 );
00434 
00435             // ( delta_offset < 0 )
00436             xtl_identity_collapse< StringT > collapse(
00437                 offset_to_i,
00438                 delta_offset
00439                 );
00440 
00441             this->first.adjust( collapse );
00442 
00443             this->first.offset( offset_from_i );
00444         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
void cttl::edge< PolicyT, StringT >::insert_go ( node_T node_  ) 

Inserts substring at the current position of the node.

Parameters:
node_ the node specifying the target position.
Postcondition:
node position is adjusted to the end of the inserted text. Logical positions of all nodes at the same position and at higher offsets are also adjusted.

Definition at line 362 of file edge.h.

00363         {
00364             node_.insert_go(
00365                 this->parent(),
00366                 this->first.offset(),
00367                 this->second.offset()
00368                 );
00369         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
void cttl::edge< PolicyT, StringT >::insert_stay ( node_T node_  ) 

Inserts substring at the current position of the node.

Parameters:
node_ the node specifying the target position.
Postcondition:
Logical positions of any node at the same position remain unchanged. Positions of all nodes at higher offset positions are adjusted.

Definition at line 382 of file edge.h.

00383         {
00384             node_.insert_stay(
00385                 this->parent(),
00386                 this->first.offset(),
00387                 this->second.offset()
00388                 );
00389         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
edge< PolicyT, StringT >& cttl::edge< PolicyT, StringT >::operator= ( StringT const &  str_  ) 

Assigns new content to the substring.

Parameters:
str_ reference to the source string.

Definition at line 470 of file edge.h.

00471         {
00472             text( str_ );
00473             return *this;
00474         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
edge< PolicyT, StringT >& cttl::edge< PolicyT, StringT >::operator= ( const_edge< PolicyT, StringT > const &  other_  ) 

Substring assignment.

Parameters:
other_ instance of another substring.
Note: substring assignment mathces behavior of the copy constructor.

Reimplemented from cttl::const_edge< PolicyT, StringT >.

Definition at line 458 of file edge.h.

00459         {
00460             const_edge< PolicyT, StringT >::operator=( other_ );
00461             return *this;
00462         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
StringT cttl::edge< PolicyT, StringT >::text (  )  const

Returns content of the substring.

Reimplemented from cttl::const_edge< PolicyT, StringT >.

Definition at line 332 of file edge.h.

00333         {
00334             return const_edge< PolicyT, StringT >::text();
00335         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
void cttl::edge< PolicyT, StringT >::text ( edge< PolicyT, StringT > const &  other_  ) 

Replaces content of the substring with the content of another substring.

Definition at line 322 of file edge.h.

00323         {
00324             text_replace(
00325                 other_.parent(),
00326                 other_.first.offset(),
00327                 other_.second.offset()
00328                 );
00329         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
void cttl::edge< PolicyT, StringT >::text ( const_edge< PolicyT, StringT > const &  other_  ) 

Replaces content of the substring with the content of another substring.

Definition at line 309 of file edge.h.

00310         {
00311             text_replace(
00312                 other_.parent(),
00313                 other_.first.offset(),
00314                 other_.second.offset()
00315                 );
00316         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
void cttl::edge< PolicyT, StringT >::text ( StringT const &  str_  ) 

Replaces content of the substring.

Definition at line 300 of file edge.h.

00301         {
00302             text_replace( str_ );
00303         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
void cttl::edge< PolicyT, StringT >::text_swap ( edge< PolicyT, StringT > &  other_  ) 

Exchanges text content with another substring.

Remarks:
Standard version of std::swap() exchanges positions of the substring boundaries.

Definition at line 344 of file edge.h.

00345         {
00346             const StringT str_this = text();
00347             text( other_ );
00348             other_.text( str_this );
00349         }


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

Generated on Sun Aug 23 13:43:44 2009 for Common Text Transformation Library by  doxygen 1.5.9