StreamFactory.cpp

Go to the documentation of this file.
00001 // StreamFactory.cpp,v 1.5 2004/10/26 18:59:25 elliott_c Exp
00002 
00003 #include "ace/OS_NS_string.h"
00004 
00005 #include "ACEXML/common/StreamFactory.h"
00006 #include "ACEXML/common/FileCharStream.h"
00007 #include "ACEXML/common/HttpCharStream.h"
00008 
00009 #ifdef USE_ZZIP
00010 #include "ACEXML/common/ZipCharStream.h"
00011 #endif /* USE_ZZIP */
00012 
00013 ACE_RCSID (common, StreamFactory, "StreamFactory.cpp,v 1.5 2004/10/26 18:59:25 elliott_c Exp")
00014 
00015 ACEXML_CharStream*
00016 ACEXML_StreamFactory::create_stream (const ACEXML_Char* uri)
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 }
00052 
00053 ACEXML_StreamFactory::~ACEXML_StreamFactory ()
00054 {
00055   // No op
00056 }

Generated on Thu Nov 9 11:45:39 2006 for ACEXML by doxygen 1.3.6