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.
vsnprintf
) in order to be usable (EDIT: Okay, C99's standard library being in C++11 adds most/all of these now)I love iostreams in concept, even the use of operator<<
which some people seem to not like, but it seems entirely too over engineered to me. Someone should not have to spend countless hours reading books in order to be a simple client of your library. Sure, if you're adding a new output source or something like that I could understand, but.... clients should be shielded from that complexity. (Isn't that what a library's for?)
This is about the only thing that's painful in C++ that "just works" in other programming languages, that I see no reason to be complicated.