Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
jsonrpc.h
1#ifndef SOURCEMETA_CORE_JSONRPC_H_
2#define SOURCEMETA_CORE_JSONRPC_H_
3
4#ifndef SOURCEMETA_CORE_JSONRPC_EXPORT
5#include <sourcemeta/core/jsonrpc_export.h>
6#endif
7
8#include <sourcemeta/core/json.h>
9
10#include <cstdint> // std::int64_t
11#include <optional> // std::optional, std::nullopt
12
21
22namespace sourcemeta::core {
23
27constexpr std::int64_t JSONRPC_CODE_PARSE = -32700;
28
31constexpr std::int64_t JSONRPC_CODE_INVALID_REQUEST = -32600;
32
35constexpr std::int64_t JSONRPC_CODE_METHOD_NOT_FOUND = -32601;
36
39constexpr std::int64_t JSONRPC_CODE_INVALID_PARAMS = -32602;
40
43constexpr std::int64_t JSONRPC_CODE_INTERNAL = -32603;
44
48constexpr std::int64_t JSONRPC_CODE_SERVER_ERROR_MIN = -32099;
49
53constexpr std::int64_t JSONRPC_CODE_SERVER_ERROR_MAX = -32000;
54
66SOURCEMETA_CORE_JSONRPC_EXPORT
67auto jsonrpc_is_server_error(const std::int64_t code) -> bool;
68
83SOURCEMETA_CORE_JSONRPC_EXPORT
84auto jsonrpc_is_batch(const sourcemeta::core::JSON &payload) -> bool;
85
99SOURCEMETA_CORE_JSONRPC_EXPORT
101
119SOURCEMETA_CORE_JSONRPC_EXPORT
121 -> const sourcemeta::core::JSON *;
122
136SOURCEMETA_CORE_JSONRPC_EXPORT
137auto jsonrpc_is_request(const sourcemeta::core::JSON &request) -> bool;
138
152SOURCEMETA_CORE_JSONRPC_EXPORT
154
174SOURCEMETA_CORE_JSONRPC_EXPORT
176 -> const sourcemeta::core::JSON *;
177
191SOURCEMETA_CORE_JSONRPC_EXPORT
193
211SOURCEMETA_CORE_JSONRPC_EXPORT
215
231SOURCEMETA_CORE_JSONRPC_EXPORT
234
251SOURCEMETA_CORE_JSONRPC_EXPORT
253 const std::int64_t code, const JSON::StringView message,
254 std::optional<sourcemeta::core::JSON> data =
255 std::nullopt) -> sourcemeta::core::JSON;
256
269SOURCEMETA_CORE_JSONRPC_EXPORT
271
283SOURCEMETA_CORE_JSONRPC_EXPORT
285 const sourcemeta::core::JSON *identifier = nullptr)
287
302SOURCEMETA_CORE_JSONRPC_EXPORT
305
321SOURCEMETA_CORE_JSONRPC_EXPORT
323 const sourcemeta::core::JSON &identifier,
324 std::optional<sourcemeta::core::JSON> data = std::nullopt)
326
338SOURCEMETA_CORE_JSONRPC_EXPORT
340 nullptr) -> sourcemeta::core::JSON;
341
342} // namespace sourcemeta::core
343
344#endif
std::basic_string_view< Char, CharTraits > StringView
The string view type used by the JSON document.
Definition json_value.h:54
Definition json_value.h:39
constexpr std::int64_t JSONRPC_CODE_INVALID_PARAMS
Definition jsonrpc.h:39
SOURCEMETA_CORE_JSONRPC_EXPORT auto jsonrpc_is_request(const sourcemeta::core::JSON &request) -> bool
constexpr std::int64_t JSONRPC_CODE_SERVER_ERROR_MAX
Definition jsonrpc.h:53
SOURCEMETA_CORE_JSONRPC_EXPORT auto jsonrpc_make_error_invalid_request(const sourcemeta::core::JSON *identifier=nullptr) -> sourcemeta::core::JSON
SOURCEMETA_CORE_JSONRPC_EXPORT auto jsonrpc_is_batch(const sourcemeta::core::JSON &payload) -> bool
SOURCEMETA_CORE_JSONRPC_EXPORT auto jsonrpc_make_error_parse() -> const sourcemeta::core::JSON &
SOURCEMETA_CORE_JSONRPC_EXPORT auto jsonrpc_is_valid_batch(const sourcemeta::core::JSON &payload) -> bool
constexpr std::int64_t JSONRPC_CODE_SERVER_ERROR_MIN
Definition jsonrpc.h:48
constexpr std::int64_t JSONRPC_CODE_PARSE
Definition jsonrpc.h:27
SOURCEMETA_CORE_JSONRPC_EXPORT auto jsonrpc_request_id(const sourcemeta::core::JSON &request) -> const sourcemeta::core::JSON *
SOURCEMETA_CORE_JSONRPC_EXPORT auto jsonrpc_make_error_internal(const sourcemeta::core::JSON *identifier=nullptr) -> sourcemeta::core::JSON
SOURCEMETA_CORE_JSONRPC_EXPORT auto jsonrpc_params(const sourcemeta::core::JSON &request) -> const sourcemeta::core::JSON *
SOURCEMETA_CORE_JSONRPC_EXPORT auto jsonrpc_is_notification(const sourcemeta::core::JSON &request) -> bool
constexpr std::int64_t JSONRPC_CODE_INTERNAL
Definition jsonrpc.h:43
SOURCEMETA_CORE_JSONRPC_EXPORT auto jsonrpc_make_error_invalid_params(const sourcemeta::core::JSON &identifier, std::optional< sourcemeta::core::JSON > data=std::nullopt) -> sourcemeta::core::JSON
constexpr std::int64_t JSONRPC_CODE_METHOD_NOT_FOUND
Definition jsonrpc.h:35
SOURCEMETA_CORE_JSONRPC_EXPORT auto jsonrpc_make_success_empty(const sourcemeta::core::JSON &identifier) -> sourcemeta::core::JSON
SOURCEMETA_CORE_JSONRPC_EXPORT auto jsonrpc_make_error(const sourcemeta::core::JSON *identifier, const std::int64_t code, const JSON::StringView message, std::optional< sourcemeta::core::JSON > data=std::nullopt) -> sourcemeta::core::JSON
SOURCEMETA_CORE_JSONRPC_EXPORT auto jsonrpc_make_error_method_not_found(const sourcemeta::core::JSON &identifier) -> sourcemeta::core::JSON
constexpr std::int64_t JSONRPC_CODE_INVALID_REQUEST
Definition jsonrpc.h:31
SOURCEMETA_CORE_JSONRPC_EXPORT auto jsonrpc_method(const sourcemeta::core::JSON &request) -> JSON::StringView
SOURCEMETA_CORE_JSONRPC_EXPORT auto jsonrpc_make_success(const sourcemeta::core::JSON &identifier, sourcemeta::core::JSON result) -> sourcemeta::core::JSON
SOURCEMETA_CORE_JSONRPC_EXPORT auto jsonrpc_is_server_error(const std::int64_t code) -> bool