ACEXML_StreamFactory Class Reference

A generic factory used to create an appropriate. More...

#include <ACEXML/common/ACEXML_StreamFactory.h>

List of all members.

Public Member Functions

virtual ~ACEXML_StreamFactory (void)
virtual ACEXML_CharStreamcreate_stream (const ACEXML_Char *uri)


Detailed Description

A generic factory used to create an appropriate.

See also:
ACEXML_CharStream from a SYSTEM id. This class creates a

ACEXML_FileCharStream or a

ACEXML_HttpCharStream depending on the URI supplied.

Todo:
Write a stream abstraction for handling ftp:// type URIs and add a function to create and return such streams. That is the only chunk missing in the armour.

Definition at line 38 of file StreamFactory.h.


Constructor & Destructor Documentation

ACEXML_StreamFactory::~ACEXML_StreamFactory void   )  [virtual]
 

Definition at line 53 of file StreamFactory.cpp.

00054 {
00055   // No op
00056 }


Member Function Documentation

ACEXML_CharStream * ACEXML_StreamFactory::create_stream const ACEXML_Char uri  )  [virtual]
 

Create the appropriate stream from the uri passed and return the stream. The caller is responsible for deallocating the returned stream.

Parameters:
uri SYSTEM id or a stream of characters (in the case of a StrCharStream).

Definition at line 16 of file StreamFactory.cpp.

References ACE_NEW_RETURN, ACE_TEXT, ACEXML_Char, ACEXML_FileCharStream::open(), ACEXML_HttpCharStream::open(), and ACE_OS::strstr().

Referenced by ACEXML_InputSource::ACEXML_InputSource(), ACEXML_Parser::parse_entity_reference(), ACEXML_Parser::parse_external_dtd(), and ACEXML_Parser::parse_PE_reference().

00017 {
00018   if (uri == 0)
00019     return 0;
00020   ACEXML_FileCharStream* fstream = 0;
00021   ACEXML_HttpCharStream* hstream = 0;
00022 
00023   if (ACE_OS::strstr (uri, ACE_TEXT("ftp://")) != 0)
00024     {
00025       return 0;
00026     }
00027   else if (ACE_OS::strstr (uri, ACE_TEXT ("http://")) != 0)
00028     {
00029       ACE_NEW_RETURN (hstream, ACEXML_HttpCharStream, 0);
00030       if (hstream->open (uri) != -1)
00031         return hstream;
00032     }
00033   else
00034     {
00035       if (ACE_OS::strstr (uri, ACE_TEXT ("file://")) != 0)
00036         uri += 7; // Skip over file://
00037       ACE_NEW_RETURN (fstream, ACEXML_FileCharStream, 0);
00038       if (fstream->open (uri) != -1)
00039         return fstream;
00040 #ifdef USE_ZZIP
00041       else
00042         {
00043           ACEXML_ZipCharStream* zstream = 0;
00044           ACE_NEW_RETURN (zstream, ACEXML_ZipCharStream, 0);
00045           if (zstream->open (uri) != -1)
00046             return zstream;
00047         }
00048 #endif /* USE_ZZIP */
00049     }
00050   return 0;
00051 }


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:48:13 2006 for ACEXML by doxygen 1.3.6