44 t::streamSource(is) >> t::streamSink(os);
47 t::streamSource(is) >> t::stripSpace(
"\n") >> t::base64Decode(
false) >> t::streamSink(os);
50 t::streamSource(is) >> t::hexDecode() >> t::streamSink(os);
54 catch (
const std::runtime_error& e) {
58 NDN_THROW(std::invalid_argument(
"Unknown IoEncoding " + to_string(encoding)));
69 t::bufferSource(buf) >> t::streamSink(os);
72 t::bufferSource(buf) >> t::base64Encode() >> t::streamSink(os);
75 t::bufferSource(buf) >> t::hexEncode(
true) >> t::streamSink(os);
79 catch (
const std::runtime_error& e) {
83 NDN_THROW(std::invalid_argument(
"Unknown IoEncoding " + to_string(encoding)));
An output stream that writes to a Buffer.
std::shared_ptr< Buffer > buf()
Return a shared pointer to the underlying buffer.
#define NDN_THROW_NESTED(e)
void saveBuffer(span< const uint8_t > buf, std::ostream &os, IoEncoding encoding)
Writes a sequence of bytes to a stream.
IoEncoding
Indicates how a file or stream of bytes is encoded.
@ NO_ENCODING
Raw binary, without encoding.
@ HEX
Hexadecimal encoding.
shared_ptr< Buffer > loadBuffer(std::istream &is, IoEncoding encoding)
Reads bytes from a stream until EOF.