nlib
|
The class for reading text from streams. More...
#include "nn/nlib/TextReader.h"
Public Member Functions | |
bool | Init (InputStream *stream) noexcept |
Initializes a text reader for the specified stream. 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... | |
int | ReadAsUtf8 (char *b0, char *b1, char *b2, char *b3) noexcept |
Reads one code point from the stream and stores it as UTF-8 in b0, b1, b2, and b3. More... | |
int | ReadAsUtf16 (nlib_utf16_t *upper, nlib_utf16_t *lower) noexcept |
Reads one code point from the stream and stores it as UTF-16 in upper and lower. More... | |
int | PeekAsUtf16 (nlib_utf16_t *upper, nlib_utf16_t *lower) noexcept |
Stores the one code point from the start of the stream as UTF-16 in upper and lower. 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 152 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 149 of file TextReader.h.
|
inlinenoexcept |
Gets the current line number.
Definition at line 151 of file TextReader.h.
|
inlinenoexcept |
Gets the stream for the text reader to read.
Definition at line 150 of file TextReader.h.
|
noexcept |
Initializes a text reader for the specified stream.
[in] | stream | A stream. |
true
when successful.false
if a text reader is already initialized or if stream is NULL
. If the text is UTF-8 with BOM, the function tries to read the BOM. The function also returns false
if it fails to read the BOM.
|
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 45 of file TextReader.h.
|
inlinenoexcept |
Stores the one code point from the start of the stream as UTF-16 in upper and lower.
[out] | upper | Stores a UTF-16 character, or the high surrogate. |
[out] | lower | If there is a surrogate pair, stores the low surrogate. |
1 | Data has been stored in just upper. |
2 | Data has been stored in both upper and lower. |
0 | Indicates that the end of the stream was reached or there was an error. |
Definition at line 141 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 89 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 25 of file TextReader.h.
|
inlinenoexcept |
Reads one code point from the stream and stores it as UTF-16 in upper and lower.
[out] | upper | Stores a UTF-16 character, or the high surrogate. |
[out] | lower | If there is a surrogate pair, stores the low surrogate. |
1 | Data has been stored in just upper. |
2 | Data has been stored in both upper and lower. |
0 | Indicates that the end of the stream was reached or there was an error. |
Definition at line 137 of file TextReader.h.
|
inlinenoexcept |
Reads one code point from the stream and stores it as UTF-8 in b0, b1, b2, and b3.
[out] | b0 | Stores the first byte of a UTF-8 character. |
[out] | b1 | Stores the second byte of a UTF-8 character. |
[out] | b2 | Stores the third byte of a UTF-8 character. |
[out] | b3 | Stores the fourth byte of a UTF-8 character. |
1 | Data has been stored in just b0. |
2 | Data has been stored in b0 and b1. |
3 | Data has been stored in b0, b1 and b2. |
4 | Data has been stored in b0, b1, b2 and b3. |
0 | Indicates that the end of the stream was reached or there was an error. |
Definition at line 101 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 187 of file TextReader.h.
|
inlinenoexcept |
Sets an error value.
[in] | e | An error value. |
Definition at line 146 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 55 of file TextReader.h.
© 2013, 2014, 2015 Nintendo Co., Ltd. All rights reserved.