3 /// Connector class to join parsers and builders together
7 Copyright (C) 2010-2011, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program 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.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
26 Pipe::Pipe(Builder
&builder
)
35 bool Pipe::PumpEntry(Parser
&parser
, const IConverter
*ic
)
37 // if false, end of series, so pass that on to the caller
38 if( !m_builder
.FetchRecord(m_buffer
, ic
) )
41 // pass the data into the parser
42 parser
.ParseRecord(m_buffer
, ic
);
46 /// Reads all items from builder, feeding them into the parser,
47 /// until the builder's Retrieve() signals the end of the series.
48 void Pipe::PumpSeries(Parser
&parser
, const IConverter
*ic
)
50 while( PumpEntry(parser
, ic
) )
54 /// Reads all series from the builder, feeding them into the parser,
55 /// until the builder's EndOfFile() is true.
56 void Pipe::PumpFile(Parser
&parser
, const IConverter
*ic
)
58 while( !m_builder
.EndOfFile() ) {
59 PumpSeries(parser
, ic
);