nlib
|
The class for reading binary from streams (from InputStream
).
More...
#include "nn/nlib/BinaryReader.h"
Public Types | |
enum | EndianSetting { kEndianDefault = 0, kEndianLittle, kEndianBig } |
Specifies the endianness. More... | |
Public Member Functions | |
errno_t | Init (EndianSetting endian) noexcept |
Initializes the binary reader with the endian specified. More... | |
errno_t | Init () noexcept |
Initializes the binary reader using the same endianness as the machine the program is running on. More... | |
errno_t | Open (InputStream *stream) noexcept |
Associates the stream with the binary reader. More... | |
template<class T > | |
bool | Read (T *x) noexcept |
Calls binary_reader::Read() . | |
int | Peek () noexcept |
References the first byte of the stream. More... | |
bool | Skip (size_t n) noexcept |
Skips over n bytes when reading from stream. More... | |
template<class T > | |
size_t | ReadArray (T *x, size_t n) noexcept |
Calls binary_reader::ReadArray() . | |
template<class T , size_t N> | |
size_t | ReadArray (T(&a)[N]) noexcept |
Reads an array from a stream. More... | |
bool | Close () noexcept |
Closes the binary reader. More... | |
void | SetError (errno_t e) noexcept |
Sets an error. If an error has been set already, this function does not set an error. More... | |
errno_t | GetErrorValue () const noexcept |
This function can get the cause of the error when writing has failed. More... | |
operator bool () const | |
Returns true if no internal error has occurred. | |
Basic Member Functions | |
BinaryReader () noexcept | |
Instantiates the object with default parameters (default constructor). | |
~BinaryReader () noexcept | |
Destructor. This function does not close the stream. | |
Reading Basic Data Types | |
bool | Read (char *x) noexcept |
Reads char -type data as binary from a stream. Returns true if successful. | |
bool | Read (signed char *x) noexcept |
Reads signed char -type data as binary from a stream. Returns true if successful. | |
bool | Read (unsigned char *x) noexcept |
Reads unsigned char -type data as binary from a stream. Returns true if successful. | |
bool | Read (short *x) noexcept |
Reads short -type data as binary from a stream. Returns true if successful. | |
bool | Read (unsigned short *x) noexcept |
Reads unsigned short -type data as binary from a stream. Returns true if successful. | |
bool | Read (int *x) noexcept |
Reads int -type data as binary from a stream. Returns true if successful. | |
bool | Read (unsigned int *x) noexcept |
Reads unsigned int -type data as binary from a stream. Returns true if successful. | |
bool | Read (long *x) noexcept |
Reads long -type data as binary from a stream. Returns true if successful. | |
bool | Read (unsigned long *x) noexcept |
Reads unsigned long -type data as binary from a stream. Returns true if successful. | |
bool | Read (long long *x) noexcept |
Reads long long -type data as binary from a stream. Returns true if successful. | |
bool | Read (unsigned long long *x) noexcept |
Reads unsigned long long -type data as binary from a stream. Returns true if successful. | |
bool | Read (float *x) noexcept |
Reads float -type data as binary from a stream. Returns true if successful. | |
bool | Read (double *x) noexcept |
Reads double -type data as binary from a stream. Returns true if successful. | |
Reading Basic Data Types Arrays | |
size_t | ReadArray (unsigned char *x, size_t n) noexcept |
Reads an unsigned char -type data string as binary from a stream. | |
size_t | ReadArray (unsigned short *x, size_t n) noexcept |
Reads an unsigned short -type data string as binary from a stream. | |
size_t | ReadArray (unsigned int *x, size_t n) noexcept |
Reads an unsigned int -type data string as binary from a stream. | |
size_t | ReadArray (unsigned long long *x, size_t n) noexcept |
Reads an unsigned long long -type data string as binary from a stream. | |
size_t | ReadArray (unsigned long *x, size_t n) noexcept |
Reads an unsigned long -type data string as binary from a stream. | |
size_t | ReadArray (float *x, size_t n) noexcept |
Reads a float -type data string as binary from a stream. | |
size_t | ReadArray (double *x, size_t n) noexcept |
Reads a double -type data string as binary from a stream. | |
size_t | ReadArray (signed char *x, size_t n) noexcept |
Reads a signed char -type data string as binary from a stream. | |
size_t | ReadArray (char *x, size_t n) noexcept |
Reads a char -type data string as binary from a stream. | |
size_t | ReadArray (short *x, size_t n) noexcept |
Reads a short -type data string as binary from a stream. | |
size_t | ReadArray (int *x, size_t n) noexcept |
Reads an int -type data string as binary from a stream. | |
size_t | ReadArray (long *x, size_t n) noexcept |
Reads a long -type data string as binary from a stream. | |
size_t | ReadArray (long long *x, size_t n) noexcept |
Reads a long long -type data string as binary from a stream. | |
The class for reading binary from streams (from InputStream
).
Definition at line 26 of file BinaryReader.h.
Specifies the endianness.
Enumerator | |
---|---|
kEndianDefault | Writes data in the same endianness as the machine the program is running on. |
kEndianLittle | Writes in little-endian. |
kEndianBig | Writes in big-endian. |
Definition at line 28 of file BinaryReader.h.
|
inlinenoexcept |
Closes the binary reader.
true
on success. (Always successful.)Definition at line 123 of file BinaryReader.h.
|
inlinenoexcept |
This function can get the cause of the error when writing has failed.
0 | No error occurred. |
EINVAL | Invalid argument. |
EEXIST | Initialized redundantly. |
EBADF | No stream to read. |
EIO | Failed to read from the stream for some reason. |
Definition at line 131 of file BinaryReader.h.
|
noexcept |
Initializes the binary reader with the endian specified.
[in] | endian | Specifies the endian. |
0
if successful.
|
inlinenoexcept |
Initializes the binary reader using the same endianness as the machine the program is running on.
0
if successful. Definition at line 43 of file BinaryReader.h.
|
noexcept |
Associates the stream with the binary reader.
[in] | stream | A stream. |
0
if successful.
|
inlinenoexcept |
References the first byte of the stream.
-1 | Failure. |
Any | other value The first byte of the stream. |
Definition at line 65 of file BinaryReader.h.
|
inlinenoexcept |
Reads an array from a stream.
T | The numeric type (such as int32_t or float ). |
[out] | a | The array storing the data. |
Definition at line 191 of file BinaryReader.h.
|
inlinenoexcept |
Sets an error. If an error has been set already, this function does not set an error.
[in] | e | An error value. |
Definition at line 128 of file BinaryReader.h.
|
inlinenoexcept |
Skips over n bytes when reading from stream.
[in] | n | The number of bytes to skip. |
true
when successful. Definition at line 68 of file BinaryReader.h.
© 2012-2017 Nintendo Co., Ltd. All rights reserved.