diff options
Diffstat (limited to 'cpp/src')
33 files changed, 368 insertions, 338 deletions
diff --git a/cpp/src/Ice/Application.cpp b/cpp/src/Ice/Application.cpp index af4e6458ef2..96be888b7c9 100644 --- a/cpp/src/Ice/Application.cpp +++ b/cpp/src/Ice/Application.cpp @@ -314,7 +314,7 @@ Ice::Application::main(int argc, char* argv[], const char* configFile) if(argc > 0 && argv[0] && ICE_DYNAMIC_CAST(LoggerI, getProcessLogger())) { - setProcessLogger(ICE_MAKE_SHARED(LoggerI, argv[0], "", true, IceUtil::getProcessStringConverter())); + setProcessLogger(ICE_MAKE_SHARED(LoggerI, argv[0], "", true, Ice::getProcessStringConverter())); } InitializationData initData; @@ -369,7 +369,7 @@ Ice::Application::main(int argc, char* argv[], const InitializationData& initial const bool convert = initializationData.properties ? initializationData.properties->getPropertyAsIntWithDefault("Ice.LogStdErr.Convert", 1) > 0 && initializationData.properties->getProperty("Ice.StdErr").empty() : true; - setProcessLogger(ICE_MAKE_SHARED(LoggerI, argv[0], "", convert, IceUtil::getProcessStringConverter())); + setProcessLogger(ICE_MAKE_SHARED(LoggerI, argv[0], "", convert, Ice::getProcessStringConverter())); } if(IceInternal::Application::_communicator != 0) @@ -662,7 +662,7 @@ Ice::Application::doMain(int argc, char* argv[], const InitializationData& initD initData.properties->getProperty("Ice.StdErr").empty(); setProcessLogger(ICE_MAKE_SHARED(LoggerI, initData.properties->getProperty("Ice.ProgramName"), "", convert, - IceUtil::getProcessStringConverter())); + Ice::getProcessStringConverter())); } IceInternal::Application::_communicator = initialize(argc, argv, initData); diff --git a/cpp/src/Ice/DynamicLibrary.cpp b/cpp/src/Ice/DynamicLibrary.cpp index 75985b6ab06..8cb221fbfce 100644 --- a/cpp/src/Ice/DynamicLibrary.cpp +++ b/cpp/src/Ice/DynamicLibrary.cpp @@ -9,7 +9,7 @@ #include <Ice/DynamicLibrary.h> #include <IceUtil/StringUtil.h> -#include <IceUtil/StringConverter.h> +#include <Ice/StringConverter.h> #ifndef _WIN32 # include <dlfcn.h> @@ -214,9 +214,9 @@ IceInternal::DynamicLibrary::load(const string& lib) // to Windows API. // #ifdef ICE_OS_WINRT - _hnd = LoadPackagedLibrary(IceUtil::stringToWstring(lib, IceUtil::getProcessStringConverter()).c_str(), 0); + _hnd = LoadPackagedLibrary(stringToWstring(lib, getProcessStringConverter()).c_str(), 0); #elif defined(_WIN32) - _hnd = LoadLibraryW(IceUtil::stringToWstring(lib, IceUtil::getProcessStringConverter()).c_str()); + _hnd = LoadLibraryW(stringToWstring(lib, getProcessStringConverter()).c_str()); #else int flags = RTLD_NOW | RTLD_GLOBAL; diff --git a/cpp/src/Ice/Exception.cpp b/cpp/src/Ice/Exception.cpp index 848d7260502..7e2fc340c9d 100644 --- a/cpp/src/Ice/Exception.cpp +++ b/cpp/src/Ice/Exception.cpp @@ -16,7 +16,7 @@ #include <Ice/InputStream.h> #include <IceUtil/StringUtil.h> #ifdef ICE_OS_WINRT -# include <IceUtil/StringConverter.h> +# include <Ice/StringConverter.h> #endif #include <iomanip> @@ -48,9 +48,9 @@ socketErrorToString(int error) // Don't need to use a wide string converter as the wide string come // from Windows API. // - return IceUtil::wstringToString( + return wstringToString( static_cast<Windows::Networking::Sockets::SocketErrorStatus>(error).ToString()->Data(), - IceUtil::getProcessStringConverter()); + getProcessStringConverter()); } #else return IceUtilInternal::errorToString(error); diff --git a/cpp/src/Ice/IconvStringConverter.cpp b/cpp/src/Ice/IconvStringConverter.cpp new file mode 100644 index 00000000000..7414d03f9be --- /dev/null +++ b/cpp/src/Ice/IconvStringConverter.cpp @@ -0,0 +1,56 @@ +// ********************************************************************** +// +// 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. +// +// ********************************************************************** + +#include <Ice/IconvStringConverter.h> + +#ifndef _WIN32 + +using namespace std; +using namespace Ice; +using namespace IceUtil; + +IconvInitializationException::IconvInitializationException(const char* file, int line, const string& reason) : + ExceptionHelper<IconvInitializationException>(file, line), + _reason(reason) +{ +} + +#ifndef ICE_CPP11_COMPILER +IconvInitializationException::~IconvInitializationException() throw() +{ +} +#endif + +void +IconvInitializationException::ice_print(ostream& out) const +{ + IceUtil::Exception::ice_print(out); + out << ": " << _reason; +} + +string +IconvInitializationException::ice_id() const +{ + return "::Ice::IconvInitializationException"; +} + +#ifndef ICE_CPP11_MAPPING +IconvInitializationException* +IconvInitializationException::ice_clone() const +{ + return new IconvInitializationException(*this); +} +#endif + +string +IconvInitializationException::reason() const +{ + return _reason; +} +#endif diff --git a/cpp/src/Ice/Initialize.cpp b/cpp/src/Ice/Initialize.cpp index f558c0d78e4..baccbcb50cd 100644 --- a/cpp/src/Ice/Initialize.cpp +++ b/cpp/src/Ice/Initialize.cpp @@ -19,7 +19,7 @@ #include <IceUtil/StringUtil.h> #include <IceUtil/Mutex.h> #include <IceUtil/MutexPtrLock.h> -#include <IceUtil/StringConverter.h> +#include <Ice/StringConverter.h> using namespace std; using namespace Ice; @@ -71,11 +71,11 @@ Ice::argsToStringSeq(int /*argc*/, wchar_t* argv[]) // Don't need to use a wide string converter argv is expected to // come from Windows API. // - const IceUtil::StringConverterPtr converter = IceUtil::getProcessStringConverter(); + const StringConverterPtr converter = getProcessStringConverter(); StringSeq args; for(int i=0; argv[i] != 0; i++) { - args.push_back(IceUtil::wstringToString(argv[i], converter)); + args.push_back(wstringToString(argv[i], converter)); } return args; } @@ -122,13 +122,13 @@ Ice::stringSeqToArgs(const StringSeq& args, int& argc, char* argv[]) PropertiesPtr Ice::createProperties() { - return PropertiesPtr(new PropertiesI(IceUtil::getProcessStringConverter())); + return PropertiesPtr(new PropertiesI(getProcessStringConverter())); } PropertiesPtr Ice::createProperties(StringSeq& args, const PropertiesPtr& defaults) { - return PropertiesPtr(new PropertiesI(args, defaults, IceUtil::getProcessStringConverter())); + return PropertiesPtr(new PropertiesI(args, defaults, getProcessStringConverter())); } PropertiesPtr @@ -272,7 +272,7 @@ Ice::getProcessLogger() // // TODO: Would be nice to be able to use process name as prefix by default. // - processLogger = ICE_MAKE_SHARED(Ice::LoggerI, "", "", true, IceUtil::getProcessStringConverter()); + processLogger = ICE_MAKE_SHARED(LoggerI, "", "", true, getProcessStringConverter()); } return processLogger; } @@ -443,8 +443,8 @@ Ice::stringToIdentity(const string& s) } } - ident.name = UTF8ToNative(ident.name, IceUtil::getProcessStringConverter()); - ident.category = UTF8ToNative(ident.category, IceUtil::getProcessStringConverter()); + ident.name = UTF8ToNative(ident.name, getProcessStringConverter()); + ident.category = UTF8ToNative(ident.category, getProcessStringConverter()); return ident; } @@ -456,8 +456,8 @@ Ice::identityToString(const Identity& ident) // This method returns the stringified identity. The returned string only // contains printable ascii. It can contain UTF8 in the escaped form. // - string name = nativeToUTF8(ident.name, IceUtil::getProcessStringConverter()); - string category = nativeToUTF8(ident.category, IceUtil::getProcessStringConverter()); + string name = nativeToUTF8(ident.name, getProcessStringConverter()); + string category = nativeToUTF8(ident.category, getProcessStringConverter()); if(category.empty()) { diff --git a/cpp/src/Ice/InputStream.cpp b/cpp/src/Ice/InputStream.cpp index 2e5dcdf2965..912c1b2b425 100644 --- a/cpp/src/Ice/InputStream.cpp +++ b/cpp/src/Ice/InputStream.cpp @@ -23,7 +23,6 @@ #include <Ice/TraceLevels.h> #include <Ice/LoggerUtil.h> #include <Ice/SlicedData.h> -#include <IceUtil/StringConverter.h> #include <iterator> #ifndef ICE_UNALIGNED @@ -202,7 +201,7 @@ Ice::InputStream::clear() } void -Ice::InputStream::setStringConverters(const IceUtil::StringConverterPtr& sc, const IceUtil::WstringConverterPtr& wsc) +Ice::InputStream::setStringConverters(const StringConverterPtr& sc, const WstringConverterPtr& wsc) { _stringConverter = sc; _wstringConverter = wsc; diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index cd9feeca62b..a5062c4e20b 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -949,8 +949,8 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi _batchAutoFlushSize(0), _collectObjects(false), _implicitContext(0), - _stringConverter(IceUtil::getProcessStringConverter()), - _wstringConverter(IceUtil::getProcessWstringConverter()), + _stringConverter(Ice::getProcessStringConverter()), + _wstringConverter(Ice::getProcessWstringConverter()), _adminEnabled(false) { try @@ -1343,9 +1343,9 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[], const Ice::Communica // // Reset _stringConverter and _wstringConverter, in case a plugin changed them // - _stringConverter = IceUtil::getProcessStringConverter(); + _stringConverter = Ice::getProcessStringConverter(); - IceUtil::WstringConverterPtr newWstringConverter = IceUtil::getProcessWstringConverter(); + Ice::WstringConverterPtr newWstringConverter = Ice::getProcessWstringConverter(); if(newWstringConverter) { _wstringConverter = newWstringConverter; diff --git a/cpp/src/Ice/Instance.h b/cpp/src/Ice/Instance.h index 86d465705bb..659eef3157f 100644 --- a/cpp/src/Ice/Instance.h +++ b/cpp/src/Ice/Instance.h @@ -15,7 +15,7 @@ #include <IceUtil/Mutex.h> #include <IceUtil/RecMutex.h> #include <IceUtil/Timer.h> -#include <IceUtil/StringConverter.h> +#include <Ice/StringConverter.h> #include <Ice/InstanceF.h> #include <Ice/CommunicatorF.h> #include <Ice/InstrumentationF.h> @@ -135,8 +135,8 @@ public: void setThreadHook(const Ice::ThreadNotificationPtr&); #endif - IceUtil::StringConverterPtr getStringConverter() const { return _stringConverter; } - IceUtil::WstringConverterPtr getWstringConverter() const { return _wstringConverter; } + Ice::StringConverterPtr getStringConverter() const { return _stringConverter; } + Ice::WstringConverterPtr getWstringConverter() const { return _wstringConverter; } BufSizeWarnInfo getBufSizeWarn(Ice::Short type); void setSndBufSizeWarn(Ice::Short type, int size); @@ -198,8 +198,8 @@ private: DynamicLibraryListPtr _dynamicLibraryList; Ice::PluginManagerPtr _pluginManager; const Ice::ImplicitContextIPtr _implicitContext; - IceUtil::StringConverterPtr _stringConverter; - IceUtil::WstringConverterPtr _wstringConverter; + Ice::StringConverterPtr _stringConverter; + Ice::WstringConverterPtr _wstringConverter; bool _adminEnabled; Ice::ObjectAdapterPtr _adminAdapter; Ice::FacetMap _adminFacets; diff --git a/cpp/src/Ice/LoggerI.cpp b/cpp/src/Ice/LoggerI.cpp index 2a7a1586f24..b94b713a740 100644 --- a/cpp/src/Ice/LoggerI.cpp +++ b/cpp/src/Ice/LoggerI.cpp @@ -52,13 +52,13 @@ const IceUtil::Time retryTimeout = IceUtil::Time::seconds(5 * 60); } Ice::LoggerI::LoggerI(const string& prefix, const string& file, - bool convert, const IceUtil::StringConverterPtr& converter, + bool convert, const StringConverterPtr& converter, size_t sizeMax) : _prefix(prefix), _convert(convert), _converter(converter), #if defined(_WIN32) && !defined(ICE_OS_WINRT) - _consoleConverter(IceUtil::createWindowsStringConverter(GetConsoleOutputCP())), + _consoleConverter(createWindowsStringConverter(GetConsoleOutputCP())), #endif _sizeMax(sizeMax) { @@ -235,7 +235,7 @@ Ice::LoggerI::write(const string& message, bool indent) else { #if defined(ICE_OS_WINRT) - OutputDebugString(IceUtil::stringToWstring(s).c_str()); + OutputDebugString(stringToWstring(s).c_str()); #elif defined(_WIN32) // // Convert the message from the native narrow string encoding to the console @@ -249,7 +249,7 @@ Ice::LoggerI::write(const string& message, bool indent) // to Windows console. When _convert is set to false we always output // UTF-8 encoded messages. // - fprintf_s(stderr, "%s\n", IceUtil::nativeToUTF8(s, _converter).c_str()); + fprintf_s(stderr, "%s\n", nativeToUTF8(s, _converter).c_str()); fflush(stderr); } else @@ -257,7 +257,7 @@ Ice::LoggerI::write(const string& message, bool indent) try { // Convert message to UTF-8 - string u8s = IceUtil::nativeToUTF8(s, _converter); + string u8s = nativeToUTF8(s, _converter); // Then from UTF-8 to console CP string consoleString; diff --git a/cpp/src/Ice/LoggerI.h b/cpp/src/Ice/LoggerI.h index 580371a9f83..3ab62255d34 100644 --- a/cpp/src/Ice/LoggerI.h +++ b/cpp/src/Ice/LoggerI.h @@ -11,7 +11,7 @@ #define ICE_LOGGER_I_H #include <Ice/Logger.h> -#include <IceUtil/StringConverter.h> +#include <Ice/StringConverter.h> #include <fstream> namespace Ice @@ -22,7 +22,7 @@ class LoggerI : public Logger public: LoggerI(const std::string&, const std::string&, bool convert = true, - const IceUtil::StringConverterPtr& converter = 0, std::size_t sizeMax = 0); + const StringConverterPtr& converter = 0, std::size_t sizeMax = 0); ~LoggerI(); virtual void print(const std::string&); @@ -39,7 +39,7 @@ private: const std::string _prefix; std::string _formattedPrefix; const bool _convert; - const IceUtil::StringConverterPtr _converter; + const StringConverterPtr _converter; std::ofstream _out; std::string _file; @@ -51,7 +51,7 @@ private: // IceUtil::Time _nextRetry; #if defined(_WIN32) && !defined(ICE_OS_WINRT) - const IceUtil::StringConverterPtr _consoleConverter; + const StringConverterPtr _consoleConverter; #endif }; diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp index 09688766350..d46e3ab195f 100755 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -21,7 +21,7 @@ #include <Ice/Network.h> #include <Ice/NetworkProxy.h> #include <IceUtil/StringUtil.h> -#include <IceUtil/StringConverter.h> +#include <Ice/StringConverter.h> #include <Ice/LocalException.h> #include <Ice/ProtocolInstance.h> // For setTcpBufSize #include <Ice/Properties.h> // For setTcpBufSize @@ -584,7 +584,7 @@ getInterfaceIndex(const string& name) // Don't need to pass a wide string converter as the wide string // come from Windows API. // - if(IceUtil::wstringToString(paddrs->FriendlyName, IceUtil::getProcessStringConverter()) == name) + if(wstringToString(paddrs->FriendlyName, getProcessStringConverter()) == name) { index = paddrs->Ipv6IfIndex; break; @@ -728,7 +728,7 @@ getInterfaceAddress(const string& name) // Don't need to pass a wide string converter as the wide string come // from Windows API. // - if(IceUtil::wstringToString(paddrs->FriendlyName, IceUtil::getProcessStringConverter()) == name) + if(wstringToString(paddrs->FriendlyName, getProcessStringConverter()) == name) { struct sockaddr_in addrin; memcpy(&addrin, paddrs->FirstUnicastAddress->Address.lpSockaddr, @@ -979,16 +979,16 @@ IceInternal::getAddresses(const string& host, int port, ProtocolSupport, Ice::En // to Windows API. // addr.host = ref new HostName(ref new String( - IceUtil::stringToWstring(host, - IceUtil::getProcessStringConverter()).c_str())); + stringToWstring(host, + getProcessStringConverter()).c_str())); } stringstream os; os << port; // // Don't need to use any string converter here as the port number use just - // ACII characters. + // ASCII characters. // - addr.port = ref new String(IceUtil::stringToWstring(os.str()).c_str()); + addr.port = ref new String(stringToWstring(os.str()).c_str()); result.push_back(addr); return result; } @@ -1156,7 +1156,7 @@ IceInternal::getAddressForServer(const string& host, int port, ProtocolSupport p // Don't need to use any string converter here as the port number use just // ASCII characters. // - addr.port = ref new String(IceUtil::stringToWstring(os.str()).c_str()); + addr.port = ref new String(stringToWstring(os.str()).c_str()); addr.host = nullptr; // Equivalent of inaddr_any, see doBind implementation. #else memset(&addr.saStorage, 0, sizeof(sockaddr_storage)); @@ -1603,8 +1603,8 @@ IceInternal::getHostsForEndpointExpand(const string& host, ProtocolSupport proto HostName^ h = it->Current; if(h->IPInformation != nullptr && h->IPInformation->NetworkAdapter != nullptr) { - hosts.push_back(IceUtil::wstringToString(h->CanonicalName->Data(), - IceUtil::getProcessStringConverter())); + hosts.push_back(wstringToString(h->CanonicalName->Data(), + getProcessStringConverter())); } } if(includeLoopback) @@ -1672,7 +1672,7 @@ IceInternal::inetAddrToString(const Address& ss) // Don't need to pass a wide string converter as the wide string come // from Windows API. // - return IceUtil::wstringToString(ss.host->RawName->Data(), IceUtil::getProcessStringConverter()); + return wstringToString(ss.host->RawName->Data(), getProcessStringConverter()); } #endif } @@ -1698,7 +1698,7 @@ IceInternal::getPort(const Address& addr) // // Don't need to use any string converter here as the port number use just ASCII characters. // - if(addr.port == nullptr || !IceUtilInternal::stringToInt64(IceUtil::wstringToString(addr.port->Data()), port)) + if(addr.port == nullptr || !IceUtilInternal::stringToInt64(wstringToString(addr.port->Data()), port)) { return -1; } @@ -1724,9 +1724,9 @@ IceInternal::setPort(Address& addr, int port) os << port; // // Don't need to use any string converter here as the port number use just - // ACII characters. + // ASCII characters. // - addr.port = ref new String(IceUtil::stringToWstring(os.str()).c_str()); + addr.port = ref new String(stringToWstring(os.str()).c_str()); #endif } @@ -1751,7 +1751,7 @@ IceInternal::isMulticast(const Address& addr) // Don't need to use string converters here, this is just to do a local // comparison to find if the address is multicast. // - string host = IceUtil::wstringToString(addr.host->RawName->Data()); + string host = wstringToString(addr.host->RawName->Data()); string ip = IceUtilInternal::toUpper(host); vector<string> tokens; IceUtilInternal::splitString(ip, ".", tokens); diff --git a/cpp/src/Ice/OutputStream.cpp b/cpp/src/Ice/OutputStream.cpp index 653b8e39adb..45d649131fa 100644 --- a/cpp/src/Ice/OutputStream.cpp +++ b/cpp/src/Ice/OutputStream.cpp @@ -20,7 +20,6 @@ #include <Ice/TraceUtil.h> #include <Ice/LoggerUtil.h> #include <Ice/SlicedData.h> -#include <IceUtil/StringConverter.h> #include <iterator> using namespace std; @@ -153,7 +152,7 @@ Ice::OutputStream::clear() } void -Ice::OutputStream::setStringConverters(const IceUtil::StringConverterPtr& sc, const IceUtil::WstringConverterPtr& wsc) +Ice::OutputStream::setStringConverters(const StringConverterPtr& sc, const WstringConverterPtr& wsc) { _stringConverter = sc; _wstringConverter = wsc; diff --git a/cpp/src/Ice/PropertiesI.cpp b/cpp/src/Ice/PropertiesI.cpp index 51a5ae151e7..d348255cda5 100644 --- a/cpp/src/Ice/PropertiesI.cpp +++ b/cpp/src/Ice/PropertiesI.cpp @@ -303,7 +303,7 @@ Ice::PropertiesI::load(const std::string& file) if(file.find("HKLM\\") == 0) { HKEY iceKey; - const wstring keyName = IceUtil::stringToWstring(file, _converter).substr(5).c_str(); + const wstring keyName = stringToWstring(file, _converter).substr(5).c_str(); LONG err; if((err = RegOpenKeyExW(HKEY_LOCAL_MACHINE, keyName.c_str(), 0, KEY_QUERY_VALUE, &iceKey)) != ERROR_SUCCESS) { @@ -350,7 +350,7 @@ Ice::PropertiesI::load(const std::string& file) getProcessLogger()->warning(os.str()); continue; } - string name = IceUtil::wstringToString( + string name = wstringToString( wstring(reinterpret_cast<wchar_t*>(&nameBuf[0]), nameBufSize), _converter); if(keyType != REG_SZ && keyType != REG_EXPAND_SZ) { @@ -364,7 +364,7 @@ Ice::PropertiesI::load(const std::string& file) wstring valueW = wstring(reinterpret_cast<wchar_t*>(&dataBuf[0]), (dataBufSize / sizeof(wchar_t)) - 1); if(keyType == REG_SZ) { - value = IceUtil::wstringToString(valueW, _converter); + value = wstringToString(valueW, _converter); } else // keyType == REG_EXPAND_SZ { @@ -384,7 +384,7 @@ Ice::PropertiesI::load(const std::string& file) continue; } } - value = IceUtil::wstringToString(wstring(&expandedValue[0], sz -1), _converter); + value = wstringToString(wstring(&expandedValue[0], sz -1), _converter); } setProperty(name, value); } @@ -460,12 +460,12 @@ Ice::PropertiesI::PropertiesI(const PropertiesI* p) : { } -Ice::PropertiesI::PropertiesI(const IceUtil::StringConverterPtr& converter) : +Ice::PropertiesI::PropertiesI(const StringConverterPtr& converter) : _converter(converter) { } -Ice::PropertiesI::PropertiesI(StringSeq& args, const PropertiesPtr& defaults, const IceUtil::StringConverterPtr& converter) : +Ice::PropertiesI::PropertiesI(StringSeq& args, const PropertiesPtr& defaults, const StringConverterPtr& converter) : _converter(converter) { if(defaults != 0) @@ -537,7 +537,7 @@ Ice::PropertiesI::PropertiesI(StringSeq& args, const PropertiesPtr& defaults, co } void -Ice::PropertiesI::parseLine(const string& line, const IceUtil::StringConverterPtr& converter) +Ice::PropertiesI::parseLine(const string& line, const StringConverterPtr& converter) { string key; string value; @@ -702,8 +702,8 @@ Ice::PropertiesI::parseLine(const string& line, const IceUtil::StringConverterPt return; } - key = IceUtil::UTF8ToNative(key, converter); - value = IceUtil::UTF8ToNative(value, converter); + key = UTF8ToNative(key, converter); + value = UTF8ToNative(value, converter); setProperty(key, value); } @@ -728,7 +728,7 @@ Ice::PropertiesI::loadConfig() } if(ret > 0) { - value = IceUtil::wstringToString(wstring(&v[0], ret), _converter); + value = wstringToString(wstring(&v[0], ret), _converter); } else { diff --git a/cpp/src/Ice/PropertiesI.h b/cpp/src/Ice/PropertiesI.h index 592c564ed05..cbaaaa5e9a6 100644 --- a/cpp/src/Ice/PropertiesI.h +++ b/cpp/src/Ice/PropertiesI.h @@ -12,7 +12,7 @@ #include <IceUtil/Mutex.h> #include <Ice/Properties.h> -#include <IceUtil/StringConverter.h> +#include <Ice/StringConverter.h> #include <set> @@ -44,14 +44,15 @@ public: PropertiesI(const PropertiesI*); private: - PropertiesI(const IceUtil::StringConverterPtr&); - PropertiesI(StringSeq&, const PropertiesPtr&, const IceUtil::StringConverterPtr&); + + PropertiesI(const StringConverterPtr&); + PropertiesI(StringSeq&, const PropertiesPtr&, const StringConverterPtr&); friend ICE_API PropertiesPtr createProperties(); friend ICE_API PropertiesPtr createProperties(StringSeq&, const PropertiesPtr&); friend ICE_API PropertiesPtr createProperties(int&, char*[], const PropertiesPtr&); - void parseLine(const std::string&, const IceUtil::StringConverterPtr&); + void parseLine(const std::string&, const StringConverterPtr&); void loadConfig(); @@ -72,7 +73,7 @@ private: bool used; }; std::map<std::string, PropertyValue> _properties; - const IceUtil::StringConverterPtr _converter; + const StringConverterPtr _converter; }; } diff --git a/cpp/src/Ice/Service.cpp b/cpp/src/Ice/Service.cpp index b739818e2cd..e9241223c4a 100644 --- a/cpp/src/Ice/Service.cpp +++ b/cpp/src/Ice/Service.cpp @@ -14,7 +14,7 @@ #include <IceUtil/Mutex.h> #include <IceUtil/ArgVector.h> #include <IceUtil/FileUtil.h> -#include <IceUtil/StringConverter.h> +#include <Ice/StringConverter.h> #include <Ice/Service.h> #include <Ice/LoggerI.h> #include <Ice/Initialize.h> @@ -209,14 +209,14 @@ class SMEventLoggerI : public SMEventLogger { public: - SMEventLoggerI(const string& source, const IceUtil::StringConverterPtr& stringConverter) : + SMEventLoggerI(const string& source, const StringConverterPtr& stringConverter) : _stringConverter(stringConverter) { // // Don't need to use a wide string converter as the wide string is passed // to Windows API. // - _source = RegisterEventSourceW(0, IceUtil::stringToWstring(mangleSource(source), _stringConverter).c_str()); + _source = RegisterEventSourceW(0, stringToWstring(mangleSource(source), _stringConverter).c_str()); if(_source == 0) { SyscallException ex(__FILE__, __LINE__); @@ -232,7 +232,7 @@ public: } static void - addKeys(const string& source, const IceUtil::StringConverterPtr& stringConverter) + addKeys(const string& source, const StringConverterPtr& stringConverter) { HKEY hKey; DWORD d; @@ -241,7 +241,7 @@ public: // to Windows API. // LONG err = RegCreateKeyExW(HKEY_LOCAL_MACHINE, - IceUtil::stringToWstring(createKey(source), stringConverter).c_str(), + stringToWstring(createKey(source), stringConverter).c_str(), 0, const_cast<wchar_t*>(L"REG_SZ"), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, &d); if(err != ERROR_SUCCESS) @@ -294,14 +294,14 @@ public: } static void - removeKeys(const string& source, const IceUtil::StringConverterPtr& stringConverter) + removeKeys(const string& source, const StringConverterPtr& stringConverter) { // // Don't need to use a wide string converter as the wide string is passed // to Windows API. // LONG err = RegDeleteKeyW(HKEY_LOCAL_MACHINE, - IceUtil::stringToWstring(createKey(source), stringConverter).c_str()); + stringToWstring(createKey(source), stringConverter).c_str()); if(err != ERROR_SUCCESS) { SyscallException ex(__FILE__, __LINE__); @@ -330,7 +330,7 @@ public: // Don't need to use a wide string converter as the wide string is passed // to Windows API. // - wstring msg = IceUtil::stringToWstring(message, _stringConverter); + wstring msg = stringToWstring(message, _stringConverter); const wchar_t* messages[1]; messages[0] = msg.c_str(); // @@ -368,7 +368,7 @@ public: // Don't need to use a wide string converter as the wide string is passed // to Windows API. // - wstring msg = IceUtil::stringToWstring(s, _stringConverter); + wstring msg = stringToWstring(s, _stringConverter); const wchar_t* messages[1]; messages[0] = msg.c_str(); // @@ -398,7 +398,7 @@ public: // Don't need to use a wide string converter as the wide string is passed // to Windows API. // - wstring msg = IceUtil::stringToWstring(message, _stringConverter); + wstring msg = stringToWstring(message, _stringConverter); const wchar_t* messages[1]; messages[0] = msg.c_str(); // @@ -428,7 +428,7 @@ public: // Don't need to use a wide string converter as the wide string is passed // to Windows API. // - wstring msg = IceUtil::stringToWstring(message, _stringConverter); + wstring msg = stringToWstring(message, _stringConverter); const wchar_t* messages[1]; messages[0] = msg.c_str(); // @@ -471,7 +471,7 @@ private: return "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\" + mangleSource(name); } - IceUtil::StringConverterPtr _stringConverter; + StringConverterPtr _stringConverter; HANDLE _source; static HMODULE _module; }; @@ -567,7 +567,7 @@ Ice::Service::main(int& argc, char* argv[], const InitializationData& initializa string name; string eventLogSource; int idx = 1; - const IceUtil::StringConverterPtr stringConverter = IceUtil::getProcessStringConverter(); + const StringConverterPtr stringConverter = getProcessStringConverter(); while(idx < argc) { if(strcmp(argv[idx], "--service") == 0) @@ -719,7 +719,7 @@ Ice::Service::main(int& argc, char* argv[], const InitializationData& initializa initData.properties->getProperty("Ice.StdErr").empty(); _logger = ICE_MAKE_SHARED(LoggerI, initData.properties->getProperty("Ice.ProgramName"), "", convert, - IceUtil::getProcessStringConverter()); + getProcessStringConverter()); setProcessLogger(_logger); } } @@ -1106,7 +1106,7 @@ Ice::Service::runService(int argc, char* argv[], const InitializationData& initD SERVICE_TABLE_ENTRYW ste[] = { { const_cast<wchar_t*>( - IceUtil::stringToWstring(_name, IceUtil::getProcessStringConverter()).c_str()), + stringToWstring(_name, getProcessStringConverter()).c_str()), Ice_Service_ServiceMain }, { 0, 0 }, }; @@ -1287,14 +1287,14 @@ Ice::Service::serviceMain(int argc, wchar_t* argv[]) // // Merge the executable's arguments with the service's arguments. // - const IceUtil::StringConverterPtr converter(IceUtil::getProcessStringConverter()); + const StringConverterPtr converter(getProcessStringConverter()); // // Don't need to pass a wide string converter in the bellow argv conversions // as argv come from Windows API. // char** args = new char*[_serviceArgs.size() + argc]; - args[0] = const_cast<char*>(IceUtil::wstringToString(argv[0], converter).c_str()); + args[0] = const_cast<char*>(wstringToString(argv[0], converter).c_str()); int i = 1; for(vector<string>::iterator p = _serviceArgs.begin(); p != _serviceArgs.end(); ++p) { @@ -1302,7 +1302,7 @@ Ice::Service::serviceMain(int argc, wchar_t* argv[]) } for(int j = 1; j < argc; ++j) { - args[i++] = const_cast<char*>(IceUtil::wstringToString(argv[j], converter).c_str()); + args[i++] = const_cast<char*>(wstringToString(argv[j], converter).c_str()); } argc += static_cast<int>(_serviceArgs.size()); diff --git a/cpp/src/Ice/StreamSocket.cpp b/cpp/src/Ice/StreamSocket.cpp index b0964507277..7a405c30a3d 100755 --- a/cpp/src/Ice/StreamSocket.cpp +++ b/cpp/src/Ice/StreamSocket.cpp @@ -106,7 +106,7 @@ StreamSocket::connect(Buffer& readBuffer, Buffer& writeBuffer) // Windows API. // const Address& addr = _proxy ? _proxy->getAddress() : _addr; - ex.host = IceUtil::wstringToString(addr.host->RawName->Data(), IceUtil::getProcessStringConverter()); + ex.host = wstringToString(addr.host->RawName->Data(), Ice::getProcessStringConverter()); throw; } } @@ -553,7 +553,7 @@ StreamSocket::startWrite(Buffer& buf) // Don't need to pass a wide string converter as the wide string come from // Windows API. // - ex.host = IceUtil::wstringToString(addr.host->RawName->Data(), IceUtil::getProcessStringConverter()); + ex.host = wstringToString(addr.host->RawName->Data(), Ice::getProcessStringConverter()); throw; } return false; diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index ea2e18d99c3..4e9a5735835 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -19,7 +19,7 @@ #include <Ice/TraceLevels.h> #if defined(ICE_OS_WINRT) -# include <IceUtil/StringConverter.h> +# include <Ice/StringConverter.h> #endif using namespace std; @@ -863,7 +863,7 @@ IceInternal::ThreadPool::run(const EventHandlerThreadPtr& thread) // Error out(_instance->initializationData().logger); out << "exception in `" << _prefix << "':\n" - << IceUtil::wstringToString(ex->Message->Data(), _instance->getStringConverter()) + << wstringToString(ex->Message->Data(), _instance->getStringConverter()) << "\nevent handler: " << current._handler->toString(); } #endif diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp index c6a6b6352f7..aac82cf874d 100755 --- a/cpp/src/Ice/UdpTransceiver.cpp +++ b/cpp/src/Ice/UdpTransceiver.cpp @@ -82,7 +82,7 @@ IceInternal::UdpTransceiver::initialize(Buffer& /*readBuffer*/, Buffer& /*writeB } catch(Ice::DNSException& ex) { - ex.host = IceUtil::wstringToString(_addr.host->RawName->Data(), IceUtil::getProcessStringConverter()); + ex.host = wstringToString(_addr.host->RawName->Data(), Ice::getProcessStringConverter()); throw; } } diff --git a/cpp/src/Ice/WindowsStringConverter.cpp b/cpp/src/Ice/WindowsStringConverter.cpp new file mode 100644 index 00000000000..6ecd6dd2490 --- /dev/null +++ b/cpp/src/Ice/WindowsStringConverter.cpp @@ -0,0 +1,148 @@ +// ********************************************************************** +// +// 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. +// +// ********************************************************************** + +#include <Ice/StringConverter.h> + +#ifdef _WIN32 + +#include <IceUtil/StringUtil.h> + + +using namespace Ice; +using namespace std; + +namespace +{ +// +// Converts to/from UTF-8 using MultiByteToWideChar and WideCharToMultiByte +// +class WindowsStringConverter : public StringConverter +{ +public: + + explicit WindowsStringConverter(unsigned int); + + virtual Byte* toUTF8(const char*, const char*, UTF8Buffer&) const; + + virtual void fromUTF8(const Byte*, const Byte*, string& target) const; + +private: + unsigned int _cp; + WstringConverterPtr _unicodeConverter; + +}; + +WindowsStringConverter::WindowsStringConverter(unsigned int cp) : + _cp(cp), + _unicodeConverter(createUnicodeWstringConverter()) +{ +} + +Byte* +WindowsStringConverter::toUTF8(const char* sourceStart, const char* sourceEnd, UTF8Buffer& buffer) const +{ + // + // First convert to UTF-16 + // + int sourceSize = static_cast<int>(sourceEnd - sourceStart); + if(sourceSize == 0) + { + return buffer.getMoreBytes(1, 0); + } + + int writtenWchar = 0; + wstring wbuffer; + + // + // The following code pages doesn't support MB_ERR_INVALID_CHARS flag + // see http://msdn.microsoft.com/en-us/library/windows/desktop/dd319072(v=vs.85).aspx + // + DWORD flags = + (_cp == 50220 || _cp == 50221 || _cp == 50222 || + _cp == 50225 || _cp == 50227 || _cp == 50229 || + _cp == 65000 || _cp == 42 || (_cp >= 57002 && _cp <= 57011)) ? 0 : MB_ERR_INVALID_CHARS; + + do + { + wbuffer.resize(wbuffer.size() == 0 ? sourceSize + 2 : 2 * wbuffer.size()); + writtenWchar = MultiByteToWideChar(_cp, flags, sourceStart, sourceSize, + const_cast<wchar_t*>(wbuffer.data()), static_cast<int>(wbuffer.size())); + } while(writtenWchar == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER); + + if(writtenWchar == 0) + { + throw IllegalConversionException(__FILE__, __LINE__, IceUtilInternal::lastErrorToString()); + } + + wbuffer.resize(static_cast<size_t>(writtenWchar)); + + // + // Then convert this UTF-16 wbuffer into UTF-8 + // + return _unicodeConverter->toUTF8(wbuffer.data(), wbuffer.data() + wbuffer.size(), buffer); +} + +void +WindowsStringConverter::fromUTF8(const Byte* sourceStart, const Byte* sourceEnd, string& target) const +{ + if(sourceStart == sourceEnd) + { + target = ""; + return; + } + + if(_cp == CP_UTF8) + { + string tmp(reinterpret_cast<const char*>(sourceStart), sourceEnd - sourceStart); + tmp.swap(target); + return; + } + + // + // First convert to wstring (UTF-16) + // + wstring wtarget; + _unicodeConverter->fromUTF8(sourceStart, sourceEnd, wtarget); + + // + // WC_ERR_INVALID_CHARS conversion flag is only supported with 65001 (UTF-8) and + // 54936 (GB18030 Simplified Chinese) + // + DWORD flags = (_cp == 65001 || _cp == 54936) ? WC_ERR_INVALID_CHARS : 0; + + // + // And then to a multi-byte narrow string + // + int writtenChar = -1; + do + { + target.resize(writtenChar == -1 ? + std::max<size_t>(sourceEnd - sourceStart + 2, target.size()) : + 2 * target.size()); + + writtenChar = WideCharToMultiByte(_cp, flags, wtarget.data(), static_cast<int>(wtarget.size()), + const_cast<char*>(target.data()), static_cast<int>(target.size()), + 0, 0); + } while(writtenChar == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER); + + if(writtenChar == 0) + { + throw IllegalConversionException(__FILE__, __LINE__, IceUtilInternal::lastErrorToString()); + } + + target.resize(static_cast<size_t>(writtenChar)); +} +} + +StringConverterPtr +Ice::createWindowsStringConverter(unsigned int cp) +{ + return ICE_MAKE_SHARED(WindowsStringConverter, cp); +} +#endif diff --git a/cpp/src/Ice/msbuild/iceuwp++11/iceuwp++11.vcxproj b/cpp/src/Ice/msbuild/iceuwp++11/iceuwp++11.vcxproj index 68b41ffea80..ffbb4f1a54a 100644 --- a/cpp/src/Ice/msbuild/iceuwp++11/iceuwp++11.vcxproj +++ b/cpp/src/Ice/msbuild/iceuwp++11/iceuwp++11.vcxproj @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|ARM"> @@ -146,6 +146,7 @@ <ClCompile Include="..\..\SHA1.cpp" /> <ClCompile Include="..\..\..\IceUtil\Shared.cpp" /> <ClCompile Include="..\..\..\IceUtil\StringConverter.cpp" /> + <ClCompile Include="..\..\WindowsStringConverter.cpp" /> <ClCompile Include="..\..\..\IceUtil\StringUtil.cpp" /> <ClCompile Include="..\..\StreamSocket.cpp" /> <ClCompile Include="..\..\Thread.cpp" /> @@ -3567,4 +3568,4 @@ <Import Project="$(IceBuilderCppTargets)" Condition="Exists('$(IceBuilderCppTargets)')" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> -</Project>
\ No newline at end of file +</Project> diff --git a/cpp/src/IceGrid/Activator.cpp b/cpp/src/IceGrid/Activator.cpp index cdb5ed64c03..afcca9685e5 100644 --- a/cpp/src/IceGrid/Activator.cpp +++ b/cpp/src/IceGrid/Activator.cpp @@ -389,7 +389,7 @@ Activator::activate(const string& name, // IceGrid doesn't support to use string converters, so don't need to use // any string converter in wstringToString conversions. // - if(SearchPathW(NULL, IceUtil::stringToWstring(path).c_str(), ext.c_str(), _MAX_PATH, absbuf, &fPart) == 0) + if(SearchPathW(NULL, stringToWstring(path).c_str(), ext.c_str(), _MAX_PATH, absbuf, &fPart) == 0) { if(_traceLevels->activator > 0) { @@ -398,7 +398,7 @@ Activator::activate(const string& name, } throw string("Couldn't find `" + path + "' executable."); } - path = IceUtil::wstringToString(absbuf); + path = wstringToString(absbuf); } else if(!pwd.empty()) { @@ -416,7 +416,7 @@ Activator::activate(const string& name, if(!pwd.empty()) { wchar_t absbuf[_MAX_PATH]; - if(_wfullpath(absbuf, IceUtil::stringToWstring(pwd).c_str(), _MAX_PATH) == NULL) + if(_wfullpath(absbuf, stringToWstring(pwd).c_str(), _MAX_PATH) == NULL) { if(_traceLevels->activator > 0) { @@ -425,7 +425,7 @@ Activator::activate(const string& name, } throw string("The server working directory path `" + pwd + "' can't be converted into an absolute path."); } - pwd = IceUtil::wstringToString(absbuf); + pwd = wstringToString(absbuf); } #endif @@ -504,13 +504,13 @@ Activator::activate(const string& name, // IceGrid doesn't support to use string converters, so don't need to use // any string converter in stringToWstring conversions. // - wstring wpwd = IceUtil::stringToWstring(pwd); + wstring wpwd = stringToWstring(pwd); const wchar_t* dir = !wpwd.empty() ? wpwd.c_str() : NULL; // // Make a copy of the command line. // - wchar_t* cmdbuf = _wcsdup(IceUtil::stringToWstring(cmd).c_str()); + wchar_t* cmdbuf = _wcsdup(stringToWstring(cmd).c_str()); // // Create the environment block for the child process. We start with the environment @@ -554,7 +554,7 @@ Activator::activate(const string& name, // IceGrid doesn't support to use string converters, so don't need to use // any string converter in stringToWstring conversions. // - wstring s = IceUtil::stringToWstring(*p); + wstring s = stringToWstring(*p); wstring::size_type pos = s.find(L'='); if(pos != wstring::npos) { diff --git a/cpp/src/IceGrid/IceGridNode.cpp b/cpp/src/IceGrid/IceGridNode.cpp index 63b7a20a755..bae445fa879 100644 --- a/cpp/src/IceGrid/IceGridNode.cpp +++ b/cpp/src/IceGrid/IceGridNode.cpp @@ -100,7 +100,7 @@ private: void setNoIndexingAttribute(const string& pa) { - wstring path = IceUtil::stringToWstring(pa); + wstring path = Ice::stringToWstring(pa); DWORD attrs = GetFileAttributesW(path.c_str()); if(attrs == INVALID_FILE_ATTRIBUTES) { diff --git a/cpp/src/IceGrid/Parser.cpp b/cpp/src/IceGrid/Parser.cpp index db58e8f242a..30f80de48c7 100644 --- a/cpp/src/IceGrid/Parser.cpp +++ b/cpp/src/IceGrid/Parser.cpp @@ -246,7 +246,7 @@ const char* _commandsHelp[][3] = { int loggerCallbackCount = 0; #ifdef _WIN32 -IceUtil::StringConverterPtr windowsConsoleConverter = 0; +Ice::StringConverterPtr windowsConsoleConverter = 0; #endif void outputNewline() @@ -2923,7 +2923,7 @@ Parser::Parser(const CommunicatorPtr& communicator, #ifdef _WIN32 if(!windowsConsoleConverter) { - windowsConsoleConverter = IceUtil::createWindowsStringConverter(GetConsoleOutputCP()); + windowsConsoleConverter = Ice::createWindowsStringConverter(GetConsoleOutputCP()); } #endif } diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp index d8ba54d1095..1ac85f57a0d 100644 --- a/cpp/src/IceGrid/ServerI.cpp +++ b/cpp/src/IceGrid/ServerI.cpp @@ -392,9 +392,9 @@ struct EnvironmentEval : std::unary_function<string, string> break; } string variable = v.substr(beg + 1, end - beg - 1); - DWORD ret = GetEnvironmentVariableW(IceUtil::stringToWstring(variable).c_str(), &buf[0], + DWORD ret = GetEnvironmentVariableW(Ice::stringToWstring(variable).c_str(), &buf[0], static_cast<DWORD>(buf.size())); - string valstr = (ret > 0 && ret < buf.size()) ? IceUtil::wstringToString(&buf[0]) : string(""); + string valstr = (ret > 0 && ret < buf.size()) ? Ice::wstringToString(&buf[0]) : string(""); v.replace(beg, end - beg + 1, valstr); beg += valstr.size(); } diff --git a/cpp/src/IcePatch2Lib/Util.cpp b/cpp/src/IcePatch2Lib/Util.cpp index 4e89aebc6a2..88798feaba5 100644 --- a/cpp/src/IcePatch2Lib/Util.cpp +++ b/cpp/src/IcePatch2Lib/Util.cpp @@ -469,7 +469,7 @@ IcePatch2Internal::readDirectory(const string& pa) while(true) { - string name = IceUtil::wstringToString(data.name); + string name = wstringToString(data.name); assert(!name.empty()); if(name != ".." && name != ".") diff --git a/cpp/src/IceSSL/Certificate.cpp b/cpp/src/IceSSL/Certificate.cpp index 1d1a545e7a4..92374649035 100755 --- a/cpp/src/IceSSL/Certificate.cpp +++ b/cpp/src/IceSSL/Certificate.cpp @@ -512,12 +512,12 @@ certificateAltNames(CERT_INFO* certInfo, LPCSTR altNameOID) { case CERT_ALT_NAME_RFC822_NAME: { - altNames.push_back(make_pair(AltNameEmail, IceUtil::wstringToString(entry->pwszRfc822Name))); + altNames.push_back(make_pair(AltNameEmail, wstringToString(entry->pwszRfc822Name))); break; } case CERT_ALT_NAME_DNS_NAME: { - altNames.push_back(make_pair(AltNameDNS, IceUtil::wstringToString(entry->pwszDNSName))); + altNames.push_back(make_pair(AltNameDNS, wstringToString(entry->pwszDNSName))); break; } case CERT_ALT_NAME_DIRECTORY_NAME: @@ -527,7 +527,7 @@ certificateAltNames(CERT_INFO* certInfo, LPCSTR altNameOID) } case CERT_ALT_NAME_URL: { - altNames.push_back(make_pair(AltNameURL, IceUtil::wstringToString(entry->pwszURL))); + altNames.push_back(make_pair(AltNameURL, wstringToString(entry->pwszURL))); break; } case CERT_ALT_NAME_IP_ADDRESS: @@ -576,19 +576,19 @@ certificateAltNames(Windows::Security::Cryptography::Certificates::SubjectAltern vector<pair<int, string> > altNames; for (auto iter = subAltNames->EmailName->First(); iter->HasCurrent; iter->MoveNext()) { - altNames.push_back(make_pair(AltNameEmail, IceUtil::wstringToString(iter->Current->Data()))); + altNames.push_back(make_pair(AltNameEmail, wstringToString(iter->Current->Data()))); } for (auto iter = subAltNames->DnsName->First(); iter->HasCurrent; iter->MoveNext()) { - altNames.push_back(make_pair(AltNameDNS, IceUtil::wstringToString(iter->Current->Data()))); + altNames.push_back(make_pair(AltNameDNS, wstringToString(iter->Current->Data()))); } for (auto iter = subAltNames->Url->First(); iter->HasCurrent; iter->MoveNext()) { - altNames.push_back(make_pair(AltNameURL, IceUtil::wstringToString(iter->Current->Data()))); + altNames.push_back(make_pair(AltNameURL, wstringToString(iter->Current->Data()))); } for (auto iter = subAltNames->IPAddress->First(); iter->HasCurrent; iter->MoveNext()) { - altNames.push_back(make_pair(AltNAmeIP, IceUtil::wstringToString(iter->Current->Data()))); + altNames.push_back(make_pair(AltNAmeIP, wstringToString(iter->Current->Data()))); } return altNames; } @@ -1542,7 +1542,7 @@ Certificate::getIssuerDN() const #elif defined(ICE_USE_OPENSSL) return DistinguishedName(RFC2253::parseStrict(convertX509NameToString(X509_get_issuer_name(_cert)))); #elif defined(ICE_OS_WINRT) - return DistinguishedName(IceUtil::wstringToString(_cert->Issuer->Data())); + return DistinguishedName(wstringToString(_cert->Issuer->Data())); #else # error "Unknown platform" #endif @@ -1588,7 +1588,7 @@ Certificate::getSubjectDN() const #elif defined(ICE_USE_OPENSSL) return DistinguishedName(RFC2253::parseStrict(convertX509NameToString(X509_get_subject_name(_cert)))); #elif defined(ICE_OS_WINRT) - return DistinguishedName(IceUtil::wstringToString(_cert->Subject->Data())); + return DistinguishedName(wstringToString(_cert->Subject->Data())); #else # error "Unknown platform" #endif diff --git a/cpp/src/IceSSL/OpenSSLEngine.cpp b/cpp/src/IceSSL/OpenSSLEngine.cpp index 04409461957..0a248126467 100644 --- a/cpp/src/IceSSL/OpenSSLEngine.cpp +++ b/cpp/src/IceSSL/OpenSSLEngine.cpp @@ -19,7 +19,6 @@ #include <Ice/LoggerUtil.h> #include <Ice/Properties.h> -#include <IceUtil/StringConverter.h> #include <IceUtil/StringUtil.h> #include <IceUtil/Mutex.h> #include <IceUtil/MutexPtrLock.h> diff --git a/cpp/src/IceSSL/SChannelEngine.cpp b/cpp/src/IceSSL/SChannelEngine.cpp index c8b2885909a..de509399d0b 100644 --- a/cpp/src/IceSSL/SChannelEngine.cpp +++ b/cpp/src/IceSSL/SChannelEngine.cpp @@ -395,7 +395,7 @@ SChannelEngine::initialize() do { string s = password(false); - store = PFXImportCertStore(&pfxBlob, stringToWstring(s).c_str(), importFlags); + store = PFXImportCertStore(&pfxBlob, Ice::stringToWstring(s).c_str(), importFlags); err = store ? 0 : GetLastError(); } while(err == ERROR_INVALID_PASSWORD && passwordPrompt && ++count < passwordRetryMax); @@ -537,7 +537,7 @@ SChannelEngine::initialize() // // Create a new RSA key set to store our key // - const wstring keySetName = stringToWstring(generateUUID()); + const wstring keySetName = Ice::stringToWstring(generateUUID()); HCRYPTPROV cryptProv = 0; DWORD contextFlags = CRYPT_NEWKEYSET; diff --git a/cpp/src/IceSSL/Util.cpp b/cpp/src/IceSSL/Util.cpp index 5dc8bcf4b42..d75d8da861a 100755 --- a/cpp/src/IceSSL/Util.cpp +++ b/cpp/src/IceSSL/Util.cpp @@ -1457,7 +1457,7 @@ IceSSL::findCertificates(const string& location, const string& name, const strin storeLoc = CERT_SYSTEM_STORE_LOCAL_MACHINE; } - HCERTSTORE store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, storeLoc, stringToWstring(name).c_str()); + HCERTSTORE store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, storeLoc, Ice::stringToWstring(name).c_str()); if(!store) { throw PluginInitializationException(__FILE__, __LINE__, "IceSSL: failed to open certificate store `" + name + @@ -1558,13 +1558,13 @@ IceSSL::findCertificates(const string& location, const string& name, const strin if(field == "SUBJECT" || field == "ISSUER") { - const wstring argW = stringToWstring(arg); + const wstring argW = Ice::stringToWstring(arg); DWORD findType = field == "SUBJECT" ? CERT_FIND_SUBJECT_STR : CERT_FIND_ISSUER_STR; addMatchingCertificates(store, tmpStore, findType, argW.c_str()); } else if(field == "SUBJECTDN" || field == "ISSUERDN") { - const wstring argW = stringToWstring(arg); + const wstring argW = Ice::stringToWstring(arg); DWORD flags[] = { CERT_OID_NAME_STR, CERT_OID_NAME_STR | CERT_NAME_STR_REVERSE_FLAG, diff --git a/cpp/src/IceUtil/FileUtil.cpp b/cpp/src/IceUtil/FileUtil.cpp index 0bb94620137..9da2b9bd3c5 100644 --- a/cpp/src/IceUtil/FileUtil.cpp +++ b/cpp/src/IceUtil/FileUtil.cpp @@ -101,7 +101,7 @@ bool IceUtilInternal::isEmptyDirectory(const string& path) { # ifdef _WIN32 - return PathIsDirectoryEmptyW(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str()); + return PathIsDirectoryEmptyW(stringToWstring(path, IceUtil::getProcessStringConverter()).c_str()); # else struct dirent* d; DIR* dir = opendir(path.c_str()); @@ -154,8 +154,8 @@ IceUtilInternal::freopen(const std::string& path, const std::string& mode, FILE* // to Windows API. // const IceUtil::StringConverterPtr converter = IceUtil::getProcessStringConverter(); - return _wfreopen(IceUtil::stringToWstring(path, converter).c_str(), - IceUtil::stringToWstring(mode, converter).c_str(), stream); + return _wfreopen(stringToWstring(path, converter).c_str(), + stringToWstring(mode, converter).c_str(), stream); # else return freopen(path.c_str(), mode.c_str(), stream); # endif @@ -174,13 +174,13 @@ IceUtilInternal::stat(const string& path, structstat* buffer) // Don't need to use a wide string converter, the wide string is directly passed // to Windows API. // - return _wstat(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), buffer); + return _wstat(stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), buffer); } int IceUtilInternal::remove(const string& path) { - return ::_wremove(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str()); + return ::_wremove(stringToWstring(path, IceUtil::getProcessStringConverter()).c_str()); } int @@ -191,8 +191,8 @@ IceUtilInternal::rename(const string& from, const string& to) // to Windows API. // const IceUtil::StringConverterPtr converter = IceUtil::getProcessStringConverter(); - return ::_wrename(IceUtil::stringToWstring(from, converter).c_str(), - IceUtil::stringToWstring(to, converter).c_str()); + return ::_wrename(stringToWstring(from, converter).c_str(), + stringToWstring(to, converter).c_str()); } int @@ -202,7 +202,7 @@ IceUtilInternal::rmdir(const string& path) // Don't need to use a wide string converter, the wide string is directly passed // to Windows API. // - return ::_wrmdir(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str()); + return ::_wrmdir(stringToWstring(path, IceUtil::getProcessStringConverter()).c_str()); } int @@ -212,7 +212,7 @@ IceUtilInternal::mkdir(const string& path, int) // Don't need to use a wide string converter, the wide string is directly passed // to Windows API. // - return ::_wmkdir(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str()); + return ::_wmkdir(stringToWstring(path, IceUtil::getProcessStringConverter()).c_str()); } FILE* @@ -223,8 +223,8 @@ IceUtilInternal::fopen(const string& path, const string& mode) // to Windows API. // const IceUtil::StringConverterPtr converter = IceUtil::getProcessStringConverter(); - return ::_wfopen(IceUtil::stringToWstring(path, converter).c_str(), - IceUtil::stringToWstring(mode, converter).c_str()); + return ::_wfopen(stringToWstring(path, converter).c_str(), + stringToWstring(mode, converter).c_str()); } int @@ -236,12 +236,12 @@ IceUtilInternal::open(const string& path, int flags) // if(flags & _O_CREAT) { - return ::_wopen(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), + return ::_wopen(stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), flags, _S_IREAD | _S_IWRITE); } else { - return ::_wopen(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), flags); + return ::_wopen(stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), flags); } } @@ -258,7 +258,7 @@ IceUtilInternal::getcwd(string& cwd) { return -1; } - cwd = IceUtil::wstringToString(cwdbuf, IceUtil::getProcessStringConverter()); + cwd = wstringToString(cwdbuf, IceUtil::getProcessStringConverter()); return 0; } #endif @@ -270,7 +270,7 @@ IceUtilInternal::unlink(const string& path) // Don't need to use a wide string converter, the wide string is directly passed // to Windows API. // - return _wunlink(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str()); + return _wunlink(stringToWstring(path, IceUtil::getProcessStringConverter()).c_str()); } int @@ -292,12 +292,12 @@ IceUtilInternal::FileLock::FileLock(const std::string& path) : // to Windows API. // #ifndef ICE_OS_WINRT - _fd = ::CreateFileW(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), + _fd = ::CreateFileW(stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); #else CREATEFILE2_EXTENDED_PARAMETERS params; params.dwFileAttributes = FILE_ATTRIBUTE_NORMAL; - _fd = ::CreateFile2(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), + _fd = ::CreateFile2(stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), GENERIC_WRITE, 0, OPEN_ALWAYS, ¶ms); #endif _path = path; @@ -348,7 +348,7 @@ IceUtilInternal::FileLock::~FileLock() wstring IceUtilInternal::streamFilename(const string& filename) { - return IceUtil::stringToWstring(filename, IceUtil::getProcessStringConverter()); + return stringToWstring(filename, IceUtil::getProcessStringConverter()); } #endif diff --git a/cpp/src/IceUtil/StringConverter.cpp b/cpp/src/IceUtil/StringConverter.cpp index f122084eb68..dc029626c4f 100644 --- a/cpp/src/IceUtil/StringConverter.cpp +++ b/cpp/src/IceUtil/StringConverter.cpp @@ -238,27 +238,6 @@ public: #endif -#ifdef _WIN32 - -// -// Converts to/from UTF-8 using MultiByteToWideChar and WideCharToMultiByte -// -class WindowsStringConverter : public StringConverter -{ -public: - - explicit WindowsStringConverter(unsigned int); - - virtual Byte* toUTF8(const char*, const char*, UTF8Buffer&) const; - - virtual void fromUTF8(const Byte*, const Byte*, string& target) const; - -private: - unsigned int _cp; -}; -#endif - - class Init { public: @@ -324,108 +303,6 @@ private: string _buffer; }; -#ifdef _WIN32 -WindowsStringConverter::WindowsStringConverter(unsigned int cp) : - _cp(cp) -{ -} - -Byte* -WindowsStringConverter::toUTF8(const char* sourceStart, const char* sourceEnd, UTF8Buffer& buffer) const -{ - // - // First convert to UTF-16 - // - int sourceSize = static_cast<int>(sourceEnd - sourceStart); - if(sourceSize == 0) - { - return buffer.getMoreBytes(1, 0); - } - - int writtenWchar = 0; - wstring wbuffer; - - // - // The following code pages doesn't support MB_ERR_INVALID_CHARS flag - // see http://msdn.microsoft.com/en-us/library/windows/desktop/dd319072(v=vs.85).aspx - // - DWORD flags = - (_cp == 50220 || _cp == 50221 || _cp == 50222 || - _cp == 50225 || _cp == 50227 || _cp == 50229 || - _cp == 65000 || _cp == 42 || (_cp >= 57002 && _cp <= 57011)) ? 0 : MB_ERR_INVALID_CHARS; - - do - { - wbuffer.resize(wbuffer.size() == 0 ? sourceSize + 2 : 2 * wbuffer.size()); - writtenWchar = MultiByteToWideChar(_cp, flags, sourceStart, sourceSize, - const_cast<wchar_t*>(wbuffer.data()), static_cast<int>(wbuffer.size())); - } while(writtenWchar == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER); - - if(writtenWchar == 0) - { - throw IllegalConversionException(__FILE__, __LINE__, IceUtilInternal::lastErrorToString()); - } - - wbuffer.resize(static_cast<size_t>(writtenWchar)); - - // - // Then convert this UTF-16 wbuffer into UTF-8 - // - return getUnicodeWstringConverter()->toUTF8(wbuffer.data(), wbuffer.data() + wbuffer.size(), buffer); -} - -void -WindowsStringConverter::fromUTF8(const Byte* sourceStart, const Byte* sourceEnd, string& target) const -{ - if(sourceStart == sourceEnd) - { - target = ""; - return; - } - - if(_cp == CP_UTF8) - { - string tmp(reinterpret_cast<const char*>(sourceStart), sourceEnd - sourceStart); - tmp.swap(target); - return; - } - - // - // First convert to wstring (UTF-16) - // - wstring wtarget; - getUnicodeWstringConverter()->fromUTF8(sourceStart, sourceEnd, wtarget); - - // - // WC_ERR_INVALID_CHARS conversion flag is only supported with 65001 (UTF-8) and - // 54936 (GB18030 Simplified Chinese) - // - DWORD flags = (_cp == 65001 || _cp == 54936) ? WC_ERR_INVALID_CHARS : 0; - - // - // And then to a multi-byte narrow string - // - int writtenChar = -1; - do - { - target.resize(writtenChar == -1 ? - std::max<size_t>(sourceEnd - sourceStart + 2, target.size()) : - 2 * target.size()); - - writtenChar = WideCharToMultiByte(_cp, flags, wtarget.data(), static_cast<int>(wtarget.size()), - const_cast<char*>(target.data()), static_cast<int>(target.size()), - 0, 0); - } while(writtenChar == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER); - - if(writtenChar == 0) - { - throw IllegalConversionException(__FILE__, __LINE__, IceUtilInternal::lastErrorToString()); - } - - target.resize(static_cast<size_t>(writtenChar)); -} -#endif - } IceUtil::UTF8Buffer::~UTF8Buffer() @@ -439,15 +316,6 @@ IceUtil::createUnicodeWstringConverter() return getUnicodeWstringConverter(); } -#ifdef _WIN32 -StringConverterPtr -IceUtil::createWindowsStringConverter(unsigned int cp) -{ - return ICE_MAKE_SHARED(WindowsStringConverter, cp); -} -#endif - - StringConverterPtr IceUtil::getProcessStringConverter() { diff --git a/cpp/src/IceUtil/UtilException.cpp b/cpp/src/IceUtil/UtilException.cpp index 50b5b7ce0f6..46873339daa 100644 --- a/cpp/src/IceUtil/UtilException.cpp +++ b/cpp/src/IceUtil/UtilException.cpp @@ -473,7 +473,7 @@ getStackTrace(const vector<void*>& stackFrames) if(ok) { #ifdef DBGHELP_TRANSLATE_TCHAR - s << IceUtil::wstringToString(symbol->Name, converter); + s << wstringToString(symbol->Name, converter); #else s << symbol->Name; #endif @@ -482,7 +482,7 @@ getStackTrace(const vector<void*>& stackFrames) { s << " at " #ifdef DBGHELP_TRANSLATE_TCHAR - << IceUtil::wstringToString(line.FileName, converter) + << wstringToString(line.FileName, converter) #else << line.FileName #endif @@ -885,44 +885,3 @@ IceUtil::OptionalNotSetException::ice_clone() const return new OptionalNotSetException(*this); } #endif - -#ifndef _WIN32 -IceUtil::IconvInitializationException::IconvInitializationException(const char* file, int line, const string& reason) : - ExceptionHelper<IconvInitializationException>(file, line), - _reason(reason) -{ -} - -#ifndef ICE_CPP11_COMPILER -IceUtil::IconvInitializationException::~IconvInitializationException() throw() -{ -} -#endif - -void -IceUtil::IconvInitializationException::ice_print(ostream& out) const -{ - Exception::ice_print(out); - out << ": " << _reason; -} - -string -IceUtil::IconvInitializationException::ice_id() const -{ - return "::IceUtil::IconvInitializationException"; -} - -#ifndef ICE_CPP11_MAPPING -IceUtil::IconvInitializationException* -IceUtil::IconvInitializationException::ice_clone() const -{ - return new IconvInitializationException(*this); -} -#endif - -string -IceUtil::IconvInitializationException::reason() const -{ - return _reason; -} -#endif diff --git a/cpp/src/iceserviceinstall/ServiceInstaller.cpp b/cpp/src/iceserviceinstall/ServiceInstaller.cpp index ee44f425cf3..d9b76c23dfe 100644 --- a/cpp/src/iceserviceinstall/ServiceInstaller.cpp +++ b/cpp/src/iceserviceinstall/ServiceInstaller.cpp @@ -275,18 +275,18 @@ IceServiceInstaller::install(const PropertiesPtr& properties) // SC_HANDLE service = CreateServiceW( scm, - IceUtil::stringToWstring(_serviceName).c_str(), - IceUtil::stringToWstring(displayName).c_str(), + stringToWstring(_serviceName).c_str(), + stringToWstring(displayName).c_str(), SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, autoStart ? SERVICE_AUTO_START : SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, - IceUtil::stringToWstring(command).c_str(), + stringToWstring(command).c_str(), 0, 0, - IceUtil::stringToWstring(deps).c_str(), - IceUtil::stringToWstring(_sidName).c_str(), - IceUtil::stringToWstring(password).c_str()); + stringToWstring(deps).c_str(), + stringToWstring(_sidName).c_str(), + stringToWstring(password).c_str()); if(service == 0) { @@ -298,7 +298,7 @@ IceServiceInstaller::install(const PropertiesPtr& properties) // // Set description // - wstring uDescription = IceUtil::stringToWstring(description); + wstring uDescription = stringToWstring(description); SERVICE_DESCRIPTIONW sd = { const_cast<wchar_t*>(uDescription.c_str()) }; if(!ChangeServiceConfig2W(service, SERVICE_CONFIG_DESCRIPTION, &sd)) @@ -327,7 +327,7 @@ IceServiceInstaller::uninstall() // We don't support to use a string converter with this tool, so don't need to // use string converters in calls to stringToWstring. // - SC_HANDLE service = OpenServiceW(scm, IceUtil::stringToWstring(_serviceName).c_str(), SERVICE_ALL_ACCESS); + SC_HANDLE service = OpenServiceW(scm, stringToWstring(_serviceName).c_str(), SERVICE_ALL_ACCESS); if(service == 0) { DWORD res = GetLastError(); @@ -449,7 +449,7 @@ IceServiceInstaller::initializeSid(const string& name) // use string converters in calls to stringToWstring. // SID_NAME_USE nameUse; - while(LookupAccountNameW(0, IceUtil::stringToWstring(name).c_str(), + while(LookupAccountNameW(0, stringToWstring(name).c_str(), _sidBuffer.data(), &sidSize, const_cast<wchar_t*>(domainName.data()), &domainNameSize, &nameUse) == false) { @@ -495,7 +495,7 @@ IceServiceInstaller::initializeSid(const string& name) throw "Could not retrieve full account name for " + name + ": " + IceUtilInternal::errorToString(res); } - _sidName = IceUtil::wstringToString(domainName) + "\\" + IceUtil::wstringToString(accountName); + _sidName = wstringToString(domainName) + "\\" + wstringToString(accountName); } if(_debug) @@ -503,7 +503,7 @@ IceServiceInstaller::initializeSid(const string& name) Trace trace(_communicator->getLogger(), "IceServiceInstaller"); wchar_t* sidString = 0; ConvertSidToStringSidW(_sid, &sidString); - trace << "SID: " << IceUtil::wstringToString(sidString) << "; "; + trace << "SID: " << wstringToString(sidString) << "; "; LocalFree(sidString); trace << "Full name: " << _sidName; } @@ -559,7 +559,7 @@ IceServiceInstaller::grantPermissions(const string& path, SE_OBJECT_TYPE type, b SECURITY_INFORMATION flags = DACL_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION; - DWORD res = GetNamedSecurityInfoW(const_cast<wchar_t*>(IceUtil::stringToWstring(path).c_str()), type, + DWORD res = GetNamedSecurityInfoW(const_cast<wchar_t*>(stringToWstring(path).c_str()), type, flags, 0, 0, &acl, 0, &sd); if(res != ERROR_SUCCESS) { @@ -665,7 +665,7 @@ IceServiceInstaller::grantPermissions(const string& path, SE_OBJECT_TYPE type, b throw "Could not modify ACL for " + path + ": " + IceUtilInternal::errorToString(res); } - res = SetNamedSecurityInfoW(const_cast<wchar_t*>(IceUtil::stringToWstring(path).c_str()), type, + res = SetNamedSecurityInfoW(const_cast<wchar_t*>(stringToWstring(path).c_str()), type, DACL_SECURITY_INFORMATION, 0, 0, newAcl, 0); if(res != ERROR_SUCCESS) { @@ -702,7 +702,7 @@ IceServiceInstaller::mkdir(const string& path) const // We don't support to use a string converter with this tool, so don't need to // use string converters in calls to stringToWstring. // - if(CreateDirectoryW(IceUtil::stringToWstring(path).c_str(), 0) == 0) + if(CreateDirectoryW(stringToWstring(path).c_str(), 0) == 0) { DWORD res = GetLastError(); if(res == ERROR_ALREADY_EXISTS) @@ -741,7 +741,7 @@ IceServiceInstaller::addLog(const string& log) const // We don't support to use a string converter with this tool, so don't need to // use string converters in calls to stringToWstring. // - LONG res = RegCreateKeyExW(HKEY_LOCAL_MACHINE, IceUtil::stringToWstring(createLog(log)).c_str(), 0, L"REG_SZ", + LONG res = RegCreateKeyExW(HKEY_LOCAL_MACHINE, stringToWstring(createLog(log)).c_str(), 0, L"REG_SZ", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &key, &disposition); if(res != ERROR_SUCCESS) @@ -763,7 +763,7 @@ IceServiceInstaller::removeLog(const string& log) const // We don't support to use a string converter with this tool, so don't need to // use string converters in calls to stringToWstring. // - LONG res = RegDeleteKeyW(HKEY_LOCAL_MACHINE, IceUtil::stringToWstring(createLog(log)).c_str()); + LONG res = RegDeleteKeyW(HKEY_LOCAL_MACHINE, stringToWstring(createLog(log)).c_str()); // // We get ERROR_ACCESS_DENIED when the log is shared by several sources @@ -783,7 +783,7 @@ IceServiceInstaller::addSource(const string& source, const string& log, const st // HKEY key = 0; DWORD disposition = 0; - LONG res = RegCreateKeyExW(HKEY_LOCAL_MACHINE, IceUtil::stringToWstring(createSource(source, log)).c_str(), + LONG res = RegCreateKeyExW(HKEY_LOCAL_MACHINE, stringToWstring(createSource(source, log)).c_str(), 0, L"REG_SZ", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &key, &disposition); if(res != ERROR_SUCCESS) { @@ -796,7 +796,7 @@ IceServiceInstaller::addSource(const string& source, const string& log, const st // DLL. // res = RegSetValueExW(key, L"EventMessageFile", 0, REG_EXPAND_SZ, - reinterpret_cast<const BYTE*>(IceUtil::stringToWstring(resourceFile).c_str()), + reinterpret_cast<const BYTE*>(stringToWstring(resourceFile).c_str()), static_cast<DWORD>(resourceFile.length() + 1) * sizeof(wchar_t)); if(res == ERROR_SUCCESS) @@ -857,8 +857,8 @@ IceServiceInstaller::removeSource(const string& source) const // use string converters in calls to stringToWstring. // LONG delRes = RegDeleteKeyW(HKEY_LOCAL_MACHINE, - IceUtil::stringToWstring(createSource(source, - IceUtil::wstringToString(subkey))).c_str()); + stringToWstring(createSource(source, + wstringToString(subkey))).c_str()); if(delRes == ERROR_SUCCESS) { res = RegCloseKey(key); @@ -866,7 +866,7 @@ IceServiceInstaller::removeSource(const string& source) const { throw "Could not close registry key handle: " + IceUtilInternal::errorToString(res); } - return IceUtil::wstringToString(subkey); + return wstringToString(subkey); } ++index; |