cttl::const_edge< PolicyT, StringT > Class Template Reference

Implements constant parseable substring. More...

#include <const_edge.h>

Inheritance diagram for cttl::const_edge< PolicyT, StringT >:

cttl::edge< PolicyT, StringT >

List of all members.

Public Types

typedef StringT::value_type char_T
 Defines type of referenced character.
typedef node< StringT > node_T
 Defines type of substring boundaries, represented by instances of two cttl::node objects.
typedef xtl_const_offset_guard offset_guard_T
 Defines offset guard type for substring boundary.
typedef PolicyT policy_T
 Defines type of the space policy.
typedef StringT::size_type size_type
 Defines size type of substring.
typedef const_edge
< strict_policy_T, StringT > 
strict_edge_T
 Defines type of the substring specialized for strict grammar evaluation algorithm.
typedef PolicyT::strict_policy_T strict_policy_T
 Defines type of the strict space policy.
typedef StringT string_T
 Defines type of referenced string.
typedef StringT value_type
 Defines value type of substring.

Public Member Functions

 const_edge (StringT &inp_, PolicyT &policy_)
 Constructor taking a string and a user-defined space policy.
template<typename Other_policyT >
 const_edge (const_edge< Other_policyT, StringT > const &other_, PolicyT &policy_)
 Constructor taking another substring and a user-defined space policy.
 const_edge (const_edge< PolicyT, StringT > const &other_, size_type start_, size_type finish_)
 Constructs copy of the existing substring with explicitly specified boundary positions.
 const_edge (const_edge< PolicyT, StringT > const &other_)
 Constructs exact copy of the existing substring.
template<typename Other_policyT >
 const_edge (const_edge< Other_policyT, StringT > const &other_)
 Constructor converting another cttl::edge or cttl::const_edge to a substring with a different space policy type.
 const_edge (node< StringT > const &node_first_, node< StringT > const &node_second_, size_type start_, size_type finish_)
 Constructor taking two cttl::node objects that specify substring boundaries and override specific boundary positions.
 const_edge (node< StringT > const &node_first_, node< StringT > const &node_second_)
 Constructor taking two cttl::node objects that specify substring boundaries.
 const_edge (StringT &inp_, size_type start_, size_type finish_)
 Constructor taking reference to a string and specific boundary positions.
 const_edge (StringT &inp_)
 Constructor taking reference to a string.
size_type length () const
 Calculates and returns length of the referenced substring.
 operator StringT () const
 Conversion to StringT.
template<typename ExprT >
xtl_wrap< xtl_edge< const_edge
< PolicyT, StringT >, xtl_wrap
< ExprT > > > 
operator() (xtl_wrap< ExprT > const &expr_)
 Grammar rule adaptor of the edge object.
const_edge< PolicyT, StringT > & operator= (const_edge< PolicyT, StringT > const &other_)
 Substring assignment.
StringT const & parent () const
 Returns constant reference to the referenced string.
StringT & parent ()
 Returns mutable reference to the referenced string.
StringT region_difference ()
 Extracts and returns the content corresponding to the substring boundaries, excluding the intersecting client regions of the the region-aware space policy object attached to this substring.
void region_erase ()
 Erases region(s) described by the current substring boundaries from the region-aware space policy object attached to this substring.
void region_insert ()
 Inserts a region described by the current substring boundaries into the region-aware space policy object attached to this substring.
PolicyT const & space_policy () const
 Returns constant reference to instance of the space policy attached to this substring.
PolicyT & space_policy ()
 Returns mutable reference to instance of the space policy attached to this substring.
StringT text () const
 Returns content of the substring.
void text_tolower ()
 Converts substring to lowercase.
void text_toupper ()
 Converts substring to uppercase.

Public Attributes

node< StringT > first
 cttl::node representing substring upper boundary.
node< StringT > second
 cttl::node representing substring lower boundary.

Static Protected Member Functions

static PolicyT & default_policy ()
 Returns reference to a stateless static object representing default space policy of the substring.

Protected Attributes

PolicyT & m_space_policy
 Stores reference to the space policy of this substring.


Detailed Description

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
class cttl::const_edge< PolicyT, StringT >

Implements constant parseable substring.

Template Parameters:
PolicyT specifies space policy for the grammar evaluation algorithm of this substring. The default policy is cttl::policy_default.
StringT specifies the type of the referenced string. The default type is std::string.

Definition at line 62 of file const_edge.h.


Member Typedef Documentation

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
typedef StringT::value_type cttl::const_edge< PolicyT, StringT >::char_T

Defines type of referenced character.

Reimplemented in cttl::edge< PolicyT, StringT >.

Definition at line 72 of file const_edge.h.

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
typedef node< StringT > cttl::const_edge< PolicyT, StringT >::node_T

Defines type of substring boundaries, represented by instances of two cttl::node objects.

Reimplemented in cttl::edge< PolicyT, StringT >.

Definition at line 98 of file const_edge.h.

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
typedef xtl_const_offset_guard cttl::const_edge< PolicyT, StringT >::offset_guard_T

Defines offset guard type for substring boundary.

Reimplemented in cttl::edge< PolicyT, StringT >.

Definition at line 66 of file const_edge.h.

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
typedef PolicyT cttl::const_edge< PolicyT, StringT >::policy_T

Defines type of the space policy.

Reimplemented in cttl::edge< PolicyT, StringT >.

Definition at line 81 of file const_edge.h.

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
typedef StringT::size_type cttl::const_edge< PolicyT, StringT >::size_type

Defines size type of substring.

Reimplemented in cttl::edge< PolicyT, StringT >.

Definition at line 78 of file const_edge.h.

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
typedef const_edge< strict_policy_T, StringT > cttl::const_edge< PolicyT, StringT >::strict_edge_T

Defines type of the substring specialized for strict grammar evaluation algorithm.

Reimplemented in cttl::edge< PolicyT, StringT >.

Definition at line 92 of file const_edge.h.

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
typedef PolicyT::strict_policy_T cttl::const_edge< PolicyT, StringT >::strict_policy_T

Defines type of the strict space policy.

Reimplemented in cttl::edge< PolicyT, StringT >.

Definition at line 86 of file const_edge.h.

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
typedef StringT cttl::const_edge< PolicyT, StringT >::string_T

Defines type of referenced string.

Definition at line 69 of file const_edge.h.

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
typedef StringT cttl::const_edge< PolicyT, StringT >::value_type

Defines value type of substring.

Definition at line 75 of file const_edge.h.


Constructor & Destructor Documentation

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
cttl::const_edge< PolicyT, StringT >::const_edge ( StringT &  inp_  )  [explicit]

Constructor taking reference to a string.

Parameters:
inp_ Mutable reference to a string.
Postcondition:
Substring boundaries are set to the positions corresponding to the beginning and the ending of the referenced string.

Definition at line 182 of file const_edge.h.

00183             :
00184         first( inp_, 0 ),
00185             second( inp_, inp_.length() ),
00186             m_space_policy( default_policy() )
00187         {
00188             first.link( second );
00189         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
cttl::const_edge< PolicyT, StringT >::const_edge ( StringT &  inp_,
size_type  start_,
size_type  finish_ 
)

Constructor taking reference to a string and specific boundary positions.

Parameters:
inp_ Mutable reference to a string.
start_ Initial offset of the upper boundary (edge::first node.)
finish_ Initial offset of the lower boundary (edge::second node.)

Definition at line 204 of file const_edge.h.

00205             :
00206         first( inp_, start_ ),
00207             second( inp_, finish_ ),
00208             m_space_policy( default_policy() )
00209         {
00210             first.link( second );
00211         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
cttl::const_edge< PolicyT, StringT >::const_edge ( node< StringT > const &  node_first_,
node< StringT > const &  node_second_ 
)

Constructor taking two cttl::node objects that specify substring boundaries.

Parameters:
node_first_ Specifies initial offset of the upper boundary.
node_second_ Specifies initial offset of the lower boundary.
Precondition:
The nodes must belong to the same parent string;
the nodes must be part of the same list.

Definition at line 227 of file const_edge.h.

00228             :
00229         first( node_first_ ),
00230             second( node_second_ ),
00231             m_space_policy( default_policy() )
00232         {
00233             assert( &node_first_.parent() == &node_second_.parent() );
00234         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
cttl::const_edge< PolicyT, StringT >::const_edge ( node< StringT > const &  node_first_,
node< StringT > const &  node_second_,
size_type  start_,
size_type  finish_ 
)

Constructor taking two cttl::node objects that specify substring boundaries and override specific boundary positions.

Parameters:
node_first_ Specifies initial offset of the upper boundary.
node_second_ Specifies initial offset of the lower boundary.
start_ Initial offset of the upper boundary (edge::first node.)
finish_ Initial offset of the lower boundary (edge::second node.)
Precondition:
The nodes must belong to the same parent string;
the nodes must be part of the same list.

Definition at line 256 of file const_edge.h.

00262             :
00263         first( node_first_, start_ ),
00264             second( node_second_, finish_ ),
00265             m_space_policy( default_policy() )
00266         {
00267             assert( &node_first_.parent() == &node_second_.parent() );
00268         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
template<typename Other_policyT >
cttl::const_edge< PolicyT, StringT >::const_edge ( const_edge< Other_policyT, StringT > const &  other_  ) 

Constructor converting another cttl::edge or cttl::const_edge to a substring with a different space policy type.

Template Parameters:
Other_policyT space policy of another substring.
Parameters:
other_ reference to an instance of another substring.
Postcondition:
This constructor converts a "relaxed" substring with user-specified space policy to a "strict" substring, which is using the space policy obtained via call to const_edge::default_policy().

Definition at line 289 of file const_edge.h.

00290             :
00291         first( other_.first ),
00292             second( other_.second ),
00293             m_space_policy( default_policy() )
00294         {
00295         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
cttl::const_edge< PolicyT, StringT >::const_edge ( const_edge< PolicyT, StringT > const &  other_  ) 

Constructs exact copy of the existing substring.

Definition at line 298 of file const_edge.h.

00299             :
00300         first( other_.first ),
00301             second( other_.second ),
00302             m_space_policy( other_.m_space_policy )
00303         {
00304         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
cttl::const_edge< PolicyT, StringT >::const_edge ( const_edge< PolicyT, StringT > const &  other_,
size_type  start_,
size_type  finish_ 
)

Constructs copy of the existing substring with explicitly specified boundary positions.

Parameters:
other_ The reference to another substring.
start_ Initial offset of the upper boundary (edge::first node.)
finish_ Initial offset of the lower boundary (edge::second node.)

Definition at line 319 of file const_edge.h.

00324             :
00325         first( other_.first, start_ ),
00326             second( other_.second, finish_ ),
00327             m_space_policy( other_.m_space_policy )
00328         {
00329         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
template<typename Other_policyT >
cttl::const_edge< PolicyT, StringT >::const_edge ( const_edge< Other_policyT, StringT > const &  other_,
PolicyT &  policy_ 
)

Constructor taking another substring and a user-defined space policy.

Template Parameters:
Other_policyT Type of space policy of another substring.
Parameters:
other_ reference to instance of another substring.
policy_ mutable reference to an instance of the user-defined space policy object.
Postcondition:
References to the string and the policy objects are retained for the lifetime of the substring. The program should never let those two objects go out of scope for as long as the corresponding substrings are in use.

Definition at line 354 of file const_edge.h.

00355             :
00356         first( other_.first ),
00357             second( other_.second ),
00358             m_space_policy( policy_ )
00359         {
00360         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
cttl::const_edge< PolicyT, StringT >::const_edge ( StringT &  inp_,
PolicyT &  policy_ 
)

Constructor taking a string and a user-defined space policy.

Parameters:
inp_ Mutable reference to string
policy_ mutable reference to an instance of the user-defined space policy object.
Postcondition:
References to the string and the policy objects are retained for the lifetime of the substring. The program should never let those two objects go out of scope for as long as the corresponding substrings are in use.

Definition at line 379 of file const_edge.h.

00380             :
00381             first( inp_, 0 ),
00382             second( inp_, inp_.length() ),
00383             m_space_policy( policy_ )
00384         {
00385             first.link( second );
00386         }


Member Function Documentation

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
static PolicyT& cttl::const_edge< PolicyT, StringT >::default_policy (  )  [static, protected]

Returns reference to a stateless static object representing default space policy of the substring.

Precondition:
Note: static objects are not thread-safe, unless their implementation is stateless. Thus, multi-threaded environment may rely only on a stateless space policy, such as, for example, cttl::policy_default.
Note: PolicyT must be default-constructible.

Definition at line 126 of file const_edge.h.

00127         {
00128 #ifdef CTTL_STATEFUL_RUNTIME_MATCH
00129             //assert( !"Stateful policy must be provided by the user." );
00130             static PolicyT* const ptr_bad_policy = NULL;
00131             return *ptr_bad_policy;
00132 #else
00133             // Because const_edge::m_space_policy is mutable,
00134             // a static policy, such as
00135             //
00136             //      static PolicyT stateless_static_policy;
00137             //
00138             // is declared be mutable.
00139             // This might generate a compiler warning such as
00140             // "construction of local static object is not thread-safe,"
00141             // which can be ignored.
00142 
00143             static PolicyT stateless_static_policy;
00144             return stateless_static_policy;
00145 #endif //CTTL_STATEFUL_RUNTIME_MATCH
00146         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
size_type cttl::const_edge< PolicyT, StringT >::length (  )  const

Calculates and returns length of the referenced substring.

Returns:
the function returns StringT::npos, if the following condition is false:
first.offset() <= second.offset()
where first and second are the substring boundaries

Definition at line 463 of file const_edge.h.

00464         {
00465             if ( first.offset() > second.offset() )
00466                 return StringT::npos;
00467 
00468             return second.offset() - first.offset();
00469         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
cttl::const_edge< PolicyT, StringT >::operator StringT (  )  const

Conversion to StringT.

Precondition:
A valid boundary range is expected:
0 <= first.offset() <= second.offset() <= inp.length()

where inp.length() is the length of the referenced string.

Definition at line 417 of file const_edge.h.

00418         {
00419             return text();
00420         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
template<typename ExprT >
xtl_wrap< xtl_edge< const_edge< PolicyT, StringT >, xtl_wrap< ExprT > > > cttl::const_edge< PolicyT, StringT >::operator() ( xtl_wrap< ExprT > const &  expr_  ) 

Grammar rule adaptor of the edge object.

Template Parameters:
ExprT Type of the grammar expression, determined by the C++ compiler at compile time.
Parameters:
expr_ CTTL grammar expression

Definition at line 559 of file const_edge.h.

00560         {
00561             typedef
00562                 xtl_edge<
00563                 const_edge< PolicyT, StringT >,
00564                 xtl_wrap< ExprT >
00565                 > xtl_edge_T;
00566 
00567             return xtl_wrap< xtl_edge_T >( xtl_edge_T( *this, expr_ ) );
00568         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
const_edge< PolicyT, StringT >& cttl::const_edge< PolicyT, StringT >::operator= ( const_edge< PolicyT, StringT > const &  other_  ) 

Substring assignment.

Parameters:
other_ instance of another substring.
Note: substring assignment mathces behavior of the copy constructor.

Reimplemented in cttl::edge< PolicyT, StringT >.

Definition at line 396 of file const_edge.h.

00397         {
00398             if ( this != &other_ ) {
00399                 first = other_.first;
00400                 second = other_.second;
00401             }
00402             return *this;
00403         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
StringT const& cttl::const_edge< PolicyT, StringT >::parent (  )  const

Returns constant reference to the referenced string.

Definition at line 429 of file const_edge.h.

00430         {
00431             return first.parent();
00432         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
StringT& cttl::const_edge< PolicyT, StringT >::parent (  ) 

Returns mutable reference to the referenced string.

Definition at line 423 of file const_edge.h.

00424         {
00425             return first.parent();
00426         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
StringT cttl::const_edge< PolicyT, StringT >::region_difference (  ) 

Extracts and returns the content corresponding to the substring boundaries, excluding the intersecting client regions of the the region-aware space policy object attached to this substring.

Definition at line 503 of file const_edge.h.

00504         {
00505             return space_policy().region_difference(
00506                 parent(),
00507                 first.offset(),
00508                 second.offset()
00509                 );
00510         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
void cttl::const_edge< PolicyT, StringT >::region_erase (  ) 

Erases region(s) described by the current substring boundaries from the region-aware space policy object attached to this substring.

Definition at line 489 of file const_edge.h.

00490         {
00491             space_policy().region_erase(
00492                 first.offset(),
00493                 second.offset()
00494                 );
00495         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
void cttl::const_edge< PolicyT, StringT >::region_insert (  ) 

Inserts a region described by the current substring boundaries into the region-aware space policy object attached to this substring.

Definition at line 476 of file const_edge.h.

00477         {
00478             space_policy().region_insert(
00479                 first.offset(),
00480                 second.offset()
00481                 );
00482         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
PolicyT const& cttl::const_edge< PolicyT, StringT >::space_policy (  )  const

Returns constant reference to instance of the space policy attached to this substring.

Definition at line 162 of file const_edge.h.

00163         {
00164             return m_space_policy;
00165         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
PolicyT& cttl::const_edge< PolicyT, StringT >::space_policy (  ) 

Returns mutable reference to instance of the space policy attached to this substring.

Definition at line 153 of file const_edge.h.

00154         {
00155             return m_space_policy;
00156         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
StringT cttl::const_edge< PolicyT, StringT >::text (  )  const

Returns content of the substring.

Reimplemented in cttl::edge< PolicyT, StringT >.

Definition at line 436 of file const_edge.h.

00437         {
00438             assert( &first.parent() == &second.parent() );
00439             assert( first.offset() <= second.offset() );
00440             assert( second.offset() <= second.parent().length() );
00441 
00442             if ( first.offset() == second.offset() ) {
00443                 return StringT();
00444             }
00445 
00446             return second.parent().substr(
00447                 first.offset(),
00448                 length()
00449                 );
00450         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
void cttl::const_edge< PolicyT, StringT >::text_tolower (  ) 

Converts substring to lowercase.

Definition at line 513 of file const_edge.h.

00514         {
00515             typename StringT::iterator it_first = parent().begin() + first.offset();
00516             typename StringT::iterator it_last = parent().begin() + second.offset();
00517 
00518             std::transform(
00519                 it_first,
00520                 it_last,
00521                 it_first,
00522                 tolower
00523                 );
00524         }

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
void cttl::const_edge< PolicyT, StringT >::text_toupper (  ) 

Converts substring to uppercase.

Definition at line 527 of file const_edge.h.

00528         {
00529             typename StringT::iterator it_first = parent().begin() + first.offset();
00530             typename StringT::iterator it_last = parent().begin() + second.offset();
00531 
00532             std::transform(
00533                 it_first,
00534                 it_last,
00535                 it_first,
00536                 toupper
00537                 );
00538         }


Member Data Documentation

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
node< StringT > cttl::const_edge< PolicyT, StringT >::first

cttl::node representing substring upper boundary.

Definition at line 102 of file const_edge.h.

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
PolicyT& cttl::const_edge< PolicyT, StringT >::m_space_policy [protected]

Stores reference to the space policy of this substring.

Definition at line 112 of file const_edge.h.

template<typename PolicyT = policy_default, typename StringT = CTTL_STD_STRING>
node< StringT > cttl::const_edge< PolicyT, StringT >::second

cttl::node representing substring lower boundary.

Definition at line 105 of file const_edge.h.


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

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