diff options
| author | Ted Ross <tross@apache.org> | 2010-05-28 18:09:10 +0000 |
|---|---|---|
| committer | Ted Ross <tross@apache.org> | 2010-05-28 18:09:10 +0000 |
| commit | 947b1491d7a39c87c4560126a6e50646aa2a2b24 (patch) | |
| tree | 19a5c7ac347d807125f8352ef5f2d41810d79281 /cpp/bindings/qpid/dotnet/src/Address.cpp | |
| parent | 8d317104053b8258380c47af8d792517c4da10b7 (diff) | |
| download | qpid-python-947b1491d7a39c87c4560126a6e50646aa2a2b24.tar.gz | |
QPID-2628 - Patch from Chuck Rolke
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@949245 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/bindings/qpid/dotnet/src/Address.cpp')
| -rw-r--r-- | cpp/bindings/qpid/dotnet/src/Address.cpp | 186 |
1 files changed, 186 insertions, 0 deletions
diff --git a/cpp/bindings/qpid/dotnet/src/Address.cpp b/cpp/bindings/qpid/dotnet/src/Address.cpp new file mode 100644 index 0000000000..8b48a2037f --- /dev/null +++ b/cpp/bindings/qpid/dotnet/src/Address.cpp @@ -0,0 +1,186 @@ +/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+#include <windows.h>
+#include <msclr\lock.h>
+#include <oletx2xa.h>
+#include <string>
+#include <limits>
+
+#include "qpid/messaging/Address.h"
+
+#include "Address.h"
+#include "QpidMarshal.h"
+#include "QpidTypeCheck.h"
+#include "TypeTranslator.h"
+
+namespace org {
+namespace apache {
+namespace qpid {
+namespace messaging {
+
+ /// <summary>
+ /// Address is a managed wrapper for a qpid::messaging::Address
+ /// </summary>
+
+ // Create empty
+ Address::Address() :
+ addressp(new ::qpid::messaging::Address(QpidMarshal::ToNative("")))
+ {
+ }
+
+ // Create string address
+ Address::Address(System::String ^ address) :
+ addressp(new ::qpid::messaging::Address(QpidMarshal::ToNative(address)))
+ {
+ }
+
+ // Create with options
+ Address::Address(System::String ^ name,
+ System::String ^ subject,
+ System::Collections::Generic::Dictionary<
+ System::String ^, System::Object ^> ^ options) :
+ addressp(new ::qpid::messaging::Address())
+ {
+ setName(name);
+ setSubject(subject);
+ setOptions(options);
+ setType("");
+ }
+
+
+ Address::Address(System::String ^ name,
+ System::String ^ subject,
+ System::Collections::Generic::Dictionary<
+ System::String ^, System::Object ^> ^ options,
+ System::String ^ type) :
+ addressp(new ::qpid::messaging::Address())
+ {
+ setName(name);
+ setSubject(subject);
+ setOptions(options);
+ setType(type);
+ }
+
+
+ // Create from received address
+ Address::Address(::qpid::messaging::Address * addrp) :
+ addressp(addrp)
+ {
+ }
+
+ // Destructor
+ Address::~Address()
+ {
+ Cleanup();
+ }
+
+
+ // Finalizer
+ Address::!Address()
+ {
+ Cleanup();
+ }
+
+
+ // Destroys kept object
+ // TODO: add lock
+ void Address::Cleanup()
+ {
+ if (NULL != addressp)
+ {
+ delete addressp;
+ addressp = NULL;
+ }
+ }
+
+
+ //
+ // name
+ //
+ System::String ^ Address::getName()
+ {
+ return gcnew System::String(addressp->getName().c_str());
+ }
+
+ void Address::setName(System::String ^ name)
+ {
+ addressp->::qpid::messaging::Address::setName(QpidMarshal::ToNative(name));
+ }
+
+ //
+ // subject
+ //
+ System::String ^ Address::getSubject()
+ {
+ return gcnew System::String(addressp->getSubject().c_str());
+ }
+
+ void Address::setSubject(System::String ^ subject)
+ {
+ addressp->setName(QpidMarshal::ToNative(subject));
+ }
+
+ //
+ // options
+ //
+ System::Collections::Generic::Dictionary<
+ System::String ^, System::Object ^> ^ Address::getOptions()
+ {
+ ::qpid::types::Variant::Map map;
+ System::Collections::Generic::Dictionary<
+ System::String ^, System::Object ^> ^ newMap =
+ gcnew System::Collections::Generic::Dictionary<
+ System::String ^, System::Object ^>;
+ map = addressp->getOptions();
+ TypeTranslator::NativeToManaged(newMap, map);
+ return newMap;
+ }
+
+
+ void Address::setOptions(System::Collections::Generic::Dictionary<
+ System::String ^, System::Object ^> ^ options)
+ {
+ ::qpid::types::Variant::Map map;
+ TypeTranslator::ManagedToNative(map, options);
+ addressp->setOptions(map);
+ }
+
+ //
+ // type
+ //
+ System::String ^ Address::getType()
+ {
+ return gcnew System::String(addressp->getType().c_str());
+ }
+
+
+ void Address::setType(System::String ^ type)
+ {
+ addressp->setName(QpidMarshal::ToNative(type));
+ }
+
+ //
+ // str
+ //
+ System::String ^ Address::str()
+ {
+ return gcnew System::String(addressp->str().c_str());
+ }
+}}}}
|
