embd
embd is a tool for embedding files in to C++ source code. It generates a source file containing the embedded data and a header file that gives you all the facilities you need to access the embedded files.
I don't recommend using embd to embed large amounts of data, but it is useful for little demos and such like where you'd like a single file for ease of use and distribution.
The source files that embd generates are not licensed in anyway. You are free to apply your own copyright and favorite license or release the files in to the public domain.
Recent activity
Code
Clone the repository using mercurial:
> hg clone http://bitbucket.org/edd/embd
Or get a zip file of the code.
Quick start
To create a C++ source file and a corresponding header that contains files:
embd contract.txt logo.jpg
This will generated embd.cpp and embd.hpp. By compiling and linking embd.cpp in to your code, you can access the files as follows:
embd::file f("contract.txt"); // may throw an embd::file_not_found exception
std::istream &in = f.istream();
std::string token;
while ((in >> token))
std::cout << "token: " << token << '\n';
There are many configurable options to change file names, namespaces, paths to the embedded files and so on.
Further reading
Comments
All original content copyright© Edd Dawson.
All source code appearing on this website that was written by Edd Dawson is made available under the terms of the Boost software license version 1.0 unless otherwise stated or implied by the license associated with the work from which the code is derived.
