cttl_impl::xtl_iswhat_first Class Reference

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

#include <xtl_primary.h>

Inheritance diagram for cttl_impl::xtl_iswhat_first:

cttl_impl::xtl_primary< xtl_iswhat_first >

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 match evaluation grammar evaluation algorithm.
 xtl_iswhat_first (iswhat_T iswhat_)
 Constructs and initializes the object.


Detailed Description

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

Definition at line 1129 of file xtl_primary.h.


Constructor & Destructor Documentation

cttl_impl::xtl_iswhat_first::xtl_iswhat_first ( iswhat_T  iswhat_  ) 

Constructs and initializes the object.

Definition at line 1139 of file xtl_primary.h.

01140     : m_iswhat( iswhat_ )
01141     {
01142     }


Member Function Documentation

template<typename SubstrT >
size_t cttl_impl::xtl_iswhat_first::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.
Postcondition:
If algorithm succeeds, the parseable substring, specified by the edge_ parameter, is consumed accordingly to the size of the matched symbol:
    // 1. The ending position of the matched symbol is set:
    edge_.first.offset( end_offset );

    // 2. Starting position of the matched symbol is returned:
    return begin_offset;
Returns:
evaluation result: if algorithm succeeds, it returns absolute offset corresponding to the upper boundary of the matched symbol. Otherwise, it returns SubstrT::string_T::npos, indicating that the evaluation algorithm has failed.

Definition at line 1224 of file xtl_primary.h.

01225     {
01226         typename SubstrT::string_T const& str = edge_.parent();
01227         typename SubstrT::string_T::const_iterator it = str.begin() + edge_.first.offset();
01228 
01229         // find starting position
01230         it = std::find_if( it, str.end(), m_iswhat );
01231         if ( it == str.end() ) {
01232             CTTL_TRACE_TEXT_RESULT( false, 'F', xtl_trace_grammar::cttl_trace_iswhat( m_iswhat ) );
01233             return SubstrT::string_T::npos;
01234         }
01235 
01236         size_t new_offset = std::distance( str.begin(), it );
01237         // set find ending position:
01238         // at least one character in this entity is present
01239         edge_.first.offset( new_offset + 1 );
01240         CTTL_TRACE_TEXT_RESULT( true, 'F', xtl_trace_grammar::cttl_trace_iswhat( m_iswhat ) );
01241         return new_offset;
01242     }

template<typename SubstrT >
size_t cttl_impl::xtl_iswhat_first::internal_match ( SubstrT &  edge_  ) 

Implements match 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.
Postcondition:
If algorithm succeeds, the parseable substring, specified by the edge_ parameter, is consumed accordingly to the size of the matched symbol:
    // 1. The ending position of the matched symbol is set:
    edge_.first.offset( end_offset );

    // 2. Starting position of the matched symbol is returned:
    return begin_offset;
Returns:
evaluation result: if algorithm succeeds, it returns absolute offset corresponding to the upper boundary of the matched symbol. Otherwise, it returns SubstrT::string_T::npos, indicating that the evaluation algorithm has failed.

Definition at line 1177 of file xtl_primary.h.

01178     {
01179         if ( m_iswhat( edge_.parent()[ edge_.first.offset() ] ) ) {
01180             // successful match
01181             // set match starting position
01182             size_t match_offset = edge_.first.offset();
01183             // ending position:
01184             // at least one character in this entity is present
01185             edge_.first.offset( edge_.first.offset() + 1 );
01186             CTTL_TRACE_TEXT_RESULT( true, 'F', xtl_trace_grammar::cttl_trace_iswhat( m_iswhat ) );
01187             return match_offset;
01188         }
01189         CTTL_TRACE_TEXT_RESULT( false, 'F', xtl_trace_grammar::cttl_trace_iswhat( m_iswhat ) );
01190         return SubstrT::string_T::npos;
01191     }


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