本文整理汇总了C++中TChA::Len方法的典型用法代码示例。如果您正苦于以下问题:C++ TChA::Len方法的具体用法?C++ TChA::Len怎么用?C++ TChA::Len使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TChA
的用法示例。
在下文中一共展示了TChA::Len方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetCleanWrdStr
// space separated sequence of words, remove all punctuations, etc.
TChA TStrUtil::GetCleanWrdStr(const TChA& ChA) {
char *b = (char *) ChA.CStr();
while (*b && ! TCh::IsAlNum(*b)) { b++; }
if (*b == 0) { return TChA(); }
TChA OutChA(ChA.Len());
char *e = b, tmp;
while (*e) {
b = e;
while (*e && (TCh::IsAlNum(*e) || ((*e=='\'' || *e=='-') && TCh::IsAlNum(*(e+1))))) { e++; }
if (b < e) {
tmp = *e; *e=0;
OutChA += b; OutChA.AddCh(' ');
*e = tmp;
}
while (*e && ! TCh::IsAlNum(*e)) { e++; }
if (! *e) { break; }
}
OutChA.DelLastCh(); OutChA.ToLc();
return OutChA;
}
示例2: GetIsoCeFromYuascii
TStr THtmlLxChDef::GetIsoCeFromYuascii(const TChA& ChA){
TChA DstChA;
for (int ChN=0; ChN<ChA.Len(); ChN++){
char Ch=ChA[ChN];
switch (Ch){
case '~': DstChA+=uchar(232); break;
case '^': DstChA+=uchar(200); break;
case '}': DstChA+=uchar(230); break;
case ']': DstChA+=uchar(198); break;
case '|': DstChA+=uchar(240); break;
case '\\': DstChA+=uchar(208); break;
case '{': DstChA+=uchar(185); break;
case '[': DstChA+=uchar(169); break;
case '`': DstChA+=uchar(190); break;
case '@': DstChA+=uchar(174); break;
default: DstChA+=Ch;
}
}
return DstChA;
}
示例3: SplitSentences
int TStrUtil::SplitSentences(TChA& ChA, TVec<char *>& SentenceV) {
SentenceV.Clr();
const char *B = ChA.CStr();
const char *E = B+ChA.Len();
char *c = (char *) B;
while (*c && TCh::IsWs(*c)) { c++; }
if (*c) { SentenceV.Add(c); } else { return 0; }
for (; c < E; c++) {
if (c<E && (*c == '.' || *c == '!' || *c == '?') && ! TCh::IsAlNum(*(c+1))) { // end of sentence
if (c<E && *(c+1)=='"') { *c='"'; c++; } // blah." --> blah"
if (c>=E) { continue; }
*c=0; c++;
char *e = c-1;
while (e>B && *e!='"' && ! TCh::IsAlNum(*e)) { *e=0; e--; } // skip trailing non-alpha-num chars
while (c<E && ! (TCh::IsAlNum(*c) || (*c=='"' && TCh::IsAlNum(*(c+1))))) { c++; } // sentence starts with AlNum or "AlNum
if (c<E) { SentenceV.Add(c); }
}
}
return SentenceV.Len();
}
示例4: switch
TStr THtmlLxChDef::GetWin1250FromYuascii(const TChA& ChA){
TChA DstChA;
for (int ChN=0; ChN<ChA.Len(); ChN++){
char Ch=ChA[ChN];
switch (Ch){
case '~': DstChA+=uchar(232); break;
case '^': DstChA+=uchar(200); break;
case '}': DstChA+='c'; break;
case ']': DstChA+='C'; break;
case '|': DstChA+='d'; break;
case '\\': DstChA+='D'; break;
case '{': DstChA+=uchar(154); break;
case '[': DstChA+=uchar(138); break;
case '`': DstChA+=uchar(158); break;
case '@': DstChA+=uchar(142); break;
default: DstChA+=Ch;
}
}
return DstChA;
}
示例5: 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;
}
示例6: GetDocStrFromCycLConstStr
TStr TCycBs::GetDocStrFromCycLConstStr(const TStr& CycLConstStr){
TChA ChA=CycLConstStr;
TChA DstChA;
if ((ChA.Len()>2)&&(ChA[0]=='#')&&(ChA[1]=='$')){
int ChN=2;
while (ChN<ChA.Len()){
if (DstChA.Len()>0){DstChA+=' ';}
if ((ChA[ChN]=='-')||(ChA[ChN]=='_')||(ChA[ChN]==':')){
DstChA+="-"; ChN++;
} else
if (('0'<=ChA[ChN])&&(ChA[ChN]<='9')){
do {
DstChA+=ChA[ChN]; ChN++;
} while ((ChN<ChA.Len())&&('0'<=ChA[ChN])&&(ChA[ChN]<='9'));
} else
if (('a'<=ChA[ChN])&&(ChA[ChN]<='z')){
do {
DstChA+=ChA[ChN]; ChN++;
} while ((ChN<ChA.Len())&&('a'<=ChA[ChN])&&(ChA[ChN]<='z'));
} else
if (('A'<=ChA[ChN])&&(ChA[ChN]<='Z')){
if ((ChN+1<ChA.Len())&&('a'<=ChA[ChN+1])&&(ChA[ChN+1]<='z')){
do {
DstChA+=ChA[ChN]; ChN++;
} while ((ChN<ChA.Len())&&('a'<=ChA[ChN])&&(ChA[ChN]<='z'));
} else {
do {
DstChA+=ChA[ChN]; ChN++;
} while (((ChN==ChA.Len()-1)&&('A'<=ChA[ChN])&&(ChA[ChN]<='Z'))||
((ChN+1<ChA.Len())&&('A'<=ChA[ChN+1])&&(ChA[ChN+1]<='Z')));
}
} else {
DstChA=""; break;
}
}
} else {
DstChA="";
}
return DstChA;
}
示例7: 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);
}
}
示例8: GetDomNm
// 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();
}
}
}
示例9: TSBase
TMIn::TMIn(const TChA& ChA):
TSBase("Input-Memory"), TSIn("Input-Memory"), Bf(NULL), BfC(0), BfL(0){
BfL=ChA.Len(); Bf=new char[BfL]; strncpy(Bf, ChA.CStr(), BfL);
}
示例10: PutStr
int TSOut::PutStr(const TChA& ChA){
int Cs=UpdateLnLen(ChA.Len());
return Cs+PutBf(ChA.CStr(), ChA.Len());
}
示例11: GetShorStr
TChA TStrUtil::GetShorStr(const TChA& LongStr, const int MaxLen) {
if (LongStr.Len() < MaxLen) { return LongStr; }
TChA Str = LongStr.GetSubStr(0, MaxLen-1);
Str += "...";
return Str;
}
示例12: GetWebsiteNm
// get website (GetDomNm2 or blog url)
TChA TStrUtil::GetWebsiteNm(const TChA& PostUrlStr) {
TChA DomNm = TStrUtil::GetDomNm2(PostUrlStr);
// http://blog.myspace.com/index.cfm?fuseaction=blog.view&friendid=141560&blogid=420009539
if (DomNm == "blog.myspace.com") {
return PostUrlStr.GetSubStr(7, GetNthOccurence(PostUrlStr, 2, '&')-1);
}
// http://blogs.msdn.com/squasta/archive/2008/08/11/annonces-microsoft-au-black-hat-2008.aspx
// http://ameblo.jp/baptism/entry-10126216277.html
// http://xfruits.com/fcuignet/?id=8793&clic=249862689&url=http%3a%2f%2fnews.google.com%2fnews%2furl%3fsa%3dt%26ct%3dfr%2f9-0%26fd%3dr%26url%3dhttp%3a%2f%2fwww.investir-en-tunisie.net%2fnews%2farticle.php%253fid%253d5026%26cid%3d1241943065%26ei%3doy6gslh9jzycxahkjfxucw%26usg%3dafqjcnen_bczqldodsyga6zps2axphxl3q
// http://scienceblogs.com/grrlscientist/2008/08/reader_comments.php
// http://blogs.sun.com/geertjan/entry/wicket_in_action_undoubtedly_the
// http://blog.wired.com/gadgets/2008/08/apple-sells-60.html
// http://weblogs.asp.net/mehfuzh/archive/2008/08/11/linqextender-1-4-enhanced-object-tracking.aspx
// http://blogs.technet.com/plitpromicrosoftcom/archive/2008/08/11/nowa-karta-sim.aspx
// http://blogs.guardian.co.uk/greenslade/2008/08/murdoch_aims_to_boost_subscrib.html
// http://blogs.clarin.com/quimeykiltru/2008/8/11/mentira-mentira-creo
// http://blogs.sun.com/geertjan/entry/wicket_in_action_undoubtedly_the
// http://blog.wired.com/gadgets/2008/08/apple-sells-60.html
// http://weblogs.asp.net/mehfuzh/archive/2008/08/11/linqextender-1-4-enhanced-object-tracking.aspx
// http://blogs.technet.com/plitpromicrosoftcom/archive/2008/08/11/nowa-karta-sim.aspx
// http://blogs.guardian.co.uk/greenslade/2008/08/murdoch_aims_to_boost_subscrib.html
// http://blogs.clarin.com/quimeykiltru/2008/8/11/mentira-mentira-creo
// http://blogs.zdnet.com/hardware/?p=2391
// http://blogs.citypages.com/sports/2008/08/ufc_87_seek_and.php
// http://voices.washingtonpost.com/achenblog/2008/08/no_medal_for_bush.html
// http://blog.tv2.dk/ole.mork/entry254689.html
// http://blogs.menomoneefallsnow.com/in_the_race/archive/2008/08/11/sometimes-it-s-about-how-you-play-the-game.asp
// http://weblogs.baltimoresun.com/entertainment/midnight_sun/blog/2008/08/heidis_bad_break_with_dubai_pa.html
// http://eonline.com/uberblog/b23076_youtubular_from_rickrolled_barackrolled.html?sid=rss_topstories&utm_source=eo
if (DomNm=="blogs.msdn.com" || DomNm=="ameblo.jp" || DomNm=="xfruits.com" || DomNm=="scienceblogs.com" || DomNm=="blogs.sun.com"
|| DomNm=="blog.wired.com" || DomNm=="weblogs.asp.net" || DomNm=="blogs.technet.com" || DomNm=="blogs.guardian.co"
|| DomNm=="blogs.clarin.com" || DomNm=="blogs.sun.com" || DomNm=="blog.wired.com" || DomNm=="weblogs.asp.net"
|| DomNm=="blogs.technet.com" || DomNm=="blogs.guardian.com" || DomNm=="blogs.clarin.com" || DomNm=="blogs.zdnet.com"
|| DomNm=="blogs.citypages.com" || DomNm=="voices.washingtonpost.com" || DomNm=="blog.tv2.dk"
|| DomNm=="blogs.menomoneefallsnow.com" || DomNm=="weblogs.baltimoresun.com" || DomNm=="eonline.com") {
return PostUrlStr.GetSubStr(7, GetNthOccurence(PostUrlStr, 4)-1);
}
// http://digg.com/submit?phase=2&url=http://socialitelife.celebuzz.com/archive/2008/07/31/and_then_a_hero_came_along.php&title=and
// http://digg.com/general_sciences/mental_images_are_like_pictures_slide_show
if (DomNm == "digg.com") {
if (PostUrlStr.IsPrefix("http://digg.com/submit?")) {
const int Url = PostUrlStr.SearchStr(";url=");
if (Url != -1) {
return GetWebsiteNm(PostUrlStr.GetSubStr(Url+5, PostUrlStr.SearchCh('&', Url+5))); }
} else {
return PostUrlStr.GetSubStr(7, GetNthOccurence(PostUrlStr, 4)-1); }
}
// http://bbc.co.uk/blogs/thereporters/markdevenport/2008/08/back_to_porridge.html
// http://nydailynews.com/blogs/subwaysquawkers/2008/08/anaheim-is-no-magic-kingdom-fo.html
// http://newsbusters.org/blogs/p-j-gladnick/2008/08/11/sf-chronicle-writer-predicts-global-warming-shellfish-invas
// http://nydailynews.com/blogs/subwaysquawkers/2008/08/anaheim-is-no-magic-kingdom-fo.html
if (PostUrlStr.IsPrefix("http://nydailynews.com/blogs/") || PostUrlStr.IsPrefix("http://bbc.co.uk/blogs/")
|| PostUrlStr.IsPrefix("http://nydailynews.com/blogs/") || PostUrlStr.IsPrefix("http://newsbusters.org/blogs/")) {
return PostUrlStr.GetSubStr(7, GetNthOccurence(PostUrlStr, 5)-1);
}
// http://feeds.feedburner.com/~r/adesblog/ ~3/361711640
if (DomNm=="feeds.feedburner.com") {
return PostUrlStr.GetSubStr(7, GetNthOccurence(PostUrlStr, 5)-1);
}
// http://groups.google.com/group/news.admin.net-abuse.sightings/browse_thread/thread/8452c47949453216/f07daa509b90295c?show_docid=f07daa509b90295c
if (DomNm=="groups.google.com") {
return PostUrlStr.GetSubStr(7, GetNthOccurence(PostUrlStr, 5)-1);
}
// http://news.google.com/news/url?sa=t&ct=us/20-0&fd=r&url=http://www.theobserver.ca/articledisplay.aspx%3fe%3d1151495&cid=0&ei=yswgsjpndpbi8atc9knacw&usg=afqjcnhrbg-nc9z6ymtqfkear3_npwqqxa
if (DomNm=="news.google.com") { // redirect
const int UrlPos = PostUrlStr.SearchStr("&url=");
if (UrlPos != -1) {
return GetWebsiteNm(PostUrlStr.GetSubStr(UrlPos+5, PostUrlStr.SearchCh('&', UrlPos+5))); }
}
// http://bloggrevyen.no/go/110340/http://blog.christergulbrandsen.com/2008/08/11/is-nationalism-the-only-way-to-de
if (DomNm == "bloggrevyen.no") { // redirect
const int Http2 = PostUrlStr.SearchStr("/http://");
if (Http2!=-1) {
return GetWebsiteNm(PostUrlStr.GetSubStr(Http2+1, PostUrlStr.Len()-1)); }
}
//http://us.rd.yahoo.com/dailynews/rss/search/urgent+care/sig=11phgb4tu/*http%3a//www.newswise.com/articles/view/543340/?sc=rsmn
//http://ca.rd.yahoo.com/dailynews/rss/topstories/*http://ca.news.yahoo.com/s/reuters/080801/n_top_news/news_afgha
if (DomNm.IsSuffix(".rd.yahoo.com")) {
const int Http2 = PostUrlStr.SearchStr("/*");
if (Http2!=-1) {
return GetWebsiteNm(PostUrlStr.GetSubStr(Http2+9, PostUrlStr.Len()-1)); }
}
return DomNm;
}
示例13: RemoveHtmlTags
void TStrUtil::RemoveHtmlTags(const TChA& HtmlStr, TChA& TextStr) {
TextStr.Clr();
char *StrB, *StrE;
// use full page html: skip till <body>
//PageHtmlStr = "<script fdsfs> fsdfsd </script> jure";
/*if (UseFullHtml) {
StrB = PageHtmlStr.CStr();
StrE = StrB+PageHtmlStr.Len();
char * NewB = strstr(StrB, "<body>");
if (NewB != NULL) { StrB = NewB+6; }
char * NewE = strstr(StrB, "body>");
if (NewE != NULL) {
while (true) {
char *E=strstr(NewE+4, "body>");
if (E == NULL) { break; } NewE = E; }
StrE = NewE;
}
} else { // only extracted post html*/
StrB = (char *) HtmlStr.CStr();
StrE = (char *) StrB+HtmlStr.Len(); //}
for (char *e = StrB; e < StrE; ) {
char* b = e;
while (e<StrE && *e != '<') {
e++;
}
// copy text
char tmp=*e;
*e = 0;
TextStr+= b;
TextStr.AddCh(' ');
*e = tmp;
if (e >= StrE) {
return;
}
// if start of a comment: skip
if (e[1]=='!' && e[2]=='-' && e[3]=='-') { // comment
e += 3;
while(e<StrE && !(*(e-2)=='-' && *(e-1)=='-' && *e=='>')) {
e++;
}
e++;
continue;
}
// if "<script" then skip
if (e[1]=='s' && e[2]=='c' && e[3]=='r' && e[4]=='i' && e[5]=='p' && e[6]=='t') {
e += 5;
while(e<StrE && !(*(e-6)=='s' && *(e-5)=='c' && *(e-4)=='r' && *(e-3)=='i' && *(e-2)=='p' && *(e-1)=='t' && *e=='>')) {
e++;
}
e++;
continue;
}
// skip to end of tag
while (e < StrE && *e != '>') {
e++;
}
if (e>=StrE) {
return;
}
e++;
}
}