SNAP Library 2.1, User Reference
2013-09-25 10:47:25
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <html.h>
Public Member Functions | |
THtmlHldV (const PHtmlDoc &_RefHtmlDoc, const int &HldWnLen=10) | |
THtmlHldV (TSIn &) | |
void | Save (TSOut &) |
THtmlHldV & | operator= (const THtmlHldV &) |
PHtmlDoc | GetRefHtmlDoc () |
int | GetHlds () |
PHtmlDoc | GetHld (const int &HldN) |
Static Public Member Functions | |
static PHtmlHldV | Load (TSIn &) |
Private Attributes | |
TCRef | CRef |
PHtmlDoc | RefHtmlDoc |
THtmlDocV | HldV |
Friends | |
class | TPt< THtmlHldV > |
THtmlHldV::THtmlHldV | ( | const PHtmlDoc & | _RefHtmlDoc, |
const int & | HldWnLen = 10 |
||
) |
Definition at line 1148 of file html.cpp.
: RefHtmlDoc(_RefHtmlDoc), HldV(){ bool IsTitleAct=false; THtmlTokV TitleTokV; bool IsHAct=false; int ActHTagN=-1; TVec<THtmlTokV> HTokV(6); PHtmlTok Tok; THtmlLxSym TokSym; TStr TokStr; for (int TokN=0; TokN<RefHtmlDoc->GetToks(); TokN++){ Tok=RefHtmlDoc->GetTok(TokN, TokSym, TokStr); if ((TokSym==hsyBTag)&&(TokStr==THtmlTok::ATagNm)){ // collect tokens before, inside and after <a> ... </a> tags int ATokN; PHtmlTok ATok; THtmlLxSym ATokSym; TStr ATokStr; // inside <A> tags THtmlTokV ATokV; ATokN=TokN; forever{ ATok=RefHtmlDoc->GetTok(ATokN, ATokSym, ATokStr); if (ATokSym!=hsySSym){ATokV.Add(ATok);} if ((ATokSym==hsyETag)&&(ATokStr==THtmlTok::ATagNm)){break;} ATokN++; if (ATokN>=RefHtmlDoc->GetToks()){break;} } int ETagATokN=ATokN+1; // before <A> tags THtmlTokV PrevATokV; ATokN=TokN; forever{ ATokN--; if (ATokN<0){break;} ATok=RefHtmlDoc->GetTok(ATokN, ATokSym, ATokStr); if (THtmlTok::IsBreakTok(ATok)){break;} if ((ATokSym==hsyStr)||(ATokSym==hsyNum)){PrevATokV.Add(ATok);} if (ATokV.Len()>=HldWnLen){break;} } // after <A> tags THtmlTokV NextATokV; ATokN=ETagATokN; forever{ ATokN++; if (ATokN>=RefHtmlDoc->GetToks()){break;} ATok=RefHtmlDoc->GetTok(ATokN, ATokSym, ATokStr); if (THtmlTok::IsBreakTok(ATok)){break;} if ((ATokSym==hsyStr)||(ATokSym==hsyNum)){NextATokV.Add(ATok);} if (ATokV.Len()>=HldWnLen){break;} } // construct html-document with hyper-link context PHtmlDoc HtmlDoc=PHtmlDoc(new THtmlDoc()); HtmlDoc->AddTokV(TitleTokV); for (int HTagN=1; HTagN<=6; HTagN++){HtmlDoc->AddTokV(HTokV[HTagN-1]);} HtmlDoc->AddTokV(PrevATokV); HtmlDoc->AddTokV(ATokV); HtmlDoc->AddTokV(NextATokV); HldV.Add(HtmlDoc); HtmlDoc->SaveTxt(TSOut::StdOut); } else if (TokSym==hsyBTag){ int HTagN; if (TokStr==THtmlTok::TitleTagNm){ IsTitleAct=true; TitleTokV.Clr(); TitleTokV.Add(Tok); } else if (THtmlTok::IsHTag(TokStr, HTagN)){ if (IsHAct){// conclude previous <H?> tag if left open HTokV[ActHTagN-1].Add(THtmlTok::GetHTok(false, ActHTagN));} IsHAct=true; ActHTagN=HTagN; {for (int HTagN=ActHTagN; HTagN<=6; HTagN++){HTokV[HTagN-1].Clr();}} HTokV[ActHTagN-1].Add(Tok); } } else if (TokSym==hsyETag){ int HTagN; if (TokStr==THtmlTok::TitleTagNm){ if (IsTitleAct){TitleTokV.Add(Tok); IsTitleAct=false;} } else if (THtmlTok::IsHTag(TokStr, HTagN)){ if (IsHAct){HTokV[ActHTagN-1].Add(Tok); IsHAct=false;} } } else if (TokSym!=hsySSym){ if (IsTitleAct){TitleTokV.Add(Tok);} if (IsHAct){HTokV[ActHTagN-1].Add(Tok);} } } }
THtmlHldV::THtmlHldV | ( | TSIn & | ) | [inline] |
PHtmlDoc THtmlHldV::GetHld | ( | const int & | HldN | ) | [inline] |
int THtmlHldV::GetHlds | ( | ) | [inline] |
PHtmlDoc THtmlHldV::GetRefHtmlDoc | ( | ) | [inline] |
Definition at line 323 of file html.h.
{return RefHtmlDoc;}
static PHtmlHldV THtmlHldV::Load | ( | TSIn & | ) | [inline, static] |
void THtmlHldV::Save | ( | TSOut & | ) | [inline] |
TCRef THtmlHldV::CRef [private] |
THtmlDocV THtmlHldV::HldV [private] |
PHtmlDoc THtmlHldV::RefHtmlDoc [private] |