SNAP Library 4.1, Developer Reference  2018-07-26 16:30:42
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TXmlObjSer Class Reference

#include <xml.h>

Collaboration diagram for TXmlObjSer:

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
 

Detailed Description

Definition at line 5 of file xml.h.

Member Function Documentation

void TXmlObjSer::AssertXmlHd ( const PXmlTok XmlTok,
const TStr Nm,
const TStr TypeNm 
)
static

Definition at line 22 of file xml.cpp.

References EAssertR, TStr::Empty(), TPt< TRec >::Empty(), TXmlTok::GetStr(), TXmlTok::GetStrArgVal(), TXmlTok::GetSymStr(), TXmlTok::IsTag(), and TExcept::Throw().

23  {
24  // check if the token is full
25  EAssertR(!XmlTok.Empty(), "Xml-Token Empty");
26  // if name is empty then tag=type else tag=name
27  if (!Nm.Empty()){
28  // check if the token is tag
29  if (!XmlTok->IsTag()){
30  TStr ArgStr1="Expected: Tag";
31  TStr ArgStr2=TStr("Found: ")+XmlTok->GetSymStr();
32  TExcept::Throw("Invalid Xml-Token", ArgStr1, ArgStr2);
33  }
34  if (Nm!="-"){
35  // check if the tag is correct
36  if (!XmlTok->IsTag(Nm)){
37  TStr ArgStr1=TStr("Expected: ")+Nm;
38  TStr ArgStr2=TStr("Found: ")+XmlTok->GetStr();
39  TExcept::Throw("Invalid Xml-Tag", ArgStr1, ArgStr2);
40  }
41  // check if the type is correct
42  TStr TypeArgVal=XmlTok->GetStrArgVal("Type");
43  if (TypeArgVal!=TypeNm){
44  TStr ArgStr1=TStr("Expected: ")+TypeNm;
45  TStr ArgStr2=TStr("Found: ")+TypeArgVal;
46  TExcept::Throw("Invalid Xml-Type", ArgStr1, ArgStr2);
47  }
48  }
49  } else {
50  // check if the tag is correct
51  if (!XmlTok->IsTag(TypeNm)){
52  TStr ArgStr1=TStr("Expected: ")+TypeNm;
53  TStr ArgStr2=TStr("Found: ")+XmlTok->GetSymStr();
54  TExcept::Throw("Invalid Xml-Type-Tag", ArgStr1, ArgStr2);
55  }
56  }
57 }
bool Empty() const
Definition: bd.h:501
static void Throw(const TStr &MsgStr)
Definition: ut.h:187
Definition: dt.h:412
bool Empty() const
Definition: dt.h:488
#define EAssertR(Cond, MsgStr)
Definition: bd.h:283

Here is the call graph for this function:

bool TXmlObjSer::GetBoolArg ( const PXmlTok XmlTok,
const TStr Nm 
)
static

Definition at line 59 of file xml.cpp.

References Fail, TXmlTok::IsArg(), TStr::IsBool(), and TExcept::Throw().

Referenced by TPt< TRec >::LoadXml(), and TBool::LoadXml().

59  {
60  TStr ValStr;
61  if (XmlTok->IsArg(Nm, ValStr)){
62  bool Val;
63  if (ValStr.IsBool(Val)){
64  return Val;
65  } else {
66  TExcept::Throw("Invalid Xml-Argument Boolean-Value", Nm, ValStr);
67  }
68  } else {
69  TExcept::Throw("Xml-Argument Missing", Nm);
70  }
71  Fail; return 0;
72 }
#define Fail
Definition: bd.h:238
static void Throw(const TStr &MsgStr)
Definition: ut.h:187
bool IsBool(bool &Val) const
Definition: dt.cpp:1153
Definition: dt.h:412

Here is the call graph for this function:

Here is the caller graph for this function:

double TXmlObjSer::GetFltArg ( const PXmlTok XmlTok,
const TStr Nm 
)
static

Definition at line 104 of file xml.cpp.

References Fail, TXmlTok::IsArg(), TStr::IsFlt(), and TExcept::Throw().

Referenced by TFlt::LoadXml(), TSFlt::LoadXml(), TLFlt::LoadXml(), and TFltRect::LoadXml().

104  {
105  TStr ValStr;
106  if (XmlTok->IsArg(Nm, ValStr)){
107  double Val;
108  if (ValStr.IsFlt(Val)){
109  return Val;
110  } else {
111  TExcept::Throw("Invalid Xml-Argument Double-Value", Nm, ValStr);
112  }
113  } else {
114  TExcept::Throw("Xml-Argument Missing", Nm);
115  }
116  Fail; return 0;
117 }
#define Fail
Definition: bd.h:238
static void Throw(const TStr &MsgStr)
Definition: ut.h:187
bool IsFlt(const bool &Check, const double &MnVal, const double &MxVal, double &Val, const char &DecDelimCh='.') const
Definition: dt.cpp:1265
Definition: dt.h:412

Here is the call graph for this function:

Here is the caller graph for this function:

int64 TXmlObjSer::GetInt64Arg ( const PXmlTok XmlTok,
const TStr Nm 
)
static

Definition at line 89 of file xml.cpp.

References Fail, TXmlTok::IsArg(), TStr::IsInt64(), and TExcept::Throw().

Referenced by TUInt64::LoadXml().

89  {
90  TStr ValStr;
91  if (XmlTok->IsArg(Nm, ValStr)){
92  int64 Val;
93  if (ValStr.IsInt64(Val)){
94  return Val;
95  } else {
96  TExcept::Throw("Invalid Xml-Argument Integer64-Value", Nm, ValStr);
97  }
98  } else {
99  TExcept::Throw("Xml-Argument Missing", Nm);
100  }
101  Fail; return 0;
102 }
#define Fail
Definition: bd.h:238
static void Throw(const TStr &MsgStr)
Definition: ut.h:187
long long int64
Definition: bd.h:27
Definition: dt.h:412
bool IsInt64(const bool &Check, const int64 &MnVal, const int64 &MxVal, int64 &Val) const
Definition: dt.cpp:1212

Here is the call graph for this function:

Here is the caller graph for this function:

int TXmlObjSer::GetIntArg ( const PXmlTok XmlTok,
const TStr Nm 
)
static

Definition at line 74 of file xml.cpp.

References Fail, TXmlTok::IsArg(), TStr::IsInt(), and TExcept::Throw().

Referenced by TRnd::LoadXml(), TCh::LoadXml(), TUCh::LoadXml(), TInt::LoadXml(), and TUInt::LoadXml().

74  {
75  TStr ValStr;
76  if (XmlTok->IsArg(Nm, ValStr)){
77  int Val;
78  if (ValStr.IsInt(Val)){
79  return Val;
80  } else {
81  TExcept::Throw("Invalid Xml-Argument Integer-Value", Nm, ValStr);
82  }
83  } else {
84  TExcept::Throw("Xml-Argument Missing", Nm);
85  }
86  Fail; return 0;
87 }
bool IsInt(const bool &Check, const int &MnVal, const int &MxVal, int &Val) const
Definition: dt.cpp:1159
#define Fail
Definition: bd.h:238
static void Throw(const TStr &MsgStr)
Definition: ut.h:187
Definition: dt.h:412

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TXmlObjSer::GetTagNm ( const TStr TypeNm)
static

Definition at line 5 of file xml.cpp.

References THash< TKey, TDat, THashFunc >::AddDat(), TStr::Empty(), TChA::LastCh(), TChA::Len(), TChA::Pop(), TChA::PutCh(), and TypeNmToTagNmH.

5  {
6  TStr& XmlTagNm=TypeNmToTagNmH.AddDat(TypeNm);
7  if (XmlTagNm.Empty()){
8  TChA XmlTagChA=TypeNm;
9  for (int ChN=0; ChN<XmlTagChA.Len(); ChN++){
10  char Ch=XmlTagChA[ChN];
11  if (!((('A'<=Ch)&&(Ch<='Z'))||(('a'<=Ch)&&(Ch<='z'))||(('0'<=Ch)&&(Ch<='9')))){
12  XmlTagChA.PutCh(ChN, '_');
13  }
14  }
15  while ((XmlTagChA.Len()>0)&&(XmlTagChA.LastCh()=='_')){
16  XmlTagChA.Pop();}
17  XmlTagNm=XmlTagChA;
18  }
19  return XmlTagNm;
20 }
void PutCh(const int &ChN, const char &Ch)
Definition: dt.h:278
int Len() const
Definition: dt.h:259
char LastCh() const
Definition: dt.h:281
Definition: dt.h:201
Definition: dt.h:412
bool Empty() const
Definition: dt.h:488
char Pop()
Definition: dt.h:265
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
static TStrStrH TypeNmToTagNmH
Definition: xml.h:7

Here is the call graph for this function:

Member Data Documentation

TStrStrH TXmlObjSer::TypeNmToTagNmH
staticprivate

Definition at line 7 of file xml.h.

Referenced by GetTagNm().


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