当前位置: 首页>>代码示例>>C++>>正文


C++ TStr::LeftOfLast方法代码示例

本文整理汇总了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'), "");
}
开发者ID:gitter-badger,项目名称:qminer,代码行数:21,代码来源:test-TStr.cpp

示例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;
}
开发者ID:adobekan,项目名称:qminer,代码行数:101,代码来源:main.cpp


注:本文中的TStr::LeftOfLast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。