vector-of-bool/cmrc

How do I use the data from a cmrc::resource?

Tetrago opened this issue · 4 comments

I tried to use:
cmrc::resource file = cmrc::open(file); std::string data(file.begin(), file.end());
But there is no string constructor like this. How do I use CMakeRC?

Actually, I can't even get CMakeRC to run, it errors out.

Sorry for the delay. Were you able to work out a solution?

I do

auto file = fs.open("some_resource_file.txt")
auto it = file.begin();

vector<char> bytes;

do bytes.push_back(*it);
while (it++ != file.end());

But DarthGandalf has a better (C++ 17) syntax in #24.
Comes down to:

auto file = fs.open("some_resource_file.txt")
char* data = std::string_view(file.begin(), file.end() - file.begin()).data();