22 #ifndef NDN_CXX_UTIL_IO_HPP 23 #define NDN_CXX_UTIL_IO_HPP 34 class Error :
public std::runtime_error
37 using std::runtime_error::runtime_error;
68 "T::Error, if defined, must be a subclass of ndn::tlv::Error");
104 return T(
Block(buf));
106 catch (
const std::exception& e) {
123 detail::checkNestedError<T>(
nullptr);
129 catch (
const std::invalid_argument&) {
132 catch (
const std::runtime_error&) {
137 return make_shared<T>(block);
155 std::ifstream is(filename);
156 return load<T>(is, encoding);
178 detail::checkNestedError<T>(
nullptr);
182 block = obj.wireEncode();
201 std::ofstream os(filename);
202 save(obj, os, encoding);
208 #endif // NDN_CXX_UTIL_IO_HPP #define NDN_THROW_NESTED(e)
Copyright (c) 2011-2015 Regents of the University of California.
static void checkNestedError(...)
shared_ptr< T > load(std::istream &is, IoEncoding encoding=BASE64)
Reads a TLV element from a stream.
void save(const T &obj, std::ostream &os, IoEncoding encoding=BASE64)
Writes a TLV element to a stream.
Represents a TLV element of the NDN packet format.
Raw binary, without encoding.
T loadTlv(std::istream &is, IoEncoding encoding=BASE64)
Reads a TLV element of type T from a stream.
void saveBuffer(span< const uint8_t > buf, std::ostream &os, IoEncoding encoding)
Writes a sequence of bytes to a stream.
a concept check for TLV abstraction with .wireEncode method
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
represents an error in TLV encoding or decoding
shared_ptr< Buffer > loadBuffer(std::istream &is, IoEncoding encoding)
Reads bytes from a stream until EOF.
IoEncoding
Indicates how a file or stream of bytes is encoded.