mr-edd.co.uk :: horsing around with the C++ programming language

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

(optional)
(optional)
(required)

Links can be added like [this one -> http://www.mr-edd.co.uk], to my homepage.
Phrases and blocks of code can be enclosed in {{{triple braces}}}.
Any HTML markup will be escaped.