cttl_impl::xtl_quote_generic< LeftT, MiddleT, RightT > Class Template Reference

Implements behavior of generic quote helper function, defined by the match_pair() function. More...

#include <xtl_quote.h>

Inheritance diagram for cttl_impl::xtl_quote_generic< LeftT, MiddleT, RightT >:

cttl_impl::xtl_quote_base< LeftT, MiddleT, RightT, xtl_quote_generic< LeftT, MiddleT, RightT > >

List of all members.

Public Member Functions

template<typename SubstrT >
bool match_pair (SubstrT &edge_)
 Implements grammar evaluation behavior of generic quote helper function.
 xtl_quote_generic (LeftT const &left_, MiddleT const &middle_, RightT const &right_)
 Constructs and initializes the object.


Detailed Description

template<typename LeftT, typename MiddleT, typename RightT>
class cttl_impl::xtl_quote_generic< LeftT, MiddleT, RightT >

Implements behavior of generic quote helper function, defined by the match_pair() function.

Template Parameters:
LeftT specifies type of grammar expression, describing opening clause of the quote.
MiddleT specifies type of grammar expression, describing interior clause of the quote.
RightT specifies type of grammar expression, describing closing clause of the quote.

Definition at line 272 of file xtl_quote.h.


Constructor & Destructor Documentation

template<typename LeftT, typename MiddleT, typename RightT>
cttl_impl::xtl_quote_generic< LeftT, MiddleT, RightT >::xtl_quote_generic ( LeftT const &  left_,
MiddleT const &  middle_,
RightT const &  right_ 
)

Constructs and initializes the object.

Definition at line 277 of file xtl_quote.h.

00278     : xtl_quote_base< LeftT, MiddleT, RightT, xtl_quote_generic< LeftT, MiddleT, RightT > >( left_, middle_, right_ )
00279     {
00280     }


Member Function Documentation

template<typename LeftT, typename MiddleT, typename RightT>
template<typename SubstrT >
bool cttl_impl::xtl_quote_generic< LeftT, MiddleT, RightT >::match_pair ( SubstrT &  edge_  ) 

Implements grammar evaluation behavior of generic quote helper function.

Definition at line 289 of file xtl_quote.h.

00290     {
00291         // LHS matched
00292         typename SubstrT::offset_guard_T middle_offset_start( edge_.first );
00293         size_t level = 1;   // we are inside a quote
00294 
00295         typename SubstrT::offset_guard_T current_offset( edge_.first );
00296         typename SubstrT::offset_guard_T right_offset( edge_.first, SubstrT::string_T::npos );
00297         typename SubstrT::offset_guard_T right_right_offset( edge_.first, SubstrT::string_T::npos );
00298 
00299         for (
00300             ;
00301             level && ( ( right_offset = this->m_right.bang_find( edge_ ) ) != SubstrT::string_T::npos );
00302             current_offset = edge_.first.offset()
00303             )
00304         {
00305             // RHS found
00306             // restart left search position
00307             right_right_offset = edge_.first.offset( current_offset );
00308             size_t left_offset = this->m_left.bang_find( edge_ );
00309             if ( left_offset != SubstrT::string_T::npos )
00310                 if ( left_offset < right_offset ) {
00311                     // LHS found earlier, keep searching
00312                     ++level;
00313                     continue;   // ------->
00314                 }
00315 
00316             // restore edge after right pos
00317             edge_.first.offset( right_right_offset );
00318             --level;
00319         }
00320 
00321         if ( level ) {
00322             // RHS was never found - we fail
00323             CTTL_TRACE_TEXT_RESULT( false, '\"', "xtl_quote_generic: closing clause not found" );
00324             return false;
00325         }
00326 
00327         // preserve edge
00328         xtl_edge_offset_guard< SubstrT > edge_guard( edge_ );
00329         edge_.first.offset( middle_offset_start );
00330         edge_.second.offset( right_offset );
00331         if ( this->m_middle.match( edge_ ) != SubstrT::string_T::npos ) {
00332             edge_guard.restore( edge_ );
00333             return true;
00334         }
00335 
00336         edge_guard.restore( edge_ );
00337         CTTL_TRACE_TEXT_RESULT( false, '\"', "xtl_quote_generic: middle clause failed" );
00338         return false;
00339     }


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

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