Claw  1.7.3
rle_decoder.tpp
1 /*
2  CLAW - a C++ Library Absolutely Wonderful
3 
4  CLAW is a free library without any particular aim but being useful to
5  anyone.
6 
7  Copyright (C) 2005-2011 Julien Jorge
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 
23  contact: julien.jorge@gamned.org
24 */
25 /**
26  * \file rle_decoder.tpp
27  * \brief Implementation of the claw::rle_decoder class and subclasses.
28  * \author Julien Jorge
29  */
30 
31 /*----------------------------------------------------------------------------*/
32 /**
33  * \brief Constructor.
34  */
35 template< typename Pattern, typename InputBuffer, typename OutputBuffer >
36 claw::rle_decoder<Pattern, InputBuffer, OutputBuffer>::rle_decoder()
37  : m_mode(stop), m_count(0)
38 {
39 
40 } // rle_decoder::rle_decoder()
41 
42 /*----------------------------------------------------------------------------*/
43 /**
44  * \brief Destructor.
45  */
46 template< typename Pattern, typename InputBuffer, typename OutputBuffer >
47 claw::rle_decoder<Pattern, InputBuffer, OutputBuffer>::~rle_decoder()
48 {
49 
50 } // rle_decoder::~rle_decoder()
51 
52 /*----------------------------------------------------------------------------*/
53 /**
54  * \brief Decode a RLE stream.
55  * \param input The RLE stream.
56  * \param output The raw stream.
57  */
58 template< typename Pattern, typename InputBuffer, typename OutputBuffer >
59 void claw::rle_decoder<Pattern, InputBuffer, OutputBuffer>::decode
60 ( input_buffer_type& input, output_buffer_type& output )
61 {
62  m_mode = stop;
63  read_mode(input, output);
64 
65  while( m_mode != stop )
66  {
67  if ( m_mode == compressed )
68  output.fill( m_count, m_pattern );
69  else
70  output.copy( m_count, input );
71 
72  read_mode(input, output);
73  }
74 } // rle_decoder::decode()