cttl_impl::xtl_text_entity< StringT > Class Template Reference

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

#include <xtl_primary.h>

Inheritance diagram for cttl_impl::xtl_text_entity< StringT >:

cttl_impl::xtl_primary< xtl_text_entity< 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_entity (StringT const &any_text_)
 Constructs and initializes the object.
 xtl_text_entity (typename StringT::value_type const *any_text_)
 Constructs and initializes the object.


Detailed Description

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

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

Template Parameters:
StringT specifies type of the encapsulated string.

Definition at line 2857 of file xtl_primary.h.


Constructor & Destructor Documentation

template<typename StringT >
cttl_impl::xtl_text_entity< StringT >::xtl_text_entity ( typename StringT::value_type const *  any_text_  ) 

Constructs and initializes the object.

Definition at line 2867 of file xtl_primary.h.

02868         : m_any_text( any_text_ )
02869     {
02870     }

template<typename StringT >
cttl_impl::xtl_text_entity< StringT >::xtl_text_entity ( StringT const &  any_text_  ) 

Constructs and initializes the object.

Definition at line 2873 of file xtl_primary.h.

02874         : m_any_text( any_text_ )
02875     {
02876     }


Member Function Documentation

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

02942     {
02943         typename SubstrT::string_T const& str = edge_.parent();
02944         size_t new_offset = str.find_first_of( m_any_text, edge_.first.offset() );
02945         if ( new_offset != SubstrT::string_T::npos ) {
02946             // successful find
02947             // set find starting position
02948             size_t match_offset = new_offset;
02949 
02950             // find ending position
02951             new_offset = str.find_first_not_of( m_any_text, new_offset );
02952             if ( new_offset == SubstrT::string_T::npos )
02953                 new_offset = str.length();
02954 
02955             // set ending position
02956             edge_.first.offset( new_offset );
02957             CTTL_TRACE_TEXT_RESULT( true, '$', m_any_text.c_str() );
02958             return match_offset;
02959         }
02960 
02961         CTTL_TRACE_TEXT_RESULT( false, '$', m_any_text.c_str() );
02962         return SubstrT::string_T::npos;
02963     }

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

02900     {
02901         typename SubstrT::string_T const& str = edge_.parent();
02902         if ( m_any_text.find( str[ edge_.first.offset() ] ) != SubstrT::string_T::npos ) {
02903             // successful match
02904             // set match starting position
02905             size_t match_offset = edge_.first.offset();
02906 
02907             // find ending position
02908             size_t new_offset = str.find_first_not_of( m_any_text, edge_.first.offset() );
02909             if ( new_offset == SubstrT::string_T::npos )
02910                 new_offset = str.length();
02911 
02912             // set match ending position
02913             edge_.first.offset( new_offset );
02914             CTTL_TRACE_TEXT_RESULT( true, '$', m_any_text.c_str() );
02915             return match_offset;
02916         }
02917 
02918         CTTL_TRACE_TEXT_RESULT( false, '$', m_any_text.c_str() );
02919         return SubstrT::string_T::npos;
02920     }


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