nlib
|
The class for writing binary to streams (to OutputStream
).
More...
#include "nn/nlib/BinaryWriter.h"
Public Types | |
enum | EndianSetting { DEFAULT = 0, ENDIAN_LITTLE, ENDIAN_BIG } |
Specifies the endianness. More... | |
Public Member Functions | |
errno_t | Init (EndianSetting endian) noexcept |
Initializes the binary writer with the endian specified. More... | |
errno_t | Init () noexcept |
Initializes the binary writer using the same endianness as the machine the program is running on. More... | |
errno_t | Open (OutputStream *stream) noexcept |
Associates the stream with the binary writer. More... | |
template<class T > | |
bool | Write (T x) noexcept |
Calls binary_writer::Write() . | |
template<class T > | |
bool | WriteArray (const T *x, size_t n) noexcept |
Calls binary_writer::WriteArray . | |
template<class T , size_t N> | |
bool | WriteArray (const T(&a)[N]) noexcept |
Writes a numeric-type array to a stream. More... | |
bool | Flush () noexcept |
Flushes the binary writer and the base stream. More... | |
bool | Close () noexcept |
Closes the binary writer. 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... | |
OutputStream * | GetStream () noexcept |
Gets the stream for the text writer to write to. More... | |
operator bool () const | |
Returns true if no internal error has occurred. | |
Basic Member Functions | |
BinaryWriter () noexcept | |
Instantiates the object with default parameters (default constructor). | |
~BinaryWriter () noexcept | |
Destructor. This function does not close the stream. | |
Writing Basic Data Types | |
bool | Write (char x) noexcept |
Writes char -type data as binary to a stream. Returns true if successful. | |
bool | Write (signed char x) noexcept |
Writes signed char -type data as binary to a stream. Returns true if successful. | |
bool | Write (unsigned char x) noexcept |
Writes unsigned char -type data as binary to a stream. Returns true if successful. | |
bool | Write (short x) noexcept |
Writes short -type data as binary to a stream. Returns true if successful. | |
bool | Write (unsigned short x) noexcept |
Writes unsigned short -type data as binary to a stream. Returns true if successful. | |
bool | Write (int x) noexcept |
Writes int -type data as binary to a stream. Returns true if successful. | |
bool | Write (unsigned int x) noexcept |
Writes unsigned int -type data as binary to a stream. Returns true if successful. | |
bool | Write (long x) noexcept |
Writes long -type data as binary to a stream. Returns true if successful. | |
bool | Write (unsigned long x) noexcept |
Writes unsigned long -type data as binary to a stream. Returns true if successful. | |
bool | Write (long long x) noexcept |
Writes long long -type data as binary to a stream. Returns true if successful. | |
bool | Write (unsigned long long x) noexcept |
Writes unsigned long long -type data as binary to a stream. Returns true if successful. | |
bool | Write (float x) noexcept |
Writes float -type data as binary to a stream. Returns true if successful. | |
bool | Write (double x) noexcept |
Writes double -type data as binary to a stream. Returns true if successful. | |
Writing Basic Data Type Arrays | |
bool | WriteArray (const unsigned char *x, size_t n) noexcept |
Writes an unsigned char -type array as binary to a stream. Returns true if successful. If n is 0, it will also successfully complete. | |
bool | WriteArray (const unsigned short *x, size_t n) noexcept |
Writes an unsigned short -type array as binary to a stream. Returns true if successful. If n is 0, it will also successfully complete. | |
bool | WriteArray (const unsigned int *x, size_t n) noexcept |
Writes an unsigned int -type array as binary to a stream. Returns true if successful. If n is 0, it will also successfully complete. | |
bool | WriteArray (const unsigned long long *x, size_t n) noexcept |
Writes an unsigned long long -type array as binary to a stream. Returns true if successful. If n is 0, it will also successfully complete. | |
bool | WriteArray (const unsigned long *x, size_t n) noexcept |
Writes an unsigned long -type array as binary to a stream. Returns true if successful. If n is 0, it will also successfully complete. | |
bool | WriteArray (const float *x, size_t n) noexcept |
Writes a float -type array as binary to a stream. Returns true if successful. If n is 0, it will also successfully complete. | |
bool | WriteArray (const double *x, size_t n) noexcept |
Writes a double -type array as binary to a stream. Returns true if successful. If n is 0, it will also successfully complete. | |
bool | WriteArray (const signed char *x, size_t n) noexcept |
Writes a signed char -type array as binary to a stream. Returns true if successful. If n is 0, it will also successfully complete. | |
bool | WriteArray (const char *x, size_t n) noexcept |
Writes a char -type array as binary to a stream. Returns true if successful. If n is 0, it will also successfully complete. | |
bool | WriteArray (const short *x, size_t n) noexcept |
Writes a short -type array as binary to a stream. Returns true if successful. If n is 0, it will also successfully complete. | |
bool | WriteArray (const int *x, size_t n) noexcept |
Writes an int -type array as binary to a stream. Returns true if successful. If n is 0, it will also successfully complete. | |
bool | WriteArray (const long *x, size_t n) noexcept |
Writes a long -type array as binary to a stream. Returns true if successful. If n is 0, it will also successfully complete. | |
bool | WriteArray (const long long *x, size_t n) noexcept |
Writes a long long -type array as binary to a stream. Returns true if successful. If n is 0, it will also successfully complete. | |
The class for writing binary to streams (to OutputStream
).
Definition at line 13 of file BinaryWriter.h.
Specifies the endianness.
Enumerator | |
---|---|
DEFAULT | Writes data in the same endianness as the machine the program is running on. |
ENDIAN_LITTLE | Writes in little-endian. |
ENDIAN_BIG | Writes in big-endian. |
Definition at line 15 of file BinaryWriter.h.
|
noexcept |
Closes the binary writer.
true
when successful.
|
noexcept |
Flushes the binary writer and the base stream.
true
when successful.
|
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 write to. |
EIO | Writing to the stream has failed for some reason. |
Definition at line 90 of file BinaryWriter.h.
|
inlinenoexcept |
Gets the stream for the text writer to write to.
Definition at line 91 of file BinaryWriter.h.
|
noexcept |
Initializes the binary writer with the endian specified.
[in] | endian | Specifies the endian. |
0
if successful.
|
inlinenoexcept |
Initializes the binary writer using the same endianness as the machine the program is running on.
0
if successful. Definition at line 23 of file BinaryWriter.h.
|
noexcept |
Associates the stream with the binary writer.
[in] | stream | A stream. |
0
if successful.
|
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 87 of file BinaryWriter.h.
|
inlinenoexcept |
Writes a numeric-type array to a stream.
T | The numeric type (such as int32_t or float ). |
[in] | a | The array to write. |
true
when successful. Definition at line 135 of file BinaryWriter.h.
© 2012-2016 Nintendo Co., Ltd. All rights reserved.