vector-of-bool / cmrc

A Resource Compiler in a Single CMake Script
MIT License
674 stars 74 forks source link

std::string_view API on file #24

Open DarthGandalf opened 4 years ago

DarthGandalf commented 4 years ago

Please provide one.

My current workaround is: std::string_view data(file.begin(), file.end() - file.begin());

Wunkolo commented 3 years ago

Would be great to have an std::span<const std::byte> interface as well in the case of C++20.

izzyreal commented 1 year ago

Still relevant. Not sure what changed on my end, but the above syntax suddenly is giving me incomplete reads. A file of 681 bytes is parsed only up to 181 bytes. file.end() - file.begin() still correctly reports 681.

I'll mess around and will probably find a way to get the whole thing, but it would be great if CMRC provides a trivial interface for getting the data in an idiomatic way. Having to mess with char* is not ideal to begin with.

izzyreal commented 1 year ago

I'll probably resort to this:

    std::vector<char> data(file.begin(), file.end());

which so far seems to yield correct results.

sandsc commented 7 months ago

I just create a pull request to support using string_view as key to open and find resource.