3 #ifndef INCLUDE_NN_NLIB_MSGPACK_JSONRPC_JSONRPCRESPONSE_H_ 4 #define INCLUDE_NN_NLIB_MSGPACK_JSONRPC_JSONRPCRESPONSE_H_ 12 #if defined(_MSC_VER) && defined(nx_msgpack_EXPORTS) 13 #undef NLIB_VIS_PUBLIC 14 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT 27 INVALID_REQUEST = -32600,
28 METHOD_NOT_FOUND = -32601,
29 INVALID_PARAMS = -32602,
30 INTERNAL_ERROR = -32603,
34 : id_(0), is_error_(false), error_code_(0), error_msg_(NULL) {}
39 void SetError(
int errcode,
const char* msg) NLIB_NOEXCEPT {
41 this->SetError(errcode, msg, data);
45 return static_cast<ErrorCode>(error_code_);
47 reqid_t
GetId() const NLIB_NOEXCEPT {
return id_; }
49 return error_msg_ ? error_msg_ :
"";
56 void SetId(reqid_t
id) NLIB_NOEXCEPT { id_ = id; }
83 : prv_(NULL), is_msgpack_(msgpack) {}
89 struct JsonRpcResponseWriterPrivate;
90 JsonRpcResponseWriterPrivate* prv_;
99 #if defined(_MSC_VER) && defined(nx_msgpack_EXPORTS) 100 #undef NLIB_VIS_PUBLIC 101 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT 104 #endif // INCLUDE_NN_NLIB_MSGPACK_JSONRPC_JSONRPCRESPONSE_H_
UniquePtr< JsonRpcResponse > ValueType
Stores the JSON-RPC response via UniquePtr.
void SetError(int errcode, const char *msg) noexcept
Sets the JSON-RPC function error.
Class for representing the JSON-RPC response.
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
Prohibits use of the copy constructor and assignment operator for the class specified by TypeName...
#define NLIB_SAFE_BOOL(class_name, exp)
Defines a safe operator bool function in the class. Uses the C++11 explicit bool if it is available f...
JsonRpcResponseWriter(bool msgpack) noexcept
Creates a msgpack byte string when true is specified as the argument.
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.
Class that reads the JSON-RPC response byte string.
Object created when MessagePack or JSON is read.
MpObject & GetMpObject() noexcept
Returns the JSON-RPC return value, or additional information about an error.
Defines the class that resembles std::vector but can store objects that cannot be copied...
const MpObject & GetMpObject() const noexcept
Returns the JSON-RPC return value, or additional information about an error.
const char * GetErrorMessage() const noexcept
Returns an error message.
Class for representing a JSON-RPC request.
Object created when MessagePack, JSON, or CSV is read.
reqid_t GetId() const noexcept
Returns the ID of the JSON-RPC response.
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
ErrorCode
Definition of the predefined error code contained in the JSON-RPC response.
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...
Class that writes the JSON-RPC response byte string.
ErrorCode GetError() const noexcept
Returns an error code.
Nlist< ValueType > ListType
Type that stores the JSON-RPC response sequence.
#define NLIB_FINAL
Defines final if it is available for use. If not, holds an empty string.
JsonRpcResponse() noexcept
Instantiates the object with default parameters (default constructor).
JsonRpcResponseWriter() noexcept
Instantiates the object with default parameters (default constructor).