Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

saxstreamer.cpp

Go to the documentation of this file.
00001 //============================================================================= 
00002 //
00003 // XDFLengine library
00004 //
00005 //-----------------------------------------------------------------------------
00006 //  SaxStreamer.CPP
00007 //-----------------------------------------------------------------------------
00013 //_____________________________________________________________________________
00014 //
00015 //  Copyright (C) 2003 Guillaume Baurand. All Rights Reserved.
00016 //
00017 //  This file is part of the XDFLengine project.
00018 //
00019 //  The XDFLengine is free software; you can redistribute it and/or modify
00020 //  it under the terms of the GNU General Public License as published by
00021 //  the Free Software Foundation; either version 2 of the License, or
00022 //  (at your option) any later version.
00023 //
00024 //  This program is distributed in the hope that it will be useful,
00025 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00026 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00027 //  GNU General Public License for more details.
00028 //
00029 //  You should have received a copy of the GNU General Public License
00030 //  along with this program; if not, write to the Free Software
00031 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
00032 //  USA.
00033 //
00034 //  For more information, 
00035 //      contact  : guillaume@baurand.net 
00036 //      or visit : http://xdflengine.sourceforge.net
00037 //
00038 //============================================================================= 
00039 
00040 #   include "flow/consumers/streamsax2parser.hpp"
00041 #   include "processor/xmlflowcontext.hpp"
00042 #   include "saxstreamer.hpp"
00043 
00044 
00045 BEGIN_XDFLENGINE_NS
00046 
00047 //=============================================================================
00048 //  CLASS SaxStreamer
00049 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00050 
00051 // CONSTRUCTOR & DESTRUCTOR
00052 
00053     //_____________________________________________________________________
00054     //  SaxStreamer
00055     //---------------------------------------------------------------------
00056     SaxStreamer::SaxStreamer( const XMLStreamerFactory* p_pParent, StreamerParams* p_pParameters, XMLFlowContext* p_pContext, XMLStreamConsumer* p_pOutput, ContentHandler* p_pHandler, bool p_fCopyStreamToOutput)
00057     :XMLStreamer( p_pParent, p_pParameters, p_pContext, p_pOutput)
00058     {
00059         m_pHandler = p_pHandler;
00060         m_fCopyStreamToOutput=p_fCopyStreamToOutput;
00061         m_fDataPresent = false;
00062 
00063         DEBUG_CREATE(SaxStreamer)
00064     }
00065     
00066     //_____________________________________________________________________
00067     //  ~SaxStreamer
00068     //---------------------------------------------------------------------     
00069     SaxStreamer::~SaxStreamer()
00070     {
00071         DEBUG_DEL(SaxStreamer)
00072         delete m_pStreamParser;
00073         delete m_pHandler;
00074         delete m_pErrorReporter;
00075     }
00076     
00077 // STREAM   
00078 
00079     //_____________________________________________________________________
00080     //  INITSTREAM
00081     //---------------------------------------------------------------------
00082     bool SaxStreamer::initStream()
00083     {
00084         DEBUG_IN(SaxStreamer::initStream)
00085         
00086         m_pErrorReporter = new XDFLSaxErrorReporter("SaxStreamer");
00087         m_pStreamParser = new StreamSAX2Parser( m_pHandler, m_pErrorReporter);
00088 
00089         DEBUG_OUT(SaxStreamer::initStream)
00090         return true;
00091     }
00092 
00093     //_____________________________________________________________________
00094     //  WRITEDATA
00095     //---------------------------------------------------------------------
00096     void SaxStreamer::writeData( const char*    p_pszData, unsigned int p_uiDataLen)
00097     {
00098         DEBUG_IN(SaxStreamer::writeData)
00099 
00100 
00101         m_fDataPresent = true;
00102         m_pStreamParser -> writeData( p_pszData, p_uiDataLen);
00103         if(m_fCopyStreamToOutput) m_pOutput->writeData( p_pszData, p_uiDataLen);
00104 
00105         DEBUG_OUT(SaxStreamer::writeData)
00106     }
00107 
00108     //_____________________________________________________________________
00109     //  COMMITSTREAM
00110     //---------------------------------------------------------------------
00111     bool SaxStreamer::commitStream(bool p_fFinal)
00112     {
00113         bool m_fOK;
00114 
00115         DEBUG_IN(SaxStreamer::commitStream)
00116 
00117         if(p_fFinal)
00118         {
00119             //logout << "*";
00120         }
00121 
00122         if(m_fDataPresent) m_fOK = m_pStreamParser -> commitStream( p_fFinal);
00123         else 
00124         {
00125             m_pHandler->startDocument();
00126             m_pHandler->endDocument();
00127         }
00128 
00129         if(m_fCopyStreamToOutput) m_fOK = m_fOK && m_pOutput->commitStream( false);
00130 
00131 
00132         DEBUG_OUT(SaxStreamer::commitStream)
00133         return m_fOK;
00134 
00135         
00136     }
00137 
00138 
00139 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00140 //=============================================================================
00141 
00142 
00143 END_XDFLENGINE_NS

Generated on Sat Oct 4 13:20:01 2003 for XDFLengine by doxygen1.3-rc2