nlib
|
Converts JSON Schema to a byte-code format available for JsonSchemaValidator. More...
#include "nn/nlib/msgpack/JsonSchema.h"
Classes | |
struct | Detail |
If the conversion of JSON Schema has failed, a string representing the location where the conversion has failed is written into a member named path. More... | |
Public Types | |
enum | Result { kOk = 0, kInvalidParam, kAlreadyInitialized, kOutOfMemory, kInvalidSchema, kFileNotFound, kIoError, kUriError, kBufferSizeNotEnough } |
The result of the function executed. More... | |
Public Member Functions | |
Result | Convert (const char *uri, Detail *detail) noexcept |
Converts JSON Schema to a format available for JsonSchemaValidator. More... | |
Result | Convert (MpObject *schema, Detail *detail) noexcept |
Converts JSON Schema to a format available for JsonSchemaValidator. More... | |
Result | Export (size_t *written, nlib_byte_t *buf, size_t bufsize) const noexcept |
Writes JSON Schema converted to byte-code. More... | |
template<size_t N> | |
Result | Export (size_t *written, nlib_byte_t(&buf)[N]) const noexcept |
A template overload of the above function. | |
std::tuple< Result, std::unique_ptr< nlib_byte_t[]>, size_t > | Export () const noexcept |
Returns JSON Schema converted into a byte-code. More... | |
Constructor, Destructor, and Initialization | |
constexpr | JsonSchemaConverter () noexcept |
Instantiates the object with default parameters (default constructor). | |
~JsonSchemaConverter () noexcept | |
Destructor. | |
JsonSchemaConverter (JsonSchemaConverter &&rhs) | |
Instantiates the object (move constructor). | |
JsonSchemaConverter & | operator= (JsonSchemaConverter &&rhs) |
Move assignment operator. | |
Result | Init (const JsonSchemaConverterSettings &settings) noexcept |
Initializes the object. More... | |
Result | Init () noexcept |
A parameter omitted version of the above function which passes settings as the default value. | |
void | Reset () noexcept |
Resets this object to the state immediately after the default constructor was executed. | |
Converts JSON Schema to a byte-code format available for JsonSchemaValidator.
JsonSchemaValidator::Validate()
. Definition at line 70 of file JsonSchema.h.
The result of the function executed.
Definition at line 72 of file JsonSchema.h.
|
noexcept |
Converts JSON Schema to a format available for JsonSchemaValidator.
[in] | uri | The absolute URI indicating JSON which should be JSON Schema. |
[in] | detail | If specifying non-NULL, additional information can be obtained when an error has occurred. |
kOk | The conversion has been successfully completed. |
kOutOfMemory | Memory allocation failed. |
kInvalidSchema | Invalid schema. |
kFileNotFound | The file to be read could not be found. |
kIoError | Reading the file failed. |
kUriError | Invalid URI was found or uri was a relative URI. |
JsonSchemaConverterSettings::uri_mapper
is used to convert the URI to the actual file path. If uri is NULL
, uri is assumed to be "nlibpath:///jsonschema/schema.json." Converts JSON Schema to a format available for JsonSchemaValidator.
[in,out] | schema | The JSON Schema to be converted. Note that internal values may be changed. |
[in] | detail | If not specifying NULL , additional information can be obtained when an error has occurred. |
kOk | The conversion has been successfully completed. |
kOutOfMemory | Memory allocation failed. |
kInvalidParam | schema was NULL . |
kInvalidSchema | Invalid schema. |
kFileNotFound | The file to be read could not be found. |
kIoError | Reading the file failed. |
kUriError | An invalid URI was found. |
|
noexcept |
Writes JSON Schema converted to byte-code.
[out] | written | The number of bytes written. |
[out] | buf | The buffer that the data is written into. |
[in] | bufsize | The size of the buffer. |
0 | Success. |
kInvalidParam | written or buf is NULL. |
kOutOfMemory | Memory allocation failed. |
kBufferSizeNotEnough | Insufficient buffer size. |
|
noexcept |
Returns JSON Schema converted into a byte-code.
kOutOfMemory
is set, or kInvalidSchema
is set if the required memory size has exceeded 16 Mb.
|
noexcept |
Initializes the object.
[in] | settings | Structure for specifying conversion options. |
kOk | Success. |
kAlreadyInitialized | The object has been already initialized. |
kOutOfMemory | Memory allocation failed. |
© Nintendo Co., Ltd. All rights reserved.