本文整理汇总了C++中AmArg::size方法的典型用法代码示例。如果您正苦于以下问题:C++ AmArg::size方法的具体用法?C++ AmArg::size怎么用?C++ AmArg::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AmArg
的用法示例。
在下文中一共展示了AmArg::size方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: registerApplication
void DSMFactory::registerApplication(const AmArg& args, AmArg& ret) {
string diag_name = args.get(0).asCStr();
string conf_name;
if (args.size()>1 && isArgCStr(args.get(1)))
conf_name = args.get(1).asCStr();
bool has_diag;
ScriptConfigs_mut.lock();
try {
has_diag = hasDSM(diag_name, conf_name);
} catch(...) {
ScriptConfigs_mut.unlock();
throw;
}
ScriptConfigs_mut.unlock();
if (!has_diag) {
ret.push(400);
ret.push("unknown application (DSM)");
return;
}
bool res = AmPlugIn::instance()->registerFactory4App(diag_name,this);
if(res) {
INFO("DSM state machine registered: %s.\n",diag_name.c_str());
ret.push(200);
ret.push("registered DSM application");
} else {
ret.push(500);
ret.push("Error registering DSM application (already registered?)");
}
}
示例2: listDSMs
void DSMFactory::listDSMs(const AmArg& args, AmArg& ret) {
vector<string> names;
ScriptConfigs_mut.lock();
try {
if (isArgUndef(args) || !args.size())
names = MainScriptConfig.diags->getDiagramNames();
else {
if (isArgCStr(args.get(0))) {
map<string, DSMScriptConfig>::iterator i=
ScriptConfigs.find(args.get(0).asCStr());
if (i!= ScriptConfigs.end())
names = i->second.diags->getDiagramNames();
}
}
} catch (...) {
ScriptConfigs_mut.unlock();
throw;
}
ScriptConfigs_mut.unlock();
for (vector<string>::iterator it=
names.begin(); it != names.end(); it++) {
ret.push(*it);
}
}
示例3: invoke
void UACAuthFactory::invoke(const string& method, const AmArg& args, AmArg& ret)
{
if (method == "getHandler") {
CredentialHolder* c = dynamic_cast<CredentialHolder*>(args.get(0).asObject());
DialogControl* cc = dynamic_cast<DialogControl*>(args.get(1).asObject());
if ((c!=NULL)&&(cc!=NULL)) {
AmArg handler;
handler.setBorrowedPointer(getHandler(cc->getDlg(), c));
ret.push(handler);
} else {
ERROR("wrong types in call to getHandler. (c=%ld, cc= %ld)\n",
(unsigned long)c, (unsigned long)cc);
}
} else if (method == "checkAuth") {
// params: Request realm user pwd
if (args.size() < 4) {
ERROR("missing arguments to uac_auth checkAuth function, expected Request realm user pwd\n");
throw AmArg::TypeMismatchException();
}
AmSipRequest* req = dynamic_cast<AmSipRequest*>(args.get(0).asObject());
if (NULL == req)
throw AmArg::TypeMismatchException();
UACAuth::checkAuthentication(req, args.get(1).asCStr(),
args.get(2).asCStr(),
args.get(3).asCStr(), ret);
} else
throw AmDynInvoke::NotImplemented(method);
}
示例4: sendMessage
void JsonRPCServerModule::sendMessage(const AmArg& args, AmArg& ret) {
AmArg none_params;
AmArg& params = none_params;
if (args.size()>5)
params = args.get(5);
AmArg u_none_params;
AmArg& udata = u_none_params;
if (args.size()>6)
udata = args.get(6);
JsonRPCServerLoop::sendMessage(args.get(0).asCStr(), // conn_id,
args.get(1).asInt(), // type, (0 == reply)
args.get(2).asCStr(), // method,
args.get(3).asCStr(), // id
args.get(4).asCStr(), // reply_sink
params, udata, ret);
}
示例5: invoke
void JsonRPCServerModule::invoke(const string& method,
const AmArg& args, AmArg& ret) {
if (method == "execRpc"){
// todo: add connection id
args.assertArrayFmt("sssisis"); // evq_link, notificationReceiver, requestReceiver,
// flags(i), host, port (i), method, [params]
if (args.size() > 7) {
if (!isArgArray(args.get(7)) && !isArgStruct(args.get(7))) {
ERROR("internal error: params to JSON-RPC must be struct or array\n");
throw AmArg::TypeMismatchException();
}
}
execRpc(args, ret);
// sendRequestList(args, ret);
} else if (method == "sendMessage"){
args.assertArrayFmt("sisss"); // conn_id, type, method, id, reply_sink, [params]
if (args.size() > 5) {
if (!isArgArray(args.get(5)) && !isArgStruct(args.get(5))) {
ERROR("internal error: params to JSON-RPC must be struct or array\n");
throw AmArg::TypeMismatchException();
}
}
sendMessage(args, ret);
} else if (method == "execServerFunction"){
args.assertArrayFmt("ss"); // method, id, params
JsonRpcServer::execRpc(args.get(0).asCStr(), args.get(1).asCStr(), args.get(2), ret);
// JsonRpcServer::execRpc(args, ret);
} else if (method == "getServerPort"){
ret.push(port);
} else if(method == "_list"){
ret.push(AmArg("execRpc"));
ret.push(AmArg("sendMessage"));
ret.push(AmArg("getServerPort"));
ret.push(AmArg("execServerFunction"));
// ret.push(AmArg("newConnection"));
// ret.push(AmArg("sendRequest"));
// ret.push(AmArg("sendRequestList"));
} else
throw AmDynInvoke::NotImplemented(method);
}
示例6: execRpc
void JsonRPCServerModule::execRpc(const AmArg& args, AmArg& ret) {
AmArg none_params;
AmArg& params = none_params;
if (args.size()>7)
params = args.get(7);
AmArg u_none_params;
AmArg& udata = u_none_params;
if (args.size()>8)
udata = args.get(8);
JsonRPCServerLoop::execRpc(// evq_link, notification_link, request_link
args.get(0).asCStr(), args.get(1).asCStr(),
args.get(2).asCStr(),
// flags
args.get(3).asInt(),
// host, port, method
args.get(4).asCStr(),
args.get(5).asInt(), args.get(6).asCStr(),
params, udata, ret);
}
示例7: switch
void XMLRPC2DIServer::xmlrpcval2amarg(XmlRpcValue& v, AmArg& a,
unsigned int start_index) {
if (v.valid()) {
for (int i=start_index; i<v.size();i++) {
switch (v[i].getType()) {
case XmlRpcValue::TypeInt: { /* DBG("X->A INT\n");*/ a.push(AmArg((int)v[i])); } break;
case XmlRpcValue::TypeDouble:{ /* DBG("X->A DBL\n");*/ a.push(AmArg((double)v[i])); } break;
case XmlRpcValue::TypeString:{ /* DBG("X->A STR\n");*/ a.push(AmArg(((string)v[i]).c_str())); } break;
case XmlRpcValue::TypeArray: {
// DBG("X->A ARR\n");
a.push(AmArg());
a[a.size()-1].assertArray(0);
AmArg arr;
xmlrpcval2amarg(v[i], a[a.size()-1], 0);
} break;
// TODO: support more types (datetime, struct, ...)
default: throw XmlRpcException("unsupported parameter type", 400);
};
}
}
}
示例8: switch
void XMLRPC2DIServer::amarg2xmlrpcval(AmArg& a,
XmlRpcValue& result) {
switch (a.getType()) {
case AmArg::CStr:
result = string(a.asCStr()); break;
case AmArg::Int:
result=a.asInt(); break;
case AmArg::Double:
result=a.asDouble(); break;
case AmArg::Array:
result.setSize(a.size());
for (size_t i=0;i<a.size();i++) {
// duh... recursion...
amarg2xmlrpcval(a.get(i), result[i]);
}
break;
default: { WARN("unsupported return value type %d\n", a.getType()); } break;
// TODO: do sth with the data here ?
}
}
示例9: postControlCmd
void SBCFactory::postControlCmd(const AmArg& args, AmArg& ret) {
SBCControlEvent* evt;
if (args.size()<3) {
evt = new SBCControlEvent(args[1].asCStr());
} else {
evt = new SBCControlEvent(args[1].asCStr(), args[2]);
}
if (!AmSessionContainer::instance()->postEvent(args[0].asCStr(), evt)) {
ret.push(404);
ret.push("Not found");
} else {
ret.push(202);
ret.push("Accepted");
}
}
示例10: hasDSM
void DSMFactory::hasDSM(const AmArg& args, AmArg& ret) {
string conf_name;
if (args.size()>1 && isArgCStr(args.get(1)))
conf_name = args.get(1).asCStr();
bool res;
ScriptConfigs_mut.lock();
try {
res = hasDSM(args.get(0).asCStr(), conf_name);
} catch(...) {
ScriptConfigs_mut.unlock();
throw;
}
ScriptConfigs_mut.unlock();
if (res)
ret.push("1");
else
ret.push("0");
}
示例11: execute
int StatsUDPServer::execute(char* msg_buf, string& reply,
struct sockaddr_in& addr)
{
char buffer[CTRL_MSGBUF_SIZE];
string cmd_str,reply_addr,reply_port;
char *msg_c = msg_buf;
msg_get_param(msg_c,cmd_str,buffer,CTRL_MSGBUF_SIZE);
if(cmd_str == "calls")
reply = "Active calls: " + int2str(AmSession::getSessionNum()) + "\n";
else if (cmd_str == "which") {
reply =
"calls - number of active calls (Session Container size)\n"
"which - print available commands\n"
"set_loglevel <loglevel> - set log level\n"
"get_loglevel - get log level\n"
"\n"
"DI <factory> <function> (<args>)* - invoke DI command\n"
;
}
else if (cmd_str.length() > 4 && cmd_str.substr(0, 4) == "set_") {
// setters
if (cmd_str.substr(4, 8) == "loglevel") {
if (!AmConfig::setLoglevel(&cmd_str.c_str()[13]))
reply= "invalid loglevel value.\n";
else
reply= "loglevel set to "+int2str(log_level)+".\n";
}
else reply = "Unknown command: '" + cmd_str + "'\n";
}
else if (cmd_str.length() > 4 && cmd_str.substr(0, 4) == "get_") {
// setters
if (cmd_str.substr(4, 8) == "loglevel") {
reply= "loglevel is "+int2str(log_level)+".\n";
}
else reply = "Unknown command: '" + cmd_str + "'\n";
}
else if (cmd_str.length() > 4 && cmd_str.substr(0, 3) == "DI ") {
// Dynamic Invocation
size_t p = cmd_str.find(' ', 4);
string fact_name = cmd_str.substr(3, p-3);
if (!fact_name.length()) {
reply = "could not parse DI factory name.\n";
return 0;
}
size_t p2 = cmd_str.find(' ', p+1);
if (p2 == string::npos)
p2 = cmd_str.length();
string fct_name = cmd_str.substr(p+1, p2-p-1);
p=p2+1;
if (!fct_name.length()) {
reply = "could not parse function name.\n";
return 0;
}
try {
// args need to be stored in string vector,
// because stl copyconstructor does not copy
// underlying c_str
vector<string> s_args;
while (p<cmd_str.length()) {
p2 = cmd_str.find(' ', p);
if (p2 == string::npos) {
if (p+1<cmd_str.length())
p2=cmd_str.length();
else
break;
}
s_args.push_back(string(cmd_str.substr(p, p2-p)));
p=p2+1;
}
AmArg args;
for (vector<string>::iterator it = s_args.begin();
it != s_args.end(); it++) {
args.push(it->c_str());
// DBG("mod '%s' added arg a '%s'\n",
// fact_name.c_str(),
// it->c_str());
}
AmDynInvokeFactory* di_f = AmPlugIn::instance()->getFactory4Di(fact_name);
if(!di_f){
reply = "could not get '" + fact_name + "' factory\n";
return 0;
}
AmDynInvoke* di = di_f->getInstance();
if(!di){
reply = "could not get DI instance from factory\n";
return 0;
}
AmArg ret;
di->invoke(fct_name, args, ret);
if (ret.size()) {
reply="[";
for (unsigned int i=0;i<ret.size();i++) {
//.........这里部分代码省略.........