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 00036 // xst_traced_action_base.h 00037 00038 #ifndef _XST_TRACED_ACTION_BASE_H_INCLUDED_ 00039 #define _XST_TRACED_ACTION_BASE_H_INCLUDED_ 00040 00041 namespace cttl_impl { 00042 00047 class xst_traced_action_base { 00048 00049 private: 00051 int m_line; 00052 00054 char const* m_action_name; 00055 00056 protected: 00058 xst_traced_action_base( int line_, char const* action_name_ ) 00059 : 00060 m_line( line_ ), 00061 m_action_name( action_name_ ) 00062 { 00063 } 00064 00066 void trace_prolog() const 00067 { 00068 CTTL_UNILOG_FLUSH; 00069 CTTL_TRACE_DEPOSIT_JUSTIFY(); 00070 CTTL_TRACE_DEPOSIT_TEXT( m_line ); 00071 CTTL_TRACE_DEPOSIT_TEXT( "=>" ); 00072 CTTL_TRACE_DEPOSIT_TEXT( m_action_name ); 00073 CTTL_UNILOG_FLUSH; 00074 xtl_trace_grammar::depth( +1 ); 00075 CTTL_TRACE_DEPOSIT_JUSTIFY(); 00076 } 00077 00079 template< typename ArgumentT > 00080 void trace_prolog( ArgumentT const& arg_ ) const 00081 { 00082 CTTL_UNILOG_FLUSH; 00083 CTTL_TRACE_DEPOSIT_JUSTIFY(); 00084 CTTL_TRACE_DEPOSIT_TEXT( m_line ); 00085 CTTL_TRACE_DEPOSIT_TEXT( "=>" ); 00086 CTTL_TRACE_DEPOSIT_TEXT( m_action_name ); 00087 CTTL_TRACE_DEPOSIT_TEXT( '\'' ); 00088 CTTL_TRACE_DEPOSIT_TEXT( xst_scalar_traits< ArgumentT >::identity( arg_ ) ); 00089 CTTL_TRACE_DEPOSIT_TEXT( '\'' ); 00090 CTTL_UNILOG_FLUSH; 00091 xtl_trace_grammar::depth( +1 ); 00092 CTTL_TRACE_DEPOSIT_JUSTIFY(); 00093 } 00094 00096 template< typename ResultT > 00097 void trace_epilog( ResultT const& result_ ) const 00098 { 00099 xtl_trace_grammar::depth( -1 ); 00100 CTTL_UNILOG_FLUSH; 00101 CTTL_TRACE_DEPOSIT_JUSTIFY(); 00102 CTTL_TRACE_DEPOSIT_TEXT( m_line ); 00103 CTTL_TRACE_DEPOSIT_TEXT( "<=" ); 00104 CTTL_TRACE_DEPOSIT_TEXT( m_action_name ); 00105 CTTL_TRACE_DEPOSIT_TEXT( ':' ); 00106 CTTL_TRACE_DEPOSIT_TEXT( xst_non_scalar_traits< ResultT >::identity( result_ ) ); 00107 CTTL_UNILOG_FLUSH; 00108 CTTL_TRACE_DEPOSIT_JUSTIFY(); 00109 } 00110 00111 }; // class xst_traced_action_base 00112 00113 00114 } // namespace cttl_impl 00115 00116 00117 #endif //_XST_TRACED_ACTION_BASE_H_INCLUDED_