47 t::streamSource(is) >> t::streamSink(os);
50 t::streamSource(is) >> t::stripSpace(
"\n") >> t::base64Decode(
false) >> t::streamSink(os);
53 t::streamSource(is) >> t::hexDecode() >> t::streamSink(os);
56 NDN_THROW(std::invalid_argument(
"Unknown IoEncoding " + std::to_string(encoding)));
59 catch (
const std::runtime_error& e) {
74 t::bufferSource(buf) >> t::streamSink(os);
77 t::bufferSource(buf) >> t::base64Encode() >> t::streamSink(os);
80 t::bufferSource(buf) >> t::hexEncode(
true) >> t::streamSink(os);
83 NDN_THROW(std::invalid_argument(
"Unknown IoEncoding " + std::to_string(encoding)));
86 catch (
const std::runtime_error& e) {
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.