本文整理汇总了C++中MojString::format方法的典型用法代码示例。如果您正苦于以下问题:C++ MojString::format方法的具体用法?C++ MojString::format怎么用?C++ MojString::format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MojString
的用法示例。
在下文中一共展示了MojString::format方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
MojErr MojDbPerfCreateTest::run()
{
MojErr err = file.open(CreateTestFileName, MOJ_O_RDWR | MOJ_O_CREAT | MOJ_O_TRUNC, MOJ_S_IRUSR | MOJ_S_IWUSR);
MojString buf;
err = buf.format("MojoDb Create Performance Test,,,,,\n\nOperation,Kind,Total Time,Time Per Iteration,Time Per Object\n");
MojTestErrCheck(err);
err = fileWrite(file, buf);
MojTestErrCheck(err);
err = testCreate();
MojTestErrCheck(err);
err = MojPrintF("\n\n TOTAL TEST TIME: %llu microseconds\n\n", totalTestTime.microsecs());
MojTestErrCheck(err);
err = MojPrintF("\n-------\n");
MojTestErrCheck(err);
err = buf.format("\n\nTOTAL TEST TIME,,%llu,,,", totalTestTime.microsecs());
MojTestErrCheck(err);
err = fileWrite(file, buf);
MojTestErrCheck(err);
err = file.close();
MojTestErrCheck(err);
return MojErrNone;
}
示例2: updateObjsViaPut
MojErr MojDbPerfUpdateTest::updateObjsViaPut(MojDb& db, const MojChar* kindId, MojErr (MojDbPerfTest::*createFn) (MojObject&, MojUInt64))
{
// register all the kinds
MojTime time;
MojErr err = putKinds(db, time);
MojTestErrCheck(err);
// put objects using createFn
MojObject objs;
err = putObjs(db, kindId, numInsertForPut, createFn, objs);
MojTestErrCheck(err);
MojObject midObj;
bool found = objs.at(numInsertForPut/2, midObj);
MojTestAssert(found);
MojTime objTime;
err = putObj(db, midObj, objTime);
MojTestErrCheck(err);
MojUInt64 putTime = objTime.microsecs();
err = MojPrintF("\n -------------------- \n");
MojTestErrCheck(err);
err = MojPrintF(" putting single object - index %llu - of kind %s %llu times took: %llu microsecs\n", numInsertForPut/2, kindId, numPutIterations, putTime);
MojTestErrCheck(err);
err = MojPrintF(" time per put: %llu microsecs", (putTime) / (numPutIterations));
MojTestErrCheck(err);
err = MojPrintF("\n\n");
MojTestErrCheck(err);
MojString buf;
err = buf.format("Put single object - index %llu - %llu times,%s,%llu,%llu,%llu,\n", numInsertForPut/2, numPutIterations, kindId, putTime, putTime/numPutIterations, putTime/(1*numPutIterations));
MojTestErrCheck(err);
err = fileWrite(file, buf);
MojTestErrCheck(err);
MojTime batchTime;
MojObject::ArrayIterator beginArr;
err = objs.arrayBegin(beginArr);
MojErrCheck(err);
err = batchPutObj(db, beginArr, beginArr + (numInsertForPut / 10), batchTime);
putTime = batchTime.microsecs();
MojTestErrCheck(err);
err = MojPrintF(" putting batch - %llu objects - of kind %s %llu times took: %llu microsecs\n", numInsertForPut/10, kindId, numBatchPutIterations, putTime);
MojTestErrCheck(err);
err = MojPrintF(" time per batch put: %llu microsecs\n", (putTime) / (numBatchPutIterations));
MojTestErrCheck(err);
err = MojPrintF(" time per object: %llu microsecs", (putTime) / (numInsertForPut/10 * numBatchPutIterations));
MojTestErrCheck(err);
err = MojPrintF("\n\n");
MojTestErrCheck(err);
err = buf.format("Batch put %llu objects %llu times,%s,%llu,%llu,%llu,\n", numInsertForPut/10, numBatchPutIterations, kindId, putTime, putTime/numBatchPutIterations, putTime/(numInsertForPut/10*numBatchPutIterations));
MojTestErrCheck(err);
err = fileWrite(file, buf);
MojTestErrCheck(err);
return MojErrNone;
}
示例3: BuildScheduledSync
void ImapActivityFactory::BuildScheduledSync(ActivityBuilder& ab, const MojObject& accountId, const MojObject& folderId, int seconds, bool requireFair)
{
MojErr err;
ab.SetName( GetScheduledSyncName(accountId, folderId) );
MojString desc;
err = desc.format("Scheduled sync every %d minutes", seconds/60);
ErrorToException(err);
ab.SetDescription(desc.data());
ab.SetExplicit(true);
ab.SetPersist(true);
ab.SetImmediate(true, "low");
SetNetworkRequirements(ab, requireFair);
// Metadata
MojObject metadata;
SetMetadata(metadata, SCHEDULED_SYNC_NAME, accountId, folderId);
ab.SetMetadata(metadata);
// Wakeup
ab.SetSyncInterval(0, seconds);
// Callback
MojObject params;
err = params.put("accountId", accountId);
ErrorToException(err);
ab.SetCallback(SCHEDULED_SYNC_CALLBACK, params);
}
示例4: formatKindId
MojErr MojDbKindEngine::formatKindId(const MojChar* id, MojString& dbIdOut)
{
MojErr err = dbIdOut.format(_T("_kinds/%s"), id);
MojErrCheck(err);
return MojErrNone;
}
示例5: GetSentEmails
void MojoDatabase::GetSentEmails(Signal::SlotRef slot, const MojObject& outboxFolderId, MojInt32 limit)
{
MojErr err;
MojDbQuery query;
err = query.from(EmailSchema::Kind::EMAIL);
ErrorToException(err);
err = query.where(EmailSchema::FOLDER_ID, MojDbQuery::OpEq, outboxFolderId);
ErrorToException(err);
MojString sendStatus;
err = sendStatus.format("%s.%s",EmailSchema::SEND_STATUS, EmailSchema::SendStatus::SENT);
ErrorToException(err);
err = query.where(sendStatus.data(), MojDbQuery::OpEq, true);
ErrorToException(err);
// Set limit
if(limit > 0) {
query.limit(limit);
}
slot.cancel(); // cancel existing slot in case we're in a callback
err = m_dbClient.find(slot, query);
ErrorToException(err);
}
示例6: testUpdateKind
MojErr MojDbPerfUpdateTest::testUpdateKind(MojDb& db)
{
MojString buf;
MojErr err = buf.format("\nUPDATE KIND,,,,,\n");
MojTestErrCheck(err);
err = fileWrite(file, buf);
MojTestErrCheck(err);
err = updateKind(db, MojPerfSmKindId, MojPerfSmKindStr, MojPerfSmKindExtraIndex, &MojDbPerfTest::createSmallObj);
MojTestErrCheck(err);
err = updateKind(db, MojPerfMedKindId, MojPerfMedKindStr, MojPerfMedKindExtraIndex, &MojDbPerfTest::createMedObj);
MojTestErrCheck(err);
err = updateKind(db, MojPerfLgKindId, MojPerfLgKindStr, MojPerfLgKindExtraIndex, &MojDbPerfTest::createLargeObj);
MojTestErrCheck(err);
err = updateKind(db, MojPerfMedNestedKindId, MojPerfMedNestedKindStr, MojPerfMedNestedKindExtraIndex, &MojDbPerfTest::createMedNestedObj);
MojTestErrCheck(err);
err = updateKind(db, MojPerfLgNestedKindId, MojPerfLgNestedKindStr, MojPerfLgNestedKindExtraIndex, &MojDbPerfTest::createLargeNestedObj);
MojTestErrCheck(err);
err = updateKind(db, MojPerfMedArrayKindId, MojPerfMedArrayKindStr, MojPerfMedArrayKindExtraIndex, &MojDbPerfTest::createMedArrayObj);
MojTestErrCheck(err);
err = updateKind(db, MojPerfLgArrayKindId, MojPerfLgArrayKindStr, MojPerfLgArrayKindExtraIndex, &MojDbPerfTest::createLargeArrayObj);
MojTestErrCheck(err);
return MojErrNone;
}
示例7: DeleteAccountWatchResponse
MojErr SmtpAccountDisableCommand::DeleteAccountWatchResponse(MojObject& response, MojErr err)
{
MojLogInfo(m_log, "SmtpAccountDisable replying");
try {
if(err) {
if(err == ENOENT) {
MojLogWarning(m_log, "account watch activity doesn't exist");
} else {
ResponseToException(response, err);
}
}
m_msg->replySuccess();
Complete();
} catch (const std::exception& e) {
m_msg->replyError(err, e.what());
Failure(e);
} catch (...) {
MojString error;
error.format("uncaught exception in %s", __PRETTY_FUNCTION__);
m_msg->replyError(MojErrInternal, error.data());
Failure(MailException("unknown exception in cancelling activities response", __FILE__, __LINE__));
}
return MojErrNone;
}
示例8: CreateActivity
void NetworkStatusMonitor::CreateActivity()
{
ActivityBuilder ab;
static MojInt64 uniqueId = 0;
string serviceName = m_busClient.GetServiceName();
// FIXME
if(serviceName.empty()) {
throw MailException("no service name", __FILE__, __LINE__);
}
MojString name;
MojErr err = name.format("%s network status check - %lld", serviceName.c_str(), ++uniqueId);
ErrorToException(err);
ab.SetName(name.data());
ab.SetDescription("Monitors network status");
ab.SetExplicit(false);
ab.SetPersist(false);
ab.SetForeground(true);
ab.SetRequiresInternet(true);
m_activity = Activity::PrepareNewActivity(ab, true, true);
m_activity->SetSlots(m_activityUpdateSlot, m_activityErrorSlot);
m_activity->Create(m_busClient);
}
示例9: BuildOutboxWatch
void SmtpActivityFactory::BuildOutboxWatch(ActivityBuilder& ab, const MojObject& accountId, const MojObject& folderId)
{
ActivityBuilder actBuilder;
MojString name;
name.format(OUTBOX_WATCH_ACTIVITY_FMT, AsJsonString(accountId).c_str());
ab.SetName(name);
ab.SetDescription("Watches SMTP outbox for new emails");
ab.SetPersist(true);
ab.SetExplicit(true);
ab.SetRequiresInternet(false); // don't trigger until we also have connectivity
ab.SetImmediate(true, ActivityBuilder::PRIORITY_LOW);
// Callback
MojObject callbackParams;
MojErr err = callbackParams.put("accountId", accountId);
ErrorToException(err);
err = callbackParams.put("folderId", folderId);
ErrorToException(err);
ab.SetCallback(OUTBOX_BUS_METHOD, callbackParams);
ab.SetMetadata(callbackParams);
}
示例10: DeleteOutboxWatchResponse
MojErr SmtpAccountDisableCommand::DeleteOutboxWatchResponse(MojObject& response, MojErr err)
{
MojLogInfo(m_log, "SmtpAccountDisable removing outbox watch");
try {
if(err) {
if(err == ENOENT) {
MojLogWarning(m_log, "outbox watch activity doesn't exist");
} else {
ResponseToException(response, err);
}
}
MojObject payload;
payload.put("activityName", m_accountWatchActivityName);
m_client.SendRequest(m_deleteAccountWatchResponseSlot, "com.palm.activitymanager", "cancel", payload);
} catch (const std::exception& e) {
m_msg->replyError(err, e.what());
Failure(e);
} catch (...) {
MojString error;
error.format("uncaught exception in %s", __PRETTY_FUNCTION__);
m_msg->replyError(MojErrInternal, error.data());
Failure(MailException("unknown exception in cancelling activities response", __FILE__, __LINE__));
}
return MojErrNone;
}
示例11: getTestDir
MojString getTestDir()
{
MojString dir;
MojErr err = dir.format("/tmp/mojodb-test-dir-%d", getpid());
assert( err == MojErrNone );
return dir;
}
示例12: RunImpl
void MovePopEmailsCommand::RunImpl()
{
CommandTraceFunction();
try {
if (!m_client.GetAccount().get()) {
MojString err;
err.format("Account is not loaded for '%s'", AsJsonString(
m_client.GetAccountId()).c_str());
throw MailException(err.data(), __FILE__, __LINE__);
}
MojErr err = m_payload.getRequired("accountId", m_accountId);
ErrorToException(err);
m_activity = ActivityParser::GetActivityFromPayload(m_payload);
if (m_activity.get()) {
m_activity->SetSlots(m_activityUpdateSlot, m_activityErrorSlot);
m_activity->Adopt(m_client);
return;
} else {
GetEmailsToMove();
}
} catch (const std::exception& ex) {
m_msg->replyError(MojErrInternal, ex.what());
Failure(ex);
} catch (...) {
MailException ex("unknown exception", __FILE__, __LINE__);
m_msg->replyError(MojErrInternal, ex.what());
Failure(ex);
}
}
示例13: RunImpl
void SyncAccountCommand::RunImpl()
{
try {
if (!m_client.GetAccount().get()) {
MojString err;
err.format("Account is not loaded for '%s'", AsJsonString(
m_client.GetAccountId()).c_str());
throw MailException(err.data(), __FILE__, __LINE__);
}
m_account = m_client.GetAccount();
if(m_account->HasPassword()) {
m_accountId = m_account->GetAccountId();
MojObject inboxFolderId = m_account->GetInboxFolderId();
MojLogInfo(m_log, "Creating command to sync inbox emails");
MojErr err = m_payload.put(EmailSchema::FOLDER_ID, inboxFolderId);
ErrorToException(err);
m_client.SyncFolder(m_payload);
} else {
MojLogInfo(m_log, "No password! Sync aborted!");
}
Complete();
} catch (const std::exception& ex) {
Failure(ex);
} catch (...) {
Failure(MailException("Unknown exception", __FILE__, __LINE__));
}
}
示例14: testMerge
MojErr MojDbPerfUpdateTest::testMerge(MojDb& db)
{
MojString buf;
MojErr err = buf.format("\nUPDATE VIA MERGE,,,,,\n");
MojTestErrCheck(err);
err = fileWrite(file, buf);
MojTestErrCheck(err);
err = updateObjsViaMerge(db, MojPerfSmKindId, &MojDbPerfTest::createSmallObj);
MojTestErrCheck(err);
err = updateObjsViaMerge(db, MojPerfMedKindId, &MojDbPerfTest::createMedObj);
MojTestErrCheck(err);
err = updateObjsViaMerge(db, MojPerfLgKindId, &MojDbPerfTest::createLargeObj);
MojTestErrCheck(err);
err = updateObjsViaMerge(db, MojPerfMedNestedKindId, &MojDbPerfTest::createMedNestedObj);
MojTestErrCheck(err);
err = updateObjsViaMerge(db, MojPerfLgNestedKindId, &MojDbPerfTest::createLargeNestedObj);
MojTestErrCheck(err);
err = updateObjsViaMerge(db, MojPerfMedArrayKindId, &MojDbPerfTest::createMedArrayObj);
MojTestErrCheck(err);
err = updateObjsViaMerge(db, MojPerfLgArrayKindId, &MojDbPerfTest::createLargeArrayObj);
MojTestErrCheck(err);
return MojErrNone;
}
示例15: FormatName
MojString ImapActivityFactory::FormatName(const char* name, const MojObject& accountId, const MojObject& folderId)
{
MojString formattedName;
MojErr err = formattedName.format("%s/accountId=%s/folderId=%s",
name, AsJsonString(accountId).c_str(), AsJsonString(folderId).c_str());
ErrorToException(err);
return formattedName;
}