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


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

本文整理汇总了C++中TStr::SplitOnCh方法的典型用法代码示例。如果您正苦于以下问题:C++ TStr::SplitOnCh方法的具体用法?C++ TStr::SplitOnCh怎么用?C++ TStr::SplitOnCh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TStr的用法示例。


在下文中一共展示了TStr::SplitOnCh方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

TEST(TStr, SplitOnCh) {
	const TStr Str = "abcde";
	const TStr EmptyStr = "";

	TStr LStr, RStr;
	// middle
	Str.SplitOnCh(LStr, 'c', RStr);

	ASSERT_EQ(LStr, "ab");
	ASSERT_EQ(RStr, "de");

	// non-existent
	Str.SplitOnCh(LStr, 'g', RStr);

	ASSERT_EQ(LStr, "abcde");
	ASSERT_EQ(RStr, "");

	// first
	Str.SplitOnCh(LStr, 'a', RStr);

	ASSERT_EQ(LStr, "");
	ASSERT_EQ(RStr, "bcde");

	// last
	Str.SplitOnCh(LStr, 'e', RStr);

	ASSERT_EQ(LStr, "abcd");
	ASSERT_EQ(RStr, "");

	// empty
	EmptyStr.SplitOnCh(LStr, 'a', RStr);

	ASSERT_EQ(LStr, "");
	ASSERT_EQ(RStr, "");
}
开发者ID:gitter-badger,项目名称:qminer,代码行数:35,代码来源:test-TStr.cpp

示例2: ReadGraph

void ReadGraph(TStr& InFile, bool& Directed, bool& Weighted, bool& Verbose, PWNet& InNet) {
  TFIn FIn(InFile);
  int64 LineCnt = 0;
  try {
    while (!FIn.Eof()) {
      TStr Ln;
      FIn.GetNextLn(Ln);
      TStr Line, Comment;
      Ln.SplitOnCh(Line,'#',Comment);
      TStrV Tokens;
      Line.SplitOnWs(Tokens);
      if(Tokens.Len()<2){ continue; }
      int64 SrcNId = Tokens[0].GetInt();
      int64 DstNId = Tokens[1].GetInt();
      double Weight = 1.0;
      if (Weighted) { Weight = Tokens[2].GetFlt(); }
      if (!InNet->IsNode(SrcNId)){ InNet->AddNode(SrcNId); }
      if (!InNet->IsNode(DstNId)){ InNet->AddNode(DstNId); }
      InNet->AddEdge(SrcNId,DstNId,Weight);
      if (!Directed){ InNet->AddEdge(DstNId,SrcNId,Weight); }
      LineCnt++;
    }
    if (Verbose) { printf("Read %lld lines from %s\n", (long long)LineCnt, InFile.CStr()); }
  } catch (PExcept Except) {
    if (Verbose) {
      printf("Read %lld lines from %s, then %s\n", (long long)LineCnt, InFile.CStr(),
       Except->GetStr().CStr());
    }
  }
}
开发者ID:arbenson,项目名称:snap,代码行数:30,代码来源:node2vec.cpp

示例3: Split

void TFtrGenSparseNumeric::Split(
        const TStr& Str, int& Id, TStr& Val) const {

    if (!Str.IsChIn(':')) { TExcept::Throw("Wrong sparse numeric '" + Str + "'!"); }
    //split
    TStr IdStr; Str.SplitOnCh(IdStr, ':', Val);
    // parse id
    if (!IdStr.IsInt(Id)) { TExcept::Throw("Wrong sparse numeric '" + Str + "'!"); }
}
开发者ID:mkarlovc,项目名称:gcentralization,代码行数:9,代码来源:ftrgen.cpp

示例4: GetVarNmV

void TEnv::GetVarNmV(TStrV& VarNmV) {
    VarNmV.Clr();
    int VarN = 0;
    while (_environ[VarN] != NULL) {
        TStr VarNmVal = _environ[VarN++];
        TStr VarNm;
        TStr VarVal;
        VarNmVal.SplitOnCh(VarNm, '=', VarVal);
        VarNmV.Add(VarNm);
    }
}
开发者ID:zzjjzzgggg,项目名称:netsnap,代码行数:11,代码来源:env.cpp

示例5: 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;
}
开发者ID:omid55,项目名称:memestwrepo,代码行数:14,代码来源:find_cascades_of_quotes_separately.cpp

示例6: OnGetHost

void TWebPgFetchEvent::OnGetHost(const PSockHost& SockHost) {
  if (SockHost->IsOk()){
    UrlStrV.Add(CurUrl->GetUrlStr());
    OppSockClosed=false;
    SockMem.Clr();
    Sock=TSock::New(this);
    int PortN;
    if (ProxyStr.Empty()){
      PortN=CurUrl->GetPortN();
    } else {
      TStr ProxyHostNm; TStr PortNStr;
      ProxyStr.SplitOnCh(ProxyHostNm, ':', PortNStr);
      PortN=PortNStr.GetInt(80);
    }
    Sock->PutTimeOut(TimeOutMSecs);
    Sock->Connect(SockHost, PortN);
  } else {
    OnFetchError("Invalid Host");
  }
}
开发者ID:Zala,项目名称:qminer,代码行数:20,代码来源:webpgfetch.cpp


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