00001 00002 // 00003 // This file is part of Common Text Transformation Library. 00004 // Copyright (C) 1997-2009 by Igor Kholodov. 00005 // 00006 // Common Text Transformation Library is free software: you can 00007 // redistribute it and/or modify it under the terms of the 00008 // GNU Lesser General Public License as published by 00009 // the Free Software Foundation, either version 3 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // Common Text Transformation Library is distributed in the hope 00013 // that it will be useful, but WITHOUT ANY WARRANTY; without even 00014 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00015 // PURPOSE. See the GNU Lesser General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU Lesser General Public 00018 // License along with Common Text Transformation Library. 00019 // If not, see <http://www.gnu.org/licenses/>. 00020 // 00021 // mailto:cttl@users.sourceforge.net 00022 // http://cttl.sourceforge.net/ 00023 // http://sourceforge.net/projects/cttl/ 00024 // 00026 00038 // xtl_sym.h 00039 00040 #ifndef _CTTL_XTL_SYM_H_INCLUDED_ 00041 #define _CTTL_XTL_SYM_H_INCLUDED_ 00042 00043 namespace cttl { 00044 00045 using namespace cttl_impl; 00046 00067 template< typename Static_predicateT > 00068 inline xtl_wrap< xtl_predicate< Static_predicateT > > 00069 rule( const Static_predicateT pred_ ) 00070 { 00071 return xtl_wrap< xtl_predicate< Static_predicateT > >( pred_ ); 00072 } 00073 00074 00099 template< typename ObjectT, typename PredicateT > 00100 inline xtl_wrap< xtl_member_predicate< ObjectT, PredicateT > > 00101 rule( ObjectT& object_ref_, PredicateT pred_ ) 00102 { 00103 return xtl_wrap< xtl_member_predicate< ObjectT, PredicateT > >( xtl_member_predicate< ObjectT, PredicateT >( object_ref_, pred_ ) ); 00104 } 00105 00118 inline xtl_wrap< xtl_char_symbol > 00119 symbol() 00120 { 00121 return xtl_wrap< xtl_char_symbol >(); 00122 } 00123 00136 inline xtl_wrap< xtl_position_bof > 00137 begin() 00138 { 00139 return xtl_wrap< xtl_position_bof >(); 00140 } 00141 00161 inline xtl_wrap< xtl_bool< false > > 00162 symbol( bool bool_ ) 00163 { 00164 // fails on empty substring 00165 return xtl_wrap< xtl_bool< false > >( bool_ ); 00166 } 00167 00187 inline xtl_wrap< xtl_bool< true > > 00188 begin( bool bool_ ) 00189 { 00190 // succeeds on empty substring 00191 return xtl_wrap< xtl_bool< true > >( bool_ ); 00192 } 00193 00209 inline xtl_wrap< xtl_char< CTTL_STD_CHAR > > 00210 symbol( CTTL_STD_CHAR char_ ) 00211 { 00212 return xtl_wrap< xtl_char< CTTL_STD_CHAR > >( char_ ); 00213 } 00214 00230 inline xtl_wrap< xtl_char< CTTL_STD_WCHAR > > 00231 symbol( CTTL_STD_WCHAR char_ ) 00232 { 00233 return xtl_wrap< xtl_char< CTTL_STD_WCHAR > >( char_ ); 00234 } 00235 00251 inline xtl_wrap< xtl_char< CTTL_STD_CHAR > > 00252 symbol( int char_ ) 00253 { 00254 // allows symbol( 0x0a ) notation for individual characters 00255 return xtl_wrap< xtl_char< CTTL_STD_CHAR > >( CTTL_STD_CHAR( char_ ) ); 00256 } 00257 00273 inline xtl_wrap< xtl_char_begin< CTTL_STD_CHAR > > 00274 begin( CTTL_STD_CHAR char_ ) 00275 { 00276 return xtl_wrap< xtl_char_begin< CTTL_STD_CHAR > >( char_ ); 00277 } 00278 00294 inline xtl_wrap< xtl_char_begin< CTTL_STD_WCHAR > > 00295 begin( CTTL_STD_WCHAR char_ ) 00296 { 00297 return xtl_wrap< xtl_char_begin< CTTL_STD_WCHAR > >( char_ ); 00298 } 00299 00315 inline xtl_wrap< xtl_char_begin< CTTL_STD_CHAR > > 00316 begin( int char_ ) 00317 { 00318 // allows begin( 0x0a ) notation for individual characters 00319 return xtl_wrap< xtl_char_begin< CTTL_STD_CHAR > >( CTTL_STD_CHAR( char_ ) ); 00320 } 00321 00337 inline xtl_wrap< xtl_char_end< CTTL_STD_CHAR > > 00338 end( CTTL_STD_CHAR char_ ) 00339 { 00340 return xtl_wrap< xtl_char_end< CTTL_STD_CHAR > >( char_ ); 00341 } 00342 00358 inline xtl_wrap< xtl_char_end< CTTL_STD_WCHAR > > 00359 end( CTTL_STD_WCHAR char_ ) 00360 { 00361 return xtl_wrap< xtl_char_end< CTTL_STD_WCHAR > >( char_ ); 00362 } 00363 00379 inline xtl_wrap< xtl_char_end< CTTL_STD_CHAR > > 00380 end( int char_ ) 00381 { 00382 // allows end( 0x0a ) notation for individual characters 00383 return xtl_wrap< xtl_char_end< CTTL_STD_CHAR > >( CTTL_STD_CHAR( char_ ) ); 00384 } 00385 00401 inline xtl_wrap< xtl_keyword< CTTL_STD_STRING > > 00402 begin( std::set< CTTL_STD_STRING > const& keywords_ ) 00403 { 00404 return xtl_wrap< xtl_keyword< CTTL_STD_STRING > >( keywords_ ); 00405 } 00406 00422 inline xtl_wrap< xtl_keyword< CTTL_STD_WSTRING > > 00423 begin( std::set< CTTL_STD_WSTRING > const& keywords_ ) 00424 { 00425 return xtl_wrap< xtl_keyword< CTTL_STD_WSTRING > >( keywords_ ); 00426 } 00427 00429 00445 inline xtl_wrap< xtl_iswhat_begin > 00446 begin( iswhat_T iswhat_ ) 00447 { 00448 return xtl_wrap< xtl_iswhat_begin >( iswhat_ ); 00449 } 00450 00451 00467 inline xtl_wrap< xtl_iswhat_end > 00468 end( iswhat_T iswhat_ ) 00469 { 00470 return xtl_wrap< xtl_iswhat_end >( iswhat_ ); 00471 } 00472 00473 00489 inline xtl_wrap< xtl_iswhat_first > 00490 first( iswhat_T iswhat_ ) 00491 { 00492 return xtl_wrap< xtl_iswhat_first >( iswhat_ ); 00493 } 00494 00495 00511 inline xtl_wrap< xtl_iswhat_entity > 00512 entity( iswhat_T iswhat_ ) 00513 { 00514 return xtl_wrap< xtl_iswhat_entity >( iswhat_ ); 00515 } 00516 00518 00519 00535 inline xtl_wrap< xtl_iswwhat_begin > 00536 begin( iswwhat_T iswwhat_ ) 00537 { 00538 return xtl_wrap< xtl_iswwhat_begin >( iswwhat_ ); 00539 } 00540 00541 00557 inline xtl_wrap< xtl_iswwhat_end > 00558 end( iswwhat_T iswwhat_ ) 00559 { 00560 return xtl_wrap< xtl_iswwhat_end >( iswwhat_ ); 00561 } 00562 00563 00579 inline xtl_wrap< xtl_iswwhat_first > 00580 first( iswwhat_T iswwhat_ ) 00581 { 00582 return xtl_wrap< xtl_iswwhat_first >( iswwhat_ ); 00583 } 00584 00585 00601 inline xtl_wrap< xtl_iswwhat_entity > 00602 entity( iswwhat_T iswwhat_ ) 00603 { 00604 return xtl_wrap< xtl_iswwhat_entity >( iswwhat_ ); 00605 } 00606 00608 00609 00625 inline xtl_wrap< xtl_text_begin< CTTL_STD_STRING > > 00626 begin( CTTL_STD_CHAR const* any_text_ ) 00627 { 00628 return xtl_wrap< xtl_text_begin< CTTL_STD_STRING > >( any_text_ ); 00629 } 00630 00631 00647 inline xtl_wrap< xtl_text_begin< CTTL_STD_WSTRING > > 00648 begin( CTTL_STD_WCHAR const* any_text_ ) 00649 { 00650 return xtl_wrap< xtl_text_begin< CTTL_STD_WSTRING > >( any_text_ ); 00651 } 00652 00653 00669 inline xtl_wrap< xtl_text_begin< CTTL_STD_STRING > > 00670 begin( CTTL_STD_STRING const& any_text_ ) 00671 { 00672 return xtl_wrap< xtl_text_begin< CTTL_STD_STRING > >( any_text_ ); 00673 } 00674 00675 00691 inline xtl_wrap< xtl_text_begin< CTTL_STD_WSTRING > > 00692 begin( CTTL_STD_WSTRING const& any_text_ ) 00693 { 00694 return xtl_wrap< xtl_text_begin< CTTL_STD_WSTRING > >( any_text_ ); 00695 } 00696 00697 00713 inline xtl_wrap< xtl_text_ref_begin< CTTL_STD_STRING > > 00714 begin( CTTL_STD_STRING const* any_text_ ) 00715 { 00716 return xtl_wrap< xtl_text_ref_begin< CTTL_STD_STRING > >( any_text_ ); 00717 } 00718 00719 00735 inline xtl_wrap< xtl_text_ref_begin< CTTL_STD_WSTRING > > 00736 begin( CTTL_STD_WSTRING const* any_text_ ) 00737 { 00738 return xtl_wrap< xtl_text_ref_begin< CTTL_STD_WSTRING > >( any_text_ ); 00739 } 00740 00742 00743 00759 inline xtl_wrap< xtl_text_end< CTTL_STD_STRING > > 00760 end( CTTL_STD_CHAR const* any_text_ ) 00761 { 00762 return xtl_wrap< xtl_text_end< CTTL_STD_STRING > >( any_text_ ); 00763 } 00764 00765 00781 inline xtl_wrap< xtl_text_end< CTTL_STD_WSTRING > > 00782 end( CTTL_STD_WCHAR const* any_text_ ) 00783 { 00784 return xtl_wrap< xtl_text_end< CTTL_STD_WSTRING > >( any_text_ ); 00785 } 00786 00787 00803 inline xtl_wrap< xtl_text_end< CTTL_STD_STRING > > 00804 end( CTTL_STD_STRING const& any_text_ ) 00805 { 00806 return xtl_wrap< xtl_text_end< CTTL_STD_STRING > >( any_text_ ); 00807 } 00808 00809 00825 inline xtl_wrap< xtl_text_end< CTTL_STD_WSTRING > > 00826 end( CTTL_STD_WSTRING const& any_text_ ) 00827 { 00828 return xtl_wrap< xtl_text_end< CTTL_STD_WSTRING > >( any_text_ ); 00829 } 00830 00831 00847 inline xtl_wrap< xtl_text_ref_end< CTTL_STD_STRING > > 00848 end( CTTL_STD_STRING const* any_text_ ) 00849 { 00850 return xtl_wrap< xtl_text_ref_end< CTTL_STD_STRING > >( any_text_ ); 00851 } 00852 00853 00869 inline xtl_wrap< xtl_text_ref_end< CTTL_STD_WSTRING > > 00870 end( CTTL_STD_WSTRING const* any_text_ ) 00871 { 00872 return xtl_wrap< xtl_text_ref_end< CTTL_STD_WSTRING > >( any_text_ ); 00873 } 00874 00876 00892 inline xtl_wrap< xtl_text_first< CTTL_STD_STRING > > 00893 first( CTTL_STD_CHAR const* any_text_ ) 00894 { 00895 return xtl_wrap< xtl_text_first< CTTL_STD_STRING > >( any_text_ ); 00896 } 00897 00898 00914 inline xtl_wrap< xtl_text_first< CTTL_STD_WSTRING > > 00915 first( CTTL_STD_WCHAR const* any_text_ ) 00916 { 00917 return xtl_wrap< xtl_text_first< CTTL_STD_WSTRING > >( any_text_ ); 00918 } 00919 00920 00936 inline xtl_wrap< xtl_text_first< CTTL_STD_STRING > > 00937 first( CTTL_STD_STRING const& any_text_ ) 00938 { 00939 return xtl_wrap< xtl_text_first< CTTL_STD_STRING > >( any_text_ ); 00940 } 00941 00942 00958 inline xtl_wrap< xtl_text_first< CTTL_STD_WSTRING > > 00959 first( CTTL_STD_WSTRING const& any_text_ ) 00960 { 00961 return xtl_wrap< xtl_text_first< CTTL_STD_WSTRING > >( any_text_ ); 00962 } 00963 00964 00980 inline xtl_wrap< xtl_text_ref_first< CTTL_STD_STRING > > 00981 first( CTTL_STD_STRING const* any_text_ ) 00982 { 00983 return xtl_wrap< xtl_text_ref_first< CTTL_STD_STRING > >( any_text_ ); 00984 } 00985 00986 01002 inline xtl_wrap< xtl_text_ref_first< CTTL_STD_WSTRING > > 01003 first( CTTL_STD_WSTRING const* any_text_ ) 01004 { 01005 return xtl_wrap< xtl_text_ref_first< CTTL_STD_WSTRING > >( any_text_ ); 01006 } 01007 01009 01010 01026 inline xtl_wrap< xtl_char< CTTL_STD_CHAR > > 01027 entity( CTTL_STD_CHAR char_ ) 01028 { 01029 return xtl_wrap< xtl_char< CTTL_STD_CHAR > >( char_ ); 01030 } 01031 01032 01048 inline xtl_wrap< xtl_char< CTTL_STD_WCHAR > > 01049 entity( CTTL_STD_WCHAR char_ ) 01050 { 01051 return xtl_wrap< xtl_char< CTTL_STD_WCHAR > >( char_ ); 01052 } 01053 01054 01070 inline xtl_wrap< xtl_char< CTTL_STD_CHAR > > 01071 entity( int char_ ) 01072 { 01073 // allows entity( 0x0a ) notation for individual characters 01074 return xtl_wrap< xtl_char< CTTL_STD_CHAR > >( CTTL_STD_CHAR( char_ ) ); 01075 } 01076 01077 01093 inline xtl_wrap< xtl_text_entity< CTTL_STD_STRING > > 01094 entity( CTTL_STD_CHAR const* any_text_ ) 01095 { 01096 return xtl_wrap< xtl_text_entity< CTTL_STD_STRING > >( any_text_ ); 01097 } 01098 01099 01115 inline xtl_wrap< xtl_text_entity< CTTL_STD_WSTRING > > 01116 entity( CTTL_STD_WCHAR const* any_text_ ) 01117 { 01118 return xtl_wrap< xtl_text_entity< CTTL_STD_WSTRING > >( any_text_ ); 01119 } 01120 01121 01137 inline xtl_wrap< xtl_text_entity< CTTL_STD_STRING > > 01138 entity( CTTL_STD_STRING const& any_text_ ) 01139 { 01140 return xtl_wrap< xtl_text_entity< CTTL_STD_STRING > >( any_text_ ); 01141 } 01142 01143 01159 inline xtl_wrap< xtl_text_entity< CTTL_STD_WSTRING > > 01160 entity( CTTL_STD_WSTRING const& any_text_ ) 01161 { 01162 return xtl_wrap< xtl_text_entity< CTTL_STD_WSTRING > >( any_text_ ); 01163 } 01164 01165 01181 inline xtl_wrap< xtl_text_ref_entity< CTTL_STD_STRING > > 01182 entity( CTTL_STD_STRING const* any_text_ ) 01183 { 01184 return xtl_wrap< xtl_text_ref_entity< CTTL_STD_STRING > >( any_text_ ); 01185 } 01186 01187 01203 inline xtl_wrap< xtl_text_ref_entity< CTTL_STD_WSTRING > > 01204 entity( CTTL_STD_WSTRING const* any_text_ ) 01205 { 01206 return xtl_wrap< xtl_text_ref_entity< CTTL_STD_WSTRING > >( any_text_ ); 01207 } 01208 01210 01211 01227 inline xtl_wrap< xtl_text_symbol< CTTL_STD_STRING > > 01228 symbol( CTTL_STD_CHAR const* any_text_ ) 01229 { 01230 return xtl_wrap< xtl_text_symbol< CTTL_STD_STRING > >( any_text_ ); 01231 } 01232 01233 01249 inline xtl_wrap< xtl_text_symbol< CTTL_STD_WSTRING > > 01250 symbol( CTTL_STD_WCHAR const* any_text_ ) 01251 { 01252 return xtl_wrap< xtl_text_symbol< CTTL_STD_WSTRING > >( any_text_ ); 01253 } 01254 01270 inline xtl_wrap< xtl_text_symbol< CTTL_STD_STRING > > 01271 symbol( CTTL_STD_STRING const& any_text_ ) 01272 { 01273 return xtl_wrap< xtl_text_symbol< CTTL_STD_STRING > >( any_text_ ); 01274 } 01275 01276 01292 inline xtl_wrap< xtl_text_symbol< CTTL_STD_WSTRING > > 01293 symbol( CTTL_STD_WSTRING const& any_text_ ) 01294 { 01295 return xtl_wrap< xtl_text_symbol< CTTL_STD_WSTRING > >( any_text_ ); 01296 } 01297 01298 01314 inline xtl_wrap< xtl_text_ref_symbol< CTTL_STD_STRING > > 01315 symbol( CTTL_STD_STRING const* any_text_ ) 01316 { 01317 return xtl_wrap< xtl_text_ref_symbol< CTTL_STD_STRING > >( any_text_ ); 01318 } 01319 01320 01336 inline xtl_wrap< xtl_text_ref_symbol< CTTL_STD_WSTRING > > 01337 symbol( CTTL_STD_WSTRING const* any_text_ ) 01338 { 01339 return xtl_wrap< xtl_text_ref_symbol< CTTL_STD_WSTRING > >( any_text_ ); 01340 } 01341 01342 01344 01345 01358 inline xtl_wrap< xtl_position_eof > 01359 end() 01360 { 01361 return xtl_wrap< xtl_position_eof >(); 01362 } 01363 01364 } // namespace cttl 01365 01366 #endif // _CTTL_XTL_SYM_H_INCLUDED_