I see how karma can be used to generate into a container that manages memory, like std::string. But what about the case where a buffer (char[N]) has been pre-allocated?
{
using namespace boost::spirit::karma;
{
std::string buffer;
generate(std::inserter(buffer, buffer.begin()), double_, 3.13);
std::cout << ':' << buffer << ':' << std::endl;
}
{
//////////////////////////////////////////////////////////////////////
// How to make the following work? Is there a builtin output
// iterator that just works?
#if defined(MAJIC)
char buffer[1024];
generate(buffer, double_, 3.13);
std::cout << ':' << buffer << ':' << std::endl;
#endif
}
}
I would like to find a way to parse the double into an address of an existing buffer. It is ok to assume the buffer is large enough for this case. Maybe the underlying question is really - is there already an output iterator adapter or something in karma for native arrays that could be used?