From 5c41870b1df650b874069095fab2d29e93c76d3f Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Fri, 16 May 2014 10:42:54 -0400 Subject: Renamed wnativeToNative/nativeToWnative to wstringToString/stringToWstring --- cpp/src/Ice/DynamicLibrary.cpp | 4 +- cpp/src/Ice/Exception.cpp | 8 +- cpp/src/Ice/Initialize.cpp | 2 +- cpp/src/Ice/Network.cpp | 26 +++--- cpp/src/Ice/PropertiesI.cpp | 12 +-- cpp/src/Ice/Service.cpp | 20 ++--- cpp/src/Ice/ThreadPool.cpp | 6 +- cpp/src/IceGrid/Activator.cpp | 22 ++--- cpp/src/IceGrid/IceGridNode.cpp | 6 +- cpp/src/IceGrid/ServerI.cpp | 4 +- cpp/src/IcePatch2/Calc.cpp | 1 - cpp/src/IcePatch2/FileServerI.cpp | 1 - cpp/src/IcePatch2Lib/ClientUtil.cpp | 2 - cpp/src/IcePatch2Lib/Util.cpp | 6 +- cpp/src/IceUtil/ConvertUTF.cpp | 1 + cpp/src/IceUtil/ConvertUTF.h | 2 +- cpp/src/IceUtil/Exception.cpp | 56 ++++++++++++- cpp/src/IceUtil/FileUtil.cpp | 40 ++++----- cpp/src/IceUtil/StringConverter.cpp | 67 +++------------- cpp/src/IceUtil/StringUtil.cpp | 2 +- cpp/src/IceUtil/Unicode.cpp | 107 ------------------------- cpp/src/IceXML/Parser.cpp | 1 - cpp/src/Slice/Parser.cpp | 1 - cpp/src/Slice/Preprocessor.cpp | 3 +- cpp/src/Slice/Util.cpp | 1 - cpp/src/iceserviceinstall/ServiceInstaller.cpp | 62 +++++++------- 26 files changed, 175 insertions(+), 288 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/Ice/DynamicLibrary.cpp b/cpp/src/Ice/DynamicLibrary.cpp index 1fa6c86ad73..702eda02254 100644 --- a/cpp/src/Ice/DynamicLibrary.cpp +++ b/cpp/src/Ice/DynamicLibrary.cpp @@ -202,9 +202,9 @@ IceInternal::DynamicLibrary::load(const string& lib) // to Windows API. // #ifdef ICE_OS_WINRT - _hnd = LoadPackagedLibrary(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, lib).c_str(), 0); + _hnd = LoadPackagedLibrary(IceUtil::stringToWstring(lib, IceUtil::getProcessStringConverter()).c_str(), 0); #elif defined(_WIN32) - _hnd = LoadLibraryW(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, lib).c_str()); + _hnd = LoadLibraryW(IceUtil::stringToWstring(lib, IceUtil::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 d503e480eb2..c3824d95dbd 100644 --- a/cpp/src/Ice/Exception.cpp +++ b/cpp/src/Ice/Exception.cpp @@ -16,7 +16,7 @@ #include #include #ifdef ICE_OS_WINRT -# include +# include #endif #include @@ -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::wnativeToNative( - IceUtil::getProcessStringConverter(), 0, - static_cast(error).ToString()->Data()); + return IceUtil::wstringToString( + static_cast(error).ToString()->Data(), + IceUtil::getProcessStringConverter()); } #else return IceUtilInternal::errorToString(error); diff --git a/cpp/src/Ice/Initialize.cpp b/cpp/src/Ice/Initialize.cpp index bb54e11c537..a53f6add939 100644 --- a/cpp/src/Ice/Initialize.cpp +++ b/cpp/src/Ice/Initialize.cpp @@ -91,7 +91,7 @@ Ice::argsToStringSeq(int /*argc*/, wchar_t* argv[]) StringSeq args; for(int i=0; argv[i] != 0; i++) { - args.push_back(IceUtil::wnativeToNative(converter, 0, argv[i])); + args.push_back(IceUtil::wstringToString(argv[i], converter)); } return args; } diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp index 4108dd23053..a7b13e875d0 100644 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include // For setTcpBufSize #include // For setTcpBufSize @@ -520,7 +520,7 @@ getInterfaceIndex(const string& name) // Don't need to pass a wide string converter as the wide string // come from Windows API. // - if(IceUtil::wnativeToNative(IceUtil::getProcessStringConverter(), 0, paddrs->FriendlyName) == name) + if(IceUtil::wstringToString(paddrs->FriendlyName, IceUtil::getProcessStringConverter()) == name) { index = paddrs->Ipv6IfIndex; break; @@ -664,7 +664,7 @@ getInterfaceAddress(const string& name) // Don't need to pass a wide string converter as the wide string come // from Windows API. // - if(IceUtil::wnativeToNative(IceUtil::getProcessStringConverter(), 0, paddrs->FriendlyName) == name) + if(IceUtil::wstringToString(paddrs->FriendlyName, IceUtil::getProcessStringConverter()) == name) { struct sockaddr_in addrin; memcpy(&addrin, paddrs->FirstUnicastAddress->Address.lpSockaddr, @@ -892,7 +892,7 @@ IceInternal::getAddresses(const string& host, int port, ProtocolSupport, Ice::En // to Windows API. // addr.host = ref new HostName(ref new String( - IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, host).c_str())); + IceUtil::stringToWstring(host, IceUtil::getProcessStringConverter()).c_str())); } stringstream os; os << port; @@ -900,7 +900,7 @@ IceInternal::getAddresses(const string& host, int port, ProtocolSupport, Ice::En // Don't need to use any string converter here as the port number use just // ACII characters. // - addr.port = ref new String(IceUtil::nativeToWnative(0, 0, os.str()).c_str()); + addr.port = ref new String(IceUtil::stringToWstring(os.str()).c_str()); result.push_back(addr); return result; } @@ -1066,9 +1066,9 @@ IceInternal::getAddressForServer(const string& host, int port, ProtocolSupport p 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::nativeToWnative(0, 0, os.str()).c_str()); + addr.port = ref new String(IceUtil::stringToWstring(os.str()).c_str()); addr.host = nullptr; // Equivalent of inaddr_any, see doBind implementation. #else memset(&addr.saStorage, 0, sizeof(sockaddr_storage)); @@ -1548,7 +1548,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::wnativeToNative(IceUtil::getProcessStringConverter(), 0, ss.host->RawName->Data()); + return IceUtil::wstringToString(ss.host->RawName->Data(), IceUtil::getProcessStringConverter()); } #endif } @@ -1572,9 +1572,9 @@ IceInternal::getPort(const Address& addr) #else IceUtil::Int64 port; // - // Don't need to use any string converter here as the port number use just ACII characters. + // Don't need to use any string converter here as the port number use just ASCII characters. // - if(addr.port == nullptr || !IceUtilInternal::stringToInt64(IceUtil::wnativeToNative(0, 0, addr.port->Data()), port)) + if(addr.port == nullptr || !IceUtilInternal::stringToInt64(IceUtil::wstringToString(addr.port->Data()), port)) { return -1; } @@ -1602,7 +1602,7 @@ IceInternal::setPort(Address& addr, int port) // Don't need to use any string converter here as the port number use just // ACII characters. // - addr.port = ref new String(IceUtil::nativeToWnative(0, 0, os.str()).c_str()); + addr.port = ref new String(IceUtil::stringToWstring(os.str()).c_str()); #endif } @@ -1627,7 +1627,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::wnativeToNative(0, 0, addr.host->RawName->Data()); + string host = IceUtil::wstringToString(addr.host->RawName->Data()); string ip = IceUtilInternal::toUpper(host); vector tokens; IceUtilInternal::splitString(ip, ".", tokens); @@ -2533,7 +2533,7 @@ IceInternal::checkConnectErrorCode(const char* file, int line, HRESULT herr, Hos // Don't need to pass a wide string converter as the wide string come from // Windows API. // - ex.host = IceUtil::wnativeToNative(IceUtil::getProcessStringConverter(), 0, host->RawName->Data()); + ex.host = IceUtil::wstringToString(host->RawName->Data(), IceUtil::getProcessStringConverter()); throw ex; } else diff --git a/cpp/src/Ice/PropertiesI.cpp b/cpp/src/Ice/PropertiesI.cpp index b8642c3af78..b466a2cf105 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::nativeToWnative(_converter, 0, file).substr(5).c_str(); + const wstring keyName = IceUtil::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,8 +350,8 @@ Ice::PropertiesI::load(const std::string& file) getProcessLogger()->warning(os.str()); continue; } - string name = IceUtil::wnativeToNative(_converter, 0, - wstring(reinterpret_cast(&nameBuf[0]), nameBufSize)); + string name = IceUtil::wstringToString( + wstring(reinterpret_cast(&nameBuf[0]), nameBufSize), _converter); if(keyType != REG_SZ && keyType != REG_EXPAND_SZ) { ostringstream os; @@ -364,7 +364,7 @@ Ice::PropertiesI::load(const std::string& file) wstring valueW = wstring(reinterpret_cast(&dataBuf[0]), (dataBufSize / sizeof(wchar_t)) - 1); if(keyType == REG_SZ) { - value = IceUtil::wnativeToNative(_converter, 0, valueW); + value = IceUtil::wstringToString(valueW, _converter); } else // keyType == REG_EXPAND_SZ { @@ -384,7 +384,7 @@ Ice::PropertiesI::load(const std::string& file) continue; } } - value = IceUtil::wnativeToNative(_converter, 0, wstring(&expandedValue[0], sz -1)); + value = IceUtil::wstringToString(wstring(&expandedValue[0], sz -1), _converter); } setProperty(name, value); } @@ -728,7 +728,7 @@ Ice::PropertiesI::loadConfig() } if(ret > 0) { - value = IceUtil::wnativeToNative(_converter, 0, wstring(&v[0], ret)); + value = IceUtil::wstringToString(wstring(&v[0], ret), _converter); } else { diff --git a/cpp/src/Ice/Service.cpp b/cpp/src/Ice/Service.cpp index 13631d3209b..c775c1c6e5f 100644 --- a/cpp/src/Ice/Service.cpp +++ b/cpp/src/Ice/Service.cpp @@ -211,7 +211,7 @@ public: // Don't need to use a wide string converter as the wide string is passed // to Windows API. // - _source = RegisterEventSourceW(0, IceUtil::nativeToWnative(_stringConverter, 0, mangleSource(source)).c_str()); + _source = RegisterEventSourceW(0, IceUtil::stringToWstring(mangleSource(source), _stringConverter).c_str()); if(_source == 0) { SyscallException ex(__FILE__, __LINE__); @@ -236,7 +236,7 @@ public: // to Windows API. // LONG err = RegCreateKeyExW(HKEY_LOCAL_MACHINE, - IceUtil::nativeToWnative(stringConverter, 0, createKey(source)).c_str(), + IceUtil::stringToWstring(createKey(source), stringConverter).c_str(), 0, const_cast(L"REG_SZ"), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, &d); if(err != ERROR_SUCCESS) @@ -296,7 +296,7 @@ public: // to Windows API. // LONG err = RegDeleteKeyW(HKEY_LOCAL_MACHINE, - IceUtil::nativeToWnative(stringConverter, 0, createKey(source)).c_str()); + IceUtil::stringToWstring(createKey(source), stringConverter).c_str()); if(err != ERROR_SUCCESS) { SyscallException ex(__FILE__, __LINE__); @@ -325,7 +325,7 @@ public: // Don't need to use a wide string converter as the wide string is passed // to Windows API. // - wstring msg = IceUtil::nativeToWnative(_stringConverter, 0, message); + wstring msg = IceUtil::stringToWstring(message, _stringConverter); const wchar_t* messages[1]; messages[0] = msg.c_str(); // @@ -363,7 +363,7 @@ public: // Don't need to use a wide string converter as the wide string is passed // to Windows API. // - wstring msg = IceUtil::nativeToWnative(_stringConverter, 0, s); + wstring msg = IceUtil::stringToWstring(s, _stringConverter); const wchar_t* messages[1]; messages[0] = msg.c_str(); // @@ -393,7 +393,7 @@ public: // Don't need to use a wide string converter as the wide string is passed // to Windows API. // - wstring msg = IceUtil::nativeToWnative(_stringConverter, 0, message); + wstring msg = IceUtil::stringToWstring(message, _stringConverter); const wchar_t* messages[1]; messages[0] = msg.c_str(); // @@ -423,7 +423,7 @@ public: // Don't need to use a wide string converter as the wide string is passed // to Windows API. // - wstring msg = IceUtil::nativeToWnative(_stringConverter, 0, message); + wstring msg = IceUtil::stringToWstring(message, _stringConverter); const wchar_t* messages[1]; messages[0] = msg.c_str(); // @@ -1117,7 +1117,7 @@ Ice::Service::runService(int argc, char* argv[], const InitializationData& initD SERVICE_TABLE_ENTRYW ste[] = { { const_cast( - IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, _name).c_str()), + IceUtil::stringToWstring(_name, IceUtil::getProcessStringConverter()).c_str()), Ice_Service_ServiceMain }, { 0, 0 }, }; @@ -1305,7 +1305,7 @@ Ice::Service::serviceMain(int argc, wchar_t* argv[]) // as argv come from Windows API. // char** args = new char*[_serviceArgs.size() + argc]; - args[0] = const_cast(IceUtil::wnativeToNative(converter, 0, argv[0]).c_str()); + args[0] = const_cast(IceUtil::wstringToString(argv[0], converter).c_str()); int i = 1; for(vector::iterator p = _serviceArgs.begin(); p != _serviceArgs.end(); ++p) { @@ -1313,7 +1313,7 @@ Ice::Service::serviceMain(int argc, wchar_t* argv[]) } for(int j = 1; j < argc; ++j) { - args[i++] = const_cast(IceUtil::wnativeToNative(converter, 0, argv[j]).c_str()); + args[i++] = const_cast(IceUtil::wstringToString(argv[j], converter).c_str()); } argc += static_cast(_serviceArgs.size()); diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index e0c1680c745..f806e276267 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -28,7 +28,7 @@ #include #if defined(ICE_OS_WINRT) -# include +# include #endif using namespace std; @@ -959,12 +959,12 @@ IceInternal::ThreadPool::run(const EventHandlerThreadPtr& thread) catch(Platform::Exception^ ex) { // - // We don't need to pass the wide string converter in the call to wnativeToNative + // We don't need to pass the wide string converter in the call to wstringToString // because the wide string is using the platform default encoding. // Error out(_instance->initializationData().logger); out << "exception in `" << _prefix << "':\n" - << IceUtil::wnativeToNative(_instance->getStringConverter(), 0, ex->Message->Data()) + << IceUtil::wstringToString(ex->Message->Data(), _instance->getStringConverter()) << "\nevent handler: " << current._handler->toString(); } #endif diff --git a/cpp/src/IceGrid/Activator.cpp b/cpp/src/IceGrid/Activator.cpp index 1b1bb3f6d04..c67ab7af6fe 100644 --- a/cpp/src/IceGrid/Activator.cpp +++ b/cpp/src/IceGrid/Activator.cpp @@ -380,9 +380,9 @@ Activator::activate(const string& name, // // IceGrid doesn't support to use string converters, so don't need to use - // any string converter in wnativeToNative conversions. + // any string converter in wstringToString conversions. // - if(SearchPathW(NULL, IceUtil::nativeToWnative(0, 0, path).c_str(), ext.c_str(), _MAX_PATH, absbuf, &fPart) == 0) + if(SearchPathW(NULL, IceUtil::stringToWstring(path).c_str(), ext.c_str(), _MAX_PATH, absbuf, &fPart) == 0) { if(_traceLevels->activator > 0) { @@ -391,7 +391,7 @@ Activator::activate(const string& name, } throw string("Couldn't find `" + path + "' executable."); } - path = IceUtil::wnativeToNative(0, 0, absbuf); + path = IceUtil::wstringToString(absbuf); } else if(!pwd.empty()) { @@ -403,13 +403,13 @@ Activator::activate(const string& name, // Get the absolute pathname of the working directory. // // IceGrid doesn't support to use string converters, so - // don't need to use any string converter in nativeToWnative + // don't need to use any string converter in stringToWstring // conversions. // if(!pwd.empty()) { wchar_t absbuf[_MAX_PATH]; - if(_wfullpath(absbuf, IceUtil::nativeToWnative(0, 0, pwd).c_str(), _MAX_PATH) == NULL) + if(_wfullpath(absbuf, IceUtil::stringToWstring(pwd).c_str(), _MAX_PATH) == NULL) { if(_traceLevels->activator > 0) { @@ -418,7 +418,7 @@ Activator::activate(const string& name, } throw string("The server working directory path `" + pwd + "' can't be converted into an absolute path."); } - pwd = IceUtil::wnativeToNative(0, 0, absbuf); + pwd = IceUtil::wstringToString(absbuf); } #endif @@ -495,15 +495,15 @@ Activator::activate(const string& name, // // IceGrid doesn't support to use string converters, so don't need to use - // any string converter in nativeToWnative conversions. + // any string converter in stringToWstring conversions. // - wstring wpwd = IceUtil::nativeToWnative(0, 0, pwd); + wstring wpwd = IceUtil::stringToWstring(pwd); const wchar_t* dir = !wpwd.empty() ? wpwd.c_str() : NULL; // // Make a copy of the command line. // - wchar_t* cmdbuf = _wcsdup(IceUtil::nativeToWnative(0, 0, cmd).c_str()); + wchar_t* cmdbuf = _wcsdup(IceUtil::stringToWstring(cmd).c_str()); // // Create the environment block for the child process. We start with the environment @@ -545,9 +545,9 @@ Activator::activate(const string& name, { // // IceGrid doesn't support to use string converters, so don't need to use - // any string converter in nativeToWnative conversions. + // any string converter in stringToWstring conversions. // - wstring s = IceUtil::nativeToWnative(0, 0, *p); + wstring s = IceUtil::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 68ef989fb45..bc7683bb6af 100644 --- a/cpp/src/IceGrid/IceGridNode.cpp +++ b/cpp/src/IceGrid/IceGridNode.cpp @@ -126,11 +126,7 @@ private: void setNoIndexingAttribute(const string& pa) { - // - // We don't need to pass a wide string converter the wide - // string is passed to Windows API. - // - wstring path = IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, pa); + wstring path = IceUtil::stringToWstring(pa); DWORD attrs = GetFileAttributesW(path.c_str()); if(attrs == INVALID_FILE_ATTRIBUTES) { diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp index 7adbb72bb6a..283496dce8c 100644 --- a/cpp/src/IceGrid/ServerI.cpp +++ b/cpp/src/IceGrid/ServerI.cpp @@ -405,9 +405,9 @@ struct EnvironmentEval : std::unary_function break; } string variable = v.substr(beg + 1, end - beg - 1); - DWORD ret = GetEnvironmentVariableW(IceUtil::nativeToWnative(0, 0, variable).c_str(), &buf[0], + DWORD ret = GetEnvironmentVariableW(IceUtil::stringToWstring(variable).c_str(), &buf[0], static_cast(buf.size())); - string valstr = (ret > 0 && ret < buf.size()) ? IceUtil::wnativeToNative(0, 0, &buf[0]) : string(""); + string valstr = (ret > 0 && ret < buf.size()) ? IceUtil::wstringToString(&buf[0]) : string(""); v.replace(beg, end - beg + 1, valstr); beg += valstr.size(); } diff --git a/cpp/src/IcePatch2/Calc.cpp b/cpp/src/IcePatch2/Calc.cpp index fe8d7cb1ee6..b87c5e48c72 100644 --- a/cpp/src/IcePatch2/Calc.cpp +++ b/cpp/src/IcePatch2/Calc.cpp @@ -8,7 +8,6 @@ // ********************************************************************** #include -#include #include #include #include diff --git a/cpp/src/IcePatch2/FileServerI.cpp b/cpp/src/IcePatch2/FileServerI.cpp index 0441b9f6a11..66adf90ebec 100644 --- a/cpp/src/IcePatch2/FileServerI.cpp +++ b/cpp/src/IcePatch2/FileServerI.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #ifdef _WIN32 diff --git a/cpp/src/IcePatch2Lib/ClientUtil.cpp b/cpp/src/IcePatch2Lib/ClientUtil.cpp index 82d0dce208d..3c7eee1aeb8 100644 --- a/cpp/src/IcePatch2Lib/ClientUtil.cpp +++ b/cpp/src/IcePatch2Lib/ClientUtil.cpp @@ -7,10 +7,8 @@ // // ********************************************************************** -#include #include #include -#include #define ICE_PATCH2_API_EXPORTS #include #include diff --git a/cpp/src/IcePatch2Lib/Util.cpp b/cpp/src/IcePatch2Lib/Util.cpp index 2fc00be9d7c..d743528d531 100644 --- a/cpp/src/IcePatch2Lib/Util.cpp +++ b/cpp/src/IcePatch2Lib/Util.cpp @@ -424,10 +424,10 @@ IcePatch2::readDirectory(const string& pa) // // IcePatch2 doesn't support to use string converters, so don't need to use - // any string converter in nativeToWnative or wnativeToNative conversions. + // any string converter in stringToWstring or wstringToString conversions. // StringSeq result; - const wstring fs = IceUtil::nativeToWnative(0, 0, simplify(path + "/*")); + const wstring fs = IceUtil::stringToWstring(simplify(path + "/*")); struct _wfinddata_t data; intptr_t h = _wfindfirst(fs.c_str(), &data); @@ -438,7 +438,7 @@ IcePatch2::readDirectory(const string& pa) while(true) { - string name = IceUtil::wnativeToNative(0, 0, data.name); + string name = IceUtil::wstringToString(data.name); assert(!name.empty()); if(name != ".." && name != ".") diff --git a/cpp/src/IceUtil/ConvertUTF.cpp b/cpp/src/IceUtil/ConvertUTF.cpp index d6abc324738..0797c332062 100644 --- a/cpp/src/IceUtil/ConvertUTF.cpp +++ b/cpp/src/IceUtil/ConvertUTF.cpp @@ -49,6 +49,7 @@ #include +#include #ifdef CVTUTF_DEBUG #include diff --git a/cpp/src/IceUtil/ConvertUTF.h b/cpp/src/IceUtil/ConvertUTF.h index ce182b74213..17a638f320c 100644 --- a/cpp/src/IceUtil/ConvertUTF.h +++ b/cpp/src/IceUtil/ConvertUTF.h @@ -135,7 +135,7 @@ ConversionResult ConvertUTF32toUTF8( UTF8** targetStart, UTF8* targetEnd, IceUtil::ConversionFlags flags); // -// isLegalUTFSequence is declared in IceUtil/Unicode.h +// isLegalUTFSequence is declared in IceUtil/StringConverter.h // /* --------------------------------------------------------------------- */ diff --git a/cpp/src/IceUtil/Exception.cpp b/cpp/src/IceUtil/Exception.cpp index 8498a6a5f55..36d3e017899 100644 --- a/cpp/src/IceUtil/Exception.cpp +++ b/cpp/src/IceUtil/Exception.cpp @@ -224,14 +224,14 @@ getStackTrace() // // Don't need to use pass a wide string converter in the bellow - // calls to wnativeToNative as the wide strings come from + // calls to wstringToString as the wide strings come from // Windows API. // BOOL ok = SymFromAddr(process, address, 0, symbol); if(ok) { #ifdef DBGHELP_TRANSLATE_TCHAR - s << IceUtil::wnativeToNative(converter, 0, symbol->Name); + s << IceUtil::wstringToString(symbol->Name, converter); #else s << symbol->Name; #endif @@ -240,7 +240,7 @@ getStackTrace() { s << " at line " << line.LineNumber << " in " #ifdef DBGHELP_TRANSLATE_TCHAR - << IceUtil::wnativeToNative(converter, 0, line.FileName); + << IceUtil::wstringToString(line.FileName, converter); #else << line.FileName; #endif @@ -552,6 +552,56 @@ IceUtil::IllegalArgumentException::reason() const return _reason; } +// +// IllegalConversionException +// + +const char* IceUtil::IllegalConversionException::_name = "IceUtil::IllegalConversionException"; + +IceUtil::IllegalConversionException::IllegalConversionException(const char* file, int line): + Exception(file, line) +{} + +IceUtil::IllegalConversionException::IllegalConversionException(const char* file, int line, + const string& reason): + Exception(file, line), + _reason(reason) +{} + +string +IceUtil::IllegalConversionException::ice_name() const +{ + return _name; +} + +void +IceUtil::IllegalConversionException::ice_print(ostream& out) const +{ + Exception::ice_print(out); + out << ": " << _reason; + +} + +IceUtil::IllegalConversionException* +IceUtil::IllegalConversionException::ice_clone() const +{ + return new IllegalConversionException(*this); +} + +void +IceUtil::IllegalConversionException::ice_throw() const +{ + throw *this; +} + +string +IceUtil::IllegalConversionException::reason() const +{ + return _reason; +} + + + IceUtil::SyscallException::SyscallException(const char* file, int line, int err ): Exception(file, line), _error(err) diff --git a/cpp/src/IceUtil/FileUtil.cpp b/cpp/src/IceUtil/FileUtil.cpp index d9080a3c62d..89379f5f3b6 100644 --- a/cpp/src/IceUtil/FileUtil.cpp +++ b/cpp/src/IceUtil/FileUtil.cpp @@ -104,8 +104,8 @@ IceUtilInternal::freopen(const std::string& path, const std::string& mode, FILE* // to Windows API. // const IceUtil::StringConverterPtr converter = IceUtil::getProcessStringConverter(); - return _wfreopen(IceUtil::nativeToWnative(converter, 0, path).c_str(), - IceUtil::nativeToWnative(converter, 0, mode).c_str(), stderr); + return _wfreopen(IceUtil::stringToWstring(path, converter).c_str(), + IceUtil::stringToWstring(mode, converter).c_str(), stderr); # else return freopen(path.c_str(), mode.c_str(), stderr); # endif @@ -124,13 +124,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::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str(), buffer); + return _wstat(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), buffer); } int IceUtilInternal::remove(const string& path) { - return ::_wremove(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str()); + return ::_wremove(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str()); } int @@ -141,8 +141,8 @@ IceUtilInternal::rename(const string& from, const string& to) // to Windows API. // const IceUtil::StringConverterPtr converter = IceUtil::getProcessStringConverter(); - return ::_wrename(IceUtil::nativeToWnative(converter, 0, from).c_str(), - IceUtil::nativeToWnative(converter, 0, to).c_str()); + return ::_wrename(IceUtil::stringToWstring(from, converter).c_str(), + IceUtil::stringToWstring(to, converter).c_str()); } int @@ -152,7 +152,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::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str()); + return ::_wrmdir(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str()); } int @@ -162,7 +162,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::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str()); + return ::_wmkdir(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str()); } FILE* @@ -173,8 +173,8 @@ IceUtilInternal::fopen(const string& path, const string& mode) // to Windows API. // const IceUtil::StringConverterPtr converter = IceUtil::getProcessStringConverter(); - return ::_wfopen(IceUtil::nativeToWnative(converter, 0, path).c_str(), - IceUtil::nativeToWnative(converter, 0, mode).c_str()); + return ::_wfopen(IceUtil::stringToWstring(path, converter).c_str(), + IceUtil::stringToWstring(mode, converter).c_str()); } int @@ -186,12 +186,12 @@ IceUtilInternal::open(const string& path, int flags) // if(flags & _O_CREAT) { - return ::_wopen(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str(), + return ::_wopen(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), flags, _S_IREAD | _S_IWRITE); } else { - return ::_wopen(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str(), flags); + return ::_wopen(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), flags); } } @@ -208,7 +208,7 @@ IceUtilInternal::getcwd(string& cwd) { return -1; } - cwd = IceUtil::wnativeToNative(IceUtil::getProcessStringConverter(), 0, cwdbuf); + cwd = IceUtil::wstringToString(cwdbuf, IceUtil::getProcessStringConverter()); return 0; } #endif @@ -220,7 +220,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::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str()); + return _wunlink(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str()); } int @@ -242,12 +242,12 @@ IceUtilInternal::FileLock::FileLock(const std::string& path) : // to Windows API. // #ifndef ICE_OS_WINRT - _fd = ::CreateFileW(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str(), + _fd = ::CreateFileW(IceUtil::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::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str(), + _fd = ::CreateFile2(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), GENERIC_WRITE, 0, OPEN_ALWAYS, ¶ms); #endif _path = path; @@ -306,7 +306,7 @@ IceUtilInternal::ifstream::ifstream(const string& path, ios_base::openmode mode) // Don't need to use a wide string converter, the wide string is directly passed // to Windows API. // - std::ifstream(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str(), mode) + std::ifstream(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), mode) #endif { } @@ -321,7 +321,7 @@ IceUtilInternal::ifstream::open(const string& path, ios_base::openmode mode) // Don't need to use a wide string converter, the wide string is directly passed // to Windows API. // - std::ifstream::open(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str(), mode); + std::ifstream::open(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), mode); #endif } @@ -337,7 +337,7 @@ IceUtilInternal::ofstream::ofstream(const string& path, ios_base::openmode mode) // Don't need to use a wide string converter, the wide string is directly passed // to Windows API. // - std::ofstream(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str(), mode) + std::ofstream(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), mode) #endif { } @@ -352,7 +352,7 @@ IceUtilInternal::ofstream::open(const string& path, ios_base::openmode mode) // Don't need to use a wide string converter, the wide string is directly passed // to Windows API. // - std::ofstream::open(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str(), mode); + std::ofstream::open(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), mode); #endif } diff --git a/cpp/src/IceUtil/StringConverter.cpp b/cpp/src/IceUtil/StringConverter.cpp index 9b4d6e2c8f2..c76a636ac17 100644 --- a/cpp/src/IceUtil/StringConverter.cpp +++ b/cpp/src/IceUtil/StringConverter.cpp @@ -4,6 +4,7 @@ #include #include #include +#include using namespace IceUtil; using namespace IceUtilInternal; @@ -34,54 +35,6 @@ public: Init init; -const char* __IceUtil__IllegalConversionException_name = "IceUtil::IllegalConversionException"; - -} - -IllegalConversionException::IllegalConversionException(const char* file, int line) : - ::IceUtil::Exception(file, line) -{ -} - -IllegalConversionException::IllegalConversionException(const char* file, int line, const string& reason) : - ::IceUtil::Exception(file, line), - _reason(reason) -{ -} - -IllegalConversionException::~IllegalConversionException() throw() -{ -} - -string -IllegalConversionException::ice_name() const -{ - return __IceUtil__IllegalConversionException_name; -} - -void -IllegalConversionException::ice_print(ostream& out) const -{ - Exception::ice_print(out); - out << ": " << _reason; -} - -IceUtil::IllegalConversionException* -IllegalConversionException::ice_clone() const -{ - return new IllegalConversionException(*this); -} - -void -IllegalConversionException::ice_throw() const -{ - throw *this; -} - -string -IllegalConversionException::reason() const -{ - return _reason; } @@ -197,7 +150,8 @@ IceUtil::UTF8ToNative(const IceUtil::StringConverterPtr& converter, const string } string -IceUtil::wnativeToNative(const StringConverterPtr& converter, const WstringConverterPtr& wConverter, const wstring& v) +IceUtil::wstringToString(const wstring& v, const StringConverterPtr& converter, const WstringConverterPtr& wConverter, + IceUtil::ConversionFlags flags) { string target; if(!v.empty()) @@ -224,14 +178,14 @@ IceUtil::wnativeToNative(const StringConverterPtr& converter, const WstringConve ConversionResult cr = convertUTFWstringToUTF8( sourceStart, sourceStart + v.size(), - targetStart, targetEnd, lenientConversion); + targetStart, targetEnd, flags); if(cr != conversionOK) { delete[] outBuf; assert(cr == sourceExhausted || cr == sourceIllegal); - throw UTFConversionException(__FILE__, __LINE__, - cr == sourceExhausted ? partialCharacter : badEncoding); + throw IllegalConversionException(__FILE__, __LINE__, + cr == sourceExhausted ? "partial character" : "bad encoding"); } target = string(reinterpret_cast(outBuf), static_cast(targetStart - outBuf)); @@ -254,7 +208,8 @@ IceUtil::wnativeToNative(const StringConverterPtr& converter, const WstringConve } wstring -IceUtil::nativeToWnative(const StringConverterPtr& converter, const WstringConverterPtr& wConverter, const string& v) +IceUtil::stringToWstring(const string& v, const StringConverterPtr& converter, + const WstringConverterPtr& wConverter, IceUtil::ConversionFlags flags) { wstring target; if(!v.empty()) @@ -288,14 +243,14 @@ IceUtil::nativeToWnative(const StringConverterPtr& converter, const WstringConve const Byte* sourceStart = reinterpret_cast(tmp.data()); ConversionResult cr = - convertUTF8ToUTFWstring(sourceStart, sourceStart + tmp.size(), target, lenientConversion); + convertUTF8ToUTFWstring(sourceStart, sourceStart + tmp.size(), target, flags); if(cr != conversionOK) { assert(cr == sourceExhausted || cr == sourceIllegal); - throw UTFConversionException(__FILE__, __LINE__, - cr == sourceExhausted ? partialCharacter : badEncoding); + throw IllegalConversionException(__FILE__, __LINE__, + cr == sourceExhausted ? "partial character" : "bad encoding"); } } } diff --git a/cpp/src/IceUtil/StringUtil.cpp b/cpp/src/IceUtil/StringUtil.cpp index 16d7c9f18bf..e8b234f91e3 100644 --- a/cpp/src/IceUtil/StringUtil.cpp +++ b/cpp/src/IceUtil/StringUtil.cpp @@ -575,7 +575,7 @@ IceUtilInternal::errorToString(int error, LPCVOID source) LocalFree(msg); } #endif - return wnativeToNative(getProcessStringConverter(), getProcessWstringConverter(), result); + return wstringToString(result, getProcessStringConverter(), getProcessWstringConverter()); } else { diff --git a/cpp/src/IceUtil/Unicode.cpp b/cpp/src/IceUtil/Unicode.cpp index 14da4fb3b5a..ad6e2e659bd 100644 --- a/cpp/src/IceUtil/Unicode.cpp +++ b/cpp/src/IceUtil/Unicode.cpp @@ -129,110 +129,3 @@ IceUtilInternal::convertUTF8ToUTFWstring(const Byte*& sourceStart, const Byte* s } -// -// wstringToString and stringToWstring -// - -const char* IceUtil::UTFConversionException::_name = "IceUtil::UTFConversionException"; - -IceUtil::UTFConversionException::UTFConversionException(const char* file, int line, - ConversionError ce): - Exception(file, line), - _conversionError(ce) -{} - -string -IceUtil::UTFConversionException::ice_name() const -{ - return _name; -} - -void -IceUtil::UTFConversionException::ice_print(ostream& os) const -{ - Exception::ice_print(os); - switch(_conversionError) - { - case partialCharacter: - os << ": partial character"; - break; - case badEncoding: - os << ": bad encoding"; - break; - default: - assert(0); - break; - }; -} - -IceUtil::UTFConversionException* -IceUtil::UTFConversionException::ice_clone() const -{ - return new UTFConversionException(*this); -} - -void -IceUtil::UTFConversionException::ice_throw() const -{ - throw *this; -} - -IceUtil::ConversionError -IceUtil::UTFConversionException::conversionError() const -{ - return _conversionError; -} - - -string -IceUtil::wstringToString(const wstring& wstr, ConversionFlags flags) -{ - string target; - - size_t size = wstr.size() * 3 * (sizeof(wchar_t) / 2); - - Byte* outBuf = new Byte[size]; - Byte* targetStart = outBuf; - Byte* targetEnd = outBuf + size; - - const wchar_t* sourceStart = wstr.data(); - - ConversionResult cr = - convertUTFWstringToUTF8( - sourceStart, sourceStart + wstr.size(), - targetStart, targetEnd, flags); - - if(cr != conversionOK) - { - delete[] outBuf; - assert(cr == sourceExhausted || cr == sourceIllegal); - throw UTFConversionException(__FILE__, __LINE__, - cr == sourceExhausted ? partialCharacter : badEncoding); - } - - string s(reinterpret_cast(outBuf), - static_cast(targetStart - outBuf)); - s.swap(target); - delete[] outBuf; - return target; -} - -wstring -IceUtil::stringToWstring(const string& str, ConversionFlags flags) -{ - wstring result; - const Byte* sourceStart = reinterpret_cast(str.data()); - - ConversionResult cr - = convertUTF8ToUTFWstring(sourceStart, sourceStart + str.size(), - result, flags); - - if(cr != conversionOK) - { - assert(cr == sourceExhausted || cr == sourceIllegal); - - throw UTFConversionException(__FILE__, __LINE__, - cr == sourceExhausted ? partialCharacter : badEncoding); - } - return result; -} diff --git a/cpp/src/IceXML/Parser.cpp b/cpp/src/IceXML/Parser.cpp index 2087b9d4cbf..c37974c75d0 100644 --- a/cpp/src/IceXML/Parser.cpp +++ b/cpp/src/IceXML/Parser.cpp @@ -8,7 +8,6 @@ // ********************************************************************** #include -#include #include #include #include diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index aedac4d3070..ea79a4f1399 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp index da37e868ef9..07519ca2c34 100644 --- a/cpp/src/Slice/Preprocessor.cpp +++ b/cpp/src/Slice/Preprocessor.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -237,7 +236,7 @@ Slice::Preprocessor::preprocess(bool keepComments, const string& extraArgs) // Don't need to pass a wide string converter the wide string // come from Windows API. // - _cppFile = IceUtil::wnativeToNative(IceUtil::getProcessStringConverter(), 0, name); + _cppFile = IceUtil::wstringToString(name, IceUtil::getProcessStringConverter()); free(name); _cppHandle = IceUtilInternal::fopen(_cppFile, "w+"); } diff --git a/cpp/src/Slice/Util.cpp b/cpp/src/Slice/Util.cpp index 0fdec1b728d..d7362c18692 100644 --- a/cpp/src/Slice/Util.cpp +++ b/cpp/src/Slice/Util.cpp @@ -8,7 +8,6 @@ // ********************************************************************** #include -#include #include #include #include diff --git a/cpp/src/iceserviceinstall/ServiceInstaller.cpp b/cpp/src/iceserviceinstall/ServiceInstaller.cpp index 527484d1f26..714a4b695a4 100644 --- a/cpp/src/iceserviceinstall/ServiceInstaller.cpp +++ b/cpp/src/iceserviceinstall/ServiceInstaller.cpp @@ -269,22 +269,22 @@ IceServiceInstaller::install(const PropertiesPtr& properties) // // We don't support to use a string converter with this tool, so don't need to - // use string converters in calls to nativeToWnative. + // use string converters in calls to stringToWstring. // SC_HANDLE service = CreateServiceW( scm, - IceUtil::nativeToWnative(0, 0, _serviceName).c_str(), - IceUtil::nativeToWnative(0, 0, displayName).c_str(), + IceUtil::stringToWstring(_serviceName).c_str(), + IceUtil::stringToWstring(displayName).c_str(), SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, autoStart ? SERVICE_AUTO_START : SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, - IceUtil::nativeToWnative(0, 0, command).c_str(), + IceUtil::stringToWstring(command).c_str(), 0, 0, - IceUtil::nativeToWnative(0, 0, deps).c_str(), - IceUtil::nativeToWnative(0, 0, _sidName).c_str(), - IceUtil::nativeToWnative(0, 0, password).c_str()); + IceUtil::stringToWstring(deps).c_str(), + IceUtil::stringToWstring(_sidName).c_str(), + IceUtil::stringToWstring(password).c_str()); if(service == 0) { @@ -296,7 +296,7 @@ IceServiceInstaller::install(const PropertiesPtr& properties) // // Set description // - wstring uDescription = IceUtil::nativeToWnative(0, 0, description); + wstring uDescription = IceUtil::stringToWstring(description); SERVICE_DESCRIPTIONW sd = { const_cast(uDescription.c_str()) }; if(!ChangeServiceConfig2W(service, SERVICE_CONFIG_DESCRIPTION, &sd)) @@ -323,9 +323,9 @@ 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 nativeToWnative. + // use string converters in calls to stringToWstring. // - SC_HANDLE service = OpenServiceW(scm, IceUtil::nativeToWnative(0, 0, _serviceName).c_str(), SERVICE_ALL_ACCESS); + SC_HANDLE service = OpenServiceW(scm, IceUtil::stringToWstring(_serviceName).c_str(), SERVICE_ALL_ACCESS); if(service == 0) { DWORD res = GetLastError(); @@ -421,10 +421,10 @@ IceServiceInstaller::initializeSid(const string& name) // // We don't support to use a string converter with this tool, so don't need to - // use string converters in calls to nativeToWnative. + // use string converters in calls to stringToWstring. // SID_NAME_USE nameUse; - while(LookupAccountNameW(0, IceUtil::nativeToWnative(0, 0, name).c_str(), _sidBuffer.get(), &sidSize, domainName.get(), + while(LookupAccountNameW(0, IceUtil::stringToWstring(name).c_str(), _sidBuffer.get(), &sidSize, domainName.get(), &domainNameSize, &nameUse) == false) { DWORD res = GetLastError(); @@ -469,7 +469,7 @@ IceServiceInstaller::initializeSid(const string& name) throw "Could not retrieve full account name for " + name + ": " + IceUtilInternal::errorToString(res); } - _sidName = IceUtil::wnativeToNative(0, 0, domainName) + "\\" + IceUtil::wnativeToNative(0, 0, accountName); + _sidName = IceUtil::wstringToString(domainName) + "\\" + IceUtil::wstringToString(accountName); } if(_debug) @@ -477,7 +477,7 @@ IceServiceInstaller::initializeSid(const string& name) Trace trace(_communicator->getLogger(), "IceServiceInstaller"); wchar_t* sidString = 0; ConvertSidToStringSidW(_sid, &sidString); - trace << "SID: " << IceUtil::wnativeToNative(0, 0, sidString) << "; "; + trace << "SID: " << IceUtil::wstringToString(sidString) << "; "; LocalFree(sidString); trace << "Full name: " << _sidName; } @@ -522,9 +522,9 @@ IceServiceInstaller::grantPermissions(const string& path, SE_OBJECT_TYPE type, b PSECURITY_DESCRIPTOR sd = 0; // // We don't support to use a string converter with this tool, so don't need to - // use string converters in calls to nativeToWnative. + // use string converters in calls to stringToWstring. // - DWORD res = GetNamedSecurityInfoW(const_cast(IceUtil::nativeToWnative(0, 0, path).c_str()), type, + DWORD res = GetNamedSecurityInfoW(const_cast(IceUtil::stringToWstring(path).c_str()), type, DACL_SECURITY_INFORMATION, 0, 0, &acl, 0, &sd); if(res != ERROR_SUCCESS) { @@ -608,9 +608,9 @@ IceServiceInstaller::grantPermissions(const string& path, SE_OBJECT_TYPE type, b // // We don't support to use a string converter with this tool, so don't need to - // use string converters in calls to nativeToWnative. + // use string converters in calls to stringToWstring. // - res = SetNamedSecurityInfoW(const_cast(IceUtil::nativeToWnative(0, 0, path).c_str()), type, + res = SetNamedSecurityInfoW(const_cast(IceUtil::stringToWstring(path).c_str()), type, DACL_SECURITY_INFORMATION, 0, 0, newAcl, 0); if(res != ERROR_SUCCESS) { @@ -641,9 +641,9 @@ 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 nativeToWnative. + // use string converters in calls to stringToWstring. // - if(CreateDirectoryW(IceUtil::nativeToWnative(0, 0, path).c_str(), 0) == 0) + if(CreateDirectoryW(IceUtil::stringToWstring(path).c_str(), 0) == 0) { DWORD res = GetLastError(); if(res == ERROR_ALREADY_EXISTS) @@ -680,9 +680,9 @@ IceServiceInstaller::addLog(const string& log) const DWORD disposition = 0; // // We don't support to use a string converter with this tool, so don't need to - // use string converters in calls to nativeToWnative. + // use string converters in calls to stringToWstring. // - LONG res = RegCreateKeyExW(HKEY_LOCAL_MACHINE, IceUtil::nativeToWnative(0, 0, createLog(log)).c_str(), 0, L"REG_SZ", + LONG res = RegCreateKeyExW(HKEY_LOCAL_MACHINE, IceUtil::stringToWstring(createLog(log)).c_str(), 0, L"REG_SZ", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &key, &disposition); if(res != ERROR_SUCCESS) @@ -702,9 +702,9 @@ 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 nativeToWnative. + // use string converters in calls to stringToWstring. // - LONG res = RegDeleteKeyW(HKEY_LOCAL_MACHINE, IceUtil::nativeToWnative(0, 0, createLog(log)).c_str()); + LONG res = RegDeleteKeyW(HKEY_LOCAL_MACHINE, IceUtil::stringToWstring(createLog(log)).c_str()); // // We get ERROR_ACCESS_DENIED when the log is shared by several sources @@ -720,11 +720,11 @@ IceServiceInstaller::addSource(const string& source, const string& log, const st { // // We don't support to use a string converter with this tool, so don't need to - // use string converters in calls to nativeToWnative. + // use string converters in calls to stringToWstring. // HKEY key = 0; DWORD disposition = 0; - LONG res = RegCreateKeyExW(HKEY_LOCAL_MACHINE, IceUtil::nativeToWnative(0, 0, createSource(source, log)).c_str(), + LONG res = RegCreateKeyExW(HKEY_LOCAL_MACHINE, IceUtil::stringToWstring(createSource(source, log)).c_str(), 0, L"REG_SZ", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &key, &disposition); if(res != ERROR_SUCCESS) { @@ -737,7 +737,7 @@ IceServiceInstaller::addSource(const string& source, const string& log, const st // DLL. // res = RegSetValueExW(key, L"EventMessageFile", 0, REG_EXPAND_SZ, - reinterpret_cast(IceUtil::nativeToWnative(0, 0, resourceFile).c_str()), + reinterpret_cast(IceUtil::stringToWstring(resourceFile).c_str()), static_cast(resourceFile.length() + 1) * sizeof(wchar_t)); if(res == ERROR_SUCCESS) @@ -795,11 +795,11 @@ IceServiceInstaller::removeSource(const string& source) const // Check if we can delete the source sub-key // // We don't support to use a string converter with this tool, so don't need to - // use string converters in calls to nativeToWnative. + // use string converters in calls to stringToWstring. // LONG delRes = RegDeleteKeyW(HKEY_LOCAL_MACHINE, - IceUtil::nativeToWnative(0, 0, createSource(source, - IceUtil::wnativeToNative(0, 0, subkey))).c_str()); + IceUtil::stringToWstring(createSource(source, + IceUtil::wstringToString(subkey))).c_str()); if(delRes == ERROR_SUCCESS) { res = RegCloseKey(key); @@ -807,7 +807,7 @@ IceServiceInstaller::removeSource(const string& source) const { throw "Could not close registry key handle: " + IceUtilInternal::errorToString(res); } - return IceUtil::wnativeToNative(0, 0, subkey); + return IceUtil::wstringToString(subkey); } ++index; -- cgit v1.2.3