SNAP Library 4.0, Developer Reference  2017-07-27 13:18:06
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
THtmlHldV Class Reference

#include <html.h>

Collaboration diagram for THtmlHldV:

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.

References TVec< TVal, TSizeTy >::Add(), THtmlDoc::AddTokV(), TVec< TVal, TSizeTy >::Clr(), forever, THtmlTok::GetHTok(), THtmlDoc::GetTok(), THtmlDoc::GetToks(), HldV, hsyBTag, hsyETag, hsyNum, hsySSym, hsyStr, THtmlTok::IsBreakTok(), THtmlTok::IsHTag(), TVec< TVal, TSizeTy >::Len(), RefHtmlDoc, THtmlDoc::SaveTxt(), and TSOut::StdOut.

1148  :
1149  RefHtmlDoc(_RefHtmlDoc), HldV(){
1150  bool IsTitleAct=false; THtmlTokV TitleTokV;
1151  bool IsHAct=false; int ActHTagN=-1;
1152  TVec<THtmlTokV> HTokV(6);
1153  PHtmlTok Tok; THtmlLxSym TokSym; TStr TokStr;
1154  for (int TokN=0; TokN<RefHtmlDoc->GetToks(); TokN++){
1155  Tok=RefHtmlDoc->GetTok(TokN, TokSym, TokStr);
1156  if ((TokSym==hsyBTag)&&(TokStr==THtmlTok::ATagNm)){
1157  // collect tokens before, inside and after <a> ... </a> tags
1158  int ATokN; PHtmlTok ATok; THtmlLxSym ATokSym; TStr ATokStr;
1159  // inside <A> tags
1160  THtmlTokV ATokV; ATokN=TokN;
1161  forever{
1162  ATok=RefHtmlDoc->GetTok(ATokN, ATokSym, ATokStr);
1163  if (ATokSym!=hsySSym){ATokV.Add(ATok);}
1164  if ((ATokSym==hsyETag)&&(ATokStr==THtmlTok::ATagNm)){break;}
1165  ATokN++;
1166  if (ATokN>=RefHtmlDoc->GetToks()){break;}
1167  }
1168  int ETagATokN=ATokN+1;
1169  // before <A> tags
1170  THtmlTokV PrevATokV; ATokN=TokN;
1171  forever{
1172  ATokN--;
1173  if (ATokN<0){break;}
1174  ATok=RefHtmlDoc->GetTok(ATokN, ATokSym, ATokStr);
1175  if (THtmlTok::IsBreakTok(ATok)){break;}
1176  if ((ATokSym==hsyStr)||(ATokSym==hsyNum)){PrevATokV.Add(ATok);}
1177  if (ATokV.Len()>=HldWnLen){break;}
1178  }
1179  // after <A> tags
1180  THtmlTokV NextATokV; ATokN=ETagATokN;
1181  forever{
1182  ATokN++;
1183  if (ATokN>=RefHtmlDoc->GetToks()){break;}
1184  ATok=RefHtmlDoc->GetTok(ATokN, ATokSym, ATokStr);
1185  if (THtmlTok::IsBreakTok(ATok)){break;}
1186  if ((ATokSym==hsyStr)||(ATokSym==hsyNum)){NextATokV.Add(ATok);}
1187  if (ATokV.Len()>=HldWnLen){break;}
1188  }
1189  // construct html-document with hyper-link context
1190  PHtmlDoc HtmlDoc=PHtmlDoc(new THtmlDoc());
1191  HtmlDoc->AddTokV(TitleTokV);
1192  for (int HTagN=1; HTagN<=6; HTagN++){HtmlDoc->AddTokV(HTokV[HTagN-1]);}
1193  HtmlDoc->AddTokV(PrevATokV);
1194  HtmlDoc->AddTokV(ATokV);
1195  HtmlDoc->AddTokV(NextATokV);
1196  HldV.Add(HtmlDoc);
1197  HtmlDoc->SaveTxt(TSOut::StdOut);
1198  } else
1199  if (TokSym==hsyBTag){
1200  int HTagN;
1201  if (TokStr==THtmlTok::TitleTagNm){
1202  IsTitleAct=true; TitleTokV.Clr(); TitleTokV.Add(Tok);
1203  } else
1204  if (THtmlTok::IsHTag(TokStr, HTagN)){
1205  if (IsHAct){// conclude previous <H?> tag if left open
1206  HTokV[ActHTagN-1].Add(THtmlTok::GetHTok(false, ActHTagN));}
1207  IsHAct=true; ActHTagN=HTagN;
1208  {for (int HTagN=ActHTagN; HTagN<=6; HTagN++){HTokV[HTagN-1].Clr();}}
1209  HTokV[ActHTagN-1].Add(Tok);
1210  }
1211  } else
1212  if (TokSym==hsyETag){
1213  int HTagN;
1214  if (TokStr==THtmlTok::TitleTagNm){
1215  if (IsTitleAct){TitleTokV.Add(Tok); IsTitleAct=false;}
1216  } else
1217  if (THtmlTok::IsHTag(TokStr, HTagN)){
1218  if (IsHAct){HTokV[ActHTagN-1].Add(Tok); IsHAct=false;}
1219  }
1220  } else
1221  if (TokSym!=hsySSym){
1222  if (IsTitleAct){TitleTokV.Add(Tok);}
1223  if (IsHAct){HTokV[ActHTagN-1].Add(Tok);}
1224  }
1225  }
1226 }
PHtmlDoc RefHtmlDoc
Definition: html.h:313
THtmlLxSym
Definition: html.h:78
Definition: html.h:79
#define forever
Definition: bd.h:6
static bool IsBreakTok(const PHtmlTok &Tok)
Definition: html.cpp:744
Definition: html.h:79
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
static const TStr TitleTagNm
Definition: html.h:234
TPt< THtmlDoc > PHtmlDoc
Definition: html.h:6
static const TStr ATagNm
Definition: html.h:217
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:1022
int GetToks() const
Definition: html.h:270
static PHtmlTok GetHTok(const bool &IsBTag, const int &HTagN)
Definition: html.cpp:762
void SaveTxt(const PSOut &SOut, const bool &TxtMode=true) const
Definition: html.cpp:915
static const TPt< TSOut > StdOut
Definition: fl.h:208
void AddTokV(const THtmlTokV &_TokV)
Definition: html.h:274
static bool IsHTag(const TStr &TagNm, int &HTagN)
Definition: html.cpp:752
Definition: html.h:79
Definition: html.h:80
Definition: html.h:80
Definition: dt.h:412
Definition: bd.h:196
Definition: html.h:254
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
PHtmlTok GetTok(const int &TokN) const
Definition: html.h:271
THtmlDocV HldV
Definition: html.h:314

Here is the call graph for this function:

THtmlHldV::THtmlHldV ( TSIn )
inline

Definition at line 317 of file html.h.

References Fail.

317 {Fail;}
#define Fail
Definition: bd.h:238

Member Function Documentation

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

Definition at line 325 of file html.h.

325 {return HldV[HldN];}
THtmlDocV HldV
Definition: html.h:314
int THtmlHldV::GetHlds ( )
inline

Definition at line 324 of file html.h.

324 {return HldV.Len();}
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
THtmlDocV HldV
Definition: html.h:314
PHtmlDoc THtmlHldV::GetRefHtmlDoc ( )
inline

Definition at line 323 of file html.h.

323 {return RefHtmlDoc;}
PHtmlDoc RefHtmlDoc
Definition: html.h:313
static PHtmlHldV THtmlHldV::Load ( TSIn )
inlinestatic

Definition at line 318 of file html.h.

References Fail.

318 {Fail; return NULL;}
#define Fail
Definition: bd.h:238
THtmlHldV& THtmlHldV::operator= ( const THtmlHldV )
inline

Definition at line 321 of file html.h.

References Fail.

321 {Fail; return *this;}
#define Fail
Definition: bd.h:238
void THtmlHldV::Save ( TSOut )
inline

Definition at line 319 of file html.h.

References Fail.

319 {Fail;}
#define Fail
Definition: bd.h:238

Friends And Related Function Documentation

friend class TPt< THtmlHldV >
friend

Definition at line 311 of file html.h.

Member Data Documentation

TCRef THtmlHldV::CRef
private

Definition at line 311 of file html.h.

THtmlDocV THtmlHldV::HldV
private

Definition at line 314 of file html.h.

Referenced by THtmlHldV().

PHtmlDoc THtmlHldV::RefHtmlDoc
private

Definition at line 313 of file html.h.

Referenced by THtmlHldV().


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