SNAP Library , Developer Reference
2013-01-07 14:03:36
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <exp.h>
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 |
TExpVal & | operator= (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 > |
TExpVal::TExpVal | ( | const TExpValType & | _ValType = evtUndef | ) | [inline] |
TExpVal::TExpVal | ( | const TFlt & | _Flt | ) | [inline] |
TExpVal::TExpVal | ( | const double & | _Flt | ) | [inline] |
TExpVal::TExpVal | ( | const TStr & | _Str | ) | [inline] |
TExpVal::~TExpVal | ( | ) | [inline] |
TExpVal::TExpVal | ( | TSIn & | SIn | ) | [inline] |
void TExpVal::AddToLst | ( | const PExpVal & | ExpVal | ) | [inline] |
void TExpVal::AddToVec | ( | const PExpVal & | ExpVal | ) | [inline] |
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;}}
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); }
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; }
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;}
PExpVal TExpVal::GetUndefExpVal | ( | ) | [static] |
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().
{ if (UndefExpVal.Empty()){ UndefExpVal=TExpVal::New();} return UndefExpVal; }
TExpValType TExpVal::GetValType | ( | ) | const [inline] |
Definition at line 45 of file exp.h.
Referenced by TExpBi::AssertArgValType(), and TExp::EvalExpOp().
{return TExpValType(int(ValType));}
PExpVal TExpVal::GetZeroExpVal | ( | ) | [static] |
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; }
bool TExpVal::IsFltVal | ( | TFlt & | _Flt | ) | const [inline] |
bool TExpVal::IsFltVal | ( | double & | _Flt | ) | const [inline] |
static PExpVal TExpVal::Load | ( | TSIn & | SIn | ) | [inline, static] |
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; }
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().
static PExpVal TExpVal::New | ( | const TFlt & | Flt | ) | [inline, static] |
static PExpVal TExpVal::New | ( | const double & | Flt | ) | [inline, static] |
static PExpVal TExpVal::New | ( | const TStr & | Str | ) | [inline, static] |
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; } }
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; } }
void TExpVal::Save | ( | TSOut & | SOut | ) | const [inline] |
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; } }
void TExpVal::SaveTxt | ( | const PSOut & | SOut | ) | const |
TCRef TExpVal::CRef [private] |
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().
TExpValL TExpVal::ValL [private] |
Definition at line 17 of file exp.h.
Referenced by operator<(), operator==(), and SaveTxt().
TInt TExpVal::ValType [private] |
Definition at line 13 of file exp.h.
Referenced by operator<(), operator==(), and SaveTxt().
TExpValV TExpVal::ValV [private] |
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().