15 #ifndef SAMPLES_XML_RPC_XMLRPC_CLIENTSERVER_H_ // NOLINT 16 #define SAMPLES_XML_RPC_XMLRPC_CLIENTSERVER_H_ 29 #ifdef NLIB_EXI_WCHAR_INTERFACE 30 typedef std::wstring StdString;
32 typedef std::string StdString;
41 class XmlRpcServerMethod {
43 XmlRpcServerMethod(
const StdString& name, XmlRpcServer* server);
44 virtual ~XmlRpcServerMethod();
45 virtual void Execute(
const XmlRpcValue& params, XmlRpcValue* result) = 0;
46 const StdString&
GetName()
const {
return name_; }
47 XmlRpcServer* GetServer()
const {
return server_; }
51 XmlRpcServer* server_;
54 XmlRpcServerMethod(
const XmlRpcServerMethod&);
55 XmlRpcServerMethod& operator=(
const XmlRpcServerMethod&);
65 void AddServerMethod(XmlRpcServerMethod* method) { methods_[method->GetName()] = method; }
66 void RemoveServerMethod(
const StdString& name) {
67 Methods::iterator it = methods_.find(name);
68 if (it != methods_.end()) methods_.erase(it);
70 void RemoveServerMethod(XmlRpcServerMethod* method) {
71 this->RemoveServerMethod(method->GetName());
73 XmlRpcServerMethod* FindServerMethod(
const StdString& name)
const {
74 Methods::const_iterator it = methods_.find(name);
75 return (it != methods_.end()) ? it->second : NULL;
77 bool Process(nlib_ns::exi::XmlStreamReader* reader, nlib_ns::exi::XmlStreamWriter* writer);
80 typedef std::map<StdString, XmlRpcServerMethod*> Methods;
85 class XmlRpcCallResult {
86 XmlRpcServer* server_;
87 std::vector<unsigned char> to_server_;
90 XmlRpcCallResult() : server_(NULL) {}
91 void SetServer(XmlRpcServer* server) { server_ = server; }
92 void SetData(
const std::vector<unsigned char>& rhs) { to_server_ = rhs; }
93 bool GetResult(XmlRpcValue* result);
100 XmlRpcServer* server_;
103 XmlRpcClient() : server_(NULL) {}
104 void SetServer(XmlRpcServer* server) { server_ = server; }
105 bool Execute(
const ExiChar* methodName,
const XmlRpcValue& params, XmlRpcCallResult* result);
108 #endif // SAMPLES_XML_RPC_XMLRPC_CLIENTSERVER_H_ // NOLINT ディレクトリnn/nlib/exi内のヘッダを全てインクルードするためのヘッダです。
StringView GetName(StringView &str) noexcept
一般に変数名とされるような文字列を取得します。自身のオブジェクト(str)は取得した文字列の次に移動します...
nlib_utf8_t ExiChar
XMLパーサーの内部文字列型のtypedefです。