本文整理汇总了C++中Page::SetDescription方法的典型用法代码示例。如果您正苦于以下问题:C++ Page::SetDescription方法的具体用法?C++ Page::SetDescription怎么用?C++ Page::SetDescription使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Page
的用法示例。
在下文中一共展示了Page::SetDescription方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stream
Page * HTMLParser::Parse(URL _urlToParse)
{
try
{
urlToParse = _urlToParse;
Page * pageToReturn = new Page(urlToParse);
URLInputStream stream(urlToParse.getURL()); HTMLTokenizer Tokenizer(&stream);
StringURLResolver Resolver;
while(Tokenizer.HasNextToken())
{
HTMLToken current_tok = Tokenizer.GetNextToken();
if(current_tok.GetType() == COMMENT) continue; //If comment, skip.
if(current_tok.GetType() == TAG_START) //Marks flags for when we see an opening tag.
{
string tag_value = current_tok.GetValue();
StringUtil::ToLower(tag_value);
MarkStartFlags(tag_value);
if(tag_value == "a") //Extract, resolve, and add links.
{
string url = current_tok.GetAttribute("HREF");
URL urlToAdd(url);
//Before adding a URL, do some checks, clean URL up, then add.
PreAddChecks(url, urlToAdd, Resolver, _urlToParse);
}
if(tag_value[0] == 'h' && isdigit(tag_value[1]))
inH = true;
}
MarkEndFlags(current_tok); //Check current token to see if we are in title or body
if(current_tok.GetType() == TEXT) //If it's text, send it off for processing
processBlockOfText(current_tok.GetValue(), pageToReturn);
}
if(!pageToReturn->hasDescription()) //Pre-return check, see if title has 100 chars. Add if not
pageToReturn->SetDescription(BuildPossibleDescription());
return pageToReturn;
}
catch (CS240Exception & e) //If the page could not be downloaded, catch error. Do nothing.
{
cout << e.GetMessage() << endl;
}
return NULL;
}