Namespaces | |
detail | |
Classes | |
class | Error |
Enumerations | |
enum | IoEncoding { NO_ENCODING, BASE64, HEX } |
Indicates how a file or stream of bytes is encoded. More... | |
Functions | |
shared_ptr< Buffer > | loadBuffer (std::istream &is, IoEncoding encoding=BASE64) |
Reads bytes from a stream until EOF. More... | |
void | saveBuffer (span< const uint8_t > buf, std::ostream &os, IoEncoding encoding=BASE64) |
Writes a sequence of bytes to a stream. More... | |
template<typename T > | |
T | loadTlv (std::istream &is, IoEncoding encoding=BASE64) |
Reads a TLV element of type T from a stream. More... | |
template<typename T > | |
shared_ptr< T > | load (std::istream &is, IoEncoding encoding=BASE64) |
Reads a TLV element from a stream. More... | |
template<typename T > | |
shared_ptr< T > | load (const std::string &filename, IoEncoding encoding=BASE64) |
Reads a TLV element from a file. More... | |
template<typename T > | |
void | save (const T &obj, std::ostream &os, IoEncoding encoding=BASE64) |
Writes a TLV element to a stream. More... | |
template<typename T > | |
void | save (const T &obj, const std::string &filename, IoEncoding encoding=BASE64) |
Writes a TLV element to a file. More... | |
enum ndn::io::IoEncoding |
Indicates how a file or stream of bytes is encoded.
Enumerator | |
---|---|
NO_ENCODING | Raw binary, without encoding. |
BASE64 | Base64 encoding.
|
HEX | Hexadecimal encoding.
|
shared_ptr< Buffer > ndn::io::loadBuffer | ( | std::istream & | is, |
IoEncoding | encoding = BASE64 |
||
) |
Reads bytes from a stream until EOF.
Error | An error occurred, e.g., malformed input. |
std::invalid_argument | The specified encoding is not supported. |
Definition at line 37 of file io.cpp.
References BASE64, ndn::security::transform::base64Decode(), ndn::OBufferStream::buf(), HEX, ndn::security::transform::hexDecode(), NDN_THROW, NDN_THROW_NESTED, NO_ENCODING, ndn::security::transform::streamSink(), ndn::security::transform::stripSpace(), and ndn::to_string().
Referenced by ndn::io::detail::checkNestedError(), load(), and loadTlv().
void ndn::io::saveBuffer | ( | span< const uint8_t > | buf, |
std::ostream & | os, | ||
IoEncoding | encoding = BASE64 |
||
) |
Writes a sequence of bytes to a stream.
Error | error during saving |
std::invalid_argument | the specified encoding is not supported |
Definition at line 63 of file io.cpp.
References BASE64, ndn::security::transform::base64Encode(), HEX, ndn::security::transform::hexEncode(), NDN_THROW, NDN_THROW_NESTED, NO_ENCODING, ndn::security::transform::streamSink(), and ndn::to_string().
T ndn::io::loadTlv | ( | std::istream & | is, |
IoEncoding | encoding = BASE64 |
||
) |
Reads a TLV element of type T
from a stream.
T | Class type representing the TLV element; must be WireDecodable. |
Error | An error occurred, e.g., malformed input. |
std::invalid_argument | The specified encoding is not supported. |
Definition at line 98 of file io.hpp.
References loadBuffer(), and NDN_THROW_NESTED.
shared_ptr<T> ndn::io::load | ( | std::istream & | is, |
IoEncoding | encoding = BASE64 |
||
) |
Reads a TLV element from a stream.
T | Type of TLV element; T must be WireDecodable and the nested type T::Error , if defined, must be a subclass of ndn::tlv::Error. |
Definition at line 120 of file io.hpp.
References loadBuffer().
shared_ptr<T> ndn::io::load | ( | const std::string & | filename, |
IoEncoding | encoding = BASE64 |
||
) |
Reads a TLV element from a file.
T | Type of TLV element; T must be WireDecodable and the nested type T::Error , if defined, must be a subclass of ndn::tlv::Error. |
Definition at line 153 of file io.hpp.
References BASE64, and saveBuffer().
void ndn::io::save | ( | const T & | obj, |
std::ostream & | os, | ||
IoEncoding | encoding = BASE64 |
||
) |
Writes a TLV element to a stream.
T | type of TLV element; T must be WireEncodable and the nested type T::Error , if defined, must be a subclass of ndn::tlv::Error |
Error | error during encoding or saving |
std::invalid_argument | the specified encoding is not supported |
Definition at line 175 of file io.hpp.
References NDN_THROW_NESTED, and saveBuffer().
Referenced by save().
void ndn::io::save | ( | const T & | obj, |
const std::string & | filename, | ||
IoEncoding | encoding = BASE64 |
||
) |
Writes a TLV element to a file.
T | type of TLV element; T must be WireEncodable and the nested type T::Error , if defined, must be a subclass of ndn::tlv::Error |
Error | error during encoding or saving |
std::invalid_argument | the specified encoding is not supported |
Definition at line 199 of file io.hpp.
References save().