#include <node.h>
Public Types | |
typedef StringT::value_type | char_T |
Defines type of referenced character. | |
typedef StringT::size_type | size_type |
Defines node size type. | |
typedef StringT | string_T |
Defines type of referenced string. | |
typedef StringT::value_type | value_type |
Defines node value type. | |
Public Member Functions | |
template<typename AdjusterT > | |
void | adjust (AdjusterT const &adjuster_) |
Generic function accepting an adjuster object that updates positions of all nodes found in a circularly-linked list. | |
template<typename PredicateT > | |
bool | find_class (PredicateT(*iswhat_)(PredicateT)) |
Moves node position forward to the lower boundary of the specified character class. | |
size_type | go_bof () |
Moves node position to the beginning of the referenced string. | |
size_type | go_eof () |
Moves node position to the ending of the referenced string. | |
size_type | go_line (size_type line_) |
Moves node position to the beginning of the specified line. | |
size_type | go_line_end (size_type line_) |
Moves node position to the ending of the specified line. | |
size_type | go_line_end () |
Moves node position to the ending of the current line. | |
size_type | go_line_home (size_type line_) |
Moves node position to the beginning of the specified line. | |
size_type | go_line_home () |
Moves node position to the beginning of the current line. | |
size_type | go_line_next () |
Moves node position to the beginning of the next line. | |
size_type | go_line_previous () |
Moves node position to the beginning of the previous line. | |
int | identity (node< StringT > const &root_) const |
Identifies node position relative to another node. | |
void | insert_go (StringT const &str_, size_type source_from_offset_, size_type source_to_offset_) |
Inserts absolute substring at the position specified by the current node. | |
size_type | insert_go (StringT const &str_) |
Inserts text at the current position of the node. | |
void | insert_stay (StringT const &str_, size_type source_from_offset_, size_type source_to_offset_) |
Inserts absolute substring at the position specified by the current node. | |
void | insert_stay (StringT const &str_) |
Inserts text at the current position of the node. | |
size_type | line () const |
Returns line number corresponding to the current position of the node. | |
node< StringT > & | link (node< StringT > &other_) |
Inserts other node in front of the current, forming a circularly-linked list. | |
node (node< StringT > const &other_, size_type offset_) | |
Copy constructor with custom offset. | |
node (node< StringT > const &other_) | |
Copy constructor manufactures exact copy of the node. | |
node (StringT &inp_, size_type offset_) | |
Constructor taking reference to a string and initial node position. | |
node (StringT &inp_) | |
Constructor taking reference to a string. | |
size_type | offset (size_type offset_) |
Changes node position. | |
size_type | offset () const |
Returns node position. | |
template<typename ExprT > | |
cttl_impl::xtl_wrap< xtl_node < node< StringT >, xtl_wrap < ExprT > > > | operator() (xtl_wrap< ExprT > const &expr_) |
Grammar rule adaptor of the node object. | |
node< StringT > & | operator+= (StringT const &str_) |
Addition-assignment of string matches behavior of cttl::node::insert_go(). | |
node< StringT > & | operator-= (StringT const &str_) |
Subtraction-assignment of string matches behavior of cttl::node::insert_stay(). | |
node< StringT > & | operator= (size_type offset_) |
Assignment of types convertible to size_type updates node position. | |
node< StringT > & | operator= (node< StringT > const &other_) |
Assignment operator. | |
char_T & | operator[] (int subscript_) |
Returns mutable reference to the character of referenced string at the offset relative to the current position of the node. | |
char_T const & | operator[] (int subscript_) const |
Returns character from referenced string at the offset relative to the current position of the node. | |
StringT const & | parent () const |
Returns constant reference to the referenced string . | |
StringT & | parent () |
Returns mutable reference to the referenced string . | |
template<typename PredicateT > | |
bool | rfind_class (PredicateT(*iswhat_)(PredicateT)) |
Moves node position backward to the upper boundary of the specified character class. | |
Protected Attributes | |
size_type | m_offset |
Stores node position. | |
StringT * | m_pstr |
Stores pointer to the string. |
StringT | specifies type of the referenced string. The default is std::string |
Definition at line 64 of file node.h.
typedef StringT::value_type cttl::node< StringT >::char_T |
typedef StringT::size_type cttl::node< StringT >::size_type |
typedef StringT cttl::node< StringT >::string_T |
typedef StringT::value_type cttl::node< StringT >::value_type |
cttl::node< StringT >::node | ( | StringT & | inp_ | ) |
cttl::node< StringT >::node | ( | StringT & | inp_, | |
size_type | offset_ | |||
) |
cttl::node< StringT >::node | ( | node< StringT > const & | other_ | ) |
cttl::node< StringT >::node | ( | node< StringT > const & | other_, | |
size_type | offset_ | |||
) |
void cttl::node< StringT >::adjust | ( | AdjusterT const & | adjuster_ | ) |
Generic function accepting an adjuster object that updates positions of all nodes found in a circularly-linked list.
Definition at line 633 of file node.h.
00634 { 00635 node< StringT >* iter = this; 00636 do { 00637 adjuster_.adjust( iter->m_offset ); 00638 iter = static_cast< node< StringT >* >( iter->m_pnext ); 00639 00640 } while ( iter != this ); 00641 }
bool cttl::node< StringT >::find_class | ( | PredicateT(*)(PredicateT) | iswhat_ | ) |
Moves node position forward to the lower boundary of the specified character class.
Definition at line 270 of file node.h.
00271 { 00272 StringT const& str = parent(); 00273 if ( iswhat_( str[ offset() ] ) ) { 00274 // successful match found for the specified character class, 00275 // find ending position 00276 typename StringT::const_iterator it = str.begin() + offset(); 00277 it = std::find_if( it, str.end(), std::not1( std::ptr_fun( iswhat_ ) ) ); 00278 if ( it != str.end() ) 00279 offset( std::distance( str.begin(), it ) ); // set ending position 00280 else 00281 offset( str.length() ); // set ending position 00282 00283 return true; 00284 } 00285 return false; 00286 }
size_type cttl::node< StringT >::go_bof | ( | ) |
size_type cttl::node< StringT >::go_eof | ( | ) |
size_type cttl::node< StringT >::go_line | ( | size_type | line_ | ) |
Moves node position to the beginning of the specified line.
Definition at line 344 of file node.h.
00345 { 00346 m_offset = 0; 00347 while ( --line_ ) { 00348 m_offset = m_pstr->find( char_T( '\n' ), m_offset ); // find lf 00349 if ( m_offset == StringT::npos ) 00350 return m_offset = m_pstr->length(); 00351 ++m_offset; // position next to lf 00352 } 00353 return m_offset; 00354 }
size_type cttl::node< StringT >::go_line_end | ( | size_type | line_ | ) |
size_type cttl::node< StringT >::go_line_end | ( | ) |
Moves node position to the ending of the current line.
Definition at line 450 of file node.h.
00451 { 00452 static const char_T end_of_line[] = { char_T( '\r' ), char_T( '\n' ), 0x00 }; 00453 m_offset = m_pstr->find_first_of( end_of_line, m_offset ); 00454 if ( m_offset == StringT::npos ) 00455 return m_offset = m_pstr->length(); 00456 00457 return m_offset; 00458 }
size_type cttl::node< StringT >::go_line_home | ( | size_type | line_ | ) |
size_type cttl::node< StringT >::go_line_home | ( | ) |
Moves node position to the beginning of the current line.
Definition at line 417 of file node.h.
00418 { 00419 if ( (*m_pstr)[ m_offset ] == char_T( '\n' ) ) 00420 return m_offset; // stay where you are 00421 00422 m_offset = m_pstr->rfind( char_T( '\n' ), m_offset ); // find previous lf 00423 if ( m_offset == StringT::npos ) 00424 return m_offset = 0; 00425 00426 return ++m_offset; // position next to lf 00427 }
size_type cttl::node< StringT >::go_line_next | ( | ) |
Moves node position to the beginning of the next line.
Definition at line 388 of file node.h.
00389 { 00390 m_offset = m_pstr->find( char_T( '\n' ), m_offset ); // find next lf 00391 if ( m_offset == StringT::npos ) 00392 return m_offset = m_pstr->length(); 00393 00394 return ++m_offset; // position next to lf 00395 }
size_type cttl::node< StringT >::go_line_previous | ( | ) |
int cttl::node< StringT >::identity | ( | node< StringT > const & | root_ | ) | const |
Identifies node position relative to another node.
root_ | Reference to the relative node to measure the distance. |
Definition at line 254 of file node.h.
00255 { 00256 return list_distance( root_ ); 00257 }
void cttl::node< StringT >::insert_go | ( | StringT const & | str_, | |
size_type | source_from_offset_, | |||
size_type | source_to_offset_ | |||
) |
Inserts absolute substring at the position specified by the current node.
Definition at line 512 of file node.h.
00517 { 00518 size_type str_length = source_to_offset_ - source_from_offset_; 00519 00520 if ( !str_.length() ) 00521 return; // nothing to do 00522 00523 size_type insertion_offset = offset(); 00524 00525 m_pstr->insert( 00526 insertion_offset, 00527 str_, 00528 source_from_offset_, 00529 str_length 00530 ); 00531 00532 xtl_identity_insert_go< StringT > insert_go( 00533 insertion_offset, 00534 int( str_length ) 00535 ); 00536 00537 adjust( insert_go ); 00538 }
size_type cttl::node< StringT >::insert_go | ( | StringT const & | str_ | ) |
Inserts text at the current position of the node.
str_ | reference to the source string. |
Definition at line 489 of file node.h.
00490 { 00491 text_insert_go( str_ ); 00492 return offset(); 00493 }
void cttl::node< StringT >::insert_stay | ( | StringT const & | str_, | |
size_type | source_from_offset_, | |||
size_type | source_to_offset_ | |||
) |
Inserts absolute substring at the position specified by the current node.
Definition at line 541 of file node.h.
00546 { 00547 size_type str_length = source_to_offset_ - source_from_offset_; 00548 00549 if ( !str_length ) 00550 return; // nothing to do 00551 00552 size_type insertion_offset = offset(); 00553 00554 m_pstr->insert( 00555 insertion_offset, 00556 str_, 00557 source_from_offset_, 00558 str_length 00559 ); 00560 00561 xtl_identity_insert_stay< StringT > insert_stay( 00562 insertion_offset, 00563 str_length 00564 ); 00565 00566 adjust( insert_stay ); 00567 }
void cttl::node< StringT >::insert_stay | ( | StringT const & | str_ | ) |
size_type cttl::node< StringT >::line | ( | ) | const |
node< StringT >& cttl::node< StringT >::link | ( | node< StringT > & | other_ | ) |
Inserts other node in front of the current, forming a circularly-linked list.
Definition at line 160 of file node.h.
00161 { 00162 assert( m_pstr == other_.m_pstr ); 00163 list_insert( other_ ); 00164 return other_; 00165 }
size_type cttl::node< StringT >::offset | ( | size_type | offset_ | ) |
size_type cttl::node< StringT >::offset | ( | ) | const |
cttl_impl::xtl_wrap< xtl_node< node< StringT >, xtl_wrap< ExprT > > > cttl::node< StringT >::operator() | ( | xtl_wrap< ExprT > const & | expr_ | ) |
Grammar rule adaptor of the node object.
ExprT | Type of the grammar expression, determined by the C++ compiler at compile time. |
expr_ | CTTL grammar expression |
Definition at line 612 of file node.h.
00613 { 00614 // function-call operator must be a nonstatic member function 00615 typedef 00616 xtl_node< 00617 node< StringT >, 00618 xtl_wrap< ExprT > 00619 > xtl_node_T; 00620 00621 return xtl_wrap< xtl_node_T >( xtl_node_T( *this, expr_ ) ); 00622 }
node< StringT >& cttl::node< StringT >::operator+= | ( | StringT const & | str_ | ) |
Addition-assignment of string matches behavior of cttl::node::insert_go().
Definition at line 201 of file node.h.
00202 { 00203 insert_go( str_ ); 00204 return *this; 00205 }
node< StringT >& cttl::node< StringT >::operator-= | ( | StringT const & | str_ | ) |
Subtraction-assignment of string matches behavior of cttl::node::insert_stay().
Definition at line 210 of file node.h.
00211 { 00212 insert_stay( str_ ); 00213 return *this; 00214 }
node< StringT >& cttl::node< StringT >::operator= | ( | size_type | offset_ | ) |
node< StringT >& cttl::node< StringT >::operator= | ( | node< StringT > const & | other_ | ) |
Assignment operator.
node::link()
member function. Definition at line 179 of file node.h.
00180 { 00181 if ( this == &other_ ) { 00182 return *this; 00183 } 00184 00185 m_offset = other_.m_offset; 00186 return *this; 00187 }
char_T& cttl::node< StringT >::operator[] | ( | int | subscript_ | ) |
char_T const& cttl::node< StringT >::operator[] | ( | int | subscript_ | ) | const |
StringT const& cttl::node< StringT >::parent | ( | ) | const |
StringT& cttl::node< StringT >::parent | ( | ) |
bool cttl::node< StringT >::rfind_class | ( | PredicateT(*)(PredicateT) | iswhat_ | ) |
Moves node position backward to the upper boundary of the specified character class.
Definition at line 295 of file node.h.
00296 { 00297 StringT const& str = parent(); 00298 if ( offset() && iswhat_( str[ offset() - 1 ] ) ) { 00299 // successful match found for the specified character class, 00300 // find beginning position for the character class: 00301 typename StringT::const_reverse_iterator it( str.begin() + offset() ); 00302 typename StringT::const_reverse_iterator it_end( str.begin() ); 00303 it = std::find_if( it, it_end, std::not1( std::ptr_fun( iswhat_ ) ) ); 00304 offset( std::distance( it, it_end ) ); // set beginning position 00305 00306 return true; 00307 } 00308 return false; 00309 }
size_type cttl::node< StringT >::m_offset [protected] |
StringT* cttl::node< StringT >::m_pstr [protected] |