MethodResponse Dispatcher::system_methodHelp(const MethodCall &calldata, const Dispatcher *disp) { ULXR_TRACE("system_methodHelp"); if (calldata.numParams() != 1) throw ParameterException(InvalidMethodParameterError, "Exactly 1 parameter allowed for \"system.methodHelp\""); if (calldata.getParam(0).getType() != RpcStrType) throw ParameterException(InvalidMethodParameterError, "Parameter 1 not of type \"String\" \"system.listMethods\""); RpcString vs = calldata.getParam(0); std::string name = vs.getString(); std::string s; MethodCallMap::const_iterator it; std::string s_prev; for (it = disp->methodcalls.begin(); it != disp->methodcalls.end(); ++it) if (name == (*it).first.method_name && (*it).first.documentation.length() != 0) { if ( s_prev != (*it).first.documentation && (*it).first.documentation.length() != 0) { if (s.length() != 0) s = "* " +s + "\n* "; s += (*it).first.documentation; } s_prev = (*it).first.documentation; } return MethodResponse (RpcString(s)); }
MethodResponse Dispatcher::system_listMethods(const MethodCall &calldata, const Dispatcher *disp) { ULXR_TRACE("system_listMethods"); if (calldata.numParams() > 1) throw ParameterException(InvalidMethodParameterError, "At most 1 parameter allowed for \"system.listMethods\""); if ( calldata.numParams() == 1 && calldata.getParam(0).getType() != RpcStrType) throw ParameterException(InvalidMethodParameterError, "Parameter 1 not of type \"String\" \"system.listMethods\""); // FIXME: what to do with param 1 if present ?? Array arr; std::string m_prev; MethodCallMap::const_iterator it; for (it = disp->methodcalls.begin(); it != disp->methodcalls.end(); ++it) if ( m_prev != (*it).first.method_name && (*it).first.method_name.length() != 0) { arr.addItem(RpcString((*it).first.method_name)); m_prev = (*it).first.method_name; } return MethodResponse (arr); }
MethodResponse Dispatcher::xml_pretty_print(const MethodCall &calldata, const Dispatcher *disp) { ULXR_TRACE("xml_pretty_print"); if (calldata.numParams() > 1) throw ParameterException(InvalidMethodParameterError, "At most 1 parameter allowed for \"system.listMethods\""); if ( calldata.numParams() == 1 && calldata.getParam(0).getType() != RpcBoolean) throw ParameterException(InvalidMethodParameterError, "Parameter 1 not of type \"Boolean\" \"ulxmlrpcpp.xml_pretty_print\""); bool enable = Boolean(calldata.getParam(0)).getBoolean(); enableXmlPrettyPrint(enable); return MethodResponse (Void()); }
MethodResponse Dispatcher::system_methodSignature(const MethodCall &calldata, const Dispatcher *disp) { ULXR_TRACE("system_methodSignature"); if (calldata.numParams() != 1) throw ParameterException(InvalidMethodParameterError, "Exactly 1 parameter allowed for \"system.methodSignature\""); if (calldata.getParam(0).getType() != RpcStrType) throw ParameterException(InvalidMethodParameterError, "Parameter 1 not of type \"String\" \"system.listMethods\""); RpcString vs = calldata.getParam(0); std::string name = vs.getString(); MethodCallMap::const_iterator it; Array ret_arr; for (it = disp->methodcalls.begin(); it != disp->methodcalls.end(); ++it) { Array sigarr; std::string sig = (*it).first.getSignature(true, true); if (name == (*it).first.method_name && sig.length() != 0) { std::size_t pos; while ((pos = sig.find(',')) != std::string::npos) { sigarr.addItem(RpcString(sig.substr(0, pos))); sig.erase(0, pos+1); } sigarr.addItem(RpcString(sig)); ret_arr.addItem(sigarr); } } if (ret_arr.size() == 0) return MethodResponse (Integer(1)); // non-Array ==< no signatures else return MethodResponse (ret_arr); }