Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

xst_helpers.h

Go to the documentation of this file.
00001 
00002 // Common Text Transformation Library
00003 // Copyright (C) 1997-2006 by Igor Kholodov. 
00004 //
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the
00017 // Free Software Foundation, Inc.,
00018 // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019 //
00020 // mailto:cttl@users.sourceforge.net
00021 // http://sourceforge.net/projects/cttl/
00023 
00033 // xst_helpers.h
00034 
00035 #ifndef _XST_HELPERS_H_INCLUDED_
00036 #define _XST_HELPERS_H_INCLUDED_
00037 
00038 #include <utility>
00039 #include <map>
00040 
00046 namespace cttl {
00047 
00048 using namespace cttl_impl;
00049 
00067 template< typename ValueT >
00068 inline
00069 xst_lambda_wrap< xst_scalar< ValueT > >
00070 scalar( ValueT const& value_ )
00071 {
00072     return xst_lambda_wrap< xst_scalar< ValueT > >( value_ );
00073 }
00074 
00075 
00092 template< typename ValueT >
00093 inline
00094 xst_lambda_wrap< xst_stack< std::stack< ValueT > > >
00095 make_stack( ValueT const& value_ )
00096 {
00097     return xst_lambda_wrap< xst_stack< std::stack< ValueT > > >( value_ );
00098 }
00099 
00115 template< typename ValueT >
00116 inline
00117 xst_lambda_wrap< xst_stack< std::stack< ValueT > > >
00118 scalar( std::stack< ValueT > const& stack_ )
00119 {
00120     return xst_lambda_wrap< xst_stack< std::stack< ValueT > > >( stack_ );
00121 }
00122 
00141 template< typename ValueT >
00142 inline
00143 xst_lambda_wrap< xst_scalar< ValueT& > >
00144 scalar( ValueT* pvalue_ )
00145 {
00146     assert( pvalue_ );
00147     return xst_lambda_wrap< xst_scalar< ValueT& > >( pvalue_ );
00148 }
00149 
00165 template< typename ValueT >
00166 inline
00167 xst_lambda_wrap< xst_stack< std::stack< ValueT >& > >
00168 scalar( std::stack< ValueT >* pstack_ )
00169 {
00170     assert( pstack_ );
00171     return xst_lambda_wrap< xst_stack< std::stack< ValueT >& > >( pstack_ );
00172 }
00173 
00174 
00175 #ifndef CTTL_LAMBDA_SINGULAR
00176 
00178 template< typename LhsT, typename RhsT >
00179 inline
00180 xst_lambda_wrap<
00181     xst_pair<
00182         xst_lambda_wrap< typename LhsT::reference_T >,
00183         xst_lambda_wrap< typename RhsT::reference_T >
00184     >
00185 >
00186 operator^ ( // D^D
00187            xst_lambda_wrap< LhsT > const& lhs_expr_,
00188            xst_lambda_wrap< RhsT > const& rhs_expr_
00189            )
00190 {
00191     // expression a^b^c produces the following tree:
00192     //     ^    //
00193     //    / \   //
00194     //   ^  c   //
00195     //  / \     //
00196     // a   b    //
00197 
00198     typedef
00199         xst_pair<
00200             xst_lambda_wrap< typename LhsT::reference_T >,
00201             xst_lambda_wrap< typename RhsT::reference_T >
00202         >
00203         pair_T;
00204 
00205     return xst_lambda_wrap< pair_T >(
00206         pair_T(
00207             lhs_expr_.make_reference(),
00208             rhs_expr_.make_reference()
00209         )
00210     );
00211 }
00212 
00214 template< typename LhsT >
00215 inline
00216 xst_lambda_wrap<
00217     xst_pair<
00218         xst_lambda_wrap< typename LhsT::reference_T >,
00219         xst_lambda_wrap< xst_scalar< int > >
00220     >
00221 >
00222 operator^ ( // D^int
00223            xst_lambda_wrap< LhsT > const& lhs_expr_, int value_
00224            )
00225 {
00226     typedef
00227         xst_pair<
00228             xst_lambda_wrap< typename LhsT::reference_T >,
00229             xst_lambda_wrap< xst_scalar< int > >
00230         >
00231         pair_T;
00232 
00233     return xst_lambda_wrap< pair_T >(
00234         pair_T(
00235             lhs_expr_.make_reference(),
00236             xst_lambda_wrap< xst_scalar< int > >( value_ )
00237             )
00238         );
00239 }
00240 
00242 template< typename LhsT, typename ValueT >
00243 inline
00244 xst_lambda_wrap<
00245     xst_pair<
00246         xst_lambda_wrap< typename LhsT::reference_T >,
00247         xst_lambda_wrap< xst_stack< std::stack< ValueT > > >
00248     >
00249 >
00250 operator^ ( // D^stack
00251            xst_lambda_wrap< LhsT > const& lhs_expr_,
00252            std::stack< ValueT > const& stack_
00253            )
00254 {
00255     typedef
00256         xst_pair<
00257             xst_lambda_wrap< typename LhsT::reference_T >,
00258             xst_lambda_wrap< xst_stack< std::stack< ValueT > > >
00259         >
00260         pair_T;
00261 
00262     return xst_lambda_wrap< pair_T >(
00263         pair_T(
00264             lhs_expr_.make_reference(),
00265             xst_lambda_wrap< xst_stack< std::stack< ValueT > > >( stack_ )
00266             )
00267         );
00268 }
00269 
00271 template< typename LhsT, typename ValueT >
00272 inline
00273 xst_lambda_wrap<
00274     xst_pair<
00275         xst_lambda_wrap< typename LhsT::reference_T >,
00276         xst_lambda_wrap< xst_stack< std::stack< ValueT >& > >
00277     >
00278 >
00279 operator^ ( // D^stack*
00280            xst_lambda_wrap< LhsT > const& lhs_expr_,
00281            std::stack< ValueT >* pstack_
00282            )
00283 {
00284     typedef
00285         xst_pair<
00286             xst_lambda_wrap< typename LhsT::reference_T >,
00287             xst_lambda_wrap< xst_stack< std::stack< ValueT >& > >
00288         >
00289         pair_T;
00290 
00291     return xst_lambda_wrap< pair_T >(
00292         pair_T(
00293             lhs_expr_.make_reference(),
00294             xst_lambda_wrap< xst_stack< std::stack< ValueT >& > >( pstack_ )
00295             )
00296         );
00297 }
00298 
00300 template< typename LhsT >
00301 inline
00302 xst_lambda_wrap<
00303     xst_pair<
00304         xst_lambda_wrap< typename LhsT::reference_T >,
00305         xst_lambda_wrap< xst_scalar< int& > >
00306     >
00307 >
00308 operator^ ( // D^int*
00309            xst_lambda_wrap< LhsT > const& lhs_expr_,
00310            int* pvalue_
00311            )
00312 {
00313     typedef
00314         xst_pair<
00315             xst_lambda_wrap< typename LhsT::reference_T >,
00316             xst_lambda_wrap< xst_scalar< int& > >
00317         >
00318         pair_T;
00319 
00320     return xst_lambda_wrap< pair_T >(
00321         pair_T(
00322             lhs_expr_.make_reference(),
00323             xst_lambda_wrap< xst_scalar< int& > >( pvalue_ )
00324             )
00325         );
00326 }
00327 #endif //CTTL_LAMBDA_SINGULAR
00328 
00330 template< typename LambdaT, typename TranslatorT, typename PolicyT, typename StringT >
00331 inline
00332 xst_lambda_wrap<
00333     xst_translator<
00334         xst_lambda_wrap<
00335             xst_translator<
00336                 LambdaT,
00337                 TranslatorT
00338             >
00339         >
00340         ,
00341         xst_edge_translator< PolicyT, StringT >
00342     >
00343 >
00344 operator^ ( // T^const_edge
00345             xst_lambda_wrap<
00346                 xst_translator<
00347                     LambdaT,
00348                     TranslatorT
00349                 >
00350             >
00351            const&
00352            lambda_,
00353            const_edge< PolicyT, StringT >
00354            const&
00355            edge_
00356            )
00357 {
00358     typedef xst_edge_translator< PolicyT, StringT > edge_translator_T;
00359     typedef
00360         xst_translator<
00361             xst_lambda_wrap<
00362                 xst_translator<
00363                     LambdaT,
00364                     TranslatorT
00365                 >
00366             >
00367             ,
00368             edge_translator_T
00369         >
00370         translator_T;
00371 
00372     return xst_lambda_wrap< translator_T >( translator_T( lambda_, edge_translator_T( edge_ ) ) );
00373 }
00374 
00376 template< typename LambdaT, typename TranslatorT, typename PolicyT, typename StringT >
00377 inline
00378 xst_lambda_wrap<
00379     xst_translator<
00380         xst_lambda_wrap<
00381             xst_translator<
00382                 LambdaT,
00383                 TranslatorT
00384             >
00385         >
00386         ,
00387         xst_edge_translator< PolicyT, StringT >
00388     >
00389 >
00390 operator^ ( // T^edge
00391             xst_lambda_wrap<
00392                 xst_translator<
00393                     LambdaT,
00394                     TranslatorT
00395                 >
00396             >
00397            const&
00398            lambda_,
00399            edge< PolicyT, StringT >
00400            const&
00401            edge_
00402            )
00403 {
00404     typedef xst_edge_translator< PolicyT, StringT > edge_translator_T;
00405     typedef
00406         xst_translator<
00407             xst_lambda_wrap<
00408                 xst_translator<
00409                     LambdaT,
00410                     TranslatorT
00411                 >
00412             >
00413             ,
00414             edge_translator_T
00415         >
00416         translator_T;
00417 
00418     return xst_lambda_wrap< translator_T >( translator_T( lambda_, edge_translator_T( edge_ ) ) );
00419 }
00420 
00422 template< typename LambdaT, typename TranslatorT, typename ValueT >
00423 inline
00424 xst_lambda_wrap<
00425     xst_translator<
00426         xst_lambda_wrap<
00427             xst_translator<
00428                 LambdaT,
00429                 TranslatorT
00430             >
00431         >
00432         ,
00433         xst_sequence_translator< std::vector< ValueT > >
00434     >
00435 >
00436 operator^ ( // T^vector sequence translator
00437             xst_lambda_wrap<
00438                 xst_translator<
00439                     LambdaT,
00440                     TranslatorT
00441                 >
00442             >
00443            const&
00444            lambda_,
00445            std::vector< ValueT >&
00446            vector_
00447            )
00448 {
00449     typedef xst_sequence_translator< std::vector< ValueT > > sequence_translator_T;
00450     typedef
00451         xst_translator<
00452             xst_lambda_wrap<
00453                 xst_translator<
00454                     LambdaT,
00455                     TranslatorT
00456                 >
00457             >
00458             ,
00459             sequence_translator_T
00460         >
00461         translator_T;
00462 
00463     return xst_lambda_wrap< translator_T >( translator_T( lambda_, sequence_translator_T( vector_ ) ) );
00464 }
00465 
00467 template< typename LhsLambdaT, typename ValueT >
00468 inline
00469 xst_lambda_wrap<
00470     xst_translator<
00471         typename LhsLambdaT::reference_T,
00472         xst_sequence_translator< std::vector< ValueT > >
00473     >
00474 >
00475 operator^ ( // D^vector: sequence translator
00476            xst_lambda_wrap< LhsLambdaT > const& lambda_,
00477            std::vector< ValueT >&
00478            vector_
00479            )
00480 {
00481     typedef xst_sequence_translator< std::vector< ValueT > > sequence_translator_T;
00482     typedef
00483             xst_translator<
00484                 typename LhsLambdaT::reference_T,
00485                 sequence_translator_T
00486             >
00487         translator_T;
00488 
00489     return xst_lambda_wrap< translator_T >(
00490         translator_T(
00491             lambda_.right_lambda().make_reference(),
00492             sequence_translator_T( vector_ )
00493             )
00494         );
00495 }
00496 
00498 template< typename LhsLambdaT, typename SequenceT, typename MapT >
00499 inline
00500 xst_lambda_wrap<
00501     xst_translator<
00502         typename LhsLambdaT::reference_T,
00503         xst_dictionary_translator< SequenceT, MapT >
00504     >
00505 >
00506 operator^ ( // D^pair< SequenceT*, MapT* > dictionary translator
00507            xst_lambda_wrap< LhsLambdaT > const& lambda_,
00508            std::pair< SequenceT*, MapT* >&
00509            pair_
00510            )
00511 {
00512     typedef xst_dictionary_translator< SequenceT, MapT > dictionary_translator_T;
00513     typedef
00514             xst_translator<
00515                 typename LhsLambdaT::reference_T,
00516                 dictionary_translator_T
00517             >
00518         translator_T;
00519 
00520     return xst_lambda_wrap< translator_T >(
00521         translator_T(
00522             lambda_.right_lambda().make_reference(),
00523             dictionary_translator_T( *pair_.first, *pair_.second )
00524             )
00525         );
00526 }
00527 
00529 template< typename LhsLambdaT, typename SequenceT, typename MapT >
00530 inline
00531 xst_lambda_wrap<
00532     xst_translator<
00533         typename LhsLambdaT::reference_T,
00534         xst_dictionary_translator< SequenceT, MapT >
00535     >
00536 >
00537 operator^ ( // D^pair< SequenceT, MapT > dictionary translator
00538            xst_lambda_wrap< LhsLambdaT > const& lambda_,
00539            std::pair< SequenceT, MapT >&
00540            pair_
00541            )
00542 {
00543     typedef xst_dictionary_translator< SequenceT, MapT > dictionary_translator_T;
00544     typedef
00545             xst_translator<
00546                 typename LhsLambdaT::reference_T,
00547                 dictionary_translator_T
00548             >
00549         translator_T;
00550 
00551     return xst_lambda_wrap< translator_T >(
00552         translator_T(
00553             lambda_.right_lambda().make_reference(),
00554             dictionary_translator_T( pair_.first, pair_.second )
00555             )
00556         );
00557 }
00558 
00560 template< typename LhsLambdaT, typename SequenceT >
00561 inline
00562 xst_lambda_wrap<
00563     xst_translator<
00564         typename LhsLambdaT::reference_T,
00565         xst_sequence_translator< SequenceT >
00566     >
00567 >
00568 operator^ ( // D^pair< SequenceT*, int > sequence translator
00569            xst_lambda_wrap< LhsLambdaT > const& lambda_,
00570            std::pair< SequenceT*, int >&
00571            pair_
00572            )
00573 {
00574     typedef xst_sequence_translator< SequenceT > sequence_translator_T;
00575     typedef
00576             xst_translator<
00577                 typename LhsLambdaT::reference_T,
00578                 sequence_translator_T
00579             >
00580         translator_T;
00581 
00582     return xst_lambda_wrap< translator_T >(
00583         translator_T(
00584             lambda_.right_lambda().make_reference(),
00585             sequence_translator_T( *pair_.first )
00586             )
00587         );
00588 }
00589 
00591 template< typename LhsLambdaT, typename SequenceT >
00592 inline
00593 xst_lambda_wrap<
00594     xst_translator<
00595         typename LhsLambdaT::reference_T,
00596         xst_sequence_translator< SequenceT >
00597     >
00598 >
00599 operator^ ( // D^pair< SequenceT, int > sequence translator
00600            xst_lambda_wrap< LhsLambdaT > const& lambda_,
00601            std::pair< SequenceT, int >&
00602            pair_
00603            )
00604 {
00605     typedef xst_sequence_translator< SequenceT > sequence_translator_T;
00606     typedef
00607             xst_translator<
00608                 typename LhsLambdaT::reference_T,
00609                 sequence_translator_T
00610             >
00611         translator_T;
00612 
00613     return xst_lambda_wrap< translator_T >(
00614         translator_T(
00615             lambda_.right_lambda().make_reference(),
00616             sequence_translator_T( pair_.first )
00617             )
00618         );
00619 }
00620 
00622 template< typename LhsLambdaT >
00623 inline
00624 xst_lambda_wrap<
00625     xst_translator<
00626         typename LhsLambdaT::reference_T,
00627         xst_literal_translator< char >
00628     >
00629 >
00630 operator^ ( // D^"text" literal translator
00631            xst_lambda_wrap< LhsLambdaT > const& lambda_,
00632            char const* pchar_
00633            )
00634 {
00635     typedef xst_literal_translator< char > literal_translator_T;
00636     typedef
00637             xst_translator<
00638                 typename LhsLambdaT::reference_T,
00639                 literal_translator_T
00640             >
00641         translator_T;
00642 
00643     return xst_lambda_wrap< translator_T >(
00644         translator_T(
00645             lambda_.right_lambda().make_reference(),
00646             literal_translator_T( pchar_ )
00647             )
00648         );
00649 }
00650 
00651 
00653 template< typename LhsLambdaT >
00654 inline
00655 xst_lambda_wrap<
00656     xst_translator<
00657         typename LhsLambdaT::reference_T,
00658         xst_literal_translator< wchar_t >
00659     >
00660 >
00661 operator^ ( // D^L"text" literal translator
00662            xst_lambda_wrap< LhsLambdaT > const& lambda_,
00663            wchar_t const* pwchar_
00664            )
00665 {
00666     typedef xst_literal_translator< wchar_t > wliteral_translator_T;
00667     typedef
00668             xst_translator<
00669                 typename LhsLambdaT::reference_T,
00670                 wliteral_translator_T
00671             >
00672         translator_T;
00673 
00674     return xst_lambda_wrap< translator_T >(
00675         translator_T(
00676             lambda_.right_lambda().make_reference(),
00677             wliteral_translator_T( pwchar_ )
00678             )
00679         );
00680 }
00681 
00682 
00702 template< typename LhsLambdaT, typename RhsTranslatorT >
00703 inline
00704 xst_lambda_wrap<
00705     xst_translator<
00706         typename LhsLambdaT::reference_T,
00707         RhsTranslatorT
00708     >
00709 >
00710 operator^ ( // D^T
00711            xst_lambda_wrap< LhsLambdaT > const& lambda_,
00712            RhsTranslatorT translator_
00713            )
00714 {
00715     typedef
00716             xst_translator<
00717                 typename LhsLambdaT::reference_T,
00718                 RhsTranslatorT
00719             >
00720         translator_T;
00721 
00722     return xst_lambda_wrap< translator_T >(
00723         translator_T(
00724             lambda_.right_lambda().make_reference(),
00725             translator_
00726             )
00727         );
00728 }
00729 
00738 template< typename LhsLambdaT, typename RhsTranslatorT >
00739 inline
00740 xst_lambda_wrap<
00741     xst_translator<
00742         LhsLambdaT,
00743         RhsTranslatorT
00744     >
00745 >
00746 make_translator( // D^T
00747            xst_lambda_wrap< LhsLambdaT > const& lambda_,
00748            RhsTranslatorT translator_
00749            )
00750 {
00751     typedef
00752             xst_translator<
00753                 LhsLambdaT,
00754                 RhsTranslatorT
00755             >
00756         translator_T;
00757 
00758     return xst_lambda_wrap< translator_T >(
00759         translator_T(
00760             lambda_.right_lambda(),
00761             translator_
00762             )
00763         );
00764 }
00765 
00767 // Sequence operators for connecting lambda and grammar expressions
00768 // via grammar sequence operators.
00770 
00800 template< typename LeftExprT, typename LambdaExprT, typename PolicyAdaptorT >
00801 inline
00802 xtl_wrap<
00803     xtl_opbinplus<
00804         xtl_wrap< LeftExprT >,
00805         xtl_wrap< xst_unary_adaptor< LambdaExprT, PolicyAdaptorT > >
00806     >
00807 >
00808 operator+ (
00809            xtl_wrap< LeftExprT > const& lhs_expr_,
00810            xst_unary_adaptor< LambdaExprT, PolicyAdaptorT > const& rhs_expr_
00811            )
00812 {
00813     typedef
00814         xtl_opbinplus<
00815             xtl_wrap< LeftExprT >,
00816             xtl_wrap< xst_unary_adaptor< LambdaExprT, PolicyAdaptorT > >
00817         >
00818         opplus_T;
00819 
00820     return xtl_wrap< opplus_T >( opplus_T( lhs_expr_, rhs_expr_ ) );
00821 }
00822 
00851 template< typename RightExprT, typename LambdaExprT, typename PolicyAdaptorT >
00852 inline
00853 xtl_wrap<
00854     xtl_opbinplus<
00855         xtl_wrap< xst_unary_adaptor< LambdaExprT, PolicyAdaptorT > >,
00856         xtl_wrap< RightExprT >
00857     >
00858 >
00859 operator+ (
00860            xst_unary_adaptor< LambdaExprT, PolicyAdaptorT > const& lhs_expr_,
00861            xtl_wrap< RightExprT > const& rhs_expr_
00862            )
00863 {
00864     typedef
00865         xtl_opbinplus<
00866             xtl_wrap< xst_unary_adaptor< LambdaExprT, PolicyAdaptorT > >,
00867             xtl_wrap< RightExprT >
00868         >
00869         opplus_T;
00870 
00871     return xtl_wrap< opplus_T >( opplus_T( lhs_expr_, rhs_expr_ ) );
00872 }
00873 
00907 template< typename LeftExprT, typename LambdaLhsExprT, typename LambdaRhsExprT, typename PolicyAdaptorT >
00908 inline
00909 xtl_wrap<
00910     xtl_opbinplus<
00911         xtl_wrap< LeftExprT >,
00912         xtl_wrap< xst_binary_adaptor< LambdaLhsExprT, LambdaRhsExprT, PolicyAdaptorT > >
00913     >
00914 >
00915 operator+ (
00916            xtl_wrap< LeftExprT > const& lhs_expr_,
00917            xst_binary_adaptor< LambdaLhsExprT, LambdaRhsExprT, PolicyAdaptorT > const& rhs_expr_
00918            )
00919 {
00920     typedef
00921         xtl_opbinplus<
00922             xtl_wrap< LeftExprT >,
00923             xtl_wrap< xst_binary_adaptor< LambdaLhsExprT, LambdaRhsExprT, PolicyAdaptorT > >
00924         >
00925         opplus_T;
00926 
00927     return xtl_wrap< opplus_T >( opplus_T( lhs_expr_, rhs_expr_ ) );
00928 }
00929 
00930 
00963 template< typename RightExprT, typename LambdaLhsExprT, typename LambdaRhsExprT, typename PolicyAdaptorT >
00964 inline
00965 xtl_wrap<
00966     xtl_opbinplus<
00967         xtl_wrap< xst_binary_adaptor< LambdaLhsExprT, LambdaRhsExprT, PolicyAdaptorT > >,
00968         xtl_wrap< RightExprT >
00969     >
00970 >
00971 operator+ (
00972            xst_binary_adaptor< LambdaLhsExprT, LambdaRhsExprT, PolicyAdaptorT > const& lhs_expr_,
00973            xtl_wrap< RightExprT > const& rhs_expr_
00974            )
00975 {
00976     typedef
00977         xtl_opbinplus<
00978             xtl_wrap< xst_binary_adaptor< LambdaLhsExprT, LambdaRhsExprT, PolicyAdaptorT > >,
00979             xtl_wrap< RightExprT >
00980         >
00981         opplus_T;
00982 
00983     return xtl_wrap< opplus_T >( opplus_T( lhs_expr_, rhs_expr_ ) );
00984 }
00985 
00986 
00988 // Intersection operators for connecting lambda and grammar expressions
00989 // via set intersection operators.
00991 
01021 template< typename LeftExprT, typename LambdaExprT, typename PolicyAdaptorT >
01022 inline
01023 xtl_wrap<
01024     xtl_opbinand<
01025         xtl_wrap< LeftExprT >,
01026         xtl_wrap< xst_unary_adaptor< LambdaExprT, PolicyAdaptorT > >
01027     >
01028 >
01029 operator& (
01030            xtl_wrap< LeftExprT > const& lhs_expr_,
01031            xst_unary_adaptor< LambdaExprT, PolicyAdaptorT > const& rhs_expr_
01032            )
01033 {
01034     typedef
01035         xtl_opbinand<
01036             xtl_wrap< LeftExprT >,
01037             xtl_wrap< xst_unary_adaptor< LambdaExprT, PolicyAdaptorT > >
01038         >
01039         opplus_T;
01040 
01041     return xtl_wrap< opplus_T >( opplus_T( lhs_expr_, rhs_expr_ ) );
01042 }
01043 
01072 template< typename RightExprT, typename LambdaExprT, typename PolicyAdaptorT >
01073 inline
01074 xtl_wrap<
01075     xtl_opbinand<
01076         xtl_wrap< xst_unary_adaptor< LambdaExprT, PolicyAdaptorT > >,
01077         xtl_wrap< RightExprT >
01078     >
01079 >
01080 operator& (
01081            xst_unary_adaptor< LambdaExprT, PolicyAdaptorT > const& lhs_expr_,
01082            xtl_wrap< RightExprT > const& rhs_expr_
01083            )
01084 {
01085     typedef
01086         xtl_opbinand<
01087             xtl_wrap< xst_unary_adaptor< LambdaExprT, PolicyAdaptorT > >,
01088             xtl_wrap< RightExprT >
01089         >
01090         opplus_T;
01091 
01092     return xtl_wrap< opplus_T >( opplus_T( lhs_expr_, rhs_expr_ ) );
01093 }
01094 
01128 template< typename LeftExprT, typename LambdaLhsExprT, typename LambdaRhsExprT, typename PolicyAdaptorT >
01129 inline
01130 xtl_wrap<
01131     xtl_opbinand<
01132         xtl_wrap< LeftExprT >,
01133         xtl_wrap< xst_binary_adaptor< LambdaLhsExprT, LambdaRhsExprT, PolicyAdaptorT > >
01134     >
01135 >
01136 operator& (
01137            xtl_wrap< LeftExprT > const& lhs_expr_,
01138            xst_binary_adaptor< LambdaLhsExprT, LambdaRhsExprT, PolicyAdaptorT > const& rhs_expr_
01139            )
01140 {
01141     typedef
01142         xtl_opbinand<
01143             xtl_wrap< LeftExprT >,
01144             xtl_wrap< xst_binary_adaptor< LambdaLhsExprT, LambdaRhsExprT, PolicyAdaptorT > >
01145         >
01146         opplus_T;
01147 
01148     return xtl_wrap< opplus_T >( opplus_T( lhs_expr_, rhs_expr_ ) );
01149 }
01150 
01151 
01185 template< typename RightExprT, typename LambdaLhsExprT, typename LambdaRhsExprT, typename PolicyAdaptorT >
01186 inline
01187 xtl_wrap<
01188     xtl_opbinand<
01189         xtl_wrap< xst_binary_adaptor< LambdaLhsExprT, LambdaRhsExprT, PolicyAdaptorT > >,
01190         xtl_wrap< RightExprT >
01191     >
01192 >
01193 operator& (
01194            xst_binary_adaptor< LambdaLhsExprT, LambdaRhsExprT, PolicyAdaptorT > const& lhs_expr_,
01195            xtl_wrap< RightExprT > const& rhs_expr_
01196            )
01197 {
01198     typedef
01199         xtl_opbinand<
01200             xtl_wrap< xst_binary_adaptor< LambdaLhsExprT, LambdaRhsExprT, PolicyAdaptorT > >,
01201             xtl_wrap< RightExprT >
01202         >
01203         opplus_T;
01204 
01205     return xtl_wrap< opplus_T >( opplus_T( lhs_expr_, rhs_expr_ ) );
01206 }
01207 
01208 
01210 // Operators for connecting lambda and grammar expressions
01211 // via set union operators.
01213 
01243 template< typename LeftExprT, typename LambdaExprT, typename PolicyAdaptorT >
01244 inline
01245 xtl_wrap<
01246     xtl_opbinpipe<
01247         xtl_wrap< LeftExprT >,
01248         xtl_wrap< xst_unary_adaptor< LambdaExprT, PolicyAdaptorT > >
01249     >
01250 >
01251 operator| (
01252            xtl_wrap< LeftExprT > const& lhs_expr_,
01253            xst_unary_adaptor< LambdaExprT, PolicyAdaptorT > const& rhs_expr_
01254            )
01255 {
01256     typedef
01257         xtl_opbinpipe<
01258             xtl_wrap< LeftExprT >,
01259             xtl_wrap< xst_unary_adaptor< LambdaExprT, PolicyAdaptorT > >
01260         >
01261         opplus_T;
01262 
01263     return xtl_wrap< opplus_T >( opplus_T( lhs_expr_, rhs_expr_ ) );
01264 }
01265 
01294 template< typename RightExprT, typename LambdaExprT, typename PolicyAdaptorT >
01295 inline
01296 xtl_wrap<
01297     xtl_opbinpipe<
01298         xtl_wrap< xst_unary_adaptor< LambdaExprT, PolicyAdaptorT > >,
01299         xtl_wrap< RightExprT >
01300     >
01301 >
01302 operator| (
01303            xst_unary_adaptor< LambdaExprT, PolicyAdaptorT > const& lhs_expr_,
01304            xtl_wrap< RightExprT > const& rhs_expr_
01305            )
01306 {
01307     typedef
01308         xtl_opbinpipe<
01309             xtl_wrap< xst_unary_adaptor< LambdaExprT, PolicyAdaptorT > >,
01310             xtl_wrap< RightExprT >
01311         >
01312         opplus_T;
01313 
01314     return xtl_wrap< opplus_T >( opplus_T( lhs_expr_, rhs_expr_ ) );
01315 }
01316 
01350 template< typename LeftExprT, typename LambdaLhsExprT, typename LambdaRhsExprT, typename PolicyAdaptorT >
01351 inline
01352 xtl_wrap<
01353     xtl_opbinpipe<
01354         xtl_wrap< LeftExprT >,
01355         xtl_wrap< xst_binary_adaptor< LambdaLhsExprT, LambdaRhsExprT, PolicyAdaptorT > >
01356     >
01357 >
01358 operator| (
01359            xtl_wrap< LeftExprT > const& lhs_expr_,
01360            xst_binary_adaptor< LambdaLhsExprT, LambdaRhsExprT, PolicyAdaptorT > const& rhs_expr_
01361            )
01362 {
01363     typedef
01364         xtl_opbinpipe<
01365             xtl_wrap< LeftExprT >,
01366             xtl_wrap< xst_binary_adaptor< LambdaLhsExprT, LambdaRhsExprT, PolicyAdaptorT > >
01367         >
01368         opplus_T;
01369 
01370     return xtl_wrap< opplus_T >( opplus_T( lhs_expr_, rhs_expr_ ) );
01371 }
01372 
01373 
01407 template< typename RightExprT, typename LambdaLhsExprT, typename LambdaRhsExprT, typename PolicyAdaptorT >
01408 inline
01409 xtl_wrap<
01410     xtl_opbinpipe<
01411         xtl_wrap< xst_binary_adaptor< LambdaLhsExprT, LambdaRhsExprT, PolicyAdaptorT > >,
01412         xtl_wrap< RightExprT >
01413     >
01414 >
01415 operator| (
01416            xst_binary_adaptor< LambdaLhsExprT, LambdaRhsExprT, PolicyAdaptorT > const& lhs_expr_,
01417            xtl_wrap< RightExprT > const& rhs_expr_
01418            )
01419 {
01420     typedef
01421         xtl_opbinpipe<
01422             xtl_wrap< xst_binary_adaptor< LambdaLhsExprT, LambdaRhsExprT, PolicyAdaptorT > >,
01423             xtl_wrap< RightExprT >
01424         >
01425         opplus_T;
01426 
01427     return xtl_wrap< opplus_T >( opplus_T( lhs_expr_, rhs_expr_ ) );
01428 }
01429 
01430 
01432 template< typename OutputIteratorT, typename LambdaT >
01433 OutputIteratorT const& operator<<(
01434                                   OutputIteratorT const& iterator_,
01435                                   xst_lambda_wrap< LambdaT > const& lambda_
01436                                   )
01437 {
01438     OutputIteratorT* p_mutable_iterator_ = const_cast< OutputIteratorT* >( &iterator_ );
01439     xst_iterator_writer< OutputIteratorT > writer( *p_mutable_iterator_ );
01440     lambda_.traverse_top_down( writer );
01441     return iterator_;
01442 }
01443 
01444 }   // namespace cttl
01445 
01446 
01447 #endif //_XST_HELPERS_H_INCLUDED_

Generated on Thu Nov 2 17:48:23 2006 for CTTL Lambda Expression by  doxygen 1.3.9.1