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 
20 
21 #if defined(_MSC_VER) && defined(nx_msgpack_EXPORTS)
22 #undef NLIB_VIS_PUBLIC
23 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT
24 #endif
25 
26 NLIB_NAMESPACE_BEGIN
27 namespace msgpack {
28 
30  public:
33  NLIB_MOVE_MEMBER_HELPER_1(JsonPatchBuilder, oplist_);
35  return PathValueOp("add", path, value);
36  }
37  errno_t Remove(const nlib_utf8_t* path) NLIB_NOEXCEPT;
38  NLIB_ALWAYS_INLINE errno_t Replace(const nlib_utf8_t* path, MpObject* value) NLIB_NOEXCEPT {
39  return PathValueOp("replace", path, value);
40  }
42  const nlib_utf8_t* from) NLIB_NOEXCEPT {
43  return PathFromOp("move", path, from);
44  }
46  const nlib_utf8_t* from) NLIB_NOEXCEPT {
47  return PathFromOp("copy", path, from);
48  }
49  NLIB_ALWAYS_INLINE errno_t Test(const nlib_utf8_t* path, MpObject* value) NLIB_NOEXCEPT {
50  return PathValueOp("test", path, value);
51  }
52  errno_t Export(MpObject* patch) NLIB_NOEXCEPT;
53  void swap(JsonPatchBuilder& rhs) NLIB_NOEXCEPT {
54  using std::swap;
55  swap(oplist_, rhs.oplist_);
56  }
57 
58  private:
59  errno_t ResolvePath(const nlib_utf8_t* path, MpObject* path_obj) NLIB_NOEXCEPT;
60  errno_t PathValueOp(const nlib_utf8_t* opstr,
61  const nlib_utf8_t* path, MpObject* path_obj) NLIB_NOEXCEPT;
62  errno_t PathFromOp(const nlib_utf8_t* opstr,
63  const nlib_utf8_t* path, const nlib_utf8_t* from) NLIB_NOEXCEPT;
64 
65  private:
66  MpObject oplist_;
68 };
69 
71  public:
72  static errno_t Apply(MpObject* obj, MpObject* patch, size_t* index) NLIB_NOEXCEPT;
73  private:
74  JsonPatch(); // forbidden
75  ~JsonPatch(); // forbidden
76 };
77 
78 } // namespace msgpack
79 NLIB_NAMESPACE_END
80 NLIB_DEFINE_STD_SWAP(::nlib_ns::msgpack::JsonPatchBuilder)
81 #if defined(_MSC_VER) && defined(nx_msgpack_EXPORTS)
82 #undef NLIB_VIS_PUBLIC
83 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT
84 #endif
85 
86 #endif // INCLUDE_NN_NLIB_MSGPACK_JSONPATCH_H_
87 
#define NLIB_ALWAYS_INLINE
コンパイラに関数をインライン展開するように強く示します。
Definition: Platform_unix.h:97
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
TypeName で指定されたクラスのコピーコンストラクタと代入演算子を禁止します。
Definition: Config.h:163
#define NLIB_VIS_PUBLIC
関数やクラス等のシンボルをライブラリの外部に公開します。
Definition: Platform_unix.h:89
JSON Patch (RFC-6902)を適用するためのクラスです。
Definition: JsonPatch.h:70
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:45
errno_t Test(const nlib_utf8_t *path, MpObject *value) noexcept
JSON Patch文書となる配列に"test"演算を追加します。
Definition: JsonPatch.h:49
MessagePack, JSON及びCSVを読み込むと作成されるオブジェクトです。
#define NLIB_NOEXCEPT
環境に合わせてnoexcept 又は同等の定義がされます。
Definition: Config.h:99
errno_t Add(const nlib_utf8_t *path, MpObject *value) noexcept
JSON Patch文書となる配列に"add"演算を追加します。
Definition: JsonPatch.h:34
errno_t Move(const nlib_utf8_t *path, const nlib_utf8_t *from) noexcept
JSON Patch文書となる配列に"move"演算を追加します。
Definition: JsonPatch.h:41
char nlib_utf8_t
charのtypedefです。文字列がUTF-8であることを示します。
Definition: Platform.h:300
JSON Patch (RFC-6902)を作成するためのクラスです。
Definition: JsonPatch.h:29
int errno_t
intのtypedefで、戻り値としてPOSIXのエラー値を返すことを示します。
Definition: NMalloc.h:37