Merge pull request #45 from lioncash/str

DNACommon: Replace platform-specific string conversion functions with standard facilities
This commit is contained in:
Jack Andersen 2019-08-23 12:20:20 -10:00 committed by GitHub
commit 52667b2069
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 12 deletions

View File

@ -246,23 +246,15 @@ public:
UniqueID64(const hecl::ProjectPath& path) { *this = path; } UniqueID64(const hecl::ProjectPath& path) { *this = path; }
UniqueID64(const char* hexStr) { UniqueID64(const char* hexStr) {
char copy[17]; char copy[17];
strncpy(copy, hexStr, 16); std::strncpy(copy, hexStr, 16);
copy[16] = '\0'; copy[16] = '\0';
#if _WIN32 assign(std::strtoull(copy, nullptr, 16));
assign(_strtoui64(copy, nullptr, 16));
#else
assign(strtouq(copy, nullptr, 16));
#endif
} }
UniqueID64(const wchar_t* hexStr) { UniqueID64(const wchar_t* hexStr) {
wchar_t copy[17]; wchar_t copy[17];
wcsncpy(copy, hexStr, 16); std::wcsncpy(copy, hexStr, 16);
copy[16] = L'\0'; copy[16] = L'\0';
#if _WIN32 assign(std::wcstoull(copy, nullptr, 16));
assign(_wcstoui64(copy, nullptr, 16));
#else
assign(wcstoull(copy, nullptr, 16));
#endif
} }
static constexpr size_t BinarySize() { return 8; } static constexpr size_t BinarySize() { return 8; }