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

xst_sequence_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 
00033 // xst_sequence_translator.h
00034 
00035 #ifndef _XST_SEQUENCE_TRANSLATOR_H_INCLUDED_
00036 #define _XST_SEQUENCE_TRANSLATOR_H_INCLUDED_
00037 
00038 namespace cttl_impl {
00039 
00050 template< typename SequenceT >
00051 class xst_sequence_translator
00052 {
00053 public:
00055     typedef typename SequenceT::value_type value_T;
00056 
00057 private:
00059     SequenceT& m_sequence;
00060 
00061 public:
00063     xst_sequence_translator( SequenceT& vector_ )
00064         :
00065     m_sequence( vector_ )
00066     {
00067     }
00068 
00070     xst_sequence_translator( xst_sequence_translator< SequenceT > const& other_ )
00071         :
00072     m_sequence( other_.m_sequence )
00073     {
00074     }
00075 
00077     void operator=( xst_sequence_translator< SequenceT > const& ) const
00078     {
00079     }
00080 
00090     template< typename InputValueT >
00091     int operator() ( InputValueT const& value_ )
00092     {
00093         int id = m_sequence.size();
00094         m_sequence.push_back( value_T( value_ ) );
00095         trace_deposit();
00096         return id;
00097     }
00098 
00099 private:
00101     void trace_deposit()
00102     {
00103         CTTL_TRACE_DEPOSIT_TEXT( "-> seq[" );
00104         CTTL_TRACE_DEPOSIT_TEXT( m_sequence.size() - 1 );
00105         CTTL_TRACE_DEPOSIT_TEXT( "]=\"" );
00106         CTTL_TRACE_DEPOSIT_TEXT( m_sequence.back() );
00107         CTTL_TRACE_DEPOSIT_TEXT( "\" " );
00108     }
00109 
00110 }; // class xst_sequence_translator
00111 
00112 
00113 }   // namespace cttl_impl
00114 
00115 
00116 #endif //_XST_SEQUENCE_TRANSLATOR_H_INCLUDED_

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