eipp is a C++ library that offers a simple and safe interface to Erlang External Term format. Example:
using namespace eipp;
using namespace std;
int main()
{
while(1)
{
atom_t cmd; // atom type... think std::string
et data; // generic "erlang term" type
// expect tuple of the form {CmdAtom, Data}
untuple(cmd,data)=binary_to_term(receive4(cin));
// Only one command supported for now...
if(cmd=="times2")
{
int num=data; // "et" can cast itself to many types
num*=2;
send4(cout,term_to_binary(tuple("ok",num)));
}
}
}The library only supports ETF encoding/decoding and port compatible packet encoding, but this will grow in the future.