13#include <jsonrpccpp/server/abstractserverconnector.h>
17#include <json/value.h>
26#ifndef EXCEPTION_TO_DEFAULT
28#define EXCEPTION_TO_DEFAULT(__default, __body) \
39#ifndef EXCEPTION_TO_DEFAULT_AND_LOG
41 #define EXCEPTION_TO_DEFAULT_AND_LOG(__default, __body) \
46 catch (const std::exception& oEx) \
48 LOG_ERROR("%s", oEx.what()); \
51 catch (const tResult& oResult) \
53 LOG_RESULT(oResult); \
62#ifndef EXCEPTION_TO_RESULT
64#if A_UTILS_VERSION_MAJOR < 4
65 #define EXCEPTION_TO_RESULT(__body) \
72 return a_util::result::Result(ERR_FAILED); \
75 #define EXCEPTION_TO_RESULT(__body) \
80 catch (const std::exception& oEx) \
82 RETURN_ERROR_DESC(ERR_FAILED, "RPC call failed: %s", oEx.what()); \
86 RETURN_ERROR(ERR_FAILED); \
103 static inline tResult ToResult(
const Json::Value& oValue)
105 if (oValue[
"ErrorCode"].asInt() == ERR_NOERROR.error_code)
111 return tResult(oValue[
"ErrorCode"].asInt(),
112 oValue[
"Description"].asString().c_str(),
113 oValue[
"Line"].asInt(),
114 oValue[
"File"].asString().c_str(),
115 oValue[
"Function"].asString().c_str());
133 adtf::util::cFilename(oResult.
getFile()).GetName(),
137 static inline Json::Value ToJson(
const tResult & nResult)
142 oResult[
"Line"] = nResult.
GetLine();
143 oResult[
"File"] = nResult.
GetFile();
148 static inline std::string ToString(uint64_t nValue)
150#ifdef HAVE_STD_TO_STRING
151 return std::to_string(nValue);
154 std::ostringstream stream;
160 static inline std::string ToString(int64_t nValue)
162#ifdef HAVE_STD_TO_STRING
163 return std::to_string(nValue);
166 std::ostringstream stream;
172 static inline int64_t Stoll(
const std::string& strValue)
175 return std::stoll(strValue);
178 return strtoll(strValue.c_str(), 0, 10);
182 static inline uint64_t Stoull(
const std::string& strValue)
185 return std::stoull(strValue);
188 return strtoull(strValue.c_str(), 0, 10);
194template <
typename Stub,
typename Interface>
219 strName.Set(Interface::DEFAULT_NAME);
230 return *
const_cast<Stub*
>(
static_cast<const Stub*
>(
this));
235template <
typename ServerStub,
typename Interface>
239 public ucom::catwo::object<remote::ant::IRPCObjectServer, remote::catwo::IRPCInterfaceDefinition>
247 auto pData =
static_cast<const char*
>(oRequest.
Get());
248 std::string strRequest(pData, pData + oRequest.
GetSize());
249 std::string strResponse;
251 oResponse.Set(strResponse.c_str(), strResponse.size());
268 return strRPCName.Set(m_strRPCObjectName);
271 tResult SetRPCName(
const char* strRPCName)
override
273 m_strRPCObjectName = strRPCName;
279 return strInterfaceDefinition.Set(ServerStub::interface_definition);
283 adtf::util::cString m_strRPCObjectName;
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:736
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
Definition result.h:29
#define RETURN_ERROR(code)
Return specific error code, which requires the calling function's return type to be tResult.
Definition result.h:42
const tChar * GetFile() const noexcept
Get name of the file the error was reported in.
const tChar * GetDescription() const noexcept
Get user provided error description.
tInt32 GetLine() const noexcept
Get line in source file where the error was reported.
tErrorCode GetErrorCode() const noexcept
Get error code.
const tChar * GetFunction() const noexcept
Get name of the function the error was reported in.
Definition result_type_decl.h:34
const char * getFile() const
Definition result_type_impl.h:177
std::int32_t getLine() const
Definition result_type_impl.h:168
const char * getFunction() const
Definition result_type_impl.h:186
std::int32_t getErrorCode() const
Definition result_type_impl.h:136
const char * getDescription() const
Definition result_type_impl.h:154
Definition rawmemory_base.h:23
virtual size_t GetSize() const =0
virtual const void * Get() const =0
Definition string_intf.h:29
Definition rpc_object_client_intf.h:19
Definition adtf_client_connector.h:21
Definition rpc_stubs.h:99
Definition rpc_stubs.h:240
Definition rpc_stubs.h:200
rpc_remote_interface(const adtf::util::cString &strUrl)
Definition rpc_stubs.h:206
Stub & GetStub() const
Definition rpc_stubs.h:228
Definition json_rpc.h:162
jsonrpc_remote_object(const adtf::util::cString &oInitializer)
Definition json_rpc_impl.h:23
Namespace for all functionality of the ADTF Remote SDK provided since v3.7.
Definition adtf_client_connector.h:18
constexpr const char * get_iid() noexcept
Alias bringing the latest version of ant::get_iid() into scope.
Definition adtf_iid.h:429
Namespace for all functionality provided by ADTF and its SDKs.
Definition adtf_client_connector.h:14
definition of the rpc namespace
Definition json_rpc_impl.h:20