本文整理汇总了C++中TChA::IsPrefix方法的典型用法代码示例。如果您正苦于以下问题:C++ TChA::IsPrefix方法的具体用法?C++ TChA::IsPrefix怎么用?C++ TChA::IsPrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TChA
的用法示例。
在下文中一共展示了TChA::IsPrefix方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetNormalizedUrl
// 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.")) {
TStr prefix("http://");
UrlOut = prefix + UrlOut.GetSubStr(11, TInt::Mx);
}
UrlOut.ToLc();
return true;
}
示例2: GetDomNm
// get domain name and also strip starting www.
TChA TStrUtil::GetDomNm2(const TChA& UrlChA) {
TChA Dom = GetDomNm(UrlChA);
if (Dom.IsPrefix("www.")) {
return Dom.GetSubStr(4, TInt::Mx);
}
else {
return Dom;
}
}
示例3: 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(); }
}
}
示例4: 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;
}