# pipe.cc

Go to the documentation of this file.

    00001 ///
    00002 /// \file       pipe.cc
    00003 ///             Connector class to join parsers and builders together
    00004 ///
    00005
    00006 /*
    00007     Copyright (C) 2010-2011, Net Direct Inc. (http://www.netdirect.ca/)
    00008
    00009     This program is free software; you can redistribute it and/or modify
    00010     it under the terms of the GNU General Public License as published by
    00011     the Free Software Foundation; either version 2 of the License, or
    00012     (at your option) any later version.
    00013
    00014     This program is distributed in the hope that it will be useful,
    00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00017
    00018     See the GNU General Public License in the COPYING file at the
    00019     root directory of this project for more details.
    00020 */
    00021
    00022 #include "pipe.h"
    00023
    00024 namespace Barry {
    00025
    00026 Pipe::Pipe(Builder &builder)
    00027         : m_builder(builder)
    00028 {
    00029 }
    00030
    00031 Pipe::~Pipe()
    00032 {
    00033 }
    00034
    00035 bool Pipe::PumpEntry(Parser &parser, const IConverter *ic)
    00036 {
    00037         // if false, end of series, so pass that on to the caller
    00038         if( !m_builder.FetchRecord(m_buffer, ic) )
    00039                 return false;
    00040
    00041         // pass the data into the parser
    00042         parser.ParseRecord(m_buffer, ic);
    00043         return true;
    00044 }
    00045
    00046 /// Reads all items from builder, feeding them into the parser,
    00047 /// until the builder's Retrieve() signals the end of the series.
    00048 void Pipe::PumpSeries(Parser &parser, const IConverter *ic)
    00049 {
    00050         while( PumpEntry(parser, ic) )
    00051                 ;
    00052 }
    00053
    00054 /// Reads all series from the builder, feeding them into the parser,
    00055 /// until the builder's EndOfFile() is true.
    00056 void Pipe::PumpFile(Parser &parser, const IConverter *ic)
    00057 {
    00058         while( !m_builder.EndOfFile() ) {
    00059                 PumpSeries(parser, ic);
    00060         }
    00061 }
    00062
    00063 } // namespace Barry
    00064