16 #ifndef INCLUDE_NN_NLIB_MSGPACK_JSONRPC_JSONRPCREQUEST_H_ 17 #define INCLUDE_NN_NLIB_MSGPACK_JSONRPC_JSONRPCREQUEST_H_ 25 #include "nn/nlib/Swap.h" 30 #if defined(_MSC_VER) && defined(nx_msgpack_EXPORTS) 31 #undef NLIB_VIS_PUBLIC 32 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT 40 class JsonRpcErrorRequestTest;
76 friend class fortest::JsonRpcErrorRequestTest;
84 #ifdef __cpp_rvalue_references 86 : prv_(rhs.prv_), is_msgpack_(rhs.is_msgpack_) {
91 is_msgpack_ = rhs.is_msgpack_;
97 : prv_(rhs.prv_), is_msgpack_(rhs.is_msgpack_) {
102 is_msgpack_ = rhs.is_msgpack_;
108 swap(prv_, rhs.prv_);
109 swap(is_msgpack_, rhs.is_msgpack_);
112 : prv_(
nullptr), is_msgpack_(use_msgpack) {}
117 return WriteRequest(method,
id, nil_param);
120 return WriteRequest(method, 0, params);
124 return WriteRequest(method, 0, nil_param);
127 return WriteRequest(req.GetMethod(), req.GetId(), req.GetParams());
132 struct JsonRpcRequestWriterPrivate;
133 JsonRpcRequestWriterPrivate* prv_;
150 NLIB_DEFINE_STD_SWAP(::nlib_ns::msgpack::jsonrpc::JsonRpcRequestWriter)
151 #if defined(_MSC_VER) && defined(nx_msgpack_EXPORTS) 152 #undef NLIB_VIS_PUBLIC 153 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT 156 #endif // INCLUDE_NN_NLIB_MSGPACK_JSONRPC_JSONRPCREQUEST_H_
errno_t WriteRequest(const char *method, reqid_t id) noexcept
Writes a JSON-RPC request that specifies no parameters.
constexpr JsonRpcRequestWriter() noexcept
Instantiates the object with default parameters (default constructor).
Class for representing the JSON-RPC response.
JsonRpcRequest() noexcept
Instantiates the object with default parameters (default constructor).
errno_t WriteNotification(const char *method, const MpObject ¶ms) noexcept
Writes the JSON-RPC notification.
const char * GetMethod() const noexcept
Gets the method name of the request.
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
Prohibits use of the copy constructor and assignment operator for the class specified by TypeName...
void SetId(reqid_t id) noexcept
Sets the request ID.
Class to serialize and write the JSON-RPC request to memory.
reqid_t GetId() const noexcept
Get the id of the request. If 0, the request is a notification.
UniquePtr owns the pointer, and when it goes out of scope, the pointer is released by the destructor ...
Defines that class that is corresponding to std::unique_ptr.
Object created when MessagePack or JSON is read.
JsonRpcRequestWriter(bool use_msgpack) noexcept
Sets the use of msgpack instead of JSON as the JSON description method.
Defines the class that resembles std::vector but can store objects that cannot be copied...
An empty structure indicating that an argument to a function needs to be moved.
Class that reads the JSON-RPC request.
Class for representing a JSON-RPC request.
void MoveParamsFrom(MpObject ¶ms) noexcept
Sets the JSON-RPC parameters.
Object created when MessagePack, JSON, or CSV is read.
errno_t WriteNotification(const char *method) noexcept
Writes a JSON-RPC Notification that specifies no parameters.
Nlist< JsonRpcRequest > ListType
Type used to store the JSON-RPC request sequence restored from the byte string.
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
#define NLIB_CEXPR
Defines constexpr if it is available for use. If not, holds an empty string.
A file that contains the configuration information for each development environment.
uint32_t reqid_t
id type for the JSON-RPC request.
A container-like class similar to std::vector that can store objects that do not have copy constructo...
const MpObject & GetParams() const noexcept
Gets the parameter of the request.
errno_t WriteRequest(const JsonRpcRequest &req) noexcept
Writes the JSON-RPC request.
size_t JsonRpcServerExec(const void *p, size_t n, ReallocOutputStream::UniquePtrType *ptr)
Creates the JSON-RPC response byte string by processing the JSON-RPC request.
#define NLIB_FINAL
Defines final if it is available for use. If not, holds an empty string.
MpObject & GetParams() noexcept
Gets the parameter of the request.