MT Core (C++)
Core library for replacing C++ standard in project usage
|
A reader that reads data from some sort of stream or buffer Note: the data elements read should be trivially constructible, trivially destructible, and trivially copyable. More...
#include <reader.hpp>
Public Types | |
using | ReadElem = typename Impl::ReadElem |
using | ErrType = typename Impl::ErrType |
using | BuffSlice = Slice<std::remove_const_t<ReadElem>> |
using | ResSlice = Slice<std::add_const_t<ReadElem>> |
Public Member Functions | |
Result< ResSlice, ErrType > | read (BuffSlice buff) |
Tries to read data from a reader into a buffer It will stop once the buffer is full, or once the EOF is reached If EOF is reached, the resulting subslice may be smaller than the buff Will simply return smaller buffers if EOF is met (buffers may be empty) | |
Result< ResSlice, ErrType > | read_no_eof (BuffSlice buff) |
Tries to read data from a reader into a buffer It will stop once the buffer is full, or once the EOF is reached If EOF is reached, will return the error END_OF_FILE. | |
Result< ResSlice, ErrType > | read_all (BuffSlice buff) |
Tries to read all data from a reader into a buffer It will stop once the EOF is reached If the buffer is not big enough, will return the error SIZE_EXCEEDED. | |
Result< BuffSlice, ErrType > | read_all (Allocator &alloc, size_t maxSize=std::numeric_limits< size_t >::max()) |
Tries to read all data from a reader into an internally allocated buffer Will try to shrink the buffer before returning (so an extra copy) It will stop once the EOF is reached If the buffer required would exceed maxSize, will return the error SIZE_EXCEEDED If there is an allocation error at some point, will return the error ALLOCATION_FAILED May return an empty buffer if there is no data to read The caller MUST deallocate the returned Slice with alloc.destroy_many() | |
Result< ReadElem, ErrType > | read_one () |
Will try to read a single item from the reader If there is no item to read (aka at EOF), will return the error END_OF_FILE. | |
Result< void, ErrType > | skip (size_t n) |
Will skip n items (basically reads and discards them) If there are not n items left to skip (aka it hits an EOF), will return the error END_OF_FILE. | |
Public Attributes | |
Impl | underlying |
A reader that reads data from some sort of stream or buffer Note: the data elements read should be trivially constructible, trivially destructible, and trivially copyable.
Impl | Reader Implementation ( |
Definition at line 42 of file io/reader.hpp.
using mtcore::io::Reader< Impl >::BuffSlice = Slice<std::remove_const_t<ReadElem>> |
Definition at line 46 of file io/reader.hpp.
using mtcore::io::Reader< Impl >::ErrType = typename Impl::ErrType |
Definition at line 44 of file io/reader.hpp.
using mtcore::io::Reader< Impl >::ReadElem = typename Impl::ReadElem |
Definition at line 43 of file io/reader.hpp.
using mtcore::io::Reader< Impl >::ResSlice = Slice<std::add_const_t<ReadElem>> |
Definition at line 47 of file io/reader.hpp.
|
inline |
Tries to read data from a reader into a buffer It will stop once the buffer is full, or once the EOF is reached If EOF is reached, the resulting subslice may be smaller than the buff Will simply return smaller buffers if EOF is met (buffers may be empty)
buff | Buffer to place read data into |
Definition at line 59 of file io/reader.hpp.
|
inline |
Tries to read all data from a reader into an internally allocated buffer Will try to shrink the buffer before returning (so an extra copy) It will stop once the EOF is reached If the buffer required would exceed maxSize, will return the error SIZE_EXCEEDED If there is an allocation error at some point, will return the error ALLOCATION_FAILED May return an empty buffer if there is no data to read The caller MUST deallocate the returned Slice with alloc.destroy_many()
alloc | Allocator to allocate data with |
maxSize | Maximum size for allocation. Default is no limit. If over 100MB, will allocate in 8,000 item chunks while reading |
Definition at line 113 of file io/reader.hpp.
|
inline |
Tries to read all data from a reader into a buffer It will stop once the EOF is reached If the buffer is not big enough, will return the error SIZE_EXCEEDED.
buff | Buffer to place read data into |
Definition at line 83 of file io/reader.hpp.
|
inline |
Tries to read data from a reader into a buffer It will stop once the buffer is full, or once the EOF is reached If EOF is reached, will return the error END_OF_FILE.
buff | Buffer to place read data into |
Definition at line 68 of file io/reader.hpp.
|
inline |
Will try to read a single item from the reader If there is no item to read (aka at EOF), will return the error END_OF_FILE.
Definition at line 245 of file io/reader.hpp.
|
inline |
Will skip n items (basically reads and discards them) If there are not n items left to skip (aka it hits an EOF), will return the error END_OF_FILE.
n | Number of items to skip |
Definition at line 265 of file io/reader.hpp.
Impl mtcore::io::Reader< Impl >::underlying |
Definition at line 49 of file io/reader.hpp.