summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkitty <kitty@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2002-07-11 23:57:59 +0000
committerkitty <kitty@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2002-07-11 23:57:59 +0000
commit478226039842cc5f1541c548efa287e344057c3c (patch)
tree49e9a602855227ffd868feb1f592a3c8b8711be8
parentd84c481f55354bc3525dfa9e7c13b4be70e19dc2 (diff)
downloadATCD-478226039842cc5f1541c548efa287e344057c3c.tar.gz
ChangeLogTag: Thu Jul 11 18:37:35 2002 Krishnakumar B <kitty@cs.wustl.edu>
-rw-r--r--ACEXML/common/HttpCharStream.cpp3
-rw-r--r--ACEXML/common/Makefile3
-rw-r--r--ACEXML/common/StreamFactory.cpp38
-rw-r--r--ACEXML/common/StreamFactory.h58
-rw-r--r--ACEXML/common/URL_Addr.cpp2
-rw-r--r--ACEXML/common/URL_Addr.h2
-rw-r--r--ACEXML/examples/SAXPrint/main.cpp34
-rw-r--r--ChangeLog26
-rw-r--r--ChangeLogs/ChangeLog-03a26
9 files changed, 168 insertions, 24 deletions
diff --git a/ACEXML/common/HttpCharStream.cpp b/ACEXML/common/HttpCharStream.cpp
index 54c898c2f76..c2969fb5260 100644
--- a/ACEXML/common/HttpCharStream.cpp
+++ b/ACEXML/common/HttpCharStream.cpp
@@ -1,6 +1,7 @@
// $Id$
#include "ace/ACE.h"
+#include "ace/ace_wchar.h"
#include "ace/Auto_Ptr.h"
#include "ACEXML/common/HttpCharStream.h"
@@ -43,7 +44,7 @@ ACEXML_HttpCharStream::open (const ACEXML_Char *url)
ACE_NEW_RETURN (this->url_addr_, ACEXML_URL_Addr, -1);
ACE_NEW_RETURN (this->stream_, ACEXML_Mem_Map_Stream, -1);
- if (this->url_addr_->string_to_addr (this->url_) == -1)
+ if (this->url_addr_->string_to_addr (ACE_TEXT_ALWAYS_CHAR(this->url_)) == -1)
ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "cannot convert URL"), -1);
ACE_NEW_RETURN (this->connector_,
diff --git a/ACEXML/common/Makefile b/ACEXML/common/Makefile
index 5566f5af4e5..af1780aa1c8 100644
--- a/ACEXML/common/Makefile
+++ b/ACEXML/common/Makefile
@@ -27,7 +27,8 @@ FILES = Attributes_Def_Builder \
XML_Codecs \
Mem_Map_Stream \
URL_Addr \
- HttpCharStream
+ HttpCharStream \
+ StreamFactory
DEFS = $(addsuffix .h,$(FILES))
LSRC = $(addsuffix .cpp,$(FILES))
diff --git a/ACEXML/common/StreamFactory.cpp b/ACEXML/common/StreamFactory.cpp
new file mode 100644
index 00000000000..600772e1861
--- /dev/null
+++ b/ACEXML/common/StreamFactory.cpp
@@ -0,0 +1,38 @@
+// $Id$
+
+#include "ACEXML/common/StreamFactory.h"
+#include "ACEXML/common/FileCharStream.h"
+#include "ACEXML/common/HttpCharStream.h"
+
+ACE_RCSID (common, StreamFactory, "$Id$")
+
+ACEXML_CharStream*
+ACEXML_StreamFactory::create_stream (const ACEXML_Char* uri)
+{
+ if (uri == 0)
+ return 0;
+
+ ACEXML_FileCharStream* fstream = 0;
+ ACEXML_HttpCharStream* hstream = 0;
+
+ if (ACE_OS::strstr (uri, "ftp://") != 0)
+ {
+ return 0;
+ }
+ else if (ACE_OS::strstr (uri, "http://") != 0)
+ {
+ ACE_NEW_RETURN (hstream, ACEXML_HttpCharStream, 0);
+ if (hstream->open (uri) != -1)
+ return hstream;
+ else
+ return 0;
+ }
+ else
+ {
+ ACE_NEW_RETURN (fstream, ACEXML_FileCharStream, 0);
+ if (fstream->open (uri) != -1)
+ return fstream;
+ else
+ return 0;
+ }
+}
diff --git a/ACEXML/common/StreamFactory.h b/ACEXML/common/StreamFactory.h
new file mode 100644
index 00000000000..fcfda00154a
--- /dev/null
+++ b/ACEXML/common/StreamFactory.h
@@ -0,0 +1,58 @@
+/**
+ * @file StreamFactory.h
+ *
+ * $Id$
+ *
+ * @author Krishnakumar B <kitty@cs.wustl.edu>
+ */
+
+#ifndef _ACEXML_STREAM_FACTORY_H
+#define _ACEXML_STREAM_FACTORY_H
+
+#include "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XML_Types.h"
+
+// Forward declarations
+
+class ACEXML_CharStream;
+
+/**
+ * @class ACEXML_StreamFactory StreamFactory.h "ACEXML/common/ACEXML_StreamFactory.h"
+ *
+ * @brief A generic factory used to create an appropriate @sa
+ * ACEXML_CharStream from a SYSTEM id. This class creates a @sa
+ * ACEXML_FileCharStream or a @sa 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.
+ */
+
+class ACEXML_Export ACEXML_StreamFactory
+{
+public:
+
+ // Destructor
+ virtual ~ACEXML_StreamFactory (void);
+
+ /**
+ * Create the appropriate stream from the @a uri passed and return the
+ * stream. The caller is responsible for deallocating the returned
+ * stream.
+ *
+ * @param uri SYSTEM id or a stream of characters (in the case of a
+ * StrCharStream).
+ */
+ virtual ACEXML_CharStream* create_stream (const ACEXML_Char* uri);
+};
+
+#include "ace/post.h"
+
+#endif /* _ACEXML_STREAM_FACTORY_H */
diff --git a/ACEXML/common/URL_Addr.cpp b/ACEXML/common/URL_Addr.cpp
index 1644be7501e..ffc8f6c4632 100644
--- a/ACEXML/common/URL_Addr.cpp
+++ b/ACEXML/common/URL_Addr.cpp
@@ -78,7 +78,7 @@ ACEXML_URL_Addr::addr_to_string (int ipaddr_format) const
}
int
-ACEXML_URL_Addr::string_to_addr (const ACEXML_Char *s)
+ACEXML_URL_Addr::string_to_addr (const char *s)
{
if (s == 0)
return -1;
diff --git a/ACEXML/common/URL_Addr.h b/ACEXML/common/URL_Addr.h
index 7e9f01aaa5c..bf7644103b6 100644
--- a/ACEXML/common/URL_Addr.h
+++ b/ACEXML/common/URL_Addr.h
@@ -53,7 +53,7 @@ public:
* <address> it is assumed to be an ip-number or ip-address number, with
* the port number <ACE_DEFAULT_HTTP_PORT>.
*/
- virtual int string_to_addr (const ACEXML_Char *address);
+ virtual int string_to_addr (const char *address);
/**
* Transform the current <ACE_INET_Addr> address into string format. If
diff --git a/ACEXML/examples/SAXPrint/main.cpp b/ACEXML/examples/SAXPrint/main.cpp
index a226ab198f7..a16dc027d67 100644
--- a/ACEXML/examples/SAXPrint/main.cpp
+++ b/ACEXML/examples/SAXPrint/main.cpp
@@ -12,6 +12,16 @@
static const ACEXML_Char *test_string =
ACE_TEXT ("<?xml version='1.0'?> <ACE_Svc_Conf> <static id=\"ACE_Service_Manager\" params='-d -p 4911'/> <dynamic id=\"Test_Task\" type=\"service_object\"> &#65; &amp; <initializer path=\"CCM_App\" init='_make_Test_Task' params='-p 3000'/> </dynamic> </ACE_Svc_Conf>");
+static void
+usage ()
+{
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Usage: main [-sl] [-f <filename> | -u <url>]\n")
+ ACE_TEXT (" -s: Use SAXPrint_Handler (Default is Print_Handler\n")
+ ACE_TEXT (" -l: Parse the internal strings (test the StrCharStream class\n")
+ ACE_TEXT (" -f: Specify the filename when -l is not specified\n")
+ ACE_TEXT (" -u: URL specifying the path to the file\n")));
+}
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
@@ -41,27 +51,15 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[])
url = get_opt.opt_arg();
break;
default:
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("Usage: %s [-sl] [-f <filename> | -u <url>]\n%s"),
- argv[0],
- ACE_TEXT (" -s: Use SAXPrint_Handler (Default is Print_Handler\n")
- ACE_TEXT (" -l: Parse the internal strings (test the StrCharStream class\n")
- ACE_TEXT (" -f: Specify the filename when -l is not specified\n")
- ACE_TEXT (" -u: URL specifying the path to the file\n")),
- -1);
+ usage();
+ return -1;
}
}
- if (str == 0 && filename == 0 && url == 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("Usage: %s [-sl] [-f <filename> | -u <url>]\n%s"),
- argv[0],
- ACE_TEXT (" -s: Use SAXPrint_Handler (Default is Print_Handler\n")
- ACE_TEXT (" -l: Parse the internal strings (test the StrCharStream class\n")
- ACE_TEXT (" -f: Specify the filename when -l is not specified\n")
- ACE_TEXT (" -u: URL specifying the path to the file\n")),
- -1);
-
+ if (str == 0 && filename == 0 && url == 0) {
+ usage();
+ return -1;
+ }
ACEXML_DefaultHandler *handler = 0;
{
diff --git a/ChangeLog b/ChangeLog
index 184952b1ca8..ac16e32e690 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+Thu Jul 11 18:37:35 2002 Krishnakumar B <kitty@cs.wustl.edu>
+
+ * ACEXML/common/URL_Addr.cpp (string_to_addr):
+ * ACEXML/common/URL_Addr.h:
+
+ Change the argument to match the base class INET_Addr so that
+ warnings under Borland BCB is eliminated.
+
+ * ACEXML/common/HttpCharStream.cpp:
+
+ Use ACE_TEXT_ALWAYS_CHAR to convert an Unicode URL to char*
+ before converting it to an address.
+
+ * ACEXML/common/Makefile:
+ * ACEXML/common/StreamFactory.h:
+ * ACEXML/common/StreamFactory.cpp:
+
+ New class to create appropriate streams based on the URI. This
+ is needed for handling the parameter entities.
+
+ * ACEXML/examples/SAXPrint/main.cpp:
+
+ Move common error message to a new usage function.
+
Thu Jul 11 16:28:24 2002 Steve Huston <shuston@riverace.com>
* tests/Proactor_Scatter_Gather_Test.cpp: Changed Writer to derive
@@ -94,7 +118,7 @@ Thu Jul 11 15:03:47 2002 Steve Huston <shuston@riverace.com>
* ace/WIN32_Proactor.cpp (close, handle_events): completion_key
needs to be a different on Win64 than on Win32.
-
+
Thu Jul 11 08:34:22 2002 Chad Elliott <elliott_c@ociweb.com>
* bin/MakeProjectCreator/USAGE:
diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a
index 184952b1ca8..ac16e32e690 100644
--- a/ChangeLogs/ChangeLog-03a
+++ b/ChangeLogs/ChangeLog-03a
@@ -1,3 +1,27 @@
+Thu Jul 11 18:37:35 2002 Krishnakumar B <kitty@cs.wustl.edu>
+
+ * ACEXML/common/URL_Addr.cpp (string_to_addr):
+ * ACEXML/common/URL_Addr.h:
+
+ Change the argument to match the base class INET_Addr so that
+ warnings under Borland BCB is eliminated.
+
+ * ACEXML/common/HttpCharStream.cpp:
+
+ Use ACE_TEXT_ALWAYS_CHAR to convert an Unicode URL to char*
+ before converting it to an address.
+
+ * ACEXML/common/Makefile:
+ * ACEXML/common/StreamFactory.h:
+ * ACEXML/common/StreamFactory.cpp:
+
+ New class to create appropriate streams based on the URI. This
+ is needed for handling the parameter entities.
+
+ * ACEXML/examples/SAXPrint/main.cpp:
+
+ Move common error message to a new usage function.
+
Thu Jul 11 16:28:24 2002 Steve Huston <shuston@riverace.com>
* tests/Proactor_Scatter_Gather_Test.cpp: Changed Writer to derive
@@ -94,7 +118,7 @@ Thu Jul 11 15:03:47 2002 Steve Huston <shuston@riverace.com>
* ace/WIN32_Proactor.cpp (close, handle_events): completion_key
needs to be a different on Win64 than on Win32.
-
+
Thu Jul 11 08:34:22 2002 Chad Elliott <elliott_c@ociweb.com>
* bin/MakeProjectCreator/USAGE: