Public Member Functions

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.

{
  // No op
}


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.

{
  if (uri == 0)
    return 0;
  ACEXML_FileCharStream* fstream = 0;
  ACEXML_HttpCharStream* hstream = 0;

  if (ACE_OS::strstr (uri, ACE_TEXT("ftp://")) != 0)
    {
      return 0;
    }
  else if (ACE_OS::strstr (uri, ACE_TEXT ("http://")) != 0)
    {
      ACE_NEW_RETURN (hstream, ACEXML_HttpCharStream, 0);
      if (hstream->open (uri) != -1)
        return hstream;
    }
  else
    {
      if (ACE_OS::strstr (uri, ACE_TEXT ("file://")) != 0)
        uri += 7; // Skip over file://
      ACE_NEW_RETURN (fstream, ACEXML_FileCharStream, 0);
      if (fstream->open (uri) != -1)
        return fstream;
#ifdef USE_ZZIP
      else
        {
          ACEXML_ZipCharStream* zstream = 0;
          ACE_NEW_RETURN (zstream, ACEXML_ZipCharStream, 0);
          if (zstream->open (uri) != -1)
            return zstream;
        }
#endif /* USE_ZZIP */
    }
  return 0;
}


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines