nlib
nn::nlib::msgpack::jsonrpc::JsonRpcResponseWriter Class Referencefinal

Class that writes the JSON-RPC response byte string. More...

#include "nn/nlib/msgpack/jsonrpc/JsonRpcResponse.h"

Public Member Functions

constexpr JsonRpcResponseWriter () noexcept
 Instantiates the object with default parameters (default constructor).
 
 JsonRpcResponseWriter (bool msgpack) noexcept
 Creates a msgpack byte string when true is specified as the argument. More...
 
errno_t BeginWriteResponse (uint32_t n) noexcept
 Called once before writing the JSON-RPC response. More...
 
errno_t WriteResponse (JsonRpcResponse *result) noexcept
 Writes the JSON-RPC response. More...
 
errno_t EndWriteResponse (ReallocOutputStream::UniquePtrType *ptr, size_t *n) noexcept
 Finishes writing the JSON-RPC response. More...
 

Detailed Description

Class that writes the JSON-RPC response byte string.

Description
This class is used on the server side of JSON-RPC.
The send process after converting to a byte string must be written by the user.
Not required when using JsonRpcServerExec for server processing. It is used within JsonRpcServerExec.

Definition at line 101 of file JsonRpcResponse.h.

Constructor & Destructor Documentation

◆ JsonRpcResponseWriter()

nn::nlib::msgpack::jsonrpc::JsonRpcResponseWriter::JsonRpcResponseWriter ( bool  msgpack)
inlineexplicitnoexcept

Creates a msgpack byte string when true is specified as the argument.

Parameters
[in]msgpackSet to true if creating a msgpack byte string.

Definition at line 132 of file JsonRpcResponse.h.

Member Function Documentation

◆ BeginWriteResponse()

nn::nlib::msgpack::jsonrpc::JsonRpcResponseWriter::BeginWriteResponse ( uint32_t  n)
noexcept

Called once before writing the JSON-RPC response.

Parameters
[in]nNumber of responses (n >= 2 for responses to a batch request).
Return values
0Success.
ENOMEMmemory allocation failed.

◆ EndWriteResponse()

nn::nlib::msgpack::jsonrpc::JsonRpcResponseWriter::EndWriteResponse ( ReallocOutputStream::UniquePtrType ptr,
size_t *  n 
)
noexcept

Finishes writing the JSON-RPC response.

Parameters
[out]ptrPointer to the byte string.
[out]nPointer where the byte count of the data is written to.
Return values
0Success.
EINVALptr or n is NULL.
ERANGEThe response count does not match the number specified in BeginWriteRequest.
ENOMEMmemory allocation failed.
Description
When successful, n byte data is set to the ptr parameter. The server side process is completed by sending this data to the client.

◆ WriteResponse()

nn::nlib::msgpack::jsonrpc::JsonRpcResponseWriter::WriteResponse ( JsonRpcResponse result)
noexcept

Writes the JSON-RPC response.

Parameters
[in]resultPointer to JsonRpcResponse
Return values
0Success.
EINVALIndicates that result is NULL.
ERANGEThe request count is larger than the number specified in BeginWriteRequest.
ENOMEMmemory allocation failed.
Anerror occurred. Another JSON/msgpack write operation failed.
Description
In some cases the object that result points to is altered.

The documentation for this class was generated from the following files: