Example #1
0
//////////////////////////////////////
// URL-Redirect-Function
TSASFunRedirect::TSASFunRedirect(const TStr& FunNm,
		const TStr& SettingFNm): TSAppSrvFun(FunNm, saotUndef) { 

	printf("Loading redirects %s\n", FunNm.CStr());
	TFIn FIn(SettingFNm); TStr LnStr, OrgFunNm;
	while (FIn.GetNextLn(LnStr)) {
		TStrV PartV;  LnStr.SplitOnAllCh('\t', PartV, false);
		if (PartV.Empty()) { continue; }
		if (PartV[0].Empty()) {
			// parameters
			EAssert(PartV.Len() >= 3);
			TStr FldNm = PartV[1];
			TStr FldVal = PartV[2];
			if (FldVal.StartsWith("$")) {
				MapH.GetDat(OrgFunNm).FldNmMapH.AddDat(FldVal.Right(1), FldNm);
			} else {
				MapH.GetDat(OrgFunNm).FldNmValPrV.Add(TStrKd(FldNm, FldVal));
			}
		} else {
			// new function
			EAssert(PartV.Len() >= 2);
			OrgFunNm = PartV[0];
			MapH.AddDat(OrgFunNm).FunNm = PartV[1];
			printf("  %s - %s\n", PartV[0].CStr(), PartV[1].CStr());
		}
	}
	printf("Done\n");
}
Example #2
0
TEST(TStr, StartsWith) {
	TStr Str = "abcdef";
	EXPECT_TRUE(Str.StartsWith("abc"));
	EXPECT_TRUE(Str.StartsWith(TStr("abc")));

	EXPECT_FALSE(Str.StartsWith("bbc"));
	EXPECT_FALSE(Str.StartsWith(TStr("bbc")));

	// Empty string is a prefix of every string
	EXPECT_TRUE(Str.StartsWith("")); // starts with empty strin
	EXPECT_TRUE(Str.StartsWith(TStr()));

	EXPECT_FALSE(Str.StartsWith("abcdefg"));
	EXPECT_FALSE(Str.StartsWith("AB"));
	EXPECT_FALSE(Str.StartsWith("abcdef "));
}