Refactored to move write_delimited_pb call from all methods to a single ::write() call.
::write() method just calls F(message, ZeroCopyStream)
bool (F)(google::protobuf::MessageLite, google::protobuf::ZeroCopySteam*) is a template argument.
other writers (e.g.-jsonlines) can be implemented by passing a different F function as a template argument. This is demonstrated in tests.
split the tests to properly do:
a OstreamOutputStream to a temporary stringstream;
a FileOutputStream to a file descriptor.
Both are faster. The OstreamOutputStream example is still contrive since but it's a test...
the tests are fine examples of what's possible, but there's an excess of pointers, in a real program you could skip all that as long as you don't need fine-grained control over flushing.