SNAP Library 6.0, User Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
TUrlEnv Class Reference

#include <url.h>

Public Member Functions

 TUrlEnv ()
 
 TUrlEnv (const TUrlEnv &UrlEnv)
 
 ~TUrlEnv ()
 
 TUrlEnv (TSIn &SIn)
 
void Save (TSOut &SOut)
 
TUrlEnvoperator= (const TUrlEnv &Env)
 
void PutBaseUrlStr (const TStr &_BaseUrlStr)
 
TStr GetBaseUrlStr () const
 
void AddKeyVal (const TStr &KeyNm, const TStr &ValStr)
 
void AddToKeyVal (const TStr &KeyNm, const TStr &ValStr)
 
bool Empty () const
 
int GetKeys () const
 
bool IsKey (const TStr &KeyNm) const
 
int GetKeyN (const TStr &KeyNm) const
 
TStr GetKeyNm (const int &KeyN) const
 
int GetVals (const int &KeyN) const
 
int GetVals (const TStr &KeyNm) const
 
TStr GetVal (const int &KeyN, const int &ValN=0) const
 
TStr GetVal (const TStr &KeyNm, const int &ValN=0, const TStr &DfVal="") const
 
TStr GetFullUrlStr () const
 

Static Public Member Functions

static PUrlEnv New ()
 
static PUrlEnv New (const TStr &BaseUrlStr, const TStr &KeyNm1=TStr(), const TStr &ValStr1=TStr(), const TStr &KeyNm2=TStr(), const TStr &ValStr2=TStr(), const TStr &KeyNm3=TStr(), const TStr &ValStr3=TStr(), const TStr &KeyNm4=TStr(), const TStr &ValStr4=TStr())
 
static PUrlEnv Load (TSIn &SIn)
 
static PUrlEnv MkClone (const PUrlEnv &UrlEnv)
 

Private Attributes

TCRef CRef
 
TStr BaseUrlStr
 
TStrV KeyNmV
 
TStrStrVH KeyNmToValH
 

Friends

class TPt< TUrlEnv >
 

Detailed Description

Definition at line 103 of file url.h.

Constructor & Destructor Documentation

TUrlEnv::TUrlEnv ( )
inline

Definition at line 109 of file url.h.

109  :
110  KeyNmV(), KeyNmToValH(10){}
TStrV KeyNmV
Definition: url.h:106
TStrStrVH KeyNmToValH
Definition: url.h:107
TUrlEnv::TUrlEnv ( const TUrlEnv UrlEnv)
inline

Definition at line 111 of file url.h.

111  :
112  KeyNmV(UrlEnv.KeyNmV), KeyNmToValH(UrlEnv.KeyNmToValH){}
TStrV KeyNmV
Definition: url.h:106
TStrStrVH KeyNmToValH
Definition: url.h:107
TUrlEnv::~TUrlEnv ( )
inline

Definition at line 126 of file url.h.

126 {}
TUrlEnv::TUrlEnv ( TSIn SIn)
inline

Definition at line 127 of file url.h.

127 : KeyNmV(SIn), KeyNmToValH(SIn){}
TStrV KeyNmV
Definition: url.h:106
TStrStrVH KeyNmToValH
Definition: url.h:107

Member Function Documentation

void TUrlEnv::AddKeyVal ( const TStr KeyNm,
const TStr ValStr 
)
inline

Definition at line 140 of file url.h.

140  {
141  if (!IsKey(KeyNm)){KeyNmV.Add(KeyNm); KeyNmToValH.AddKey(KeyNm);}
142  KeyNmToValH.GetDat(KeyNm).Clr();
143  KeyNmToValH.GetDat(KeyNm).Add(ValStr);}
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TStrV KeyNmV
Definition: url.h:106
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:1022
bool IsKey(const TStr &KeyNm) const
Definition: url.h:151
int AddKey(const TKey &Key)
Definition: hash.h:373
TStrStrVH KeyNmToValH
Definition: url.h:107
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
void TUrlEnv::AddToKeyVal ( const TStr KeyNm,
const TStr ValStr 
)
inline

Definition at line 144 of file url.h.

144  {
145  if (!IsKey(KeyNm)){KeyNmV.Add(KeyNm); KeyNmToValH.AddKey(KeyNm);}
146  KeyNmToValH.GetDat(KeyNm).Add(ValStr);}
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TStrV KeyNmV
Definition: url.h:106
bool IsKey(const TStr &KeyNm) const
Definition: url.h:151
int AddKey(const TKey &Key)
Definition: hash.h:373
TStrStrVH KeyNmToValH
Definition: url.h:107
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
bool TUrlEnv::Empty ( ) const
inline

Definition at line 149 of file url.h.

149 {return KeyNmV.Empty();}
bool Empty() const
Tests whether the vector is empty.
Definition: ds.h:570
TStrV KeyNmV
Definition: url.h:106
TStr TUrlEnv::GetBaseUrlStr ( ) const
inline

Definition at line 137 of file url.h.

137 {return BaseUrlStr;}
TStr BaseUrlStr
Definition: url.h:105
TStr TUrlEnv::GetFullUrlStr ( ) const

Definition at line 445 of file url.cpp.

445  {
446  if (GetKeys()==0){return TStr();}
447  TChA SearchChA;
448  SearchChA+=BaseUrlStr;
449  SearchChA+="?";
450  int KeyVals=0;
451  for (int KeyN=0; KeyN<GetKeys(); KeyN++){
452  TStr KeyNm=GetKeyNm(KeyN);
453  TStrV ValStrV=KeyNmToValH.GetDat(KeyNm);
454  for (int ValStrN=0; ValStrN<ValStrV.Len(); ValStrN++){
455  if (KeyVals>0){SearchChA+="&";}
456  SearchChA+=TUrl::GetUrlSearchStr(KeyNm);
457  SearchChA+='=';
458  SearchChA+=TUrl::GetUrlSearchStr(ValStrV[ValStrN]);
459  KeyVals++;
460  }
461  }
462  return SearchChA;
463 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
int GetKeys() const
Definition: url.h:150
TStr GetKeyNm(const int &KeyN) const
Definition: url.h:153
Definition: dt.h:201
Definition: dt.h:412
static TStr GetUrlSearchStr(const TStr &Str)
Definition: url.cpp:368
TStr BaseUrlStr
Definition: url.h:105
TStrStrVH KeyNmToValH
Definition: url.h:107
int TUrlEnv::GetKeyN ( const TStr KeyNm) const
inline

Definition at line 152 of file url.h.

152 {return KeyNmV.SearchForw(KeyNm);}
TStrV KeyNmV
Definition: url.h:106
TSizeTy SearchForw(const TVal &Val, const TSizeTy &BValN=0) const
Returns the position of an element with value Val.
Definition: ds.h:1552
TStr TUrlEnv::GetKeyNm ( const int &  KeyN) const
inline

Definition at line 153 of file url.h.

153 {return KeyNmV[KeyN];}
TStrV KeyNmV
Definition: url.h:106
int TUrlEnv::GetKeys ( ) const
inline

Definition at line 150 of file url.h.

150 {return KeyNmV.Len();}
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TStrV KeyNmV
Definition: url.h:106
TStr TUrlEnv::GetVal ( const int &  KeyN,
const int &  ValN = 0 
) const
inline

Definition at line 160 of file url.h.

160  {
161  return KeyNmToValH.GetDat(KeyNmV[KeyN])[ValN];}
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TStrV KeyNmV
Definition: url.h:106
TStrStrVH KeyNmToValH
Definition: url.h:107
TStr TUrlEnv::GetVal ( const TStr KeyNm,
const int &  ValN = 0,
const TStr DfVal = "" 
) const
inline

Definition at line 162 of file url.h.

162  {
163  if (KeyNmToValH.IsKey(KeyNm)){
164  return KeyNmToValH.GetDat(KeyNm)[ValN];}
165  else {return DfVal;}}
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TStrStrVH KeyNmToValH
Definition: url.h:107
bool IsKey(const TKey &Key) const
Definition: hash.h:258
int TUrlEnv::GetVals ( const int &  KeyN) const
inline

Definition at line 156 of file url.h.

156  {
157  return KeyNmToValH.GetDat(KeyNmV[KeyN]).Len();}
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TStrV KeyNmV
Definition: url.h:106
TStrStrVH KeyNmToValH
Definition: url.h:107
int TUrlEnv::GetVals ( const TStr KeyNm) const
inline

Definition at line 158 of file url.h.

158  {
159  return KeyNmToValH.GetDat(KeyNm).Len();}
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TStrStrVH KeyNmToValH
Definition: url.h:107
bool TUrlEnv::IsKey ( const TStr KeyNm) const
inline

Definition at line 151 of file url.h.

151 {return KeyNmV.SearchForw(KeyNm)!=-1;}
TStrV KeyNmV
Definition: url.h:106
TSizeTy SearchForw(const TVal &Val, const TSizeTy &BValN=0) const
Returns the position of an element with value Val.
Definition: ds.h:1552
static PUrlEnv TUrlEnv::Load ( TSIn SIn)
inlinestatic

Definition at line 128 of file url.h.

128 {return new TUrlEnv(SIn);}
TUrlEnv()
Definition: url.h:109
PUrlEnv TUrlEnv::MkClone ( const PUrlEnv UrlEnv)
static

Definition at line 465 of file url.cpp.

465  {
466  PUrlEnv CloneUrlEnv=
467  PUrlEnv(new TUrlEnv(*UrlEnv));
468  return CloneUrlEnv;
469 }
TUrlEnv()
Definition: url.h:109
TPt< TUrlEnv > PUrlEnv
Definition: url.h:103
static PUrlEnv TUrlEnv::New ( )
inlinestatic

Definition at line 113 of file url.h.

113 {return new TUrlEnv();}
TUrlEnv()
Definition: url.h:109
static PUrlEnv TUrlEnv::New ( const TStr BaseUrlStr,
const TStr KeyNm1 = TStr(),
const TStr ValStr1 = TStr(),
const TStr KeyNm2 = TStr(),
const TStr ValStr2 = TStr(),
const TStr KeyNm3 = TStr(),
const TStr ValStr3 = TStr(),
const TStr KeyNm4 = TStr(),
const TStr ValStr4 = TStr() 
)
inlinestatic

Definition at line 114 of file url.h.

118  {
119  PUrlEnv UrlEnv=New();
120  UrlEnv->PutBaseUrlStr(BaseUrlStr);
121  if (!KeyNm1.Empty()){UrlEnv->AddKeyVal(KeyNm1, ValStr1);}
122  if (!KeyNm2.Empty()){UrlEnv->AddKeyVal(KeyNm2, ValStr2);}
123  if (!KeyNm3.Empty()){UrlEnv->AddKeyVal(KeyNm3, ValStr3);}
124  if (!KeyNm4.Empty()){UrlEnv->AddKeyVal(KeyNm4, ValStr4);}
125  return UrlEnv;}
void AddKeyVal(const TStr &KeyNm, const TStr &ValStr)
Definition: url.h:140
static PUrlEnv New()
Definition: url.h:113
void PutBaseUrlStr(const TStr &_BaseUrlStr)
Definition: url.h:136
bool Empty() const
Definition: dt.h:491
TUrlEnv& TUrlEnv::operator= ( const TUrlEnv Env)
inline

Definition at line 131 of file url.h.

131  {
132  if (this!=&Env){KeyNmV=Env.KeyNmV; KeyNmToValH=Env.KeyNmToValH;}
133  return *this;}
TStrV KeyNmV
Definition: url.h:106
TStrStrVH KeyNmToValH
Definition: url.h:107
void TUrlEnv::PutBaseUrlStr ( const TStr _BaseUrlStr)
inline

Definition at line 136 of file url.h.

136 {BaseUrlStr=_BaseUrlStr;}
TStr BaseUrlStr
Definition: url.h:105
void TUrlEnv::Save ( TSOut SOut)
inline

Definition at line 129 of file url.h.

129 {KeyNmV.Save(SOut); KeyNmToValH.Save(SOut);}
void Save(TSOut &SOut) const
Definition: hash.h:183
void Save(TSOut &SOut) const
Definition: ds.h:954
TStrV KeyNmV
Definition: url.h:106
TStrStrVH KeyNmToValH
Definition: url.h:107

Friends And Related Function Documentation

friend class TPt< TUrlEnv >
friend

Definition at line 103 of file url.h.

Member Data Documentation

TStr TUrlEnv::BaseUrlStr
private

Definition at line 105 of file url.h.

TCRef TUrlEnv::CRef
private

Definition at line 103 of file url.h.

TStrStrVH TUrlEnv::KeyNmToValH
private

Definition at line 107 of file url.h.

TStrV TUrlEnv::KeyNmV
private

Definition at line 106 of file url.h.


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