#include <xtl_primary.h>
Public Member Functions | |
template<typename SubstrT > | |
size_t | internal_find (SubstrT &edge_) |
Implements search evaluation grammar evaluation algorithm. | |
template<typename SubstrT > | |
size_t | internal_match (SubstrT &edge_) |
Implements match evaluation grammar evaluation algorithm. | |
template<typename SubstrT > | |
size_t | match (SubstrT &edge_) |
Implements grammar evaluation algorithm for multi-character entity match algorithm, starting at the upper boundary of the parseable substring. | |
xtl_text_ref_end (StringT const *str_ptr_) | |
Constructs and initializes the object. |
StringT | specifies type of the encapsulated string. |
Definition at line 2429 of file xtl_primary.h.
cttl_impl::xtl_text_ref_end< StringT >::xtl_text_ref_end | ( | StringT const * | str_ptr_ | ) |
size_t cttl_impl::xtl_text_ref_end< StringT >::internal_find | ( | SubstrT & | edge_ | ) |
Implements search evaluation grammar evaluation algorithm.
SubstrT | specifies type of the parseable substring. Can be either cttl::const_edge or cttl::edge . |
edge_ | reference to the parseable substring. |
SubstrT::string_T::npos
, indicating that the evaluation algorithm has failed. Definition at line 2562 of file xtl_primary.h.
02563 { 02564 typename SubstrT::string_T const& str = edge_.parent(); 02565 size_t new_offset = str.find_first_of( m_any_text, edge_.first.offset() ); 02566 if ( new_offset != SubstrT::string_T::npos ) { 02567 // successful find 02568 // find ending position 02569 new_offset = str.find_first_not_of( m_any_text, new_offset ); 02570 if ( new_offset == SubstrT::string_T::npos ) 02571 new_offset = str.length(); 02572 02573 // set ending position 02574 edge_.first.offset( new_offset ); 02575 CTTL_TRACE_TEXT_RESULT( true, '>', m_any_text.c_str() ); 02576 return new_offset; 02577 } 02578 02579 CTTL_TRACE_TEXT_RESULT( false, '>', m_any_text.c_str() ); 02580 return SubstrT::string_T::npos; 02581 }
size_t cttl_impl::xtl_text_ref_end< StringT >::internal_match | ( | SubstrT & | edge_ | ) |
Implements match evaluation grammar evaluation algorithm.
SubstrT | specifies type of the parseable substring. Can be either cttl::const_edge or cttl::edge . |
edge_ | reference to the parseable substring. |
SubstrT::string_T::npos
, indicating that the evaluation algorithm has failed. Definition at line 2504 of file xtl_primary.h.
02505 { 02506 typename SubstrT::string_T const& str = edge_.parent(); 02507 if ( m_any_text.find( str[ edge_.first.offset() ] ) != SubstrT::string_T::npos ) { 02508 // successful match 02509 // set match starting position 02510 size_t match_offset = edge_.first.offset(); 02511 02512 // find ending position 02513 size_t new_offset = str.find_first_not_of( m_any_text, edge_.first.offset() ); 02514 if ( new_offset == SubstrT::string_T::npos ) 02515 new_offset = str.length(); 02516 02517 // set match ending position 02518 edge_.first.offset( new_offset ); 02519 CTTL_TRACE_TEXT_RESULT( true, '>', m_any_text.c_str() ); 02520 return match_offset; 02521 02522 } else if ( edge_.first.offset() ) { 02523 // check if we are at the entity end position: 02524 // offset of the previous character 02525 size_t offset_minus_one = edge_.first.offset() - 1; 02526 if ( offset_minus_one != edge_.space_policy().lower_bound( offset_minus_one, edge_.second.offset() ) ) { 02527 // offset_minus_one is in the void region 02528 CTTL_TRACE_TEXT_RESULT( false, '>', m_any_text.c_str() ); 02529 return SubstrT::string_T::npos; 02530 } 02531 02532 if ( m_any_text.find( str[ offset_minus_one ] ) != SubstrT::string_T::npos ) { 02533 // successful match 02534 CTTL_TRACE_TEXT_RESULT( true, '>', m_any_text.c_str() ); 02535 return edge_.first.offset(); 02536 } 02537 } 02538 02539 CTTL_TRACE_TEXT_RESULT( false, '>', m_any_text.c_str() ); 02540 return SubstrT::string_T::npos; 02541 }
size_t cttl_impl::xtl_text_ref_end< StringT >::match | ( | SubstrT & | edge_ | ) |
Implements grammar evaluation algorithm for multi-character entity match algorithm, starting at the upper boundary of the parseable substring.
SubstrT | specifies type of the parseable substring. Can be either cttl::const_edge or cttl::edge . |
edge_ | reference to the parseable substring. |
edge_
parameter, is consumed according to the size of the matched symbol.SubstrT::string_T::npos
, indicating that the evaluation algorithm has failed. Reimplemented from cttl_impl::xtl_primary< xtl_text_ref_end< StringT > >.
Definition at line 2476 of file xtl_primary.h.
02477 { 02478 size_t match_offset = xtl_primary< xtl_text_ref_end >::match( edge_ ); 02479 if ( match_offset != SubstrT::string_T::npos ) { 02480 return edge_.first.offset(); 02481 } 02482 return SubstrT::string_T::npos; 02483 }