本文整理汇总了C++中TStr::LeftOfLast方法的典型用法代码示例。如果您正苦于以下问题:C++ TStr::LeftOfLast方法的具体用法?C++ TStr::LeftOfLast怎么用?C++ TStr::LeftOfLast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TStr
的用法示例。
在下文中一共展示了TStr::LeftOfLast方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(TStr, LeftOfRightOf) {
TStr Str = "abcdef";
TStr Empty = "";
EXPECT_EQ(Str.LeftOf('d'), "abc");
EXPECT_EQ(Str.RightOf('c'), "def");
EXPECT_EQ(Str.LeftOf('a'), "");
EXPECT_EQ(Empty.RightOf('c'), "");
// edge cases
EXPECT_EQ(Str.RightOf('f'), "");
EXPECT_EQ(Empty.LeftOf('d'), "");
TStr Str2 = "abcdefabcdef";
EXPECT_EQ(Str2.LeftOfLast('d'), "abcdefabc");
EXPECT_EQ(Str2.RightOfLast('c'), "def");
EXPECT_EQ(Empty.LeftOfLast('d'), "");
EXPECT_EQ(Empty.RightOfLast('c'), "");
// edge cases
Str2 = "xabcdefabcdef";
EXPECT_EQ(Str2.LeftOfLast('x'), "");
EXPECT_EQ(Str2.RightOfLast('f'), "");
}
示例2: main
//.........这里部分代码省略.........
TFAccess FAccess = RdOnlyP ? faRdOnly : faUpdate;
// load base
TQm::PBase Base = TQm::TStorage::LoadBase(Param.DbFPath, FAccess,
Param.IndexCacheSize, Param.DefStoreCacheSize, Param.StoreNmCacheSizeH);
// initialize javascript contexts
TQm::TJsUtil::SetObjStatRate(JsStatRate);
TVec<TQm::PScript> ScriptV; InitJs(Param, Base, OnlyScriptNm, ScriptV);
// start server
if (!NoLoopP) {
// prepare server functions
TSAppSrvFunV SrvFunV;
// used to stop the server
SrvFunV.Add(TSASFunExit::New());
// admin webservices
TQm::TSrvFun::RegDefFun(Base, SrvFunV);
// initialize static content serving thingies
for (int WwwRootN = 0; WwwRootN < Param.WwwRootV.Len(); WwwRootN++) {
const TStrPr& WwwRoot = Param.WwwRootV[WwwRootN];
const TStr& UrlPath = WwwRoot.Val1, FPath = WwwRoot.Val2;
TQm::TEnv::Logger->OnStatusFmt("Registering '%s' at '/%s/'", FPath.CStr(), UrlPath.CStr());
SrvFunV.Add(TSASFunFPath::New(UrlPath, FPath));
}
// register admin services
SrvFunV.Add(TQm::TJsAdminSrvFun::New(ScriptV, "qm_status"));
// register javascript contexts
for (int ScriptN = 0; ScriptN < ScriptV.Len(); ScriptN++) {
// register server function
ScriptV[ScriptN]->RegSrvFun(SrvFunV);
}
// start server
PWebSrv WebSrv = TSAppSrv::New(Param.PortN, SrvFunV, TQm::TEnv::Logger, true, true);
// report we started
TQm::TEnv::Logger->OnStatusFmt("Server started on port %d", Param.PortN);
// wait for the end
TLoop::Run();
}
// save base
TQm::TStorage::SaveBase(Base);
}
// remove lock
Lock.Unlock();
}
// Stop QMiner engine
if (StopP) {
ExecUrl(TStr::Fmt("http://127.0.0.1:%d/exit?return=%d", Param.PortN, ReturnCode),
"Server stop procedure initiated", "Error stopping server: ");
}
// Reload QMiner script
//if (ReloadP) {
// for (int ReloadNmN = 0; ReloadNmN < ReloadNmV.Len(); ReloadNmN++) {
// TStr ScriptNm = ReloadNmV[ReloadNmN];
// ExecUrl(TStr::Fmt("http://127.0.0.1:%d/%s/admin/reload", Param.PortN, ScriptNm.CStr()),
// "Initializing reload of script '" + ScriptNm + "'",
// "Error reloading script '" + ScriptNm + "': ");
// }
//}
// Debug dumps of database and index
if (DebugP) {
// do not mess with folders with existing running qminer instance
Lock.Lock();
{
// load base
TQm::PBase Base = TQm::TStorage::LoadBase(Param.DbFPath, faRdOnly,
Param.IndexCacheSize, Param.DefStoreCacheSize, Param.StoreNmCacheSizeH);
// go over task lists and prepare outputs
for (int TaskN = 0; TaskN < DebugTaskV.Len(); TaskN++) {
TStr Task = DebugTaskV[TaskN];
if (Task == "index") {
Base->PrintIndex(DebugFNm + "index.txt", true);
} else if (Task == "indexvoc") {
Base->PrintIndexVoc(DebugFNm + "indexvoc.txt");
} else if (Task == "stores") {
Base->PrintStores(DebugFNm + "stores.txt");
} else if (Task.IsSuffix("_ALL")) {
TStr StoreNm = Task.LeftOfLast('_');
Base->GetStoreByStoreNm(StoreNm)->PrintAll(Base, DebugFNm + Task + ".txt");
} else if (Base->IsStoreNm(Task)) {
Base->GetStoreByStoreNm(Task)->PrintTypes(Base, DebugFNm + Task + ".txt");
} else {
TQm::InfoLog("Unkown debug task '" + Task + "'");
}
}
}
// remove lock
Lock.Unlock();
}
} catch (const PExcept& Except) {
// GLib exception
TQm::ErrorLog("Error: " + Except->GetMsgStr());
return 2;
} catch (...) {
// other exceptions
TQm::ErrorLog("Unknown error");
return 1;
}
return TQm::TEnv::ReturnCode.Val;
}