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

xtl_op.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 
00035 // xtl_op.h
00036 
00037 #ifndef _CTTL_XTL_OP_H_INCLUDED_
00038 #define _CTTL_XTL_OP_H_INCLUDED_
00039 
00040 #include "xtl_op_impl.h"
00041 
00042 namespace cttl {
00043 
00045 // compile time functions overloading unary operators 
00047 
00064 template< typename ExprT >
00065 inline
00066 xtl_wrap<
00067     xtl_opunarbang<
00068         xtl_wrap< ExprT >
00069     >
00070 >
00071 operator! ( xtl_wrap< ExprT > const& expr_ )
00072 {
00073     typedef
00074         xtl_opunarbang<
00075             xtl_wrap< ExprT >
00076         >
00077         opfind_T;
00078 
00079     return xtl_wrap< opfind_T >( opfind_T( expr_ ) );
00080 }
00081 
00082 
00099 template< typename ExprT >
00100 inline
00101 xtl_wrap<
00102     xtl_opunarstar<
00103         xtl_wrap< ExprT >
00104     >
00105 >
00106 operator* ( xtl_wrap< ExprT > const& expr_ )
00107 {
00108     typedef
00109         xtl_opunarstar<
00110             xtl_wrap< ExprT >
00111         >
00112         opstar_T;
00113 
00114     return xtl_wrap< opstar_T >( opstar_T( expr_ ) );
00115 }
00116 
00136 template< typename Left_exprT >
00137 inline
00138 xtl_wrap<
00139     xtl_opunarstar<
00140         xtl_wrap< Left_exprT >
00141     >
00142 >
00143 operator* ( xtl_wrap< Left_exprT > const& lhs_expr_, int upper_limit_ )
00144 {
00145     typedef
00146         xtl_opunarstar<
00147             xtl_wrap< Left_exprT >
00148         >
00149         opstar_T;
00150 
00151     return xtl_wrap< opstar_T >( opstar_T( lhs_expr_, upper_limit_ ) );
00152 }
00153 
00170 template< typename ExprT >
00171 inline
00172 xtl_wrap<
00173     xtl_opunarplus<
00174         xtl_wrap< ExprT >
00175     >
00176 >
00177 operator+ ( xtl_wrap< ExprT > const& expr_ )
00178 {
00179     typedef
00180         xtl_opunarplus<
00181             xtl_wrap< ExprT >
00182         >
00183         opplus_T;
00184 
00185     return xtl_wrap< opplus_T >( opplus_T( expr_ ) );
00186 }
00187 
00207 template< typename Left_exprT >
00208 inline
00209 xtl_wrap<
00210     xtl_opunarplus<
00211         xtl_wrap< Left_exprT >
00212     >
00213 >
00214 operator+ ( xtl_wrap< Left_exprT > const& lhs_expr_, int upper_limit_ )
00215 {
00216     typedef
00217         xtl_opunarplus<
00218             xtl_wrap< Left_exprT >
00219         >
00220         opplus_T;
00221 
00222     return xtl_wrap< opplus_T >( opplus_T( lhs_expr_, upper_limit_ ) );
00223 }
00224 
00225 
00248 template< typename Left_exprT >
00249 inline
00250 xtl_wrap<
00251     xtl_opunarplus<
00252         xtl_wrap< Left_exprT >
00253     >
00254 >
00255 operator+ ( xtl_wrap< Left_exprT > const& lhs_expr_, std::pair< int, int > limits_ )
00256 {
00257     typedef
00258         xtl_opunarplus<
00259             xtl_wrap< Left_exprT >
00260         >
00261         opplus_T;
00262 
00263     return xtl_wrap< opplus_T >( opplus_T( lhs_expr_, limits_.second, limits_.first ) );
00264 }
00265 
00282 template< typename ExprT >
00283 inline
00284 xtl_wrap<
00285     xtl_opunarminus<
00286         xtl_wrap< ExprT >
00287     >
00288 >
00289 operator- ( xtl_wrap< ExprT > const& expr_ )
00290 {
00291     typedef
00292         xtl_opunarminus<
00293             xtl_wrap< ExprT >
00294         >
00295         opminus_T;
00296 
00297     return xtl_wrap< opminus_T >( opminus_T( expr_ ) );
00298 }
00299 
00301 // compile time functions overloading binary operators 
00303 
00328 template< typename Left_exprT, typename Right_exprT >
00329 inline
00330 xtl_wrap<
00331     xtl_opbinplus<
00332         xtl_wrap< Left_exprT >,
00333         xtl_wrap< Right_exprT >
00334     >
00335 >
00336 operator+ ( xtl_wrap< Left_exprT > const& lhs_expr_, xtl_wrap< Right_exprT > const& rhs_expr_ )
00337 {
00338     typedef
00339         xtl_opbinplus<
00340             xtl_wrap< Left_exprT >,
00341             xtl_wrap< Right_exprT >
00342         >
00343         opplus_T;
00344 
00345     return xtl_wrap< opplus_T >( opplus_T( lhs_expr_, rhs_expr_ ) );
00346 }
00347 
00372 template< typename Left_exprT, typename Right_exprT >
00373 inline
00374 xtl_wrap<
00375     xtl_opbinpipe<
00376         xtl_wrap< Left_exprT >,
00377         xtl_wrap< Right_exprT >
00378     >
00379 >
00380 operator| ( xtl_wrap< Left_exprT > const& lhs_expr_, xtl_wrap< Right_exprT > const& rhs_expr_ )
00381 {
00382     typedef
00383         xtl_opbinpipe<
00384             xtl_wrap< Left_exprT >,
00385             xtl_wrap< Right_exprT >
00386         >
00387         oppipe_T;
00388 
00389     return xtl_wrap< oppipe_T >( oppipe_T( lhs_expr_, rhs_expr_ ) );
00390 }
00391 
00416 template< typename Left_exprT, typename Right_exprT >
00417 inline
00418 xtl_wrap<
00419     xtl_opbin2pipe<
00420         xtl_wrap< Left_exprT >,
00421         xtl_wrap< Right_exprT >
00422     >
00423 >
00424 operator|| ( xtl_wrap< Left_exprT > const& lhs_expr_, xtl_wrap< Right_exprT > const& rhs_expr_ )
00425 {
00426     typedef
00427         xtl_opbin2pipe<
00428             xtl_wrap< Left_exprT >,
00429             xtl_wrap< Right_exprT >
00430         >
00431         oppipe_T;
00432 
00433     return xtl_wrap< oppipe_T >( oppipe_T( lhs_expr_, rhs_expr_ ) );
00434 }
00435 
00460 template< typename Left_exprT, typename Right_exprT >
00461 inline
00462 xtl_wrap<
00463     xtl_opbinconcat<
00464         xtl_wrap< Left_exprT >,
00465         xtl_wrap< Right_exprT >
00466     >
00467 >
00468 operator^ ( xtl_wrap< Left_exprT > const& lhs_expr_, xtl_wrap< Right_exprT > const& rhs_expr_ )
00469 {
00470     typedef
00471         xtl_opbinconcat<
00472             xtl_wrap< Left_exprT >,
00473             xtl_wrap< Right_exprT >
00474         >
00475         opconcat_T;
00476 
00477     return xtl_wrap< opconcat_T >( opconcat_T( lhs_expr_, rhs_expr_ ) );
00478 }
00479 
00504 template< typename Left_exprT, typename Right_exprT >
00505 inline
00506 xtl_wrap<
00507     xtl_opbinminus<
00508         xtl_wrap< Left_exprT >,
00509         xtl_wrap< Right_exprT >
00510     >
00511 >
00512 operator- ( xtl_wrap< Left_exprT > const& lhs_expr_, xtl_wrap< Right_exprT > const& rhs_expr_ )
00513 {
00514     typedef
00515         xtl_opbinminus<
00516             xtl_wrap< Left_exprT >,
00517             xtl_wrap< Right_exprT >
00518         >
00519         opbinminus_T;
00520 
00521     return xtl_wrap< opbinminus_T >( opbinminus_T( lhs_expr_, rhs_expr_ ) );
00522 }
00523 
00548 template< typename Left_exprT, typename Right_exprT >
00549 inline
00550 xtl_wrap<
00551     xtl_opbinand<
00552         xtl_wrap< Left_exprT >,
00553         xtl_wrap< Right_exprT >
00554     >
00555 >
00556 operator& ( xtl_wrap< Left_exprT > const& lhs_expr_, xtl_wrap< Right_exprT > const& rhs_expr_ )
00557 {
00558     typedef
00559         xtl_opbinand<
00560             xtl_wrap< Left_exprT >,
00561             xtl_wrap< Right_exprT >
00562         >
00563         opbinand_T;
00564 
00565     return xtl_wrap< opbinand_T >( opbinand_T( lhs_expr_, rhs_expr_ ) );
00566 }
00567 
00568 }   // namespace cttl
00569 
00570 #endif // _CTTL_XTL_OP_H_INCLUDED_

Generated on Thu Nov 2 17:44:06 2006 for Common Text Transformation Library by  doxygen 1.3.9.1