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

std::string_view API on file #24

Open
DarthGandalf opened this issue Nov 29, 2020 · 4 comments
Open

std::string_view API on file #24

DarthGandalf opened this issue Nov 29, 2020 · 4 comments

Comments

@DarthGandalf
Copy link

Please provide one.

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

@Wunkolo
Copy link

Wunkolo commented Nov 18, 2021

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

@izzyreal
Copy link

izzyreal commented Apr 25, 2023

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
Copy link

I'll probably resort to this:

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

which so far seems to yield correct results.

@sandsc
Copy link

sandsc commented Apr 11, 2024

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

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

No branches or pull requests

4 participants