nlib
|
The class for reading text from streams. More...
#include "nn/nlib/TextReader.h"
Public Member Functions | |
errno_t | Init () noexcept |
Initializes the text reader. More... | |
errno_t | Open (InputStream *stream) noexcept |
Opens a text reader with a stream specified. More... | |
int | Read () noexcept |
Reads one character from the stream and returns UTF-32 data. More... | |
int | Peek () noexcept |
Returns one character from the start of the stream in UTF-32. More... | |
int | SkipWs () noexcept |
Skips white-space characters (space, newline, tab, and return) in the stream and returns the number that were skipped. More... | |
bool | ReadUntil (size_t *len, char *buf, size_t n, char delim) noexcept |
Reads as many as n bytes of UTF-8 characters until delim and stores them in buf. More... | |
template<size_t N> | |
bool | ReadUntil (size_t *len, char(&buf)[N], char delim) noexcept |
Calls ReadUntil(len, buf, N, delim) . | |
template<class T > | |
bool | ReadUntil (size_t *len, char *buf, size_t n, T pred) noexcept |
Reads as many as n bytes of UTF-8 characters and stores them in buf. More... | |
template<class T , size_t N> | |
bool | ReadUntil (size_t *len, char(&buf)[N], T pred) noexcept |
Calls ReadUntil(len, buf, N, pred) . | |
size_t | ReadDecimalString (char *buf, size_t n) noexcept |
Reads as many as n of the characters 0 through 9 and stores them in buf. More... | |
template<size_t N> | |
size_t | ReadDecimalString (char(&buf)[N]) noexcept |
Calls ReadDecimalString(buf, N) . | |
bool | Proceed (const char *str, size_t n) noexcept |
Advances the stream by the amount of the text string str. More... | |
bool | Proceed (char c) noexcept |
Advances the stream by the amount of the character specified by c. More... | |
bool | ProceedEx (const char *str) noexcept |
Advances the stream by the amount of the text string str. There is no limit on the length of the text string, and the position of the stream might be changed even if it does not match. More... | |
bool | Close () noexcept |
Closes the text reader. More... | |
void | SetError (errno_t e) const noexcept |
Sets an error value. More... | |
errno_t | GetErrorValue () const noexcept |
This function can get the cause of the error when reading has failed. More... | |
InputStream * | GetStream () noexcept |
Gets the stream for the text reader to read. More... | |
int | GetLine () const noexcept |
Gets the current line number. More... | |
int | GetColumn () const noexcept |
Gets the current column. More... | |
operator bool () const | |
Returns true if no internal error has occurred. | |
Basic Member Functions | |
TextReader () noexcept | |
Instantiates the object with default parameters (default constructor). | |
virtual | ~TextReader () noexcept |
Destructor. The stream is not closed. | |
The class for reading text from streams.
EILSEQ
). An error (EILSEQ
) is also generated if UTF-8 corresponding to U+D800-U+DFFF is detected. TextReader
and overriding a FillBuffer_
member function. The TextReader
class checks if UTF-8 is enabled and processes newline codes. Definition at line 20 of file TextReader.h.
|
noexcept |
Closes the text reader.
true
if successful.
|
inlinenoexcept |
Gets the current column.
0
and sets the error EBADF
if the stream is not open. Definition at line 108 of file TextReader.h.
|
inlinenoexcept |
This function can get the cause of the error when reading 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. |
EILSEQ | Invalid character found. |
Definition at line 105 of file TextReader.h.
|
inlinenoexcept |
Gets the current line number.
Definition at line 107 of file TextReader.h.
|
inlinenoexcept |
Gets the stream for the text reader to read.
Definition at line 106 of file TextReader.h.
|
noexcept |
Initializes the text reader.
EALREADY
if already initialized.
|
noexcept |
Opens a text reader with a stream specified.
[in] | stream | A stream. |
0 | if successful. |
EINVAL | if the stream is NULL . |
EEXIST | if already opened. |
|
inlinenoexcept |
Returns one character from the start of the stream in UTF-32.
-1
if the end of the stream was reached or there was an error. Definition at line 46 of file TextReader.h.
|
noexcept |
Advances the stream by the amount of the text string str.
[in] | str | A pointer to a UTF-8 text string. |
[in] | n | The length of the string, in bytes. |
true | Indicates that the start of the stream matched str. |
false | Returned in all other cases. |
|
inlinenoexcept |
Advances the stream by the amount of the character specified by c.
[in] | c | The character to skip over. |
true | Indicates that the start of the stream matched c. |
false | Returned in all other cases. |
Definition at line 90 of file TextReader.h.
|
noexcept |
Advances the stream by the amount of the text string str. There is no limit on the length of the text string, and the position of the stream might be changed even if it does not match.
[in] | str | A pointer to a UTF-8 text string. |
true | Indicates that the start of the stream matched str. |
false | Returned in all other cases. |
|
inlinenoexcept |
Reads one character from the stream and returns UTF-32 data.
-1
if the end of the stream was reached or there was an error. Definition at line 26 of file TextReader.h.
|
noexcept |
Reads as many as n of the characters 0 through 9 and stores them in buf.
[out] | buf | The buffer to which the string is stored. |
[in] | n | The size of the buffer. |
|
noexcept |
Reads as many as n bytes of UTF-8 characters until delim and stores them in buf.
[out] | len | The number of bytes stored in buf. |
[out] | buf | The buffer where the text string is stored. |
[in] | n | The size of the buffer. |
[in] | delim | The delimiter. |
true
if a delimiter was found somewhere within the n bytes. If not, returns false
.
|
noexcept |
Reads as many as n bytes of UTF-8 characters and stores them in buf.
T | The type for function objects for making determinations. |
[out] | len | The number of bytes stored in buf. |
[out] | buf | The buffer where the text string is stored. |
[in] | n | The size of the buffer. |
[in] | pred | A function object. |
true
if a delimiter was found somewhere within the n bytes. If not, returns false
.pred(const char* ptr)
and determines whether there is a delimiter. ptr, which is an argument for pred, takes a pointer to a UTF-8 character. One code point of data can be accessed. Definition at line 143 of file TextReader.h.
|
inlinenoexcept |
Sets an error value.
[in] | e | An error value. |
Definition at line 102 of file TextReader.h.
|
inlinenoexcept |
Skips white-space characters (space, newline, tab, and return) in the stream and returns the number that were skipped.
Definition at line 56 of file TextReader.h.
© 2012-2016 Nintendo Co., Ltd. All rights reserved.