本文整理汇总了C++中TStr::SplitOnStr方法的典型用法代码示例。如果您正苦于以下问题:C++ TStr::SplitOnStr方法的具体用法?C++ TStr::SplitOnStr怎么用?C++ TStr::SplitOnStr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TStr
的用法示例。
在下文中一共展示了TStr::SplitOnStr方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetAuthNmVPubStr
void TGgSchRef::GetAuthNmVPubStr(
const TStr& AuthNmVPubStr, TStrV& AuthNmV, TStr& PubNm, TStr& PubYearStr){
// split input string into two parts
TStr AuthNmVStr; TStr PubStr;
AuthNmVPubStr.SplitOnStr(AuthNmVStr, " - ", PubStr);
// author-names string
AuthNmVStr.SplitOnAllCh(',', AuthNmV, true);
for (int AuthN=0; AuthN<AuthNmV.Len(); AuthN++){
AuthNmV[AuthN].ToTrunc();
}
if ((!AuthNmV.Empty())&&
((AuthNmV.Last().IsStrIn("..."))||(AuthNmV.Last().Len()<=2))){
AuthNmV.DelLast();
}
// publication-name & publication-year string
TStr OriginStr; TStr LinkStr;
PubStr.SplitOnStr(OriginStr, " - ", LinkStr);
OriginStr.SplitOnLastCh(PubNm, ',', PubYearStr);
PubNm.ToTrunc(); PubYearStr.ToTrunc();
if ((PubYearStr.Len()>=4)&&(PubYearStr.GetSubStr(0, 3).IsInt())){
PubYearStr=PubYearStr.GetSubStr(0, 3);
} else
if ((PubNm.Len()>=4)&&(PubNm.GetSubStr(0, 3).IsInt())){
PubYearStr=PubNm.GetSubStr(0, 3); PubNm="";
} else {
PubYearStr="";
}
}
示例2: GetStdNameV
void TStrUtil::GetStdNameV(TStr AuthorNames, TStrV& StdNameV) {
AuthorNames.ChangeChAll('\n', ' ');
AuthorNames.ToLc();
// split into author names
TStrV AuthV, TmpV, Tmp2V;
// split on 'and'
AuthorNames.SplitOnStr(" and ", TmpV);
int i;
for (i = 0; i < TmpV.Len(); i++) {
TmpV[i].SplitOnAllCh(',', Tmp2V); AuthV.AddV(Tmp2V); }
// split on '&'
TmpV = AuthV; AuthV.Clr();
for (i = 0; i < TmpV.Len(); i++) {
TmpV[i].SplitOnAllCh('&', Tmp2V); AuthV.AddV(Tmp2V); }
// split on ','
TmpV = AuthV; AuthV.Clr();
for (i = 0; i < TmpV.Len(); i++) {
TmpV[i].SplitOnAllCh(',', Tmp2V); AuthV.AddV(Tmp2V); }
// split on ';'
TmpV = AuthV; AuthV.Clr();
for (i = 0; i < TmpV.Len(); i++) {
TmpV[i].SplitOnAllCh(';', Tmp2V); AuthV.AddV(Tmp2V); }
// standardize names
StdNameV.Clr();
//printf("\n*** %s\n", AuthorNames.CStr());
for (i = 0; i < AuthV.Len(); i++) {
TStr StdName = GetStdName(AuthV[i]);
if (! StdName.Empty()) {
//printf("\t%s ==> %s\n", AuthV[i].CStr(), StdName.CStr());
StdNameV.Add(StdName);
}
}
}
示例3: ExtrEuPartV
void TCordisEuPart::ExtrEuPartV(const TStr& AllEuPartStr, TCordisEuPartV& EuPartV){
TStrV EuPartStrV; AllEuPartStr.SplitOnStr("Organisation Type:", EuPartStrV);
for (int EuPartN=1; EuPartN<EuPartStrV.Len(); EuPartN++){
TStr EuPartStr=EuPartStrV[EuPartN];
TStr WcStr=
"</span>*</td>"
"*Organisation:</span>*<br>"
"*</td>*";
TStrV StarStrV;
if (EuPartStr.IsWcMatch(WcStr, StarStrV)){
PCordisEuPart EuPart=TCordisEuPart::New();
EuPart->DeptNm=ExtrDeptNm(EuPartStr);
EuPart->OrgNm=TXmlLx::GetPlainStrFromXmlStr(StarStrV[2].GetTrunc());
EuPart->OrgTypeNm=StarStrV[0].GetTrunc();
EuPart->CountryNm=ExtrCountry(StarStrV[3].GetTrunc());
EuPart->CoordP=(EuPartN==1);
printf(" Partner: '%s'/'%s'/'%s'/'%s'/'%s'\n",
EuPart->DeptNm.CStr(), EuPart->OrgNm.CStr(),
EuPart->OrgTypeNm.CStr(), EuPart->CountryNm.CStr(),
TBool::GetStr(EuPart->CoordP).CStr());
EuPartV.Add(EuPart);
} else {
printf("Partner Fields Not Found!\n");
}
}
}
示例4: TInt
DCluster::DCluster(TStr LineInput) {
// Parse start/end date
TStrV Params;
LineInput.SplitOnStr("\t", Params);
Id = TInt(Params[0].GetInt());
Start = TSecTm::GetDtTmFromYmdHmsStr(Params[1]);
End = TSecTm::GetDtTmFromYmdHmsStr(Params[2]);
uint StartDay = Start.GetInUnits(tmuDay);
uint EndDay = End.GetInUnits(tmuDay);
DiffDay = EndDay - StartDay + 1;
// Stats/size
Unique = TInt(Params[3].GetInt());
Size = TInt(Params[4].GetInt());
NumPeaks = TInt(Params[5].GetInt());
RepStrLen = TInt(Params[6].GetInt());
// Strings
RepStr = Params[7];
RepURL = Params[8];
// Peak times
First = TSecTm::GetDtTmFromYmdHmsStr(Params[9]);
Last = TSecTm::GetDtTmFromYmdHmsStr(Params[10]);
Peak = TSecTm::GetDtTmFromYmdHmsStr(Params[11]);
bool ArchiveBool = true;
Params[12].IsBool(ArchiveBool);
Archived = TBool(ArchiveBool);
DiscardState = TInt(Params[13].GetInt());
}
示例5:
///// Splits on the first occurrence of the target string
///// if the target string is not found the whole string is returned as the left side
//void SplitOnStr(TStr& LStr, const TStr& SplitStr, TStr& RStr) const;
TEST(TStr, SplitOnStr) {
const TStr Str = "abcd";
const TStr EmptyStr = "";
TStr LStr, RStr;
// left empty
Str.SplitOnStr(LStr, "ab", RStr);
EXPECT_EQ(LStr, "");
EXPECT_EQ(RStr, "cd");
// both nonempty
Str.SplitOnStr(LStr, "bc", RStr);
EXPECT_EQ(LStr, "a");
EXPECT_EQ(RStr, "d");
// right empty
Str.SplitOnStr(LStr, "cd", RStr);
EXPECT_EQ(LStr, "ab");
EXPECT_EQ(RStr, "");
// both empty
Str.SplitOnStr(LStr, "abcd", RStr);
EXPECT_EQ(LStr, "");
EXPECT_EQ(RStr, "");
// no-match
Str.SplitOnStr(LStr, "fg", RStr);
EXPECT_EQ(LStr, Str);
EXPECT_EQ(RStr, "");
Str.SplitOnStr(LStr, "abcde", RStr);
EXPECT_EQ(LStr, Str);
EXPECT_EQ(RStr, "");
Str.SplitOnStr(LStr, "", RStr);
EXPECT_EQ(LStr, Str);
EXPECT_EQ(RStr, "");
// empty
EmptyStr.SplitOnStr(LStr, "aa", RStr);
EXPECT_EQ(LStr, "");
EXPECT_EQ(RStr, "");
EmptyStr.SplitOnStr(LStr, "", RStr);
EXPECT_EQ(LStr, "");
EXPECT_EQ(RStr, "");
}
示例6: ExtrCountry
/////////////////////////////////////////////////
// EuPartner
TStr TCordisEuPart::ExtrCountry(const TStr& AddrStr){
TStr CountryStr;
TStrV LnV; AddrStr.SplitOnStr("<br>", LnV);
if (LnV.Len()>0){
CountryStr=LnV.Last();
if (CountryStr.Empty()&&(LnV.Len()>1)){
CountryStr=LnV[LnV.Len()-2];}
CountryStr.DelChAll('\r');
CountryStr.DelChAll('\n');
}
if (CountryStr.Empty()){
printf("Country Field Not Found!\n");}
return CountryStr;
}
示例7: getWebsite
inline TStr getWebsite(TStr fulladdress)
{
TStr left,right,tmp,res;
if(fulladdress.SearchStr(TStr("http"),0)>=0)
{
fulladdress.SplitOnStr(left,TStr("//"),right);
right.SplitOnCh(res,'/',tmp);
}
else
{
fulladdress.SplitOnCh(res,'/',tmp);
}
return res;
}