summaryrefslogtreecommitdiff
path: root/cpp/include/IceUtil
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/include/IceUtil')
-rw-r--r--cpp/include/IceUtil/Algorithm.h33
-rw-r--r--cpp/include/IceUtil/ArgVector.h2
-rw-r--r--cpp/include/IceUtil/Base64.h36
-rw-r--r--cpp/include/IceUtil/Cache.h4
-rw-r--r--cpp/include/IceUtil/Cond.h24
-rw-r--r--cpp/include/IceUtil/CountDownLatch.h2
-rw-r--r--cpp/include/IceUtil/IceUtil.h16
-rw-r--r--cpp/include/IceUtil/InputUtil.h6
-rw-r--r--cpp/include/IceUtil/Iterator.h17
-rw-r--r--cpp/include/IceUtil/MD5.h44
-rwxr-xr-xcpp/include/IceUtil/Options.h4
-rw-r--r--cpp/include/IceUtil/OutputUtil.h4
-rw-r--r--cpp/include/IceUtil/Random.h4
-rw-r--r--cpp/include/IceUtil/ScopedArray.h4
-rw-r--r--cpp/include/IceUtil/Shared.h75
-rw-r--r--cpp/include/IceUtil/StringUtil.h2
-rw-r--r--cpp/include/IceUtil/Timer.h4
-rw-r--r--cpp/include/IceUtil/Unicode.h73
18 files changed, 87 insertions, 267 deletions
diff --git a/cpp/include/IceUtil/Algorithm.h b/cpp/include/IceUtil/Algorithm.h
deleted file mode 100644
index 80aa2ddd725..00000000000
--- a/cpp/include/IceUtil/Algorithm.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2007 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_UTIL_ALGORITHM_H
-#define ICE_UTIL_ALGORITHM_H
-
-#include <algorithm>
-
-
-// Work-around for a limitation in the standard library provided
-// with the Sun C++ 5.x compilers
-#if defined(__SUNPRO_CC) && defined(_RWSTD_NO_CLASS_PARTIAL_SPEC)
-
-template<class InputIterator, class Predicate>
-inline typename InputIterator::difference_type
-ice_count_if(InputIterator first, InputIterator last, Predicate pred)
-{
- InputIterator::difference_type result = 0;
- std::count_if(first, last, pred, result);
- return result;
-}
-
-#else
-#define ice_count_if(x,y,z) std::count_if(x,y,z)
-#endif
-
-#endif
diff --git a/cpp/include/IceUtil/ArgVector.h b/cpp/include/IceUtil/ArgVector.h
index 7d8d4c1c7a6..d3947ffe892 100644
--- a/cpp/include/IceUtil/ArgVector.h
+++ b/cpp/include/IceUtil/ArgVector.h
@@ -14,7 +14,7 @@
#include <vector>
#include <string>
-namespace IceUtil
+namespace IceUtilInternal
{
class ICE_UTIL_API ArgVector
diff --git a/cpp/include/IceUtil/Base64.h b/cpp/include/IceUtil/Base64.h
deleted file mode 100644
index a649927ed7d..00000000000
--- a/cpp/include/IceUtil/Base64.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2007 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_UTIL_BASE_64_H
-#define ICE_UTIL_BASE_64_H
-
-#include <IceUtil/Config.h>
-#include <string>
-#include <vector>
-
-namespace IceUtil
-{
-
-class ICE_UTIL_API Base64
-{
-public:
-
- static std::string encode(const std::vector<unsigned char>&);
- static std::vector<unsigned char> decode(const std::string&);
- static bool isBase64(char);
-
-private:
-
- static char encode(unsigned char);
- static unsigned char decode(char);
-};
-
-}
-
-#endif
diff --git a/cpp/include/IceUtil/Cache.h b/cpp/include/IceUtil/Cache.h
index 1449734e908..3bc87c6d2b6 100644
--- a/cpp/include/IceUtil/Cache.h
+++ b/cpp/include/IceUtil/Cache.h
@@ -33,10 +33,10 @@ public:
// application code should not use them.
//
- struct Latch : public CountDownLatch
+ struct Latch : public IceUtilInternal::CountDownLatch
{
Latch() :
- CountDownLatch(1),
+ IceUtilInternal::CountDownLatch(1),
useCount(0)
{
}
diff --git a/cpp/include/IceUtil/Cond.h b/cpp/include/IceUtil/Cond.h
index 954dd1dcd35..c22a507c01c 100644
--- a/cpp/include/IceUtil/Cond.h
+++ b/cpp/include/IceUtil/Cond.h
@@ -18,17 +18,11 @@
# include <IceUtil/Mutex.h>
#endif
-namespace IceUtil
-{
-
-//
-// Forward declaration (for friend declarations).
-//
-template <class T> class Monitor;
-class RecMutex;
-class Mutex;
#ifdef _WIN32
+
+namespace IceUtilInternal
+{
//
// Needed for implementation.
//
@@ -47,8 +41,20 @@ private:
mutable HANDLE _sem;
};
+}
#endif
+
+namespace IceUtil
+{
+
+//
+// Forward declaration (for friend declarations).
+//
+template <class T> class Monitor;
+class RecMutex;
+class Mutex;
+
//
// Condition variable implementation. Conforms to the same semantics
// as a POSIX threads condition variable.
diff --git a/cpp/include/IceUtil/CountDownLatch.h b/cpp/include/IceUtil/CountDownLatch.h
index 00fb6a967d5..29cb0a6de32 100644
--- a/cpp/include/IceUtil/CountDownLatch.h
+++ b/cpp/include/IceUtil/CountDownLatch.h
@@ -12,7 +12,7 @@
#include <IceUtil/Config.h>
-namespace IceUtil
+namespace IceUtilInternal
{
//
diff --git a/cpp/include/IceUtil/IceUtil.h b/cpp/include/IceUtil/IceUtil.h
index 74e3994c29d..fa469555575 100644
--- a/cpp/include/IceUtil/IceUtil.h
+++ b/cpp/include/IceUtil/IceUtil.h
@@ -12,41 +12,29 @@
//
// This file must include *all* other headers of IceUtil, except
-// for DisableWarnings.h.
+// for DisableWarnings.h and headers with only IceUtilInternal symbols
//
#include <IceUtil/Config.h>
#include <IceUtil/AbstractMutex.h>
-#include <IceUtil/Algorithm.h>
-#include <IceUtil/ArgVector.h>
-#include <IceUtil/Base64.h>
#include <IceUtil/Cache.h>
#include <IceUtil/Cond.h>
-#include <IceUtil/CountDownLatch.h>
#include <IceUtil/CtrlCHandler.h>
#include <IceUtil/Exception.h>
#include <IceUtil/Functional.h>
#include <IceUtil/Handle.h>
-#include <IceUtil/InputUtil.h>
-#include <IceUtil/Iterator.h>
#include <IceUtil/Lock.h>
-#include <IceUtil/MD5.h>
#include <IceUtil/Monitor.h>
#include <IceUtil/Mutex.h>
-#include <IceUtil/Options.h>
-#include <IceUtil/OutputUtil.h>
#include <IceUtil/RWRecMutex.h>
-#include <IceUtil/Random.h>
#include <IceUtil/RecMutex.h>
-#include <IceUtil/ScopedArray.h>
#include <IceUtil/Shared.h>
#include <IceUtil/StaticMutex.h>
-#include <IceUtil/StringUtil.h>
#include <IceUtil/Thread.h>
#include <IceUtil/ThreadException.h>
#include <IceUtil/Time.h>
+#include <IceUtil/Timer.h>
#include <IceUtil/UUID.h>
#include <IceUtil/Unicode.h>
-#include <IceUtil/Timer.h>
#endif
diff --git a/cpp/include/IceUtil/InputUtil.h b/cpp/include/IceUtil/InputUtil.h
index 480147bffdd..7b5ecb44f9f 100644
--- a/cpp/include/IceUtil/InputUtil.h
+++ b/cpp/include/IceUtil/InputUtil.h
@@ -13,13 +13,13 @@
#include <IceUtil/Config.h>
#include <string>
-namespace IceUtil
+namespace IceUtilInternal
{
//
// Portable strtoll/_strtoi64
//
-ICE_UTIL_API Int64 strToInt64(const char*, char**, int);
+ICE_UTIL_API IceUtil::Int64 strToInt64(const char*, char**, int);
//
// stringToInt64 converts a string into a signed 64-bit integer.
@@ -40,7 +40,7 @@ ICE_UTIL_API Int64 strToInt64(const char*, char**, int);
// - result == 0 indicates that no digits were available for conversion
// - result == "Int64 Min" or result == "Int64 Max" indicate underflow or overflow.
//
-ICE_UTIL_API bool stringToInt64(const std::string&, Int64&);
+ICE_UTIL_API bool stringToInt64(const std::string&, IceUtil::Int64&);
}
diff --git a/cpp/include/IceUtil/Iterator.h b/cpp/include/IceUtil/Iterator.h
index 8f8fbc4b0a9..4327960537e 100644
--- a/cpp/include/IceUtil/Iterator.h
+++ b/cpp/include/IceUtil/Iterator.h
@@ -12,22 +12,25 @@
#include <iterator>
+namespace IceUtilInternal
+{
+template<class ForwardIterator>
+inline typename ForwardIterator::difference_type
+distance(ForwardIterator first, ForwardIterator last)
+{
+//
// Work-around for a limitation in the standard library provided
// with the Sun C++ 5.x compilers
#if defined(__SUNPRO_CC) && defined(_RWSTD_NO_CLASS_PARTIAL_SPEC)
-template<class ForwardIterator>
-inline typename ForwardIterator::difference_type
-ice_distance(ForwardIterator first, ForwardIterator last)
-{
ForwardIterator::difference_type result = 0;
std::distance(first, last, result);
return result;
-}
-
#else
-#define ice_distance(x,y) std::distance(x,y)
+ return ::std::distance(first, last);
#endif
+}
+}
#endif
diff --git a/cpp/include/IceUtil/MD5.h b/cpp/include/IceUtil/MD5.h
deleted file mode 100644
index 568a9212423..00000000000
--- a/cpp/include/IceUtil/MD5.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2007 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_UTIL_MD5_H
-#define ICE_UTIL_MD5_H
-
-#include <IceUtil/Config.h>
-
-extern "C"
-{
-struct md5_state_s;
-}
-
-namespace IceUtil
-{
-
-class ICE_UTIL_API MD5
-{
-public:
-
- MD5();
- MD5(const unsigned char*, int);
- ~MD5();
-
- void update(const unsigned char*, int);
- void finish();
-
- void getDigest(unsigned char*) const;
-
-private:
-
- md5_state_s* _state;
- unsigned char _digest[16];
-};
-
-}
-
-#endif
diff --git a/cpp/include/IceUtil/Options.h b/cpp/include/IceUtil/Options.h
index ef14133eb7e..ebb42d0154c 100755
--- a/cpp/include/IceUtil/Options.h
+++ b/cpp/include/IceUtil/Options.h
@@ -19,7 +19,7 @@
#include <vector>
#include <map>
-namespace IceUtil
+namespace IceUtilInternal
{
class ICE_UTIL_API APIException : public IceUtil::Exception
@@ -128,7 +128,7 @@ private:
bool parseCalled;
- RecMutex _m;
+ IceUtil::RecMutex _m;
Options(const Options&); // Not allowed.
void operator=(const Options&); // Not allowed.
diff --git a/cpp/include/IceUtil/OutputUtil.h b/cpp/include/IceUtil/OutputUtil.h
index d45a69d1a25..b1b0941f0f4 100644
--- a/cpp/include/IceUtil/OutputUtil.h
+++ b/cpp/include/IceUtil/OutputUtil.h
@@ -15,10 +15,10 @@
#include <stack>
#include <vector>
-namespace IceUtil
+namespace IceUtilInternal
{
-ICE_UTIL_API std::string int64ToString(Int64);
+ICE_UTIL_API std::string int64ToString(IceUtil::Int64);
// ----------------------------------------------------------------------
// OutputBase
diff --git a/cpp/include/IceUtil/Random.h b/cpp/include/IceUtil/Random.h
index 2a8fe4972d9..31111bc65d0 100644
--- a/cpp/include/IceUtil/Random.h
+++ b/cpp/include/IceUtil/Random.h
@@ -13,10 +13,10 @@
#include <IceUtil/Config.h>
#include <IceUtil/Exception.h>
-namespace IceUtil
+namespace IceUtilInternal
{
-class ICE_UTIL_API RandomGeneratorException : public Exception
+class ICE_UTIL_API RandomGeneratorException : public IceUtil::Exception
{
public:
diff --git a/cpp/include/IceUtil/ScopedArray.h b/cpp/include/IceUtil/ScopedArray.h
index 52be7c0ae12..f42cfee3e15 100644
--- a/cpp/include/IceUtil/ScopedArray.h
+++ b/cpp/include/IceUtil/ScopedArray.h
@@ -12,11 +12,11 @@
#include <IceUtil/Config.h>
-namespace IceUtil
+namespace IceUtilInternal
{
template<typename T>
-class ScopedArray : private noncopyable
+class ScopedArray : private IceUtil::noncopyable
{
public:
diff --git a/cpp/include/IceUtil/Shared.h b/cpp/include/IceUtil/Shared.h
index 61b466d9895..b830a550854 100644
--- a/cpp/include/IceUtil/Shared.h
+++ b/cpp/include/IceUtil/Shared.h
@@ -18,6 +18,10 @@
#elif (defined(__linux) || defined(__FreeBSD__)) && (defined(__i386) || defined(__x86_64)) && !defined(__ICC)
# define ICE_HAS_ATOMIC_FUNCTIONS
+
+namespace IceUtilInternal
+{
+
// __ICC: The inline assembler causes problems with shared libraries.
//
// Linux only. Unfortunately, asm/atomic.h builds non-SMP safe code
@@ -32,77 +36,10 @@
* on us. We need to use _exactly_ the address the user gave us,
* not some alias that contains the same information.
*/
-struct ice_atomic_t
+struct AtomicCounter
{
volatile int counter;
};
-
-/*
- * ice_atomic_set - set ice_atomic variable
- * @v: pointer of type ice_atomic_t
- * @i: required value
- *
- * Atomically sets the value of @v to @i. Note that the guaranteed
- * useful range of an ice_atomic_t is only 24 bits.
- */
-inline void ice_atomic_set(ice_atomic_t* v, int i)
-{
- v->counter = i;
-}
-
-/*
- * ice_atomic_inc - increment ice_atomic variable
- * @v: pointer of type ice_atomic_t
- *
- * Atomically increments @v by 1. Note that the guaranteed useful
- * range of an ice_atomic_t is only 24 bits.
- *
- * Inlined because this operation is performance critical.
- */
-inline void ice_atomic_inc(ice_atomic_t *v)
-{
- __asm__ __volatile__(
- "lock ; incl %0"
- :"=m" (v->counter)
- :"m" (v->counter));
-}
-
-/**
- * ice_atomic_dec_and_test - decrement and test
- * @v: pointer of type ice_atomic_t
- *
- * Atomically decrements @v by 1 and returns true if the result is 0,
- * or false for all other cases. Note that the guaranteed useful
- * range of an ice_atomic_t is only 24 bits.
- *
- * Inlined because this operation is performance critical.
- */
-inline int ice_atomic_dec_and_test(ice_atomic_t *v)
-{
- unsigned char c;
- __asm__ __volatile__(
- "lock ; decl %0; sete %1"
- :"=m" (v->counter), "=qm" (c)
- :"m" (v->counter) : "memory");
- return c != 0;
-}
-
-/**
- * ice_atomic_exchange_add - same as InterlockedExchangeAdd. This
- * didn't come from atomic.h (the code was derived from similar code
- * in /usr/include/asm/rwsem.h)
- *
- * Inlined because this operation is performance critical.
- */
-inline int ice_atomic_exchange_add(int i, ice_atomic_t* v)
-{
- int tmp = i;
- __asm__ __volatile__(
- "lock ; xadd %0,(%2)"
- :"+r"(tmp), "=m"(v->counter)
- :"r"(v), "m"(v->counter)
- : "memory");
- return tmp + i;
}
#elif defined(_WIN32)
@@ -207,7 +144,7 @@ protected:
#if defined(_WIN32)
LONG _ref;
#elif defined(ICE_HAS_ATOMIC_FUNCTIONS)
- ice_atomic_t _ref;
+ IceUtilInternal::AtomicCounter _ref;
#else
int _ref;
Mutex _mutex;
diff --git a/cpp/include/IceUtil/StringUtil.h b/cpp/include/IceUtil/StringUtil.h
index 35704981e52..1073bfc2573 100644
--- a/cpp/include/IceUtil/StringUtil.h
+++ b/cpp/include/IceUtil/StringUtil.h
@@ -13,7 +13,7 @@
#include <IceUtil/Config.h>
#include <vector>
-namespace IceUtil
+namespace IceUtilInternal
{
//
diff --git a/cpp/include/IceUtil/Timer.h b/cpp/include/IceUtil/Timer.h
index 3725f9e4d46..29fc76aedb6 100644
--- a/cpp/include/IceUtil/Timer.h
+++ b/cpp/include/IceUtil/Timer.h
@@ -7,8 +7,8 @@
//
// **********************************************************************
-#ifndef ICEUTIL_TIMER_H
-#define ICEUTIL_TIMER_H
+#ifndef ICE_UTIL_TIMER_H
+#define ICE_UTIL_TIMER_H
#include <IceUtil/Shared.h>
#include <IceUtil/Thread.h>
diff --git a/cpp/include/IceUtil/Unicode.h b/cpp/include/IceUtil/Unicode.h
index 03c95a3fa56..937aadf2715 100644
--- a/cpp/include/IceUtil/Unicode.h
+++ b/cpp/include/IceUtil/Unicode.h
@@ -83,17 +83,10 @@ ICE_UTIL_API std::wstring stringToWstring(const std::string&);
#endif
+typedef unsigned char Byte;
-//
-// Converts UTF-8 byte-sequences to and from UTF-16 or UTF-32 (with native
-// endianness) depending on sizeof(wchar_t).
-//
-// These are thin wrappers over the UTF8/16/32 converters provided by
-// unicode.org
-//
-//
-// TODO: provide the same support for /Zc:wchar_t as the functions above
-//
+ICE_UTIL_API bool
+isLegalUTF8Sequence(const Byte* source, const Byte* end);
enum ConversionResult
{
@@ -103,33 +96,6 @@ enum ConversionResult
sourceIllegal /* source sequence is illegal/malformed */
};
-
-enum ConversionFlags
-{
- strictConversion = 0,
- lenientConversion
-};
-
-typedef unsigned char Byte;
-
-ICE_UTIL_API bool
-isLegalUTF8Sequence(const Byte* source, const Byte* end);
-
-ICE_UTIL_API ConversionResult
-convertUTFWstringToUTF8(const wchar_t*& sourceStart, const wchar_t* sourceEnd,
- Byte*& targetStart, Byte* targetEnd, ConversionFlags flags);
-
-ICE_UTIL_API ConversionResult
-convertUTF8ToUTFWstring(const Byte*& sourceStart, const Byte* sourceEnd,
- wchar_t*& targetStart, wchar_t* targetEnd, ConversionFlags flags);
-
-ICE_UTIL_API ConversionResult
-convertUTF8ToUTFWstring(const Byte*& sourceStart, const Byte* sourceEnd,
- std::wstring& target, ConversionFlags flags);
-
-
-
-
//
// UTFConversionException is raised by wstringToString() or stringToWstring()
// to report a conversion error
@@ -153,4 +119,37 @@ private:
}
+namespace IceUtilInternal
+{
+
+//
+// Converts UTF-8 byte-sequences to and from UTF-16 or UTF-32 (with native
+// endianness) depending on sizeof(wchar_t).
+//
+// These are thin wrappers over the UTF8/16/32 converters provided by
+// unicode.org
+//
+
+
+enum ConversionFlags
+{
+ strictConversion = 0,
+ lenientConversion
+};
+
+
+ICE_UTIL_API IceUtil::ConversionResult
+convertUTFWstringToUTF8(const wchar_t*& sourceStart, const wchar_t* sourceEnd,
+ IceUtil::Byte*& targetStart, IceUtil::Byte* targetEnd, ConversionFlags flags);
+
+ICE_UTIL_API IceUtil::ConversionResult
+convertUTF8ToUTFWstring(const IceUtil::Byte*& sourceStart, const IceUtil::Byte* sourceEnd,
+ wchar_t*& targetStart, wchar_t* targetEnd, ConversionFlags flags);
+
+ICE_UTIL_API IceUtil::ConversionResult
+convertUTF8ToUTFWstring(const IceUtil::Byte*& sourceStart, const IceUtil::Byte* sourceEnd,
+ std::wstring& target, ConversionFlags flags);
+
+}
+
#endif