nlib
JsonPatch.h
Go to the documentation of this file.
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
Indicates that the compiler is forced to perform inline expansion of functions.
Definition: Platform_unix.h:97
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
Prohibits use of the copy constructor and assignment operator for the class specified by TypeName...
Definition: Config.h:163
#define NLIB_VIS_PUBLIC
Symbols for functions and classes are made available outside of the library.
Definition: Platform_unix.h:89
Class to apply JSON Patch (RFC-6902).
Definition: JsonPatch.h:70
Object created when MessagePack or JSON is read.
Definition: MpObject.h:95
errno_t Copy(const nlib_utf8_t *path, const nlib_utf8_t *from) noexcept
Adds a "copy" operation to the array that serves as the JSON Patch document.
Definition: JsonPatch.h:45
errno_t Test(const nlib_utf8_t *path, MpObject *value) noexcept
Adds a "test" operation to the array that serves as the JSON Patch document.
Definition: JsonPatch.h:49
Object created when MessagePack, JSON, or CSV is read.
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
Definition: Config.h:99
errno_t Add(const nlib_utf8_t *path, MpObject *value) noexcept
Adds an "add" operation to the array that serves as the JSON Patch document.
Definition: JsonPatch.h:34
errno_t Move(const nlib_utf8_t *path, const nlib_utf8_t *from) noexcept
Adds a "move" operation to the array that serves as the JSON Patch document.
Definition: JsonPatch.h:41
char nlib_utf8_t
Defines char with a typedef. Indicates that it is a UTF-8 string.
Definition: Platform.h:300
Class to create JSON Patch (RFC-6902).
Definition: JsonPatch.h:29
int errno_t
Indicates with an int-type typedef that a POSIX error value is returned as the return value...
Definition: NMalloc.h:37