CSV parser. Reads and parses the CSV string from the stream.
More...
#include "nn/nlib/msgpack/CsvReader.h"
|
static bool | Read (MpObject *obj, const char *csvtext) noexcept |
| Parses a CSV string and stores it in an object. More...
|
|
CSV parser. Reads and parses the CSV string from the stream.
- Description
- Generally follows RFC 4180 (https://www.ietf.org/rfc/rfc4180.txt).
- However, it is different in the following ways.
-
Both CR and LF alone, in addition to CRLF, are recognized as new line codes.
-
UTF-8 strings are passed. UTF-8 strings are checked for UTF-8 validity.
- The read data is converted to
MpObject
. The data takes the form of an array of arrays, and the length is normalized to the longest item. The field string may be converted to a different type when parsing.
- Specifics are shown below.
-
Integer and floating point values are converted to numerical values. Hex expressions are read as a string.
-
true
and false
are converted to a boolean value.
-
Empty strings are converted to
nil
.
Definition at line 18 of file CsvReader.h.
nn::nlib::msgpack::CsvReader::Close |
( |
| ) |
|
|
inlinenoexcept |
Closes CsvReader
.
- Returns
- Returns
true
when successful.
- Description
- Closes
CsvReader
and detaches the base stream. The base stream will not be closed.
- The object may be reused by calling the
Init
member function again.
Definition at line 27 of file CsvReader.h.
nn::nlib::msgpack::CsvReader::GetErrorValue |
( |
| ) |
const |
|
inlinenoexcept |
Gets the error that occurred.
- Return values
-
0 | No error occurred. |
EILSEQ | Incorrect CSV character found (parse error). |
EINVAL | Error in an argument. |
EEXIST | Attempted to initialize a CsvReader that has already been initialized. |
EIO | An error occurred in the base stream. |
EBADF | Attempted to use an uninitialized CsvReader . |
ENOMEM | Failed to allocate memory. |
Definition at line 28 of file CsvReader.h.
nn::nlib::msgpack::CsvReader::GetStream |
( |
| ) |
|
|
inlinenoexcept |
Gets the base stream specified in Init
.
- Returns
- Returns the pointer to the stream.
Definition at line 33 of file CsvReader.h.
nn::nlib::msgpack::CsvReader::Init |
( |
InputStream * |
stream | ) |
|
|
noexcept |
Initializes CsvWriter
.
- Parameters
-
[in] | stream | Pointer to the input stream. |
- Returns
- Returns
true
when successful.
nn::nlib::msgpack::CsvReader::Read |
( |
MpObject * |
obj, |
|
|
const char * |
csvtext |
|
) |
| |
|
staticnoexcept |
Parses a CSV string and stores it in an object.
- Parameters
-
[in] | obj | Object used to store the converted CSV. |
[in] | csvtext | CSV string. |
- Returns
- Returns
true
on success.
- Description
- Internally creates
CsvReader
to read and parse the CSV string from the stream. Returns false
if there is any error during this process. If this occurs, obj is not altered.
nn::nlib::msgpack::CsvReader::Read |
( |
MpObject * |
obj | ) |
|
|
noexcept |
- Parameters
-
[in] | obj | Object where the CSV is stored after being read. |
- Returns
- Returns
true
when successful. Reads and parses the CSV string from the stream, and stores it in the obj parameter.
- Description
- The CSV string is converted to
MpObject
and stored in the obj parameter. Sets an error and returns false
when an error occurs while reading.
The documentation for this class was generated from the following files: