2 #ifndef SAMPLES_XML_RPC_XMLRPC_CLIENTSERVER_H_ // NOLINT
3 #define SAMPLES_XML_RPC_XMLRPC_CLIENTSERVER_H_
16 #ifdef NLIB_EXI_WCHAR_INTERFACE
17 typedef std::wstring StdString;
19 typedef std::string StdString;
28 class XmlRpcServerMethod {
30 XmlRpcServerMethod(
const StdString& name, XmlRpcServer* server);
31 virtual ~XmlRpcServerMethod();
32 virtual void Execute(
const XmlRpcValue& params, XmlRpcValue* result) = 0;
33 const StdString& GetName()
const {
return m_Name; }
34 XmlRpcServer* GetServer()
const {
return m_Server; }
38 XmlRpcServer* m_Server;
41 XmlRpcServerMethod(
const XmlRpcServerMethod&);
42 XmlRpcServerMethod& operator=(
const XmlRpcServerMethod&);
52 void AddServerMethod(XmlRpcServerMethod* method) { m_Methods[method->GetName()] = method; }
53 void RemoveServerMethod(
const StdString& name) {
54 Methods::iterator it = m_Methods.find(name);
55 if (it != m_Methods.end()) m_Methods.erase(it);
57 void RemoveServerMethod(XmlRpcServerMethod* method) {
58 this->RemoveServerMethod(method->GetName());
60 XmlRpcServerMethod* FindServerMethod(
const StdString& name)
const {
61 Methods::const_iterator it = m_Methods.find(name);
62 return (it != m_Methods.end()) ? it->second : NULL;
64 bool Process(nlib_ns::exi::XmlStreamReader* reader, nlib_ns::exi::XmlStreamWriter* writer);
67 typedef std::map<StdString, XmlRpcServerMethod*> Methods;
72 class XmlRpcCallResult {
73 XmlRpcServer* m_Server;
74 std::vector<unsigned char> m_ToServer;
77 XmlRpcCallResult() : m_Server(NULL) {}
78 void SetServer(XmlRpcServer* server) { m_Server = server; }
79 void SetData(
const std::vector<unsigned char>& rhs) { m_ToServer = rhs; }
80 bool GetResult(XmlRpcValue* result);
87 XmlRpcServer* m_Server;
90 XmlRpcClient() : m_Server(NULL) {}
91 void SetServer(XmlRpcServer* server) { m_Server = server; }
92 bool Execute(
const ExiChar* methodName,
const XmlRpcValue& params, XmlRpcCallResult* result);
95 #endif // SAMPLES_XML_RPC_XMLRPC_CLIENTSERVER_H_ // NOLINT
Header that includes all the headers within the nn/nlib/exi directory.
wchar_t ExiChar
A string-type typedef used internally by the XML parser.