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


C++ TChA类代码示例

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


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

示例1: GetDtTmFromStr

// Parse strings of the form 2006-08-28 14:11:16 or 14:11:16  08/28/2008
// Non-numeric characters act as separators (there can be many consecutive separating characters)
// Variables give indexes of the date fields
TSecTm TSecTm::GetDtTmFromStr(const TChA& YmdHmsPmStr, const int& YearId, const int& MonId,
 const int& DayId, const int& HourId, const int& MinId, const int& SecId) {
  TChA Tmp = YmdHmsPmStr;
  TVec<char *> FldV;
  // get the sequences of numbers
  for (char *c = (char *) Tmp.CStr(); *c; c++) {
    if (TCh::IsNum(*c)) {
      FldV.Add(c);
      while (TCh::IsNum(*c)) { c++; }
      c--;
    } else { *c = 0; }
  }
  const int Y = atoi(FldV[YearId]);
  const int M = atoi(FldV[MonId]);
  const int D = atoi(FldV[DayId]);
  const int H = atoi(FldV[HourId]);
  const int m = atoi(FldV[MinId]);
  const int S = atoi(FldV[SecId]);
  IAssert(Y>0 && M>0 && D>0 && M<13 && D<32);
  IAssert(H>=0 && H<24 && m>=0 && m<60 && S>=0 && S<60);
  return TSecTm(Y,M,D,H,m,S);
}
开发者ID:SherlockYang,项目名称:Archive,代码行数:25,代码来源:tm.cpp

示例2: TStr

PSs TSs::LoadTxt(
    const TSsFmt& SsFmt, const TStr& FNm,
    const PNotify& Notify, const bool& IsExcelEoln,
    const int& MxY, const TIntV& AllowedColNV, const bool& IsQStr) {
    TNotify::OnNotify(Notify, ntInfo, TStr("Loading File ")+FNm+" ...");
    PSIn SIn=TFIn::New(FNm);
    PSs Ss=TSs::New();
    if (!SIn->Eof()) {
        int X=0;
        int Y=0;
        int PrevX=-1;
        int PrevY=-1;
        char Ch=SIn->GetCh();
        TChA ChA;
        while (!SIn->Eof()) {
            // compose value
            ChA.Clr();
            if (IsQStr&&(Ch=='"')) {
                // quoted string ('""' sequence means '"')
                Ch=SIn->GetCh();
                forever {
                    while ((!SIn->Eof())&&(Ch!='"')) {
                        ChA+=Ch;
                        Ch=SIn->GetCh();
                    }
                    if (Ch=='"') {
                        Ch=SIn->GetCh();
                        if (Ch=='"') {
                            ChA+=Ch;
                            Ch=SIn->GetCh();
                        }
                        else {
                            break;
                        }
                    }
                }
            } else {
                if (SsFmt==ssfTabSep) {
开发者ID:amrsobhy,项目名称:qminer,代码行数:38,代码来源:ss.cpp

示例3: Paragraphize

void TTokenizerUtil::Paragraphize(const PSIn& SIn, TStrV& Paragraphs) {
	TChA ParagraphBuf;
	int c;
	bool wasSpace = false;
	while (!SIn->Eof()) {
		c = SIn->GetCh();
		// two consecutive spaces signal a new paragraph
		if (c == ' ' || c == '\t' || c == '\n') {
			if (wasSpace) {
				Paragraphs.Add(ParagraphBuf);
				ParagraphBuf.Clr();
				continue;
			}
			wasSpace = true;
		} else {
			wasSpace = false;
		}
		ParagraphBuf += c;
	}
	if (ParagraphBuf.Len() > 0) {
		Paragraphs.Add(ParagraphBuf);
	}
}
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:23,代码来源:tokenizer.cpp

示例4: TChA

// http://www.ijs.si/fdfd/blah.html --> www.ijs.si
TChA TStrUtil::GetDomNm(const TChA& UrlChA) {
    int EndSlash = UrlChA.SearchCh('/', 7)-1; // skip starting http://
    if (EndSlash > 0) {
        const int BegSlash = UrlChA.SearchChBack('/', EndSlash);
        if (BegSlash > 0) {
            return UrlChA.GetSubStr(BegSlash+1, EndSlash).ToLc();
        }
        else {
            return UrlChA.GetSubStr(0, UrlChA.SearchCh('/', 0)-1).ToLc();
        }
    } else {
        if (UrlChA.IsPrefix("http://")) {
            return UrlChA.GetSubStr(7, UrlChA.Len()-1).ToLc();
        }
        EndSlash = UrlChA.SearchCh('/', 0);
        if (EndSlash > 0) {
            return UrlChA.GetSubStr(0, EndSlash-1).ToLc();
        }
        else {
            return TChA(UrlChA).ToLc();
        }
    }
}
开发者ID:pikma,项目名称:Snap,代码行数:24,代码来源:util.cpp

示例5: FIn

void TBowFl::LoadLnDocTxt(PBowDocBs BowDocBs, const TStr& LnDocFNm,
 TIntV& NewDIdV, const bool& NamedP, const int& MxDocs, const bool& SaveDocP) {
  // open line-doc file
  NewDIdV.Clr(); TFIn FIn(LnDocFNm); char Ch=' '; int Docs=0;
  while (!FIn.Eof()){
    Docs++; if ((MxDocs!=-1)&&(Docs>=MxDocs)){break;}
    printf("%d\r", Docs);
    // document name
    TChA DocNm;
    Ch=FIn.GetCh();
    if (NamedP){
      while ((!FIn.Eof())&&(Ch!='\r')&&(Ch!='\n')&&(Ch!=' ')){
        DocNm+=Ch; Ch=FIn.GetCh();}
      DocNm.Trunc();
      if (DocNm.Empty()){Docs--; continue;}
    } else {
        DocNm = TInt::GetStr(Docs);
    }
    // categories
    TStrV CatNmV;
    forever {
      while ((!FIn.Eof())&&(Ch==' ')){Ch=FIn.GetCh();}
      if (Ch=='!'){
        if (!FIn.Eof()){Ch=FIn.GetCh();}
        TChA CatNm;
        while ((!FIn.Eof())&&(Ch!='\r')&&(Ch!='\n')&&(Ch!=' ')){
          CatNm+=Ch; Ch=FIn.GetCh();}
        if (!CatNm.Empty()){CatNmV.Add(CatNm);}
      } else {
        break;
      }
    }
    // document text
    TChA DocChA;
    while ((!FIn.Eof())&&(Ch!='\r')&&(Ch!='\n')){
      DocChA+=Ch; Ch=FIn.GetCh();}
    // skip empty documents (empty lines)
    if (DocNm.Empty()&&DocChA.Empty()){
      continue;}
    // add document to document-base
    NewDIdV.Add(BowDocBs->AddHtmlDoc(DocNm, CatNmV, DocChA, SaveDocP));
  }
  // return document-base
  BowDocBs->AssertOk();
  printf("\n");
}
开发者ID:Accio,项目名称:snap,代码行数:46,代码来源:bowfl.cpp

示例6: ParseArrayVal

const char* TJsonObj::ParseArrayVal(const char* JsonStr) {
  const char *c = JsonStr;
  bool Nested = false;
  TChA ValStr;
  Clr();
  while (*c && TCh::IsWs(*c)) { c++; }
  if (*c == '"') { c = GetStr(c, ValStr); } // string
  else if (TCh::IsNum(*c) || (*c=='-' &&  TCh::IsNum(*(c+1)))) {  // number
    while (*c && *c!=',' && *c!='}' && *c!=']' && ! TCh::IsWs(*c)) { ValStr.Push(*c); c++; } }
  else if (*c=='t' || *c=='f' || *c=='n') { // true, false, null
    while (*c && *c!=',' && *c!='}' && *c!=']') { ValStr.Push(*c); c++; } }
  else if (*c=='{') { // nested object
    EAssertR(! KeyArrayH.IsKey("key"), "JSON error: object with key 'key' already exists");
    TJsonObj& Obj = KeyObjH.AddDat("key");
    c = Obj.Parse(c) + 1;  Nested = true;
  }
  else if (*c=='[') { // array
    EAssertR(! KeyArrayH.IsKey("key"), "JSON error: array with key 'key' already exists");
    TVec<TJsonObj>& Array = KeyArrayH.AddDat("key");
      c++;
      while (*c && *c!=']') {
        while (*c && TCh::IsWs(*c)) { c++; }
        Array.Add();
        if (*c=='{') { c = Array.Last().Parse(c) + 1; } // nested object
        else { c = Array.Last().ParseArrayVal(c); }
        if (*c && *c==',') { c++; }
      }
      c++; Nested = true;
  }
  if (! Nested) {
    EAssertR(! KeyArrayH.IsKey("key"), "JSON error: object with key 'key' already exists");
    KeyValH.AddDat("key", ValStr); 
  }
  while (*c && TCh::IsWs(*c)) { c++; }
  return c;
}
开发者ID:Networks-Learning,项目名称:infopath,代码行数:36,代码来源:json.cpp

示例7: if

// remove ending /, /index.html, etc. and strip starting www.
bool TStrUtil::GetNormalizedUrl(const TChA& UrlIn, const TChA& BaseUrl, TChA& UrlOut) {
  UrlOut = UrlIn;
  if (StripEnd(UrlIn, "/", UrlOut)) {}
  else if (StripEnd(UrlIn, "/index.html", UrlOut)) {}
  else if (StripEnd(UrlIn, "/index.htm", UrlOut)) {}
  else if (StripEnd(UrlIn, "/index.php", UrlOut)) {}
  if (! (UrlOut.IsPrefix("http://") || UrlOut.IsPrefix("ftp://"))) {
    // if UrlIn is relative url, try combine it with BaseUrl
    if (UrlIn.Empty() || ! (BaseUrl.IsPrefix("http://") || BaseUrl.IsPrefix("ftp://"))) {
      //printf("** Bad URL: base:'%s' url:'%s'\n", BaseUrl.CStr(), UrlIn.CStr());
      return false; }
    TChA Out;
    if (! GetNormalizedUrl(BaseUrl, TChA(), Out)) { return false; }
    if (UrlIn[0] != '/') { Out.AddCh('/'); }
    Out += UrlOut;
    UrlOut = Out;
  }
  // http://www. --> http://
  if (UrlOut.IsPrefix("http://www.")) {
    UrlOut = "http://"+UrlOut.GetSubStr(11, TInt::Mx);
  }
  UrlOut.ToLc();
  return true;
}
开发者ID:hmipakchi,项目名称:FinalYearProject,代码行数:25,代码来源:util.cpp

示例8: SplitLines

int TStrUtil::SplitLines(TChA& ChA, TVec<char *>& LineV, const bool& SkipEmpty) {
    LineV.Clr(false);
    LineV.Add(ChA.CStr());
    bool IsChs=false;
    for (char *c = (char *) ChA.CStr(); *c; c++) {
        if (*c == '\n') {
            if (c > ChA.CStr() && *(c-1)=='\r') {
                *(c-1)=0;    // \r\n
            }
            *c=0;
            if (SkipEmpty) {
                if (IsChs) {
                    LineV.Add(c+1);
                }
            } else {
                LineV.Add(c+1);
            }
            IsChs=false;
        } else {
            IsChs=true;
        }
    }
    return LineV.Len();
}
开发者ID:pikma,项目名称:Snap,代码行数:24,代码来源:util.cpp

示例9: Sentencize

///////////////////////////////
// Tokenizer-Utils
void TTokenizerUtil::Sentencize(const PSIn& SIn, TStrV& Sentences, const bool& SplitNewLineP) {
	TChA SentenceBuf;
	int c;
	while (!SIn->Eof()) {
		c = SIn->GetCh();
		switch (c) {
			case '\r':
			case '\n':	{
				if (!SplitNewLineP) {
					SentenceBuf += ' ';
					break;
				}
			}
			case '"' :
			case '.' :
			case '!' :
			case ':' :
			case ';' :
			case '?' :
			case '\t': {
				if (SentenceBuf.Len() > 2) {
					Sentences.Add(SentenceBuf);
					printf("%s\n", SentenceBuf.CStr());
					SentenceBuf.Clr();
				}
				break;
			}
			default: 
				SentenceBuf += c;
				break;
		}
	}
	if (SentenceBuf.Len() > 0) {
		Sentences.Add(SentenceBuf);
	}	
}
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:38,代码来源:tokenizer.cpp

示例10: if

// get <TagNm>*</TagNm> (can be many tags inbetween
bool TStrUtil::GetXmlTagNmVal2(TXmlLx& XmlLx, TChA& TagNm, TChA& TagVal, const bool& TakeTagNms) {
    if (XmlLx.GetSym() != xsySTag) {
        return false;
    }
    TagVal.Clr();
    TagNm = XmlLx.TagNm;
    //const TXmlLxSym NextSym = XmlLx.GetSym();
    while (XmlLx.Sym != xsyETag || XmlLx.TagNm != TagNm.CStr()) {
        if (TakeTagNms) {
            TagVal += XmlLx.TxtChA;
        }
        else if (XmlLx.Sym == xsyStr) {
            TagVal += XmlLx.TxtChA;
        }
        XmlLx.GetSym();
    }
    return true;
    //if (NextSym == xsyStr) {
    //  EAssertR(XmlLx.GetSym() == xsyETag, TagNm);
    //} else {
    //  EAssertR(NextSym == xsyETag, TagNm); // empty tag
    //printf("  token: %s empty! %s\n", XmlLx.TagNm.CStr(), XmlLx.GetFPosStr().CStr());
    //}
}
开发者ID:pikma,项目名称:Snap,代码行数:25,代码来源:util.cpp

示例11: switch

TStr THtmlLxChDef::GetCSZFromWin1250(const TChA& ChA){
  TChA DstChA;
  for (int ChN=0; ChN<ChA.Len(); ChN++){
    unsigned char Ch=ChA[ChN];
    switch (Ch){
      case 232: DstChA+='c'; break;
      case 200: DstChA+='C'; break;
      case 154: DstChA+='s'; break;
      case 138: DstChA+='S'; break;
      case 158: DstChA+='z'; break;
      case 142: DstChA+='Z'; break;
      default: DstChA+=Ch;
    }
  }
  return DstChA;
}
开发者ID:pikma,项目名称:Snap,代码行数:16,代码来源:html.cpp

示例12: IsLatinStr

bool TStrUtil::IsLatinStr(const TChA& Str, const double& MinAlFrac) {
    int AlNumCnt=0, ChCnt=0;
    for (const char *c = Str.CStr(); *c; c++) {
        if (TCh::IsWs(*c)) {
            continue;
        }
        if (*c > 0 && TCh::IsAlNum(*c)) {
            AlNumCnt++;
        }
        ChCnt++;
    }
    if (double(AlNumCnt)/double(ChCnt) > MinAlFrac) {
        return true;
    }
    return false;
}
开发者ID:pikma,项目名称:Snap,代码行数:16,代码来源:util.cpp

示例13: GetDtTmFromYmdHmsStr

TSecTm TSecTm::GetDtTmFromYmdHmsStr(const TStr& YmdHmsPmStr,
 const char& DateSepCh, const char& TimeSepCh){
  int YmdHmsPmStrLen=YmdHmsPmStr.Len();
  // year
  TChA ChA; int ChN=0;
  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=DateSepCh)){
    ChA+=YmdHmsPmStr[ChN]; ChN++;}
  TStr YearStr=ChA;
  // month
  ChA.Clr(); ChN++;
  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=DateSepCh)){
    ChA+=YmdHmsPmStr[ChN]; ChN++;}
  TStr MonthStr=ChA;
  // day
  ChA.Clr(); ChN++;
  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=' ')){
    ChA+=YmdHmsPmStr[ChN]; ChN++;}
  TStr DayStr=ChA;
  // hour
  ChA.Clr(); ChN++;
  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=TimeSepCh)){
    ChA+=YmdHmsPmStr[ChN]; ChN++;}
  TStr HourStr=ChA;
  // minute
  ChA.Clr(); ChN++;
  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=TimeSepCh)){
    ChA+=YmdHmsPmStr[ChN]; ChN++;}
  TStr MinStr=ChA;
  // second
  ChA.Clr(); ChN++;
  while (ChN<YmdHmsPmStrLen){
    ChA+=YmdHmsPmStr[ChN]; ChN++;}
  TStr SecStr=ChA;
  // transform to numbers
  int MonthN=MonthStr.GetInt();
  int DayN=DayStr.GetInt();
  int YearN=YearStr.GetInt();
  int HourN; int MinN; int SecN;
  if (HourStr.IsInt()){
    HourN=HourStr.GetInt();
    MinN=MinStr.GetInt();
    SecN=SecStr.GetInt();
  } else {
    HourN=0; MinN=0; SecN=0;
  }
  // construct the time
  TSecTm Tm=TSecTm::GetDtTm(YearN, MonthN, DayN);
  Tm.AddHours(HourN);
  Tm.AddMins(MinN);
  Tm.AddSecs(SecN);
  return Tm;
}
开发者ID:Networks-Learning,项目名称:infopath,代码行数:52,代码来源:tm.cpp

示例14: TestChA

bool THttpLx::IsRespStatusLn(){
  static const TChA MouldChA="http/N.N NNN ";
  TChA TestChA(MouldChA);
  int TestLen=TestChA.Len();
  if (1+Len()<TestLen){return false;}
  TestChA.PutCh(0, ChDef.GetLcCh(Ch));
  {for (int ChN=1; ChN<TestLen; ChN++){
    TestChA.PutCh(ChN, ChDef.GetLcCh(GetCh()));}}
  {for (int ChN=1; ChN<TestLen; ChN++){
    PutCh(TestChA[TestLen-ChN-1]);}}
  {for (int ChN=0; ChN<MouldChA.Len(); ChN++){
    if (MouldChA[ChN]=='N'){
      if (!ChDef.IsDigit(TestChA[ChN])){return false;}
    } else {
      if (MouldChA[ChN]!=TestChA[ChN]){return false;}
    }
  }}
  return true;
}
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:19,代码来源:http.cpp

示例15: GetCSZFromYuascii

TStr THtmlLxChDef::GetCSZFromYuascii(const TChA& ChA){
  TChA DstChA;
  for (int ChN=0; ChN<ChA.Len(); ChN++){
    char Ch=ChA[ChN];
    switch (Ch){
      case '~': DstChA+='c'; break;
      case '^': DstChA+='C'; break;
      case '}': DstChA+='c'; break;
      case ']': DstChA+='C'; break;
      case '|': DstChA+='d'; break;
      case '\\': DstChA+='D'; break;
      case '{': DstChA+='s'; break;
      case '[': DstChA+='S'; break;
      case '`': DstChA+='z'; break;
      case '@': DstChA+='Z'; break;
      default: DstChA+=Ch;
    }
  }
  return DstChA;
}
开发者ID:pikma,项目名称:Snap,代码行数:20,代码来源:html.cpp


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