ndn::io Namespace Reference

Namespaces

 detail
 

Data Structures

class  Error
 

Enumerations

enum  IoEncoding { NO_ENCODING, BASE64, HEX }
 indicates how a file or stream is encoded More...
 

Functions

optional< BlockloadBlock (std::istream &is, IoEncoding encoding=BASE64)
 loads a TLV block from a stream More...
 
void saveBlock (const Block &block, std::ostream &os, IoEncoding encoding=BASE64)
 saves a TLV block to a stream More...
 
template<typename T >
shared_ptr< T > load (std::istream &is, IoEncoding encoding=BASE64)
 loads a TLV element from a stream More...
 
template<typename T >
shared_ptr< T > load (const std::string &filename, IoEncoding encoding=BASE64)
 loads a TLV element from a file More...
 
template<typename T >
void save (const T &obj, std::ostream &os, IoEncoding encoding=BASE64)
 saves a TLV element to a stream More...
 
template<typename T >
void save (const T &obj, const std::string &filename, IoEncoding encoding=BASE64)
 saves a TLV element to a file More...
 

Variables

constexpr IoEncoding BASE_64 = BASE64
 

Enumeration Type Documentation

indicates how a file or stream is encoded

Enumerator
NO_ENCODING 

binary without encoding

BASE64 

base64 encoding

save() inserts a newline after every 64 characters, load() can accept base64 text with or without newlines

HEX 

hexadecimal encoding

save() uses uppercase letters A-F, load() can accept mixed-case

Definition at line 46 of file io.hpp.

Function Documentation

template<typename T >
shared_ptr<T> ndn::io::load ( std::istream &  is,
IoEncoding  encoding = BASE64 
)

loads a TLV element from a stream

Template Parameters
Ttype of TLV element; T must be WireDecodable, and must have a Error nested type
Returns
the TLV element, or nullptr if an error occurs

Definition at line 100 of file io.hpp.

template<typename T >
shared_ptr<T> ndn::io::load ( const std::string &  filename,
IoEncoding  encoding = BASE64 
)

loads a TLV element from a file

Definition at line 122 of file io.hpp.

optional< Block > ndn::io::loadBlock ( std::istream &  is,
IoEncoding  encoding = BASE64 
)

loads a TLV block from a stream

Returns
if success, the Block and true otherwise, a default-constructed Block and false

Definition at line 30 of file io.cpp.

template<typename T >
void ndn::io::save ( const T &  obj,
std::ostream &  os,
IoEncoding  encoding = BASE64 
)

saves a TLV element to a stream

Template Parameters
Ttype of TLV element; T must be WireEncodable, and must have a Error nested type
Exceptions
Errorerror during encoding or saving

Definition at line 141 of file io.hpp.

template<typename T >
void ndn::io::save ( const T &  obj,
const std::string &  filename,
IoEncoding  encoding = BASE64 
)

saves a TLV element to a file

Definition at line 161 of file io.hpp.

void ndn::io::saveBlock ( const Block block,
std::ostream &  os,
IoEncoding  encoding = BASE64 
)

saves a TLV block to a stream

Exceptions
Errorerror during saving

Definition at line 63 of file io.cpp.

Variable Documentation

constexpr IoEncoding ndn::io::BASE_64 = BASE64

Definition at line 65 of file io.hpp.