summaryrefslogtreecommitdiff
path: root/cppe/src/TcpTransport/EndpointFactory.cpp
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2005-06-20 16:43:38 +0000
committerDwayne Boone <dwayne@zeroc.com>2005-06-20 16:43:38 +0000
commit8b0d67e9ad16a3b6bdfff6d9900ea009442249a0 (patch)
treed1cfce0274d58c377392d56f64d57b10d8a1c8fb /cppe/src/TcpTransport/EndpointFactory.cpp
parentImproved fix for bug #377 (diff)
downloadice-8b0d67e9ad16a3b6bdfff6d9900ea009442249a0.tar.bz2
ice-8b0d67e9ad16a3b6bdfff6d9900ea009442249a0.tar.xz
ice-8b0d67e9ad16a3b6bdfff6d9900ea009442249a0.zip
Separated TCP into separate transport library
Diffstat (limited to 'cppe/src/TcpTransport/EndpointFactory.cpp')
-rw-r--r--cppe/src/TcpTransport/EndpointFactory.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/cppe/src/TcpTransport/EndpointFactory.cpp b/cppe/src/TcpTransport/EndpointFactory.cpp
new file mode 100644
index 00000000000..d7a0a61525a
--- /dev/null
+++ b/cppe/src/TcpTransport/EndpointFactory.cpp
@@ -0,0 +1,82 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#include <Ice/EndpointFactory.h>
+#include <Ice/Endpoint.h>
+#include <Ice/LocalException.h>
+#include <Ice/BasicStream.h>
+
+using namespace std;
+using namespace Ice;
+using namespace IceInternal;
+
+void IceInternal::incRef(EndpointFactory* p) { p->__incRef(); }
+void IceInternal::decRef(EndpointFactory* p) { p->__decRef(); }
+
+IceInternal::EndpointFactory::EndpointFactory(const InstancePtr& instance)
+ : _instance(instance)
+{
+}
+
+IceInternal::EndpointFactory::~EndpointFactory()
+{
+}
+
+EndpointPtr
+IceInternal::EndpointFactory::create(const std::string& str) const
+{
+ const string delim = " \t\n\r";
+
+ string::size_type beg = str.find_first_not_of(delim);
+ if(beg == string::npos)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
+
+ string::size_type end = str.find_first_of(delim, beg);
+ if(end == string::npos)
+ {
+ end = str.length();
+ }
+
+ string protocol = str.substr(beg, end - beg);
+
+ if(protocol == "default" || protocol == "tcp")
+ {
+ return new Endpoint(_instance, str.substr(end));
+ }
+
+ EndpointParseException ex(__FILE__, __LINE__);
+}
+
+EndpointPtr
+IceInternal::EndpointFactory::read(BasicStream* s) const
+{
+ Short type;
+ s->read(type);
+
+ if(type == TcpEndpointType)
+ {
+ return new Endpoint(s);
+ }
+
+ //
+ // XXX: What should this do? Old code returned UnknownEndpoint. Maybe that needs
+ // to be added back?
+ //
+ return 0;
+}
+
+void
+IceInternal::EndpointFactory::destroy()
+{
+ _instance = 0;
+}