nlib
JsonPatch.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 
15 #pragma once
16 #ifndef INCLUDE_NN_NLIB_MSGPACK_JSONPATCH_H_
17 #define INCLUDE_NN_NLIB_MSGPACK_JSONPATCH_H_
18 
19 #include <utility>
21 
22 #if defined(_MSC_VER) && defined(nx_msgpack_EXPORTS)
23 #undef NLIB_VIS_PUBLIC
24 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT
25 #endif
26 
27 NLIB_NAMESPACE_BEGIN
28 namespace msgpack {
29 
31  public:
34 #ifdef __cpp_rvalue_references
35 #ifdef NLIB_CXX11_DEFAULTED_AND_DELETED_FUNCTIONS
36  JsonPatchBuilder(JsonPatchBuilder&& rhs) = default;
37  JsonPatchBuilder& operator=(JsonPatchBuilder&& rhs) = default;
38 #else
39  JsonPatchBuilder(JsonPatchBuilder&& rhs) NLIB_NOEXCEPT : oplist_(std::move(rhs.oplist_)) {}
41  oplist_ = std::move(rhs.oplist_);
42  return *this;
43  }
44 #endif
45 #endif
47  : oplist_(rhs.oplist_, move_tag()) {}
48  JsonPatchBuilder& assign(JsonPatchBuilder& rhs, move_tag) NLIB_NOEXCEPT { // NOLINT
49  oplist_.assign(rhs.oplist_, move_tag());
50  return *this;
51  }
53  return PathValueOp("add", path, value);
54  }
55  errno_t Remove(const nlib_utf8_t* path) NLIB_NOEXCEPT;
56  NLIB_ALWAYS_INLINE errno_t Replace(const nlib_utf8_t* path, MpObject* value) NLIB_NOEXCEPT {
57  return PathValueOp("replace", path, value);
58  }
60  const nlib_utf8_t* from) NLIB_NOEXCEPT {
61  return PathFromOp("move", path, from);
62  }
64  const nlib_utf8_t* from) NLIB_NOEXCEPT {
65  return PathFromOp("copy", path, from);
66  }
67  NLIB_ALWAYS_INLINE errno_t Test(const nlib_utf8_t* path, MpObject* value) NLIB_NOEXCEPT {
68  return PathValueOp("test", path, value);
69  }
70  errno_t Export(MpObject* patch) NLIB_NOEXCEPT;
71 #ifdef __cpp_rvalue_references
72  std::pair<errno_t, MpObject> Export() NLIB_NOEXCEPT {
73  std::pair<errno_t, MpObject> rval;
74  rval.first = Export(&rval.second);
75  return rval;
76  }
77 #endif
78  NLIB_DEPRECATED void swap(JsonPatchBuilder& rhs) NLIB_NOEXCEPT {
79  using std::swap;
80  swap(oplist_, rhs.oplist_);
81  }
82 
83  private:
84  errno_t ResolvePath(const nlib_utf8_t* path, MpObject* path_obj) NLIB_NOEXCEPT;
85  errno_t PathValueOp(const nlib_utf8_t* opstr,
86  const nlib_utf8_t* path, MpObject* path_obj) NLIB_NOEXCEPT;
87  errno_t PathFromOp(const nlib_utf8_t* opstr,
88  const nlib_utf8_t* path, const nlib_utf8_t* from) NLIB_NOEXCEPT;
89 
90  private:
91  MpObject oplist_;
93 };
94 
96  public:
97  static errno_t Apply(MpObject* obj, MpObject* patch, size_t* index) NLIB_NOEXCEPT;
98 
99  private:
101 };
102 
103 } // namespace msgpack
104 NLIB_NAMESPACE_END
105 NLIB_DEFINE_STD_SWAP(::nlib_ns::msgpack::JsonPatchBuilder)
106 #if defined(_MSC_VER) && defined(nx_msgpack_EXPORTS)
107 #undef NLIB_VIS_PUBLIC
108 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT
109 #endif
110 
111 #endif // INCLUDE_NN_NLIB_MSGPACK_JSONPATCH_H_
112 
#define NLIB_ALWAYS_INLINE
コンパイラに関数をインライン展開するように強く示します。
Definition: Platform_unix.h:97
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
TypeName で指定されたクラスのコピーコンストラクタと代入演算子を禁止します。
Definition: Config.h:179
#define NLIB_DEPRECATED
関数等がdeprecatedになったことを示します。
Definition: Config.h:109
#define NLIB_VIS_PUBLIC
関数やクラス等のシンボルをライブラリの外部に公開します。
Definition: Platform_unix.h:89
JSON Patch (RFC-6902)を適用するためのクラスです。
Definition: JsonPatch.h:95
MessagePack又はJSONを読み込むことで作成されるオブジェクトです。
Definition: MpObject.h:95
errno_t Copy(const nlib_utf8_t *path, const nlib_utf8_t *from) noexcept
JSON Patch文書となる配列に"copy"演算を追加します。
Definition: JsonPatch.h:63
errno_t Test(const nlib_utf8_t *path, MpObject *value) noexcept
JSON Patch文書となる配列に"test"演算を追加します。
Definition: JsonPatch.h:67
空の構造体で、関数の引数をムーブすべきことを示すために利用されます。
Definition: Config.h:265
MessagePack, JSON及びCSVを読み込むと作成されるオブジェクトです。
#define NLIB_NOEXCEPT
環境に合わせてnoexcept 又は同等の定義がされます。
Definition: Config.h:105
errno_t Add(const nlib_utf8_t *path, MpObject *value) noexcept
JSON Patch文書となる配列に"add"演算を追加します。
Definition: JsonPatch.h:52
#define NLIB_FINAL
利用可能であればfinalが定義されます。そうでない場合は空文字列です。
Definition: Config.h:245
errno_t Move(const nlib_utf8_t *path, const nlib_utf8_t *from) noexcept
JSON Patch文書となる配列に"move"演算を追加します。
Definition: JsonPatch.h:59
char nlib_utf8_t
charのtypedefです。文字列がUTF-8であることを示します。
Definition: Platform.h:308
JSON Patch (RFC-6902)を作成するためのクラスです。
Definition: JsonPatch.h:30
int errno_t
intのtypedefで、戻り値としてPOSIXのエラー値を返すことを示します。
Definition: NMalloc.h:37