diff options
Diffstat (limited to 'cpp/include')
-rw-r--r-- | cpp/include/Ice/Exception.h | 39 | ||||
-rw-r--r-- | cpp/include/Ice/Ice.h | 2 | ||||
-rw-r--r-- | cpp/include/Ice/IconvStringConverter.h (renamed from cpp/include/IceUtil/IconvStringConverter.h) | 96 | ||||
-rw-r--r-- | cpp/include/Ice/InputStream.h | 8 | ||||
-rw-r--r-- | cpp/include/Ice/OutputStream.h | 8 | ||||
-rw-r--r-- | cpp/include/Ice/StringConverter.h | 55 | ||||
-rw-r--r-- | cpp/include/IceUtil/Exception.h | 26 | ||||
-rw-r--r-- | cpp/include/IceUtil/IceUtil.h | 4 | ||||
-rw-r--r-- | cpp/include/IceUtil/StringConverter.h | 12 |
9 files changed, 160 insertions, 90 deletions
diff --git a/cpp/include/Ice/Exception.h b/cpp/include/Ice/Exception.h index b957a91be0c..b2b4720b8ea 100644 --- a/cpp/include/Ice/Exception.h +++ b/cpp/include/Ice/Exception.h @@ -17,20 +17,6 @@ #include <Ice/ObjectF.h> #include <Ice/ValueF.h> -namespace IceInternal -{ - -namespace Ex -{ - -ICE_API void throwUOE(const ::std::string&, const ::Ice::ValuePtr&); -ICE_API void throwMemoryLimitException(const char*, int, size_t, size_t); -ICE_API void throwMarshalException(const char*, int, const std::string&); - -} - -} - namespace Ice { @@ -39,6 +25,9 @@ class InputStream; typedef IceUtil::Exception Exception; +// +// Base class for all Ice run-time exceptions +// class ICE_API LocalException : public IceUtil::Exception { public: @@ -60,6 +49,10 @@ public: static const std::string& ice_staticId(); }; + +// +// Base class for all Ice user exceptions +// class ICE_API UserException : public IceUtil::Exception { public: @@ -83,6 +76,10 @@ protected: virtual void __readImpl(::Ice::InputStream*) {}; }; + +// +// Base class for all Ice system exceptions +// class ICE_API SystemException : public IceUtil::Exception { public: @@ -105,4 +102,18 @@ public: } +namespace IceInternal +{ + +namespace Ex +{ + +ICE_API void throwUOE(const ::std::string&, const ::Ice::ValuePtr&); +ICE_API void throwMemoryLimitException(const char*, int, size_t, size_t); +ICE_API void throwMarshalException(const char*, int, const std::string&); + +} + +} + #endif diff --git a/cpp/include/Ice/Ice.h b/cpp/include/Ice/Ice.h index 23d9ee6236e..150dcd71491 100644 --- a/cpp/include/Ice/Ice.h +++ b/cpp/include/Ice/Ice.h @@ -52,6 +52,8 @@ #endif #include <Ice/RegisterPlugins.h> #include <Ice/InterfaceByValue.h> +#include <Ice/StringConverter.h> +#include <Ice/IconvStringConverter.h> #include <IceUtil/PopDisableWarnings.h> #endif diff --git a/cpp/include/IceUtil/IconvStringConverter.h b/cpp/include/Ice/IconvStringConverter.h index 85fd4c965f6..75a7455d440 100644 --- a/cpp/include/IceUtil/IconvStringConverter.h +++ b/cpp/include/Ice/IconvStringConverter.h @@ -7,10 +7,18 @@ // // ********************************************************************** -#ifndef ICE_UTIL_ICONV_STRING_CONVERTER -#define ICE_UTIL_ICONV_STRING_CONVERTER +#ifndef ICE_ICONV_STRING_CONVERTER +#define ICE_ICONV_STRING_CONVERTER -#include <IceUtil/StringConverter.h> +#include <Ice/Config.h> + +// +// For all platforms except Windows +// +#ifndef _WIN32 + +#include <Ice/StringConverter.h> +#include <IceUtil/ThreadException.h> #include <IceUtil/UndefSysMacros.h> #include <algorithm> @@ -19,13 +27,42 @@ #include <string.h> // For strerror #if (defined(__APPLE__) && _LIBICONV_VERSION < 0x010B) - // - // See http://sourceware.org/bugzilla/show_bug.cgi?id=2962 - // +// +// See http://sourceware.org/bugzilla/show_bug.cgi?id=2962 +// # define ICE_CONST_ICONV_INBUF 1 #endif -namespace IceUtilInternal +namespace Ice +{ + +class ICE_API IconvInitializationException : public IceUtil::ExceptionHelper<IconvInitializationException> +{ +public: + + IconvInitializationException(const char*, int, const std::string&); + +#ifndef ICE_CPP11_COMPILER + virtual ~IconvInitializationException() throw(); +#endif + + virtual std::string ice_id() const; + virtual void ice_print(std::ostream&) const; + +#ifndef ICE_CPP11_MAPPING + virtual IconvInitializationException* ice_clone() const; +#endif + + std::string reason() const; + +private: + + std::string _reason; +}; + +} + +namespace IceInternal { // @@ -44,9 +81,9 @@ public: virtual ~IconvStringConverter(); - virtual IceUtil::Byte* toUTF8(const charT*, const charT*, IceUtil::UTF8Buffer&) const; + virtual Ice::Byte* toUTF8(const charT*, const charT*, Ice::UTF8Buffer&) const; - virtual void fromUTF8(const IceUtil::Byte*, const IceUtil::Byte*, std::basic_string<charT>&) const; + virtual void fromUTF8(const Ice::Byte*, const Ice::Byte*, std::basic_string<charT>&) const; private: @@ -82,9 +119,9 @@ IconvStringConverter<charT>::IconvStringConverter(const char* internalCode) : { close(createDescriptors()); } - catch(const IceUtil::IllegalConversionException& sce) + catch(const Ice::IllegalConversionException& sce) { - throw IceUtil::IconvInitializationException(__FILE__, __LINE__, sce.reason()); + throw Ice::IconvInitializationException(__FILE__, __LINE__, sce.reason()); } // @@ -128,7 +165,7 @@ IconvStringConverter<charT>::createDescriptors() const { std::ostringstream os; os << "iconv cannot convert from " << externalCode << " to " << _internalCode; - throw IceUtil::IllegalConversionException(__FILE__, __LINE__, os.str()); + throw Ice::IllegalConversionException(__FILE__, __LINE__, os.str()); } cdp.second = iconv_open(externalCode, _internalCode.c_str()); @@ -137,7 +174,7 @@ IconvStringConverter<charT>::createDescriptors() const iconv_close(cdp.first); std::ostringstream os; os << "iconv cannot convert from " << _internalCode << " to " << externalCode; - throw IceUtil::IllegalConversionException(__FILE__, __LINE__, os.str()); + throw Ice::IllegalConversionException(__FILE__, __LINE__, os.str()); } return cdp; } @@ -186,10 +223,10 @@ IconvStringConverter<charT>::close(std::pair<iconv_t, iconv_t> cdp) #endif } -template<typename charT> IceUtil::Byte* +template<typename charT> Ice::Byte* IconvStringConverter<charT>::toUTF8(const charT* sourceStart, const charT* sourceEnd, - IceUtil::UTF8Buffer& buf) const + Ice::UTF8Buffer& buf) const { iconv_t cd = getDescriptors().second; @@ -219,21 +256,21 @@ IconvStringConverter<charT>::toUTF8(const charT* sourceStart, { size_t howMany = std::max(inbytesleft, size_t(4)); outbuf = reinterpret_cast<char*>(buf.getMoreBytes(howMany, - reinterpret_cast<IceUtil::Byte*>(outbuf))); + reinterpret_cast<Ice::Byte*>(outbuf))); count = iconv(cd, &inbuf, &inbytesleft, &outbuf, &howMany); } while(count == size_t(-1) && errno == E2BIG); if(count == size_t(-1)) { - throw IceUtil::IllegalConversionException(__FILE__, - __LINE__, - errno != 0 ? strerror(errno) : "Unknown error"); + throw Ice::IllegalConversionException(__FILE__, + __LINE__, + errno != 0 ? strerror(errno) : "Unknown error"); } - return reinterpret_cast<IceUtil::Byte*>(outbuf); + return reinterpret_cast<Ice::Byte*>(outbuf); } template<typename charT> void -IconvStringConverter<charT>::fromUTF8(const IceUtil::Byte* sourceStart, const IceUtil::Byte* sourceEnd, +IconvStringConverter<charT>::fromUTF8(const Ice::Byte* sourceStart, const Ice::Byte* sourceEnd, std::basic_string<charT>& target) const { iconv_t cd = getDescriptors().first; @@ -251,7 +288,7 @@ IconvStringConverter<charT>::fromUTF8(const IceUtil::Byte* sourceStart, const Ic #ifdef ICE_CONST_ICONV_INBUF const char* inbuf = reinterpret_cast<const char*>(sourceStart); #else - char* inbuf = reinterpret_cast<char*>(const_cast<IceUtil::Byte*>(sourceStart)); + char* inbuf = reinterpret_cast<char*>(const_cast<Ice::Byte*>(sourceStart)); #endif size_t inbytesleft = sourceEnd - sourceStart; @@ -281,25 +318,24 @@ IconvStringConverter<charT>::fromUTF8(const IceUtil::Byte* sourceStart, const Ic if(count == size_t(-1)) { - throw IceUtil::IllegalConversionException(__FILE__, - __LINE__, - errno != 0 ? strerror(errno) : "Unknown error"); + throw Ice::IllegalConversionException(__FILE__, + __LINE__, + errno != 0 ? strerror(errno) : "Unknown error"); } target.resize(target.size() - (outbytesleft / sizeof(charT))); } } -namespace IceUtil +namespace Ice { - template<typename charT> -ICE_HANDLE <BasicStringConverter<charT> > +ICE_HANDLE<IceUtil::BasicStringConverter<charT> > createIconvStringConverter(const char* internalCode = nl_langinfo(CODESET)) { - return ICE_MAKE_SHARED(IceUtilInternal::IconvStringConverter<charT>, internalCode); + return ICE_MAKE_SHARED(IceInternal::IconvStringConverter<charT>, internalCode); } - } #endif +#endif diff --git a/cpp/include/Ice/InputStream.h b/cpp/include/Ice/InputStream.h index a79e0a46411..bb563ab8fff 100644 --- a/cpp/include/Ice/InputStream.h +++ b/cpp/include/Ice/InputStream.h @@ -10,7 +10,7 @@ #ifndef ICE_INPUT_STREAM_H #define ICE_INPUT_STREAM_H -#include <IceUtil/StringConverter.h> +#include <Ice/StringConverter.h> #include <Ice/CommunicatorF.h> #include <Ice/InstanceF.h> #include <Ice/Object.h> @@ -121,7 +121,7 @@ public: // IceInternal::Instance* instance() const { return _instance; } // Inlined for performance reasons. - void setStringConverters(const IceUtil::StringConverterPtr&, const IceUtil::WstringConverterPtr&); + void setStringConverters(const StringConverterPtr&, const WstringConverterPtr&); void setValueFactoryManager(const ValueFactoryManagerPtr&); @@ -964,8 +964,8 @@ private: int _startSeq; int _minSeqSize; - IceUtil::StringConverterPtr _stringConverter; - IceUtil::WstringConverterPtr _wstringConverter; + StringConverterPtr _stringConverter; + WstringConverterPtr _wstringConverter; ValueFactoryManagerPtr _valueFactoryManager; LoggerPtr _logger; #ifdef ICE_CPP11_MAPPING diff --git a/cpp/include/Ice/OutputStream.h b/cpp/include/Ice/OutputStream.h index 67994253814..f7094db56f0 100644 --- a/cpp/include/Ice/OutputStream.h +++ b/cpp/include/Ice/OutputStream.h @@ -10,7 +10,7 @@ #ifndef ICE_OUTPUT_STREAM_H #define ICE_OUTPUT_STREAM_H -#include <IceUtil/StringConverter.h> +#include <Ice/StringConverter.h> #include <Ice/CommunicatorF.h> #include <Ice/InstanceF.h> #include <Ice/Object.h> @@ -86,7 +86,7 @@ public: // IceInternal::Instance* instance() const { return _instance; } // Inlined for performance reasons. - void setStringConverters(const IceUtil::StringConverterPtr&, const IceUtil::WstringConverterPtr&); + void setStringConverters(const StringConverterPtr&, const WstringConverterPtr&); void setFormat(FormatType); @@ -750,8 +750,8 @@ private: Encaps _preAllocatedEncaps; - IceUtil::StringConverterPtr _stringConverter; - IceUtil::WstringConverterPtr _wstringConverter; + StringConverterPtr _stringConverter; + WstringConverterPtr _wstringConverter; }; } // End namespace Ice diff --git a/cpp/include/Ice/StringConverter.h b/cpp/include/Ice/StringConverter.h new file mode 100644 index 00000000000..ac002394a21 --- /dev/null +++ b/cpp/include/Ice/StringConverter.h @@ -0,0 +1,55 @@ +// ********************************************************************** +// +// 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_STRING_CONVERTER_H +#define ICE_STRING_CONVERTER_H + +#include <Ice/Config.h> +#include <IceUtil/StringConverter.h> + +namespace Ice +{ + +typedef IceUtil::UTF8Buffer UTF8Buffer; +typedef IceUtil::StringConverter StringConverter; +typedef IceUtil::StringConverterPtr StringConverterPtr; +typedef IceUtil::WstringConverter WstringConverter; +typedef IceUtil::WstringConverterPtr WstringConverterPtr; + +typedef IceUtil::IllegalConversionException IllegalConversionException; + +#ifdef ICE_CPP11_MAPPING +template<typename charT> +using BasicStringConverter = IceUtil::BasicStringConverter<charT>; +#endif + +#ifdef _WIN32 +// +// Create a StringConverter that converts to and from narrow chars +// in the given code page, using MultiByteToWideChar and WideCharToMultiByte +// +ICE_API StringConverterPtr createWindowsStringConverter(unsigned int); +#endif + +using IceUtil::createUnicodeWstringConverter; + +using IceUtil::setProcessStringConverter; +using IceUtil::getProcessStringConverter; +using IceUtil::setProcessWstringConverter; +using IceUtil::getProcessWstringConverter; + +using IceUtil::wstringToString; +using IceUtil::stringToWstring; + +using IceUtil::nativeToUTF8; +using IceUtil::UTF8ToNative; + +} + +#endif diff --git a/cpp/include/IceUtil/Exception.h b/cpp/include/IceUtil/Exception.h index e7e6a21a52f..20d7e074469 100644 --- a/cpp/include/IceUtil/Exception.h +++ b/cpp/include/IceUtil/Exception.h @@ -266,32 +266,6 @@ public: #endif }; -#ifndef _WIN32 -class ICE_API IconvInitializationException : public ExceptionHelper<IconvInitializationException> -{ -public: - - IconvInitializationException(const char*, int, const std::string&); - -#ifndef ICE_CPP11_COMPILER - virtual ~IconvInitializationException() throw(); -#endif - - virtual std::string ice_id() const; - virtual void ice_print(std::ostream&) const; - -#ifndef ICE_CPP11_MAPPING - virtual IconvInitializationException* ice_clone() const; -#endif - - std::string reason() const; - -private: - - std::string _reason; -}; -#endif - } namespace IceUtilInternal diff --git a/cpp/include/IceUtil/IceUtil.h b/cpp/include/IceUtil/IceUtil.h index d88df9f83e0..1f9f4b56313 100644 --- a/cpp/include/IceUtil/IceUtil.h +++ b/cpp/include/IceUtil/IceUtil.h @@ -41,9 +41,5 @@ #include <IceUtil/UUID.h> #include <IceUtil/UniquePtr.h> -#ifndef _WIN32 -# include <IceUtil/IconvStringConverter.h> -#endif - #include <IceUtil/PopDisableWarnings.h> #endif diff --git a/cpp/include/IceUtil/StringConverter.h b/cpp/include/IceUtil/StringConverter.h index 1979107cc67..2f986fb6a06 100644 --- a/cpp/include/IceUtil/StringConverter.h +++ b/cpp/include/IceUtil/StringConverter.h @@ -1,3 +1,6 @@ +// ********************************************************************** +// +// 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. @@ -74,14 +77,6 @@ ICE_DEFINE_PTR(WstringConverterPtr, WstringConverter); // ICE_API WstringConverterPtr createUnicodeWstringConverter(); -#ifdef _WIN32 -// -// Create a StringConverter that converts to and from narrow chars -// in the given code page, using MultiByteToWideChar and WideCharToMultiByte -// -ICE_API StringConverterPtr createWindowsStringConverter(unsigned int); -#endif - // // Retrieve the per process narrow string converter. // @@ -160,6 +155,7 @@ ICE_API std::vector<unsigned int> toUTF32(const std::vector<IceUtil::Byte>&); // Convert from UTF-32 to UTF-8 // ICE_API std::vector<IceUtil::Byte> fromUTF32(const std::vector<unsigned int>&); + } #endif |