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

xst_literal_translator.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 
00034 // xst_literal_translator.h
00035 
00036 #ifndef _XST_LITERAL_TRANSLATOR_H_INCLUDED_
00037 #define _XST_LITERAL_TRANSLATOR_H_INCLUDED_
00038 
00039 #ifdef NDEBUG
00040 
00041 #define CTTL_LAMBDA_ASSERT( xexpr ) +const_scalar( 1 )
00042 #define CTTL_LAMBDA_TRACE( xexpr ) +const_scalar( 1 )
00043 #else
00044 
00045 #define CTTL_LAMBDA_ASSERT( xexpr )                 \
00046     (                                                   \
00047         ( xexpr )                                       \
00048         ||                                              \
00049         --(                                             \
00050             scalar( 0 )                                 \
00051             ^                                           \
00052             atoi                                        \
00053             ^                                           \
00054             "Assertion failed: " #xexpr                 \
00055             " in "                                      \
00056             __FILE__                                    \
00057             ":"                                         \
00058             CTTL_QUOTED_EXPRESSION( __LINE__ )          \
00059         )                                               \
00060     )
00061 
00063 #define CTTL_LAMBDA_TRACE( xmessage ) ( ++( scalar( 0 )^atoi^( xmessage ) ) )
00064 
00065 #endif // NDEBUG
00066 
00067 namespace cttl_impl {
00068 
00081 template< typename CharT >
00082 class xst_literal_translator
00083 {
00084 private:
00086     CharT const* m_pchar;
00087 
00088 public:
00090     xst_literal_translator( CharT const* pchar_ )
00091         :
00092     m_pchar( pchar_ )
00093     {
00094     }
00095 
00097     xst_literal_translator( xst_literal_translator< CharT > const& other_ )
00098         :
00099     m_pchar( other_.m_pchar )
00100     {
00101     }
00102 
00107     CharT const* operator() ( bool CTTL_LAMBDA_ASSERT_ )
00108     {
00109         trace_deposit();
00110         assert( CTTL_LAMBDA_ASSERT_ );
00111         return m_pchar;
00112     }
00113 
00114 private:
00116     void trace_deposit()
00117     {
00118         CTTL_TRACE_DEPOSIT_TEXT( '\"' );
00119         CTTL_TRACE_DEPOSIT_MONOSPACE_TEXT( m_pchar );
00120         CTTL_TRACE_DEPOSIT_TEXT( "\" " );
00121     }
00122 
00123 }; // class xst_literal_translator
00124 
00125 }   // namespace cttl_impl
00126 
00127 
00128 #endif //_XST_LITERAL_TRANSLATOR_H_INCLUDED_

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