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
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
THtmlHldV Class Reference

#include <html.h>

List of all members.

Public Member Functions

 THtmlHldV (const PHtmlDoc &_RefHtmlDoc, const int &HldWnLen=10)
 THtmlHldV (TSIn &)
void Save (TSOut &)
THtmlHldVoperator= (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 >

Detailed Description

Definition at line 311 of file html.h.


Constructor & Destructor Documentation

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]

Definition at line 317 of file html.h.

{Fail;}

Member Function Documentation

PHtmlDoc THtmlHldV::GetHld ( const int &  HldN) [inline]

Definition at line 325 of file html.h.

{return HldV[HldN];}
int THtmlHldV::GetHlds ( ) [inline]

Definition at line 324 of file html.h.

{return HldV.Len();}

Definition at line 323 of file html.h.

{return RefHtmlDoc;}
static PHtmlHldV THtmlHldV::Load ( TSIn ) [inline, static]

Definition at line 318 of file html.h.

{Fail; return NULL;}
THtmlHldV& THtmlHldV::operator= ( const THtmlHldV ) [inline]

Definition at line 321 of file html.h.

{Fail; return *this;}
void THtmlHldV::Save ( TSOut ) [inline]

Definition at line 319 of file html.h.

{Fail;}

Friends And Related Function Documentation

friend class TPt< THtmlHldV > [friend]

Definition at line 311 of file html.h.


Member Data Documentation

Definition at line 311 of file html.h.

Definition at line 314 of file html.h.

Definition at line 313 of file html.h.


The documentation for this class was generated from the following files: