interface of stream I/O for serialization
More...
#include <io.h>
|
virtual size_t | Read (void *ptr, size_t size)=0 |
| reads data from a stream More...
|
|
virtual void | Write (const void *ptr, size_t size)=0 |
| writes data to a stream More...
|
|
virtual | ~Stream (void) |
| virtual destructor More...
|
|
template<typename T > |
void | Write (const T &data) |
| writes a data to stream. More...
|
|
template<typename T > |
bool | Read (T *out_data) |
| loads a data from stream. More...
|
|
template<typename T > |
void | WriteArray (const T *data, size_t num_elems) |
| Endian aware write array of data. More...
|
|
template<typename T > |
bool | ReadArray (T *data, size_t num_elems) |
| Endian aware read array of data. More...
|
|
|
static Stream * | Create (const char *uri, const char *const flag, bool allow_null=false) |
| generic factory function create an stream, the stream will close the underlying files upon deletion More...
|
|
interface of stream I/O for serialization
virtual dmlc::Stream::~Stream |
( |
void |
| ) |
|
|
inlinevirtual |
static Stream* dmlc::Stream::Create |
( |
const char * |
uri, |
|
|
const char *const |
flag, |
|
|
bool |
allow_null = false |
|
) |
| |
|
static |
generic factory function create an stream, the stream will close the underlying files upon deletion
- Parameters
-
uri | the uri of the input currently we support hdfs://, s3://, and file:// by default file:// will be used |
flag | can be "w", "r", "a" |
allow_null | whether NULL can be returned, or directly report error |
- Returns
- the created stream, can be NULL when allow_null == true and file do not exist
virtual size_t dmlc::Stream::Read |
( |
void * |
ptr, |
|
|
size_t |
size |
|
) |
| |
|
pure virtual |
template<typename T >
bool dmlc::Stream::Read |
( |
T * |
out_data | ) |
|
|
inline |
loads a data from stream.
dmlc::Stream support Write/Read of most STL composites and base types. If the data type is not supported, a compile time error will be issued.
This function is endian-aware, the input endian defined by DMLC_IO_USE_LITTLE_ENDIAN
- Parameters
-
out_data | place holder of data to be deserialized |
- Returns
- whether the load was successful
template<typename T >
bool dmlc::Stream::ReadArray |
( |
T * |
data, |
|
|
size_t |
num_elems |
|
) |
| |
|
inline |
Endian aware read array of data.
- Parameters
-
data | The data pointer |
num_elems | Number of elements |
- Template Parameters
-
- Returns
- whether the load was successful
virtual void dmlc::Stream::Write |
( |
const void * |
ptr, |
|
|
size_t |
size |
|
) |
| |
|
pure virtual |
template<typename T >
void dmlc::Stream::Write |
( |
const T & |
data | ) |
|
|
inline |
writes a data to stream.
dmlc::Stream support Write/Read of most STL composites and base types. If the data type is not supported, a compile time error will be issued.
This function is endian-aware, the output endian defined by DMLC_IO_USE_LITTLE_ENDIAN
- Parameters
-
- Template Parameters
-
T | the data type to be written |
template<typename T >
void dmlc::Stream::WriteArray |
( |
const T * |
data, |
|
|
size_t |
num_elems |
|
) |
| |
|
inline |
Endian aware write array of data.
- Parameters
-
data | The data pointer |
num_elems | Number of elements |
- Template Parameters
-
The documentation for this class was generated from the following file:
- /work/mxnet/3rdparty/dmlc-core/include/dmlc/io.h