cttl_impl::xtl_iswhat_entity Class Reference

Implements behavior of entity(iswhat_T), character entity lexeme inside CTTL grammar expression. More...

#include <xtl_primary.h>

Inheritance diagram for cttl_impl::xtl_iswhat_entity:

cttl_impl::xtl_primary< xtl_iswhat_entity >

List of all members.

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.


Detailed Description

Implements behavior of entity(iswhat_T), character entity lexeme inside CTTL grammar expression.

Definition at line 1420 of file xtl_primary.h.


Constructor & Destructor Documentation

cttl_impl::xtl_iswhat_entity::xtl_iswhat_entity ( iswhat_T  iswhat_  ) 

Constructs and initializes the object.

Definition at line 1430 of file xtl_primary.h.

01431     : m_iswhat( iswhat_ )
01432     {
01433     }


Member Function Documentation

template<typename SubstrT >
size_t cttl_impl::xtl_iswhat_entity::internal_find ( SubstrT &  edge_  ) 

Implements search evaluation grammar evaluation algorithm.

Template Parameters:
SubstrT specifies type of the parseable substring. Can be either cttl::const_edge or cttl::edge.
Parameters:
edge_ reference to the parseable substring.
Returns:
evaluation result: if algorithm succeeds, it returns absolute offset corresponding to the upper boundary of the matched entity. Otherwise, it returns 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     }

template<typename SubstrT >
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.

Template Parameters:
SubstrT specifies type of the parseable substring. Can be either cttl::const_edge or cttl::edge.
Parameters:
edge_ reference to the parseable substring.
Postcondition:
If algorithm succeeds, the parseable substring, specified by the edge_ parameter, is consumed according to the size of the matched entity.
Returns:
evaluation result: if algorithm succeeds, it returns absolute offset corresponding to the upper boundary of the matched entity. Otherwise, it returns 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     }


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

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