本文整理汇总了C++中AmArg::assertArray方法的典型用法代码示例。如果您正苦于以下问题:C++ AmArg::assertArray方法的具体用法?C++ AmArg::assertArray怎么用?C++ AmArg::assertArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AmArg
的用法示例。
在下文中一共展示了AmArg::assertArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: asArgArray
AmArg ConferenceRoom::asArgArray() {
cleanExpired();
AmArg res;
res.assertArray(0); // make array from it
for (list<ConferenceRoomParticipant>::iterator it=participants.begin();
it != participants.end(); it++) {
res.push(it->asArgArray());
}
return res;
}
示例2: userdir_open
void MsgStorage::userdir_open(string domain, string user, AmArg& ret) {
// TODO: block the directory from delete (increase lock)
string path = msg_dir + "/" + domain + "/" + user + "/";
DBG("trying to list '%s'\n", path.c_str());
DIR* dir = opendir(path.c_str());
if (!dir) {
ret.push(MSG_EUSRNOTFOUND);
ret.push(AmArg()); // empty list
return;
}
int err=0;
struct dirent* entry;
AmArg msglist;
msglist.assertArray(0); // make it an array
while( ((entry = readdir(dir)) != NULL) && (err == 0) ){
string msgname(entry->d_name);
if(!msgname.length() ||
msgname[0] == '.'){
continue;
}
struct stat e_stat;
if (stat((path+msgname).c_str(), &e_stat)) {
ERROR("cannot stat '%s': %s\n",
(path+msgname).c_str(),strerror(errno));
continue;
}
AmArg msg;
msg.push(msgname.c_str());
// TODO: change the system here, st_atime/mtime/...
// is not really safe for saving read status!
if (e_stat.st_atime != e_stat.st_mtime) {
msg.push(0);
} else {
msg.push(1);
}
msg.push((int)e_stat.st_size);
msglist.push(msg);
}
closedir(dir);
// uh, this is really inefficient...
ret.push(MSG_OK);
ret.push(msglist);
}
示例3: roomInfo
void WebConferenceFactory::roomInfo(const AmArg& args, AmArg& ret) {
assertArgCStr(args.get(0));
assertArgCStr(args.get(1));
string room = args.get(0).asCStr();
string adminpin = args.get(1).asCStr();;
rooms_mut.lock();
ConferenceRoom* r = getRoom(room, adminpin);
if (NULL == r) {
ret.push(1);
ret.push("wrong adminpin");
// for consistency, add an empty array
AmArg a;
a.assertArray(0);
ret.push(a);
} else {
ret.push(0);
ret.push("OK");
ret.push(r->asArgArray());
}
rooms_mut.unlock();
}
示例4: c
void XMLRPC2DI::sendRequest(const AmArg& args, AmArg& ret) {
string app_name = args.get(0).asCStr();
string method = args.get(1).asCStr();
AmArg& params = args.get(2);
while (true) {
XMLRPCServerEntry* srv = getServer(app_name);
if (NULL == srv) {
ret.push(-1);
ret.push("no active connections");
return;
}
XmlRpcClient c((const char*)srv->server.c_str(), (int)srv->port,
(const char*)srv->uri.empty()?NULL:srv->uri.c_str()
#ifdef HAVE_XMLRPCPP_SSL
, false
#endif
);
XmlRpcValue x_args, x_result;
XMLRPC2DIServer::amarg2xmlrpcval(params, x_args);
if (c.execute(method.c_str(), x_args, x_result) && !c.isFault()) {
DBG("successfully executed method %s on server %s:%d\n",
method.c_str(), srv->server.c_str(), srv->port);
ret.push(0);
ret.push("OK");
ret.assertArray(3);
XMLRPC2DIServer::xmlrpcval2amarg(x_result, ret[2]);
return;
} else {
DBG("executing method %s failed on server %s:%d\n",
method.c_str(), srv->server.c_str(), srv->port);
srv->set_failed();
}
}
}