Files
moloapp/example/app/Embedded.cpp
T

23 lines
776 B
C++
Raw Normal View History

#include "App.hpp"
#include "gen/assets.hpp"
namespace molo::example::app {
// The bundle is generated at build time from example/assets by the MoloApp
// embedder (see example/example.mk, target example-assets). Names are
// sorted and byte-identical across runs.
void load_embedded(Services& services) {
const gen::EmbeddedFile* files = gen::bundle_files();
for (unsigned long i = 0; i < gen::bundle_count(); ++i) {
std::string body;
body.reserve(files[i].size);
for (unsigned long c = 0; c < files[i].chunk_count; ++c)
body.append(reinterpret_cast<const char*>(files[i].chunks[c].data),
files[i].chunks[c].size);
services.embedded["/" + std::string(files[i].path)] = std::move(body);
}
}
} // namespace molo::example::app