I'm looking for a library which operates similar to iostreams, in that it performs conversions, and allows writing to memory buffers, files, and the console. However, I'd like something type safe, as iostream is. Are there any serious libraries which do this?
Being able to specify the output encoding for things would be a plus.
Note that I'm not interested in libraries which simply front iostreams because they just add more complexity to what iostreams is doing, e.g. boost::format.
PreEmptive comment response: I don't want to use cstdio because using that system it's impossible to have code be output location agnostic. That is, you have to call one function for sending things to buffers, and you have to call another function to send things to files, and another for the console, etc.
EDIT2: In response to the flurry of comments below: I'm fed up with both iostreams and cstdio. Here are more specific reasons. I tried to keep my "rant" out of this question, but people keep asking my if I'm off my rocker, so here's my rationale.
cstdio
- Can't handle Unicode characters correctly
- Can't write into something like a string without doing manual buffer management
- Often requires support of nonstandard extensions (e.g.
vsnprintf) in order to be usable (EDIT: Okay, C99's standard library being in C++11 adds most/all of these now) - Can't change the location of output without changing the original code (nonstandard extensions e.g. in glibc allow you to treat a file pointer as a buffer, which kind of does this... but it's still just that, a nonstandard extension)
- Makes security "fun" (to the point where entire chapters are dedicated in security docs explaining issues, e.g. with "printf"'s format strings and such)
- Not type safe
iostreams
- Slow
- Entirely too complicated to a client. If you u