Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Database constructor for filesystem::path #296 #314

Merged
merged 5 commits into from
Jan 6, 2021

Conversation

ptrks
Copy link
Contributor

@ptrks ptrks commented Dec 30, 2020

Added an additional constructor in Database.h that accepts a std::filesystem::path object. Also updated the ctorExecCreateDropExist unit test in Database_test.h which will test the new constructor if the detected compiler supports c++17.

@coveralls
Copy link

coveralls commented Dec 30, 2020

Coverage Status

Coverage remained the same at 100.0% when pulling 340262a on ptrks:database_std_filesystem into 3fcb352 on SRombauts:master.

@SRombauts SRombauts self-assigned this Jan 4, 2021
@SRombauts SRombauts merged commit 81e5a1f into SRombauts:master Jan 6, 2021
@SRombauts
Copy link
Owner

Thanks a lot for providing this!
I was actually certain I had it merged two days ago, but I apparently had stopped before submitting....

@ptrks
Copy link
Contributor Author

ptrks commented Jan 6, 2021

Of course!

@SRombauts
Copy link
Owner

Have you seen issue #317 that it apparently fails on vs2019 (and proposed fix #318

@chronoxor
Copy link
Contributor

Possible fix is to convert std::wstring to utf-8 based string:

std::string ToUTF8(const std::wstring& wstr)
{
#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__)
    std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
    return convert.to_bytes((char16_t*)wstr.data(), (char16_t*)wstr.data() + wstr.size());
#elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
    std::wstring_convert<std::codecvt_utf8<wchar_t>> convert;
    return convert.to_bytes(wstr.data(), wstr.data() + wstr.size());
#elif defined(_WIN32) || defined(_WIN64)
    std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> convert;
    return convert.to_bytes(wstr.data(), wstr.data() + wstr.size());
#endif
}

@Chronial
Copy link

Chronial commented Jan 8, 2021

As sum01 remarked, the u8string() method already gives a utf-8 encoded string on all platforms. I implemented that in #319.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants