diff options
Diffstat (limited to 'cpp/include/Ice')
-rw-r--r-- | cpp/include/Ice/OutgoingAsync.h | 6 | ||||
-rw-r--r-- | cpp/include/Ice/SHA1.h | 47 | ||||
-rw-r--r-- | cpp/include/Ice/UniquePtr.h | 100 |
3 files changed, 150 insertions, 3 deletions
diff --git a/cpp/include/Ice/OutgoingAsync.h b/cpp/include/Ice/OutgoingAsync.h index cb83850a048..f401975a569 100644 --- a/cpp/include/Ice/OutgoingAsync.h +++ b/cpp/include/Ice/OutgoingAsync.h @@ -22,7 +22,7 @@ #include <Ice/InputStream.h> #include <Ice/ObserverHelper.h> #include <Ice/LocalException.h> -#include <IceUtil/UniquePtr.h> +#include <Ice/UniquePtr.h> #ifndef ICE_CPP11_MAPPING # include <Ice/AsyncResult.h> @@ -171,8 +171,8 @@ protected: Ice::LocalObjectPtr _cookie; #endif - IceUtil::UniquePtr<Ice::Exception> _ex; - IceUtil::UniquePtr<Ice::LocalException> _cancellationException; + IceInternal::UniquePtr<Ice::Exception> _ex; + IceInternal::UniquePtr<Ice::LocalException> _cancellationException; InvocationObserver _observer; ObserverHelperT<Ice::Instrumentation::ChildInvocationObserver> _childObserver; diff --git a/cpp/include/Ice/SHA1.h b/cpp/include/Ice/SHA1.h new file mode 100644 index 00000000000..7666d0c2a0f --- /dev/null +++ b/cpp/include/Ice/SHA1.h @@ -0,0 +1,47 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2016 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. +// +// ********************************************************************** + +#ifndef ICE_SHA1_H +#define ICE_SHA1_H + +#include <Ice/Config.h> +#include <Ice/UniquePtr.h> + +#include <vector> + +namespace IceInternal +{ + +ICE_API void +sha1(const unsigned char*, std::size_t, std::vector<unsigned char>&); + +#ifndef ICE_OS_UWP +class ICE_API SHA1 +{ +public: + + SHA1(); + ~SHA1(); + + void update(const unsigned char*, std::size_t); + void finalize(std::vector<unsigned char>&); + +private: + + // noncopyable + SHA1(const SHA1&); + SHA1 operator=(const SHA1&); + + class Hasher; + UniquePtr<Hasher> _hasher; +}; +#endif + +} +#endif diff --git a/cpp/include/Ice/UniquePtr.h b/cpp/include/Ice/UniquePtr.h new file mode 100644 index 00000000000..0abf17b5843 --- /dev/null +++ b/cpp/include/Ice/UniquePtr.h @@ -0,0 +1,100 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2016 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. +// +// ********************************************************************** + +#ifndef ICE_UNIQUE_PTR_H +#define ICE_UNIQUE_PTR_H + +#include <Ice/Config.h> + +namespace IceInternal +{ + +#ifdef ICE_CPP11_MAPPING + +template<typename T> +using UniquePtr = std::unique_ptr<T>; + +#else + +template<typename T> +class UniquePtr +{ +public: + + explicit UniquePtr(T* ptr = 0) : + _ptr(ptr) + { + } + + ~UniquePtr() + { + if(_ptr != 0) + { + delete _ptr; + } + } + + T* release() + { + T* r = _ptr; + _ptr = 0; + return r; + } + + void reset(T* ptr = 0) + { + assert(ptr == 0 || ptr != _ptr); + + if(_ptr != 0) + { + delete _ptr; + } + _ptr = ptr; + } + + T& operator*() const + { + return *_ptr; + } + + T* operator->() const + { + return _ptr; + } + + T* get() const + { + return _ptr; + } + + operator bool() const + { + return _ptr != 0; + } + + void swap(UniquePtr& a) + { + T* tmp = a._ptr; + a._ptr = _ptr; + _ptr = tmp; + } + +private: + + UniquePtr(UniquePtr&); + UniquePtr& operator=(UniquePtr&); + + T* _ptr; +}; + +#endif + +} // End of namespace IceUtil + +#endif |