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()) {}
49  oplist_.assign(rhs.oplist_, move_tag());
50  return *this;
51  }
53  return PathValueOp("add", path, value);
54  }
55 #ifdef __cpp_rvalue_references
57  return PathValueOp("add", path, &value);
58  }
59 #endif
60  errno_t Remove(const nlib_utf8_t* path) NLIB_NOEXCEPT;
62  return PathValueOp("replace", path, value);
63  }
64 #ifdef __cpp_rvalue_references
66  return PathValueOp("replace", path, &value);
67  }
68 #endif
70  const nlib_utf8_t* from) NLIB_NOEXCEPT {
71  return PathFromOp("move", path, from);
72  }
74  const nlib_utf8_t* from) NLIB_NOEXCEPT {
75  return PathFromOp("copy", path, from);
76  }
78  return PathValueOp("test", path, value);
79  }
80 #ifdef __cpp_rvalue_references
82  return PathValueOp("test", path, &value);
83  }
84 #endif
85  errno_t Export(MpObject* patch) NLIB_NOEXCEPT;
86 #ifdef __cpp_rvalue_references
87  std::pair<errno_t, std::unique_ptr<MpObject> > Export() NLIB_NOEXCEPT;
88 #endif
89 
90  private:
91  errno_t ResolvePath(const nlib_utf8_t* path, MpObject* path_obj) NLIB_NOEXCEPT;
92  errno_t PathValueOp(const nlib_utf8_t* opstr, const nlib_utf8_t* path,
93  MpObject* path_obj) NLIB_NOEXCEPT;
94  errno_t PathFromOp(const nlib_utf8_t* opstr, const nlib_utf8_t* path,
95  const nlib_utf8_t* from) NLIB_NOEXCEPT;
96 
97  private:
98  MpObject oplist_;
100 };
101 
103  public:
104  static errno_t Apply(MpObject* obj, MpObject* patch, size_t* index) NLIB_NOEXCEPT;
105 
106  private:
108 };
109 
110 } // namespace msgpack
111 NLIB_NAMESPACE_END
112 NLIB_DEFINE_STD_SWAP(::nlib_ns::msgpack::JsonPatchBuilder)
113 #if defined(_MSC_VER) && defined(nx_msgpack_EXPORTS)
114 #undef NLIB_VIS_PUBLIC
115 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT
116 #endif
117 
118 #endif // INCLUDE_NN_NLIB_MSGPACK_JSONPATCH_H_
#define NLIB_ALWAYS_INLINE
コンパイラに関数をインライン展開するように強く示します。
Definition: Platform_unix.h:95
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
TypeName で指定されたクラスのコピーコンストラクタと代入演算子を禁止します。
Definition: Config.h:183
errno_t Add(const nlib_utf8_t *path, MpObject &&value) noexcept
JSON Patch文書となる配列に"add"演算を追加します。
Definition: JsonPatch.h:56
#define NLIB_VIS_PUBLIC
関数やクラス等のシンボルをライブラリの外部に公開します。
Definition: Platform_unix.h:87
JSON Patch (RFC-6902)を適用するためのクラスです。
Definition: JsonPatch.h:102
MessagePack又はJSONを読み込むことで作成されるオブジェクトです。
Definition: MpObject.h:96
errno_t Copy(const nlib_utf8_t *path, const nlib_utf8_t *from) noexcept
JSON Patch文書となる配列に"copy"演算を追加します。
Definition: JsonPatch.h:73
errno_t Test(const nlib_utf8_t *path, MpObject *value) noexcept
JSON Patch文書となる配列に"test"演算を追加します。
Definition: JsonPatch.h:77
空の構造体で、関数の引数をムーブすべきことを示すために利用されます。
Definition: Config.h:270
MessagePack, JSON及びCSVを読み込むと作成されるオブジェクトです。
#define NLIB_NOEXCEPT
環境に合わせてnoexcept 又は同等の定義がされます。
Definition: Config.h:109
errno_t Add(const nlib_utf8_t *path, MpObject *value) noexcept
JSON Patch文書となる配列に"add"演算を追加します。
Definition: JsonPatch.h:52
errno_t Test(const nlib_utf8_t *path, MpObject &&value) noexcept
JSON Patch文書となる配列に"test"演算を追加します。
Definition: JsonPatch.h:81
errno_t Replace(const nlib_utf8_t *path, MpObject &&value) noexcept
JSON Patch文書となる配列に"replace"演算を追加します。
Definition: JsonPatch.h:65
errno_t Replace(const nlib_utf8_t *path, MpObject *value) noexcept
JSON Patch文書となる配列に"replace"演算を追加します。
Definition: JsonPatch.h:61
#define NLIB_FINAL
利用可能であればfinalが定義されます。そうでない場合は空文字列です。
Definition: Config.h:250
errno_t Move(const nlib_utf8_t *path, const nlib_utf8_t *from) noexcept
JSON Patch文書となる配列に"move"演算を追加します。
Definition: JsonPatch.h:69
char nlib_utf8_t
charのtypedefです。文字列がUTF-8であることを示します。
Definition: Platform.h:303
JSON Patch (RFC-6902)を作成するためのクラスです。
Definition: JsonPatch.h:30
int errno_t
intのtypedefで、戻り値としてPOSIXのエラー値を返すことを示します。
Definition: NMalloc.h:37