SNAP Library , Developer Reference  2013-01-07 14:03:36
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
TExpVal Class Reference

#include <exp.h>

Collaboration diagram for TExpVal:

List of all members.

Public Member Functions

 TExpVal (const TExpValType &_ValType=evtUndef)
 TExpVal (const TFlt &_Flt)
 TExpVal (const double &_Flt)
 TExpVal (const TStr &_Str)
 ~TExpVal ()
 TExpVal (TSIn &SIn)
void Save (TSOut &SOut) const
TExpValoperator= (const TExpVal &)
bool operator== (const TExpVal &ExpVal) const
bool operator< (const TExpVal &ExpVal) const
void AddToVec (const PExpVal &ExpVal)
void AddToLst (const PExpVal &ExpVal)
TExpValType GetValType () const
bool IsFltVal (TFlt &_Flt) const
bool IsFltVal (double &_Flt) const
double GetFltVal () const
int GetFltValAsInt (const bool &ThrowExceptP=true) const
TStr GetStrVal () const
void SaveTxt (TOLx &Lx) const
void SaveTxt (const PSOut &SOut) const
TStr GetStr () const

Static Public Member Functions

static PExpVal New (const TExpValType &ValType=evtUndef)
static PExpVal New (const TFlt &Flt)
static PExpVal New (const double &Flt)
static PExpVal New (const TStr &Str)
static PExpVal Load (TSIn &SIn)
static PExpVal MkClone (const PExpVal &ExpVal)
static PExpVal GetUndefExpVal ()
static PExpVal GetZeroExpVal ()

Private Attributes

TCRef CRef
TInt ValType
TAscFlt Flt
TStr Str
TExpValV ValV
TExpValL ValL

Static Private Attributes

static PExpVal UndefExpVal = NULL
static PExpVal ZeroExpVal = NULL

Friends

class TPt< TExpVal >

Detailed Description

Definition at line 9 of file exp.h.


Constructor & Destructor Documentation

TExpVal::TExpVal ( const TExpValType _ValType = evtUndef) [inline]

Definition at line 19 of file exp.h.

: ValType(_ValType){}
TExpVal::TExpVal ( const TFlt _Flt) [inline]

Definition at line 20 of file exp.h.

: ValType(evtFlt), Flt(_Flt){}
TExpVal::TExpVal ( const double &  _Flt) [inline]

Definition at line 21 of file exp.h.

: ValType(evtFlt), Flt(TFlt(_Flt)){}
TExpVal::TExpVal ( const TStr _Str) [inline]

Definition at line 22 of file exp.h.

: ValType(evtStr), Str(_Str){}
TExpVal::~TExpVal ( ) [inline]

Definition at line 28 of file exp.h.

{}
TExpVal::TExpVal ( TSIn SIn) [inline]

Definition at line 29 of file exp.h.

                    :
    ValType(SIn), Flt(SIn), Str(SIn), ValV(SIn), ValL(SIn){}

Member Function Documentation

void TExpVal::AddToLst ( const PExpVal ExpVal) [inline]

Definition at line 42 of file exp.h.

References evtLst, and IAssert.

Referenced by TExp::EvalExp().

                                      {
    IAssert(TExpValType(static_cast<int>(ValType))==evtLst); ValL.AddBack(ExpVal);}

Here is the caller graph for this function:

void TExpVal::AddToVec ( const PExpVal ExpVal) [inline]

Definition at line 40 of file exp.h.

References evtVec, and IAssert.

Referenced by TExp::EvalExp().

                                      {
    IAssert(TExpValType(static_cast<int>(ValType))==evtVec); ValV.Add(ExpVal);}

Here is the caller graph for this function:

double TExpVal::GetFltVal ( ) const [inline]

Definition at line 50 of file exp.h.

References evtFlt.

Referenced by TExp::EvalExpOp(), and GetFltValAsInt().

                           {
    if (GetValType()==evtFlt){return Flt;} else {return 0;}}

Here is the caller graph for this function:

int TExpVal::GetFltValAsInt ( const bool &  ThrowExceptP = true) const

Definition at line 62 of file exp.cpp.

References Flt, GetFltVal(), TInt::Mn, TInt::Mx, and TExcept::Throw().

Referenced by TExp::EvalExpOp().

                                                          {
  double Flt=GetFltVal();
  if ((Flt<double(TInt::Mn))&&(double(TInt::Mx)<Flt)){
    if (ThrowExceptP){TExcept::Throw("Float too big for integer.");}
    else {Flt=0;}
  }
  return int(Flt);
}

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TExpVal::GetStr ( ) const

Definition at line 99 of file exp.cpp.

References TMOut::GetSIn(), TStr::LoadTxt(), New(), and SaveTxt().

Referenced by TExp::Eval(), TExp::EvalExp(), and TExp::EvalExpOp().

                           {
  PSOut SOut=TMOut::New(); TMOut& MOut=*(TMOut*)SOut();
  SaveTxt(SOut);
  TStr ExpValStr=TStr::LoadTxt(MOut.GetSIn());
  return ExpValStr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TExpVal::GetStrVal ( ) const [inline]

Definition at line 53 of file exp.h.

References evtStr, and IAssert.

Referenced by TExp::EvalExpOp().

{IAssert(GetValType()==evtStr); return Str;}

Here is the caller graph for this function:

Definition at line 123 of file exp.cpp.

References TPt< TRec >::Empty(), New(), and UndefExpVal.

Referenced by TExp::Eval(), TExp::EvalExp(), TExpEnv::GetFuncVal(), TExpEnv::GetVarVal(), and TExpBi::TExpBi().

Here is the call graph for this function:

Here is the caller graph for this function:

TExpValType TExpVal::GetValType ( ) const [inline]

Definition at line 45 of file exp.h.

Referenced by TExpBi::AssertArgValType(), and TExp::EvalExpOp().

{return TExpValType(int(ValType));}

Here is the caller graph for this function:

Definition at line 129 of file exp.cpp.

References TPt< TRec >::Empty(), New(), and ZeroExpVal.

Referenced by TExp::EvalExpOp().

                              {
  if (ZeroExpVal.Empty()){
    ZeroExpVal=TExpVal::New(double(0));}
  return ZeroExpVal;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool TExpVal::IsFltVal ( TFlt _Flt) const [inline]

Definition at line 46 of file exp.h.

References evtFlt.

                                  {
    if (GetValType()==evtFlt){_Flt=Flt; return true;} else {return false;}}
bool TExpVal::IsFltVal ( double &  _Flt) const [inline]

Definition at line 48 of file exp.h.

References evtFlt.

                                    {
    if (GetValType()==evtFlt){_Flt=Flt; return true;} else {return false;}}
static PExpVal TExpVal::Load ( TSIn SIn) [inline, static]

Definition at line 31 of file exp.h.

{return PExpVal(new TExpVal(SIn));}
PExpVal TExpVal::MkClone ( const PExpVal ExpVal) [static]

Definition at line 106 of file exp.cpp.

References TLstNd< TVal >::GetVal(), New(), and TLstNd< TVal >::Next().

                                             {
  PExpVal CloneExpVal=TExpVal::New();
  CloneExpVal->ValType=ExpVal->ValType;
  CloneExpVal->Flt=ExpVal->Flt;
  CloneExpVal->Str=ExpVal->Str;
  CloneExpVal->ValV.Gen(ExpVal->ValV.Len(), 0);
  for (int VecValN=0; VecValN<ExpVal->ValV.Len(); VecValN++){
    CloneExpVal->ValV.Add(MkClone(ExpVal->ValV[VecValN]));
  }
  TExpValLN ExpValLN=ExpVal->ValL.First();
  while (ExpValLN!=NULL){
    CloneExpVal->ValL.AddBack(MkClone(ExpValLN->GetVal()));
    ExpValLN=ExpValLN->Next();
  }
  return CloneExpVal;
}

Here is the call graph for this function:

static PExpVal TExpVal::New ( const TExpValType ValType = evtUndef) [inline, static]

Definition at line 23 of file exp.h.

Referenced by TExp::EvalExp(), TExp::EvalExpOp(), TExpBi::GetBiFuncVal(), GetStr(), GetUndefExpVal(), GetZeroExpVal(), TExp::LoadTxtFact(), MkClone(), and TExpBi::TExpBi().

                                                         {
    return PExpVal(new TExpVal(ValType));}

Here is the caller graph for this function:

static PExpVal TExpVal::New ( const TFlt Flt) [inline, static]

Definition at line 25 of file exp.h.

{return PExpVal(new TExpVal(Flt));}
static PExpVal TExpVal::New ( const double &  Flt) [inline, static]

Definition at line 26 of file exp.h.

{return PExpVal(new TExpVal(Flt));}
static PExpVal TExpVal::New ( const TStr Str) [inline, static]

Definition at line 27 of file exp.h.

{return PExpVal(new TExpVal(Str));}
bool TExpVal::operator< ( const TExpVal ExpVal) const

Definition at line 31 of file exp.cpp.

References evtFlt, evtLst, evtStr, evtUndef, evtVec, Fail, TLst< TVal >::First(), Flt, TLstNd< TVal >::GetVal(), TVec< TVal >::Len(), TLst< TVal >::Len(), TLstNd< TVal >::Next(), Str, ValL, ValType, and ValV.

                                                   {
  if (ValType!=ExpVal.ValType){
    return ValType<ExpVal.ValType;}
  switch (ValType){
    case evtUndef: return false;
    case evtFlt: return Flt<ExpVal.Flt;
    case evtStr: return Str<ExpVal.Str;
    case evtVec:{
      int VecValN=0;
      while ((VecValN<ValV.Len())&&(VecValN<ExpVal.ValV.Len())){
        if (*ValV[VecValN]<*ExpVal.ValV[VecValN]){return true;}
        else if (*ValV[VecValN]==*ExpVal.ValV[VecValN]){VecValN++;}
        else {return false;}
      }
      return ValV.Len()<ExpVal.ValV.Len();}
    case evtLst:{
      if (ValL.Len()!=ExpVal.ValL.Len()){return false;}
      TExpValLN ValLN=ValL.First();
      TExpValLN ExpValLN=ExpVal.ValL.First();
      while ((ValLN!=NULL)&&(ExpValLN!=NULL)){
        if (*ValLN->GetVal()<*ExpValLN->GetVal()){
          return true;}
        else if (*ValLN->GetVal()==*ExpValLN->GetVal()){
          ValLN=ValLN->Next(); ExpValLN=ExpValLN->Next();}
        else {return false;}
      }
      return ValLN==NULL;}
    default: Fail; return false;
  }
}

Here is the call graph for this function:

TExpVal& TExpVal::operator= ( const TExpVal ) [inline]

Definition at line 36 of file exp.h.

References Fail.

{Fail; return *this;}
bool TExpVal::operator== ( const TExpVal ExpVal) const

Definition at line 6 of file exp.cpp.

References evtFlt, evtLst, evtStr, evtUndef, evtVec, Fail, TLst< TVal >::First(), Flt, TLstNd< TVal >::GetVal(), TVec< TVal >::Len(), TLst< TVal >::Len(), TLstNd< TVal >::Next(), Str, ValL, ValType, and ValV.

                                                    {
  if (ValType!=ExpVal.ValType){return false;}
  switch (ValType){
    case evtUndef: return true;
    case evtFlt: return Flt==ExpVal.Flt;
    case evtStr: return Str==ExpVal.Str;
    case evtVec:{
      if (ValV.Len()!=ExpVal.ValV.Len()){return false;}
      for (int VecValN=0; VecValN<ExpVal.ValV.Len(); VecValN++){
        if (*ValV[VecValN]!=*ExpVal.ValV[VecValN]){return false;}}
      return true;}
    case evtLst:{
      if (ValL.Len()!=ExpVal.ValL.Len()){return false;}
      TExpValLN ValLN=ValL.First();
      TExpValLN ExpValLN=ExpVal.ValL.First();
      while (ValLN!=NULL){
        if (*ValLN->GetVal()!=*ExpValLN->GetVal()){return false;}
        ValLN=ValLN->Next();
        ExpValLN=ExpValLN->Next();
      }
      return true;}
    default: Fail; return false;
  }
}

Here is the call graph for this function:

void TExpVal::Save ( TSOut SOut) const [inline]

Definition at line 32 of file exp.h.

                               {
    ValType.Save(SOut);
    Flt.Save(SOut); Str.Save(SOut); ValV.Save(SOut); ValL.Save(SOut);}
void TExpVal::SaveTxt ( TOLx Lx) const

Definition at line 71 of file exp.cpp.

References evtFlt, evtLst, evtStr, evtUndef, evtVec, Fail, TLst< TVal >::First(), Flt, TLstNd< TVal >::GetVal(), TVec< TVal >::Len(), TLst< TVal >::Len(), TLstNd< TVal >::Next(), TOLx::PutFlt(), TOLx::PutIdStr(), TOLx::PutQStr(), TOLx::PutSym(), SaveTxt(), Str, syLBrace, syLBracket, syRBrace, syRBracket, ValL, ValType, and ValV.

Referenced by GetStr(), SaveTxt(), and TExp::SaveTxt().

                                    {
  TExpValType _ValType=TExpValType(int(ValType));
  switch (_ValType){
    case evtUndef: Lx.PutIdStr("Undef"); break;
    case evtFlt: Lx.PutFlt(Flt); break;
    case evtStr: Lx.PutQStr(Str); break;
    case evtVec:{
      Lx.PutSym(syLBrace);
      for (int ValN=0; ValN<ValV.Len(); ValN++){
        ValV[ValN]->SaveTxt(Lx);}
      Lx.PutSym(syRBrace);
      break;}
    case evtLst:{
      Lx.PutSym(syLBracket);
      TExpValLN ValLN=ValL.First();
      for (int ValN=0; ValN<ValL.Len(); ValN++){
        ValLN->GetVal()->SaveTxt(Lx); ValLN=ValLN->Next();}
      Lx.PutSym(syRBracket);
      break;}
    default: Fail;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void TExpVal::SaveTxt ( const PSOut SOut) const

Definition at line 94 of file exp.cpp.

References oloCmtAlw, oloCsSens, oloSigNum, and SaveTxt().

                                             {
  TOLx Lx(SOut, TFSet()|oloCmtAlw|oloSigNum|oloCsSens);
  SaveTxt(Lx);
}

Here is the call graph for this function:


Friends And Related Function Documentation

friend class TPt< TExpVal > [friend]

Definition at line 9 of file exp.h.


Member Data Documentation

TCRef TExpVal::CRef [private]

Definition at line 9 of file exp.h.

TAscFlt TExpVal::Flt [private]

Definition at line 14 of file exp.h.

Referenced by GetFltValAsInt(), operator<(), operator==(), and SaveTxt().

TStr TExpVal::Str [private]

Definition at line 15 of file exp.h.

Referenced by operator<(), operator==(), and SaveTxt().

PExpVal TExpVal::UndefExpVal = NULL [static, private]

Definition at line 11 of file exp.h.

Referenced by GetUndefExpVal().

Definition at line 17 of file exp.h.

Referenced by operator<(), operator==(), and SaveTxt().

Definition at line 13 of file exp.h.

Referenced by operator<(), operator==(), and SaveTxt().

Definition at line 16 of file exp.h.

Referenced by operator<(), operator==(), and SaveTxt().

PExpVal TExpVal::ZeroExpVal = NULL [static, private]

Definition at line 12 of file exp.h.

Referenced by GetZeroExpVal().


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