SNAP Library 2.0, User Reference
2013-05-13 16:33:57
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <xml.h>
Static Public Member Functions | |
static TStr | GetTagNm (const TStr &TypeNm) |
static void | AssertXmlHd (const PXmlTok &XmlTok, const TStr &Nm, const TStr &TypeNm) |
static bool | GetBoolArg (const PXmlTok &XmlTok, const TStr &Nm) |
static int | GetIntArg (const PXmlTok &XmlTok, const TStr &Nm) |
static int64 | GetInt64Arg (const PXmlTok &XmlTok, const TStr &Nm) |
static double | GetFltArg (const PXmlTok &XmlTok, const TStr &Nm) |
Static Private Attributes | |
static TStrStrH | TypeNmToTagNmH |
void TXmlObjSer::AssertXmlHd | ( | const PXmlTok & | XmlTok, |
const TStr & | Nm, | ||
const TStr & | TypeNm | ||
) | [static] |
Definition at line 22 of file xml.cpp.
{ // check if the token is full EAssertR(!XmlTok.Empty(), "Xml-Token Empty"); // if name is empty then tag=type else tag=name if (!Nm.Empty()){ // check if the token is tag if (!XmlTok->IsTag()){ TStr ArgStr1="Expected: Tag"; TStr ArgStr2=TStr("Found: ")+XmlTok->GetSymStr(); TExcept::Throw("Invalid Xml-Token", ArgStr1, ArgStr2); } if (Nm!="-"){ // check if the tag is correct if (!XmlTok->IsTag(Nm)){ TStr ArgStr1=TStr("Expected: ")+Nm; TStr ArgStr2=TStr("Found: ")+XmlTok->GetStr(); TExcept::Throw("Invalid Xml-Tag", ArgStr1, ArgStr2); } // check if the type is correct TStr TypeArgVal=XmlTok->GetStrArgVal("Type"); if (TypeArgVal!=TypeNm){ TStr ArgStr1=TStr("Expected: ")+TypeNm; TStr ArgStr2=TStr("Found: ")+TypeArgVal; TExcept::Throw("Invalid Xml-Type", ArgStr1, ArgStr2); } } } else { // check if the tag is correct if (!XmlTok->IsTag(TypeNm)){ TStr ArgStr1=TStr("Expected: ")+TypeNm; TStr ArgStr2=TStr("Found: ")+XmlTok->GetSymStr(); TExcept::Throw("Invalid Xml-Type-Tag", ArgStr1, ArgStr2); } } }
bool TXmlObjSer::GetBoolArg | ( | const PXmlTok & | XmlTok, |
const TStr & | Nm | ||
) | [static] |
Definition at line 59 of file xml.cpp.
{ TStr ValStr; if (XmlTok->IsArg(Nm, ValStr)){ bool Val; if (ValStr.IsBool(Val)){ return Val; } else { TExcept::Throw("Invalid Xml-Argument Boolean-Value", Nm, ValStr); } } else { TExcept::Throw("Xml-Argument Missing", Nm); } Fail; return 0; }
double TXmlObjSer::GetFltArg | ( | const PXmlTok & | XmlTok, |
const TStr & | Nm | ||
) | [static] |
Definition at line 104 of file xml.cpp.
{ TStr ValStr; if (XmlTok->IsArg(Nm, ValStr)){ double Val; if (ValStr.IsFlt(Val)){ return Val; } else { TExcept::Throw("Invalid Xml-Argument Double-Value", Nm, ValStr); } } else { TExcept::Throw("Xml-Argument Missing", Nm); } Fail; return 0; }
int64 TXmlObjSer::GetInt64Arg | ( | const PXmlTok & | XmlTok, |
const TStr & | Nm | ||
) | [static] |
Definition at line 89 of file xml.cpp.
{ TStr ValStr; if (XmlTok->IsArg(Nm, ValStr)){ int64 Val; if (ValStr.IsInt64(Val)){ return Val; } else { TExcept::Throw("Invalid Xml-Argument Integer64-Value", Nm, ValStr); } } else { TExcept::Throw("Xml-Argument Missing", Nm); } Fail; return 0; }
int TXmlObjSer::GetIntArg | ( | const PXmlTok & | XmlTok, |
const TStr & | Nm | ||
) | [static] |
Definition at line 74 of file xml.cpp.
{ TStr ValStr; if (XmlTok->IsArg(Nm, ValStr)){ int Val; if (ValStr.IsInt(Val)){ return Val; } else { TExcept::Throw("Invalid Xml-Argument Integer-Value", Nm, ValStr); } } else { TExcept::Throw("Xml-Argument Missing", Nm); } Fail; return 0; }
TStr TXmlObjSer::GetTagNm | ( | const TStr & | TypeNm | ) | [static] |
Definition at line 5 of file xml.cpp.
{ TStr& XmlTagNm=TypeNmToTagNmH.AddDat(TypeNm); if (XmlTagNm.Empty()){ TChA XmlTagChA=TypeNm; for (int ChN=0; ChN<XmlTagChA.Len(); ChN++){ char Ch=XmlTagChA[ChN]; if (!((('A'<=Ch)&&(Ch<='Z'))||(('a'<=Ch)&&(Ch<='z'))||(('0'<=Ch)&&(Ch<='9')))){ XmlTagChA.PutCh(ChN, '_'); } } while ((XmlTagChA.Len()>0)&&(XmlTagChA.LastCh()=='_')){ XmlTagChA.Pop();} XmlTagNm=XmlTagChA; } return XmlTagNm; }
TStrStrH TXmlObjSer::TypeNmToTagNmH [static, private] |