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_sequence_translator.h 00037 00038 #ifndef _XST_SEQUENCE_TRANSLATOR_H_INCLUDED_ 00039 #define _XST_SEQUENCE_TRANSLATOR_H_INCLUDED_ 00040 00041 namespace cttl_impl { 00042 00053 template< typename SequenceT > 00054 class xst_sequence_translator 00055 { 00056 public: 00058 typedef typename SequenceT::value_type value_T; 00059 typedef typename SequenceT::size_type size_T; 00060 00061 private: 00063 SequenceT& m_sequence; 00064 00065 public: 00067 xst_sequence_translator( SequenceT& vector_ ) 00068 : 00069 m_sequence( vector_ ) 00070 { 00071 } 00072 00074 xst_sequence_translator( xst_sequence_translator< SequenceT > const& other_ ) 00075 : 00076 m_sequence( other_.m_sequence ) 00077 { 00078 } 00079 00080 private: 00082 xst_sequence_translator< SequenceT >& operator=( xst_sequence_translator< SequenceT > const& ); 00083 00084 public: 00094 template< typename InputValueT > 00095 size_T operator() ( InputValueT const& value_ ) 00096 { 00097 size_T id = m_sequence.size(); 00098 m_sequence.push_back( value_T( value_ ) ); 00099 trace_deposit(); 00100 return id; 00101 } 00102 00103 private: 00105 void trace_deposit() 00106 { 00107 CTTL_TRACE_DEPOSIT_TEXT( "-> seq[" ); 00108 CTTL_TRACE_DEPOSIT_TEXT( m_sequence.size() - 1 ); 00109 CTTL_TRACE_DEPOSIT_TEXT( "]=\"" ); 00110 CTTL_TRACE_DEPOSIT_TEXT( m_sequence.back() ); 00111 CTTL_TRACE_DEPOSIT_TEXT( "\" " ); 00112 } 00113 00114 }; // class xst_sequence_translator 00115 00116 00117 } // namespace cttl_impl 00118 00119 00120 #endif //_XST_SEQUENCE_TRANSLATOR_H_INCLUDED_