MCPcopy Create free account
hub / github.com/Kitware/CMake / ToWide

Method ToWide

Source/cmWindowsRegistry.cxx:209–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209std::wstring KeyHandler::ToWide(cm::string_view str)
210{
211 std::wstring wstr;
212
213 if (str.empty()) {
214 return wstr;
215 }
216
217 auto const wlength =
218 MultiByteToWideChar(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.data(),
219 int(str.size()), nullptr, 0);
220 if (wlength > 0) {
221 auto wdata = cm::make_unique<wchar_t[]>(wlength);
222 auto const r =
223 MultiByteToWideChar(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.data(),
224 int(str.size()), wdata.get(), wlength);
225 if (r > 0) {
226 wstr = std::wstring(wdata.get(), wlength);
227 } else {
228 throw registry_error(FormatSystemError(GetLastError()));
229 }
230 } else {
231 throw registry_error(FormatSystemError(GetLastError()));
232 }
233
234 return wstr;
235}
236
237std::string KeyHandler::ToNarrow(wchar_t const* wstr, int size)
238{

Callers 1

ReadValueMethod · 0.95

Calls 5

registry_errorClass · 0.85
emptyMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected