nlib
JsonSchema.h
[詳解]
1 
2 /*--------------------------------------------------------------------------------*
3  Project: CrossRoad
4  Copyright (C)Nintendo All rights reserved.
5 
6  These coded instructions, statements, and computer programs contain proprietary
7  information of Nintendo and/or its licensed developers and are protected by
8  national and international copyright laws. They may not be disclosed to third
9  parties or copied or duplicated in any form, in whole or in part, without the
10  prior written consent of Nintendo.
11 
12  The content herein is highly confidential and should be handled accordingly.
13  *--------------------------------------------------------------------------------*/
14 #pragma once
15 #ifndef INCLUDE_NN_NLIB_MSGPACK_JSONSCHEMA_H_
16 #define INCLUDE_NN_NLIB_MSGPACK_JSONSCHEMA_H_
17 
18 #include <utility>
22 #include "nn/nlib/Swap.h"
23 
24 #if defined(_MSC_VER) && defined(nx_msgpack_EXPORTS)
25 #undef NLIB_VIS_PUBLIC
26 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT
27 #endif
28 NLIB_NAMESPACE_BEGIN
29 namespace msgpack {
30 
31 class JsonSchemaValidatorPrivate;
33  public:
34  enum Result {
35  kOk = 0,
41  kVersionNotSupported
42  };
43  struct Detail {
44  nlib_utf8_t path[1024];
45  };
48  NLIB_DEFMOVE_PIMPL(JsonSchemaValidator);
49  void Reset() NLIB_NOEXCEPT;
50  Result Init(const nlib_byte_t* schema_bytecode, size_t n) NLIB_NOEXCEPT;
51  Result Validate(const MpObject& obj, Detail* detail) NLIB_NOEXCEPT;
52 
53  private:
54  JsonSchemaValidatorPrivate* prv_;
56 };
57 
60  encode_description(false),
61  uri_mapper(nullptr),
62  parser_settings() {}
67 };
68 
69 class JsonSchemaConverterPrivate;
71  public:
72  enum Result {
73  kOk = 0,
81  kBufferSizeNotEnough
82  };
83  struct Detail {
84  nlib_utf8_t path[1024];
85  };
88  NLIB_DEFMOVE_PIMPL(JsonSchemaConverter);
89  Result Init(const JsonSchemaConverterSettings& settings) NLIB_NOEXCEPT;
92  return Init(settings);
93  }
94  void Reset() NLIB_NOEXCEPT;
95  Result Convert(const char* uri, Detail* detail) NLIB_NOEXCEPT;
96  Result Convert(MpObject* schema, Detail* detail) NLIB_NOEXCEPT;
97  Result Export(size_t* written, nlib_byte_t* buf, size_t bufsize) const NLIB_NOEXCEPT;
98  template<size_t N>
99  Result Export(size_t* written, nlib_byte_t (&buf)[N]) const NLIB_NOEXCEPT {
100  return Export(written, &buf[0], N);
101  }
102 #ifdef __cpp_rvalue_references
103  std::tuple<Result, std::unique_ptr<nlib_byte_t[]>, size_t> Export() const NLIB_NOEXCEPT;
104 #endif
105 
106  private:
107  JsonSchemaConverterPrivate* prv_;
109 };
110 
111 } // namespace msgpack
112 NLIB_NAMESPACE_END
113 
114 NLIB_DEFINE_STD_SWAP(::nlib_ns::msgpack::JsonSchemaConverter)
115 NLIB_DEFINE_STD_SWAP(::nlib_ns::msgpack::JsonSchemaValidator)
116 
117 #if defined(_MSC_VER) && defined(nx_msgpack_EXPORTS)
118 #undef NLIB_VIS_PUBLIC
119 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT
120 #endif
121 #endif // INCLUDE_NN_NLIB_MSGPACK_JSONSCHEMA_H_
~JsonSchemaValidator() noexcept
デストラクタです。
Definition: JsonSchema.h:47
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
TypeName で指定されたクラスのコピーコンストラクタと代入演算子を禁止します。
Definition: Config.h:183
Result
関数の実行結果です。
Definition: JsonSchema.h:34
ファイルの読み込み中に失敗しました。
Definition: JsonSchema.h:79
JsonStreamParserSettings parser_settings
JSON Schemaをパースするための設定です。
Definition: JsonSchema.h:66
bool encode_description
現在のところこの変数は無視されます。
Definition: JsonSchema.h:64
constexpr JsonSchemaConverter() noexcept
デフォルトコンストラクタです。
Definition: JsonSchema.h:86
JsonSchemaConverterの動作オプションを指定します。
Definition: JsonSchema.h:58
Result
関数の実行結果です。
Definition: JsonSchema.h:72
#define NLIB_VIS_PUBLIC
関数やクラス等のシンボルをライブラリの外部に公開します。
Definition: Platform_unix.h:87
MessagePack又はJSONを読み込むことで作成されるオブジェクトです。
Definition: MpObject.h:96
URIの処理でエラーが発生しました。
Definition: JsonSchema.h:80
bool encode_title
現在のところこの変数は無視されます。
Definition: JsonSchema.h:63
~JsonSchemaConverter() noexcept
デストラクタです。
Definition: JsonSchema.h:87
JsonStreamParserの設定パラメータ群を格納する構造体です。
MessagePack, JSON及びCSVを読み込むと作成されるオブジェクトです。
JSONやMessagePackをパースするためのクラスが定義されています。
メモリの確保に失敗しました。
Definition: JsonSchema.h:76
JSON Schemaの検証に失敗した場合、pathというメンバに検証に失敗した場所についての文字列が書き込まれます...
Definition: JsonSchema.h:43
機種依存しないURIによるパス記述からネイティブのパス文字列を得るためのクラスです。 ...
JSON Schemaによる検証に失敗しました。
Definition: JsonSchema.h:39
JSON SchemaをJsonSchemaValidatorで利用できるバイトコード形式に変換します。
Definition: JsonSchema.h:70
#define NLIB_NOEXCEPT
環境に合わせてnoexcept 又は同等の定義がされます。
Definition: Config.h:109
Result Init() noexcept
上記関数の引数省略版で、settingsをデフォルト値で渡します。
Definition: JsonSchema.h:90
#define NLIB_CEXPR
利用可能であればconstexprが定義されます。そうでない場合は空文字列です。
Definition: Config.h:111
指定されたファイルが見つかりませんでした。
Definition: JsonSchema.h:78
メモリの確保に失敗しました。
Definition: JsonSchema.h:38
const NativePathMapper * uri_mapper
URIをファイルパスに変換するためのオブジェクトへのポインタを設定します。NULLを指定することが可能です。...
Definition: JsonSchema.h:65
URIによるパス記述からプラットフォーム固有のパス記述を得るためのクラスが定義されています。 ...
#define NLIB_FINAL
利用可能であればfinalが定義されます。そうでない場合は空文字列です。
Definition: Config.h:250
JSON Schemaの変換に失敗した場合、pathというメンバに変換に失敗した場所についての文字列が書き込まれます...
Definition: JsonSchema.h:83
unsigned char nlib_byte_t
C++17以降でstd::byteにtypedefされる型です。
Definition: Platform.h:314
char nlib_utf8_t
charのtypedefです。文字列がUTF-8であることを示します。
Definition: Platform.h:303
JSON SchemaによりJSONやmsgpackの検証を行うためのクラスです。
Definition: JsonSchema.h:32
constexpr JsonSchemaValidator() noexcept
デフォルトコンストラクタです。
Definition: JsonSchema.h:46