stubclient.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /**
  2. * This file is generated by jsonrpcstub, DO NOT CHANGE IT MANUALLY!
  3. */
  4. #ifndef JSONRPC_CPP_STUB_STUBCLIENT_H_
  5. #define JSONRPC_CPP_STUB_STUBCLIENT_H_
  6. #include <jsonrpccpp/client.h>
  7. class StubClient : public jsonrpc::Client
  8. {
  9. public:
  10. StubClient(jsonrpc::IClientConnector &conn, jsonrpc::clientVersion_t type = jsonrpc::JSONRPC_CLIENT_V2) : jsonrpc::Client(conn, type) {}
  11. std::string sayHello(const std::string& name) throw (jsonrpc::JsonRpcException)
  12. {
  13. Json::Value p;
  14. p["name"] = name;
  15. Json::Value result = this->CallMethod("sayHello",p);
  16. if (result.isString())
  17. return result.asString();
  18. else
  19. throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
  20. }
  21. void notifyServer() throw (jsonrpc::JsonRpcException)
  22. {
  23. Json::Value p;
  24. p = Json::nullValue;
  25. this->CallNotification("notifyServer",p);
  26. }
  27. int addNumbers(int param1, int param2) throw (jsonrpc::JsonRpcException)
  28. {
  29. Json::Value p;
  30. p.append(param1);
  31. p.append(param2);
  32. Json::Value result = this->CallMethod("addNumbers",p);
  33. if (result.isIntegral())
  34. return result.asInt();
  35. else
  36. throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
  37. }
  38. double addNumbers2(double param1, double param2) throw (jsonrpc::JsonRpcException)
  39. {
  40. Json::Value p;
  41. p.append(param1);
  42. p.append(param2);
  43. Json::Value result = this->CallMethod("addNumbers2",p);
  44. if (result.isDouble())
  45. return result.asDouble();
  46. else
  47. throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
  48. }
  49. bool isEqual(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
  50. {
  51. Json::Value p;
  52. p.append(param1);
  53. p.append(param2);
  54. Json::Value result = this->CallMethod("isEqual",p);
  55. if (result.isBool())
  56. return result.asBool();
  57. else
  58. throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
  59. }
  60. Json::Value buildObject(const std::string& param1, int param2) throw (jsonrpc::JsonRpcException)
  61. {
  62. Json::Value p;
  63. p.append(param1);
  64. p.append(param2);
  65. Json::Value result = this->CallMethod("buildObject",p);
  66. if (result.isObject())
  67. return result;
  68. else
  69. throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
  70. }
  71. std::string methodWithoutParameters() throw (jsonrpc::JsonRpcException)
  72. {
  73. Json::Value p;
  74. p = Json::nullValue;
  75. Json::Value result = this->CallMethod("methodWithoutParameters",p);
  76. if (result.isString())
  77. return result.asString();
  78. else
  79. throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
  80. }
  81. };
  82. #endif //JSONRPC_CPP_STUB_STUBCLIENT_H_