SNAP Library, Developer Reference  2012-10-02 12:56:23
SNAP, a general purpose network analysis and graph mining library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
macro.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 TMacro (const TStr &TxtStr, const char &_MacroCh='$', const char &_VarCh='#')
static PMacro New (const TStr &TxtStr, const char &MacroCh='$', const char &VarCh='#')
 ~TMacro ()
 TMacro (TSIn &)
static PMacro Load (TSIn &)
void Save (TSOut &) const
TMacrooperator= (const TMacro &)
bool IsOk () const
TStr GetMsgStr () const
TStr GetSrcTxtStr () const
TStr GetDstTxtStr () const
int GetSubstStrs () const
TStr GetSrcSubstStr (const int &SubstStrN) const
bool IsSrcSubstStr (const TStr &SrcSubstStr, int &SubstStrN) const
int GetSrcSubstStrN (const TStr &SrcSubstStr) const
void GetSrcSubstStrV (TStrV &SubstStrV) const
TStr GetDstSubstStr (const int &SubstStrN=0) const
void PutSubstValStr (const int &SubstStrN, const TStr &ValStr)
TStr GetSubstValStr (const int &SubstStrN) const
TStr GetAllSubstValStr () const
int GetVars () const
TStr GetVarNm (const int &VarN) const
void GetVarNmV (TStrV &VarNmV) const
void PutVarVal (const TStr &VarNm, const TStr &ValStr)
TStr GetVarVal (const TStr &VarNm) const
static void SplitVarNm (const TStr &VarNm, TStr &CapStr, bool &IsComboBox, TStr &TbNm, TStr &ListFldNm, TStr &DataFldNm)

Variables

ClassTP(TMacro, PMacro) public TStr MsgStr
char MacroCh
char VarCh
TStr TxtStr
TStrStrH SubstToValStrH
TStrStrH VarNmToValStrH

Function Documentation

Definition at line 87 of file macro.cpp.

References GetSubstStrs(), and GetSubstValStr().

                                     {
  TChA AllSubstValChA;
  for (int SubstStrN=0; SubstStrN<GetSubstStrs(); SubstStrN++){
    if (SubstStrN>0){AllSubstValChA+=", ";}
    AllSubstValChA+=GetSubstValStr(SubstStrN);
  }
  return AllSubstValChA;
}

Here is the call graph for this function:

TStr TMacro::GetDstSubstStr ( const int &  SubstStrN = 0) const

Definition at line 67 of file macro.cpp.

References THash< TKey, TDat, THashFunc >::GetKey(), GetVarVal(), IAssert, TStr::Len(), SubstToValStrH, and VarCh.

                                                      {
  TStr SrcSubstStr=SubstToValStrH.GetKey(SubstStrN);
  int SrcSubstStrLen=SrcSubstStr.Len();
  int SrcSubstChN=0;
  TChA DstSubstChA;
  while (SrcSubstChN<SrcSubstStrLen){
    if (SrcSubstStr[SrcSubstChN]==VarCh){
      TChA VarNmChA; SrcSubstChN++;
      while ((SrcSubstChN<SrcSubstStrLen)&&(SrcSubstStr[SrcSubstChN]!=VarCh)){
        VarNmChA+=SrcSubstStr[SrcSubstChN]; SrcSubstChN++;}
      IAssert(SrcSubstChN<SrcSubstStrLen); SrcSubstChN++;
      TStr VarVal=GetVarVal(VarNmChA);
      DstSubstChA+=VarVal;
    } else {
      DstSubstChA+=SrcSubstStr[SrcSubstChN]; SrcSubstChN++;
    }
  }
  return DstSubstChA;
}

Here is the call graph for this function:

Definition at line 38 of file macro.cpp.

References THash< TKey, TDat, THashFunc >::IsKey(), TStr::Len(), MacroCh, SubstToValStrH, and TxtStr.

                                {
  int TxtStrLen=TxtStr.Len(); int TxtStrChN=0;
  TChA DstTxtChA;
  while (TxtStrChN<TxtStrLen){
    if (TxtStr[TxtStrChN]==MacroCh){
      TChA SubstChA; TxtStrChN++;
      while ((TxtStrChN<TxtStrLen)&&(TxtStr[TxtStrChN]!=MacroCh)){
        SubstChA+=TxtStr[TxtStrChN]; TxtStrChN++;}
      TxtStrChN++;
      int SubstKeyId;
      if (SubstToValStrH.IsKey(SubstChA, SubstKeyId)){
        DstTxtChA+=SubstToValStrH[SubstKeyId];
      } else {
        DstTxtChA+=MacroCh; DstTxtChA+=SubstChA; DstTxtChA+=MacroCh;
      }
    } else {
      DstTxtChA+=TxtStr[TxtStrChN]; TxtStrChN++;
    }
  }
  return DstTxtChA;
}

Here is the call graph for this function:

TStr GetMsgStr ( ) const

Definition at line 25 of file macro.h.

References MsgStr.

Referenced by GetStr().

{return MsgStr;}

Here is the caller graph for this function:

TStr GetSrcSubstStr ( const int &  SubstStrN) const

Definition at line 31 of file macro.h.

References THash< TKey, TDat, THashFunc >::GetKey().

Referenced by GetSrcSubstStrV().

                                                  {
    return SubstToValStrH.GetKey(SubstStrN);}

Here is the call graph for this function:

Here is the caller graph for this function:

int GetSrcSubstStrN ( const TStr SrcSubstStr) const

Definition at line 35 of file macro.h.

References THash< TKey, TDat, THashFunc >::GetKeyId().

                                                     {
    return SubstToValStrH.GetKeyId(SrcSubstStr);}

Here is the call graph for this function:

void TMacro::GetSrcSubstStrV ( TStrV SubstStrV) const

Definition at line 60 of file macro.cpp.

References TVec< TVal >::Add(), TVec< TVal >::Gen(), GetSrcSubstStr(), and GetSubstStrs().

                                                   {
  SubstStrV.Gen(GetSubstStrs(), 0);
  for (int SubstStrN=0; SubstStrN<GetSubstStrs(); SubstStrN++){
    SubstStrV.Add(GetSrcSubstStr(SubstStrN));
  }
}

Here is the call graph for this function:

TStr GetSrcTxtStr ( ) const

Definition at line 27 of file macro.h.

References TxtStr.

{return TxtStr;}
int GetSubstStrs ( ) const

Definition at line 30 of file macro.h.

References THash< TKey, TDat, THashFunc >::Len().

Referenced by GetAllSubstValStr(), and GetSrcSubstStrV().

{return SubstToValStrH.Len();}

Here is the call graph for this function:

Here is the caller graph for this function:

TStr GetSubstValStr ( const int &  SubstStrN) const

Definition at line 41 of file macro.h.

Referenced by GetAllSubstValStr().

                                                  {
    return SubstToValStrH[SubstStrN];}

Here is the caller graph for this function:

TStr GetVarNm ( const int &  VarN) const

Definition at line 46 of file macro.h.

References THash< TKey, TDat, THashFunc >::GetKey().

{return VarNmToValStrH.GetKey(VarN);}

Here is the call graph for this function:

void GetVarNmV ( TStrV VarNmV) const
int GetVars ( ) const

Definition at line 45 of file macro.h.

References THash< TKey, TDat, THashFunc >::Len().

{return VarNmToValStrH.Len();}

Here is the call graph for this function:

TStr GetVarVal ( const TStr VarNm) const

Definition at line 50 of file macro.h.

References THash< TKey, TDat, THashFunc >::GetDat().

                                          {
    return VarNmToValStrH.GetDat(VarNm);}

Here is the call graph for this function:

bool IsOk ( ) const

Definition at line 24 of file macro.h.

{return Ok;}
bool IsSrcSubstStr ( const TStr SrcSubstStr,
int &  SubstStrN 
) const

Definition at line 33 of file macro.h.

References THash< TKey, TDat, THashFunc >::IsKey().

                                                                    {
    return SubstToValStrH.IsKey(SrcSubstStr, SubstStrN);}

Here is the call graph for this function:

static PMacro Load ( TSIn ) [static]

Definition at line 19 of file macro.h.

References Fail.

{Fail; return NULL;}
static PMacro New ( const TStr TxtStr,
const char &  MacroCh = '$',
const char &  VarCh = '#' 
) [static]

Definition at line 14 of file macro.h.

References TMacro().

                                                                      {
    return PMacro(new TMacro(TxtStr, MacroCh, VarCh));}

Here is the call graph for this function:

TMacro& operator= ( const TMacro )

Definition at line 22 of file macro.h.

References Fail.

{Fail; return *this;}
void PutSubstValStr ( const int &  SubstStrN,
const TStr ValStr 
)

Definition at line 39 of file macro.h.

                                                               {
    SubstToValStrH[SubstStrN]=ValStr;}
void PutVarVal ( const TStr VarNm,
const TStr ValStr 
)

Definition at line 48 of file macro.h.

References THash< TKey, TDat, THashFunc >::AddDat().

                                                       {
    VarNmToValStrH.AddDat(VarNm, ValStr);}

Here is the call graph for this function:

void Save ( TSOut ) const

Definition at line 20 of file macro.h.

References Fail.

{Fail;}
void TMacro::SplitVarNm ( const TStr VarNm,
TStr CapStr,
bool &  IsComboBox,
TStr TbNm,
TStr ListFldNm,
TStr DataFldNm 
) [static]

Definition at line 103 of file macro.cpp.

References TStr::GetSubStr(), IAssert, TStr::Len(), and TStr::SearchCh().

                                                                {
  if (VarNm.SearchCh(':')==-1){
    CapStr=VarNm; IsComboBox=false; TbNm=""; ListFldNm=""; DataFldNm="";
  } else {
    int FirstColonChN=VarNm.SearchCh(':');
    int SecondColonChN=VarNm.SearchCh(':', FirstColonChN+1);
    int ThirdColonChN=VarNm.SearchCh(':', SecondColonChN+1);
    IAssert((FirstColonChN!=-1)&&(SecondColonChN!=-1));
    if (ThirdColonChN==-1){ThirdColonChN=VarNm.Len();}
    CapStr=VarNm.GetSubStr(0, FirstColonChN-1);
    IsComboBox=true;
    TbNm=VarNm.GetSubStr(FirstColonChN+1, SecondColonChN-1);
    ListFldNm=VarNm.GetSubStr(SecondColonChN+1, ThirdColonChN-1);
    if (ThirdColonChN!=VarNm.Len()){
      DataFldNm=VarNm.GetSubStr(ThirdColonChN+1, VarNm.Len()-1);
    } else {
      DataFldNm=ListFldNm;
    }
  }
}

Here is the call graph for this function:

TMacro::TMacro ( const TStr TxtStr,
const char &  _MacroCh = '$',
const char &  _VarCh = '#' 
)

Definition at line 3 of file macro.cpp.

References THash< TKey, TDat, THashFunc >::AddDat(), TChA::Len(), TStr::Len(), MacroCh, MsgStr, SubstToValStrH, TxtStr, VarCh, and VarNmToValStrH.

Referenced by New().

                                                                           :
  Ok(true), MsgStr("Ok"), MacroCh(_MacroCh), VarCh(_VarCh),
  TxtStr(_TxtStr), SubstToValStrH(10), VarNmToValStrH(10){
  int TxtStrLen=TxtStr.Len(); int TxtStrChN=0;
  while ((Ok)&&(TxtStrChN<TxtStrLen)){
    if (TxtStr[TxtStrChN]==MacroCh){
      // extract substitution from text
      TChA SubstChA; TxtStrChN++;
      while ((TxtStrChN<TxtStrLen)&&(TxtStr[TxtStrChN]!=MacroCh)){
        SubstChA+=TxtStr[TxtStrChN]; TxtStrChN++;}
      Ok=(TxtStrChN<TxtStrLen);
      if (!Ok){MsgStr=SubstChA; break;}
      TxtStrChN++;
      SubstToValStrH.AddDat(SubstChA);
      // extract variable name from substitution
      int SubstChN=0;
      while ((Ok)&&(SubstChN<SubstChA.Len())){
        if (SubstChA[SubstChN]==VarCh){
          TChA VarNmChA; SubstChN++;
          while ((SubstChN<SubstChA.Len())&&(SubstChA[SubstChN]!=VarCh)){
            VarNmChA+=SubstChA[SubstChN]; SubstChN++;}
          Ok=(SubstChN<SubstChA.Len());
          if (!Ok){MsgStr=VarNmChA; break;}
          SubstChN++;
          VarNmToValStrH.AddDat(VarNmChA);
        } else {
          SubstChN++;
        }
      }
    } else {
      TxtStrChN++;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

TMacro ( TSIn )

Definition at line 18 of file macro.h.

References Fail.

{Fail;}
~TMacro ( )

Definition at line 17 of file macro.h.

{}

Variable Documentation

char MacroCh

Definition at line 7 of file macro.h.

Referenced by GetDstTxtStr(), and TMacro().

Definition at line 10 of file macro.h.

Referenced by GetDstSubstStr(), GetDstTxtStr(), and TMacro().

Definition at line 9 of file macro.h.

Referenced by GetDstTxtStr(), GetSrcTxtStr(), and TMacro().

char VarCh

Definition at line 8 of file macro.h.

Referenced by GetDstSubstStr(), and TMacro().

Definition at line 11 of file macro.h.

Referenced by TMacro().