#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 grammar evaluation algorithm for entity match algorithm, starting at the upper boundary of the parseable substring. | |
xtl_iswhat_entity (iswhat_T iswhat_) | |
Constructs and initializes the object. |
Definition at line 1420 of file xtl_primary.h.
cttl_impl::xtl_iswhat_entity::xtl_iswhat_entity | ( | iswhat_T | iswhat_ | ) |
size_t cttl_impl::xtl_iswhat_entity::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 1505 of file xtl_primary.h.
01506 { 01507 typename SubstrT::string_T const& str = edge_.parent(); 01508 typename SubstrT::string_T::const_iterator it = str.begin() + edge_.first.offset(); 01509 01510 // find starting position 01511 it = std::find_if( it, str.end(), m_iswhat ); 01512 if ( it == str.end() ) { 01513 CTTL_TRACE_TEXT_RESULT( false, '$', xtl_trace_grammar::cttl_trace_iswhat( m_iswhat ) ); 01514 return SubstrT::string_T::npos; 01515 } 01516 01517 size_t new_offset = std::distance( str.begin(), it ); 01518 // set find starting position 01519 size_t match_offset = new_offset; 01520 01521 // find ending position 01522 it = std::find_if( it, str.end(), std::not1( std::ptr_fun( m_iswhat ) ) ); 01523 if ( it != str.end() ) 01524 new_offset = std::distance( str.begin(), it ); 01525 else 01526 new_offset = str.length(); 01527 01528 // set find ending position 01529 edge_.first.offset( new_offset ); 01530 CTTL_TRACE_TEXT_RESULT( true, '$', xtl_trace_grammar::cttl_trace_iswhat( m_iswhat ) ); 01531 return match_offset; 01532 }
size_t cttl_impl::xtl_iswhat_entity::internal_match | ( | SubstrT & | edge_ | ) |
Implements grammar evaluation algorithm for 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 entity.SubstrT::string_T::npos
, indicating that the evaluation algorithm has failed. Definition at line 1462 of file xtl_primary.h.
01463 { 01464 if ( m_iswhat( edge_.parent()[ edge_.first.offset() ] ) ) { 01465 // successful match 01466 // set match starting position 01467 size_t match_offset = edge_.first.offset(); 01468 01469 // find ending position 01470 typename SubstrT::string_T const& str = edge_.parent(); 01471 typename SubstrT::string_T::const_iterator it = str.begin() + edge_.first.offset(); 01472 it = std::find_if( it, str.end(), std::not1( std::ptr_fun( m_iswhat ) ) ); 01473 // set ending position 01474 if ( it != str.end() ) 01475 edge_.first.offset( std::distance( str.begin(), it ) ); 01476 else 01477 edge_.first.offset( str.length() ); 01478 01479 CTTL_TRACE_TEXT_RESULT( true, '$', xtl_trace_grammar::cttl_trace_iswhat( m_iswhat ) ); 01480 return match_offset; 01481 } 01482 CTTL_TRACE_TEXT_RESULT( false, '$', xtl_trace_grammar::cttl_trace_iswhat( m_iswhat ) ); 01483 return SubstrT::string_T::npos; 01484 }