cttl_impl::xtl_text_ref_first< StringT > Class Template Reference

Implements behavior of first(text), first character of the user-defined multi-character entity lexeme inside CTTL grammar expression. More...

#include <xtl_primary.h>

Inheritance diagram for cttl_impl::xtl_text_ref_first< StringT >:

cttl_impl::xtl_primary< xtl_text_ref_first< StringT > >

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_text_ref_first (StringT const *str_ptr_)
 Constructs and initializes the object.


Detailed Description

template<typename StringT>
class cttl_impl::xtl_text_ref_first< StringT >

Implements behavior of first(text), first character of the user-defined multi-character entity lexeme inside CTTL grammar expression.

Template Parameters:
StringT specifies type of the encapsulated string.

Definition at line 2724 of file xtl_primary.h.


Constructor & Destructor Documentation

template<typename StringT>
cttl_impl::xtl_text_ref_first< StringT >::xtl_text_ref_first ( StringT const *  str_ptr_  ) 

Constructs and initializes the object.

Definition at line 2734 of file xtl_primary.h.

02735         : m_any_text( *str_ptr_ )
02736     {
02737     }


Member Function Documentation

template<typename StringT>
template<typename SubstrT >
size_t cttl_impl::xtl_text_ref_first< StringT >::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 2826 of file xtl_primary.h.

02827     {
02828         typename SubstrT::string_T const& str = edge_.parent();
02829         size_t new_offset = str.find_first_of( m_any_text, edge_.first.offset() );
02830         if ( new_offset != SubstrT::string_T::npos ) {
02831             // successful find
02832             // set find ending position: at least one character
02833             // in this entity is present
02834             edge_.first.offset( new_offset + 1 );
02835             CTTL_TRACE_TEXT_RESULT( true, 'F', m_any_text.c_str() );
02836             return new_offset;
02837         }
02838 
02839         CTTL_TRACE_TEXT_RESULT( false, 'F', m_any_text.c_str() );
02840         return SubstrT::string_T::npos;
02841     }

template<typename StringT>
template<typename SubstrT >
size_t cttl_impl::xtl_text_ref_first< StringT >::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 2777 of file xtl_primary.h.

02778     {
02779         typename SubstrT::string_T const& str = edge_.parent();
02780         if ( m_any_text.find( str[ edge_.first.offset() ] ) != SubstrT::string_T::npos ) {
02781             // successful match
02782             // set match starting position
02783             size_t match_offset = edge_.first.offset();
02784             // ending position: at least one character
02785             // in this entity is present
02786             edge_.first.offset( edge_.first.offset() + 1 );
02787             CTTL_TRACE_TEXT_RESULT( true, 'F', m_any_text.c_str() );
02788             return match_offset;
02789         }
02790 
02791         CTTL_TRACE_TEXT_RESULT( false, 'F', m_any_text.c_str() );
02792         return SubstrT::string_T::npos;
02793     }


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

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