#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_end (StringT const &any_text_) | |
Constructs and initializes the object. |
StringT | specifies type of the encapsulated string. |
Definition at line 2266 of file xtl_primary.h.
cttl_impl::xtl_text_end< StringT >::xtl_text_end | ( | StringT const & | any_text_ | ) |
size_t cttl_impl::xtl_text_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 2394 of file xtl_primary.h.
02395 { 02396 typename SubstrT::string_T const& str = edge_.parent(); 02397 size_t new_offset = str.find_first_of( m_any_text, edge_.first.offset() ); 02398 if ( new_offset != SubstrT::string_T::npos ) { 02399 // successful find 02400 // find ending position 02401 new_offset = str.find_first_not_of( m_any_text, new_offset ); 02402 if ( new_offset == SubstrT::string_T::npos ) 02403 new_offset = str.length(); 02404 02405 // set ending position 02406 edge_.first.offset( new_offset ); 02407 CTTL_TRACE_TEXT_RESULT( true, '>', m_any_text.c_str() ); 02408 return new_offset; 02409 } 02410 02411 CTTL_TRACE_TEXT_RESULT( false, '>', m_any_text.c_str() ); 02412 return SubstrT::string_T::npos; 02413 }
size_t cttl_impl::xtl_text_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 2336 of file xtl_primary.h.
02337 { 02338 typename SubstrT::string_T const& str = edge_.parent(); 02339 if ( m_any_text.find( str[ edge_.first.offset() ] ) != SubstrT::string_T::npos ) { 02340 // successful match 02341 // set match starting position 02342 size_t match_offset = edge_.first.offset(); 02343 02344 // find ending position 02345 size_t new_offset = str.find_first_not_of( m_any_text, edge_.first.offset() ); 02346 if ( new_offset == SubstrT::string_T::npos ) 02347 new_offset = str.length(); 02348 02349 // set match ending position 02350 edge_.first.offset( new_offset ); 02351 CTTL_TRACE_TEXT_RESULT( true, '>', m_any_text.c_str() ); 02352 return match_offset; 02353 02354 } else if ( edge_.first.offset() ) { 02355 // check if we are at the entity-end position: 02356 // offset of the previous character 02357 size_t offset_minus_one = edge_.first.offset() - 1; 02358 if ( offset_minus_one != edge_.space_policy().lower_bound( offset_minus_one, edge_.second.offset() ) ) { 02359 // offset_minus_one is in the void region 02360 CTTL_TRACE_TEXT_RESULT( false, '>', m_any_text.c_str() ); 02361 return SubstrT::string_T::npos; 02362 } 02363 02364 if ( m_any_text.find( str[ offset_minus_one ] ) != SubstrT::string_T::npos ) { 02365 // successful match 02366 CTTL_TRACE_TEXT_RESULT( true, '>', m_any_text.c_str() ); 02367 return edge_.first.offset(); 02368 } 02369 } 02370 02371 CTTL_TRACE_TEXT_RESULT( false, '>', m_any_text.c_str() ); 02372 return SubstrT::string_T::npos; 02373 }
size_t cttl_impl::xtl_text_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_end< StringT > >.
Definition at line 2308 of file xtl_primary.h.
02309 { 02310 size_t match_offset = xtl_primary< xtl_text_end >::match( edge_ ); 02311 if ( match_offset != SubstrT::string_T::npos ) { 02312 return edge_.first.offset(); 02313 } 02314 return SubstrT::string_T::npos; 02315 }