SNAP Library 4.0, Developer Reference  2017-07-27 13:18:06
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
TXmlLx Class Reference

#include <xml.h>

Collaboration diagram for TXmlLx:

Public Member Functions

void SkipWs ()
 
 TXmlLx (const PSIn &_SIn, const TXmlSpacing &_Spacing=xspIntact)
 
TXmlLxoperator= (const TXmlLx &)
 
TXmlLxSym GetSym ()
 
TStr GetSymStr () const
 
void EThrow (const TStr &MsgStr) const
 
TStr GetFPosStr () const
 
void ClrArgV ()
 
void AddArg (const TStr &ArgNm, const TStr &ArgVal)
 
bool IsArgNm (const TStr &ArgNm) const
 
int GetArgs () const
 
void GetArg (const int &ArgN, TStr &ArgNm, TStr &ArgVal) const
 
TStr GetArgVal (const TStr &ArgNm, const TStr &DfVal=TStr()) const
 
bool IsEntityNm (const TStr &EntityNm, TStr &EntityVal) const
 
void PutEntityVal (const TStr &Nm, const TStr &Val)
 
bool IsPEntityNm (const TStr &EntityNm, TStr &EntityVal) const
 
void PutPEntityVal (const TStr &Nm, const TStr &Val)
 

Static Public Member Functions

static char GetArgValQCh (const TStr &ArgVal)
 
static TStr GetXmlLxSymStr (const TXmlLxSym &XmlLxSym)
 
static bool IsTagNm (const TStr &Str)
 
static TStr GetXmlStrFromPlainMem (const TMem &PlainMem)
 
static TStr GetXmlStrFromPlainStr (const TChA &PlainChA)
 
static TStr GetPlainStrFromXmlStr (const TStr &XmlStr)
 
static TStr GetUsAsciiStrFromXmlStr (const TStr &EntRefStr)
 
static TStr GetChRefFromYuEntRef (const TStr &YuEntRefStr)
 

Public Attributes

TXmlLxSym Sym
 
TChA TxtChA
 
TStr TagNm
 
TStrKdV ArgNmValKdV
 

Private Member Functions

uchar GetCh ()
 
void PutCh (const uchar &_Ch)
 
void PutStr (const TStr &Str)
 
void ToNrSpacing ()
 
void GetWs (const bool &IsRq)
 
TStr GetReference ()
 
void GetEq ()
 
TStr GetName ()
 
TStr GetName (const TStr &RqNm)
 
void GetComment ()
 
TStr GetAttValue ()
 
TStr GetVersionNum ()
 
TStr GetEncName ()
 
TStr GetStalVal ()
 
void GetXmlDecl ()
 
void GetPI ()
 
TStr GetSystemLiteral ()
 
TStr GetPubidLiteral ()
 
TStr GetPEReference ()
 
void GetExternalId ()
 
void GetNData ()
 
void GetDocTypeDecl ()
 
void GetElement ()
 
void GetAttList ()
 
TStr GetEntityValue ()
 
void GetEntity ()
 
void GetNotation ()
 
void GetCDSect ()
 

Private Attributes

PSIn SIn
 
TSInRSIn
 
TChA ChStack
 
uchar PrevCh
 
uchar Ch
 
int LnN
 
int LnChN
 
int ChN
 
TXmlSpacing Spacing
 
TStrStrH EntityNmToValH
 
TStrStrH PEntityNmToValH
 

Static Private Attributes

static TXmlChDef ChDef
 

Detailed Description

Definition at line 98 of file xml.h.

Constructor & Destructor Documentation

TXmlLx::TXmlLx ( const PSIn _SIn,
const TXmlSpacing _Spacing = xspIntact 
)
inline

Definition at line 145 of file xml.h.

References GetCh().

145  :
146  SIn(_SIn), RSIn(*SIn),
147  ChStack(), PrevCh(' '), Ch(' '),
148  LnN(1), LnChN(0), ChN(0), Spacing(_Spacing),
149  EntityNmToValH(100), PEntityNmToValH(100),
150  Sym(xsyUndef), TxtChA(), TagNm(), ArgNmValKdV(10){GetCh();}
TStr TagNm
Definition: xml.h:141
TChA TxtChA
Definition: xml.h:140
PSIn SIn
Definition: xml.h:101
TChA ChStack
Definition: xml.h:103
TStrStrH EntityNmToValH
Definition: xml.h:113
uchar PrevCh
Definition: xml.h:104
uchar GetCh()
Definition: xml.cpp:260
TSIn & RSIn
Definition: xml.h:102
TStrKdV ArgNmValKdV
Definition: xml.h:142
int LnChN
Definition: xml.h:105
Definition: xml.h:90
TXmlSpacing Spacing
Definition: xml.h:106
int LnN
Definition: xml.h:105
TXmlLxSym Sym
Definition: xml.h:139
int ChN
Definition: xml.h:105
TStrStrH PEntityNmToValH
Definition: xml.h:113
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Member Function Documentation

void TXmlLx::AddArg ( const TStr ArgNm,
const TStr ArgVal 
)
inline

Definition at line 161 of file xml.h.

References TVec< TVal, TSizeTy >::Add(), and ArgNmValKdV.

Referenced by GetSym(), and GetXmlDecl().

161  {
162  ArgNmValKdV.Add(TStrKd(ArgNm, ArgVal));}
TStrKdV ArgNmValKdV
Definition: xml.h:142
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
TKeyDat< TStr, TStr > TStrKd
Definition: ds.h:405

Here is the call graph for this function:

Here is the caller graph for this function:

void TXmlLx::ClrArgV ( )
inline

Definition at line 160 of file xml.h.

References ArgNmValKdV, and TVec< TVal, TSizeTy >::Clr().

Referenced by GetSym().

160 {ArgNmValKdV.Clr();}
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:1022
TStrKdV ArgNmValKdV
Definition: xml.h:142

Here is the call graph for this function:

Here is the caller graph for this function:

void TXmlLx::EThrow ( const TStr MsgStr) const

Definition at line 885 of file xml.cpp.

References TSBase::GetSNm(), TInt::GetStr(), LnChN, LnN, SIn, and TExcept::Throw().

Referenced by GetAttList(), GetAttValue(), GetCDSect(), GetComment(), GetDocTypeDecl(), GetElement(), GetEncName(), GetEntity(), GetEntityValue(), GetEq(), GetExternalId(), GetName(), GetNotation(), GetPEReference(), GetPI(), GetPubidLiteral(), GetReference(), GetStalVal(), GetSym(), GetSystemLiteral(), GetVersionNum(), GetWs(), GetXmlDecl(), and TXmlDoc::LoadTxtElement().

885  {
886  TChA FPosChA;
887  FPosChA+=" [File:"; FPosChA+=SIn->GetSNm();
888  FPosChA+=" Line:"; FPosChA+=TInt::GetStr(LnN);
889  FPosChA+=" Char:"; FPosChA+=TInt::GetStr(LnChN);
890  FPosChA+="]";
891  TStr FullMsgStr=MsgStr+FPosChA;
892  TExcept::Throw(FullMsgStr);
893 }
TStr GetStr() const
Definition: dt.h:1197
PSIn SIn
Definition: xml.h:101
static void Throw(const TStr &MsgStr)
Definition: ut.h:187
int LnChN
Definition: xml.h:105
Definition: dt.h:201
Definition: dt.h:412
virtual TStr GetSNm() const
Definition: fl.cpp:20
int LnN
Definition: xml.h:105

Here is the call graph for this function:

Here is the caller graph for this function:

void TXmlLx::GetArg ( const int &  ArgN,
TStr ArgNm,
TStr ArgVal 
) const
inline

Definition at line 166 of file xml.h.

References ArgNmValKdV.

Referenced by GetSymStr(), TSnap::LoadDyNet(), and TSnap::LoadDyNetGraphV().

166  {
167  ArgNm=ArgNmValKdV[ArgN].Key; ArgVal=ArgNmValKdV[ArgN].Dat;}
TStrKdV ArgNmValKdV
Definition: xml.h:142

Here is the caller graph for this function:

int TXmlLx::GetArgs ( ) const
inline

Definition at line 165 of file xml.h.

References ArgNmValKdV, and TVec< TVal, TSizeTy >::Len().

Referenced by GetSymStr().

165 {return ArgNmValKdV.Len();}
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TStrKdV ArgNmValKdV
Definition: xml.h:142

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TXmlLx::GetArgVal ( const TStr ArgNm,
const TStr DfVal = TStr() 
) const
inline

Definition at line 168 of file xml.h.

References ArgNmValKdV, and TVec< TVal, TSizeTy >::SearchForw().

168  {
169  int ArgN=ArgNmValKdV.SearchForw(TStrKd(ArgNm));
170  if (ArgN==-1){return DfVal;} else {return ArgNmValKdV[ArgN].Dat;}}
TStrKdV ArgNmValKdV
Definition: xml.h:142
TSizeTy SearchForw(const TVal &Val, const TSizeTy &BValN=0) const
Returns the position of an element with value Val.
Definition: ds.h:1552
TKeyDat< TStr, TStr > TStrKd
Definition: ds.h:405

Here is the call graph for this function:

static char TXmlLx::GetArgValQCh ( const TStr ArgVal)
inlinestatic

Definition at line 171 of file xml.h.

References TStr::IsChIn().

Referenced by TXmlTok::AddTokToChA(), and GetSymStr().

171  {
172  if (ArgVal.IsChIn('\"')){return '\'';} else {return '\"';}}
bool IsChIn(const char &Ch) const
Definition: dt.h:553

Here is the call graph for this function:

Here is the caller graph for this function:

void TXmlLx::GetAttList ( )
private

Definition at line 665 of file xml.cpp.

References Ch, ChDef, TChA::Clr(), EThrow(), GetCh(), TXmlChDef::IsChar(), and TxtChA.

Referenced by GetSym().

665  {
666  TxtChA.Clr();
667  while (Ch!='>'){
668  if (!ChDef.IsChar(Ch)){EThrow("Invalid Element character.");}
669  TxtChA+=Ch; GetCh();
670  }
671  GetCh();
672 }
bool IsChar(const uchar &Ch) const
Definition: xml.h:68
TChA TxtChA
Definition: xml.h:140
void Clr()
Definition: dt.h:258
static TXmlChDef ChDef
Definition: xml.h:100
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
uchar GetCh()
Definition: xml.cpp:260
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TXmlLx::GetAttValue ( )
private

Definition at line 457 of file xml.cpp.

References Ch, ChDef, EThrow(), forever, GetCh(), GetReference(), and TXmlChDef::IsChar().

Referenced by GetSym().

457  {
458  // [10] AttValue ::= '"' ([^<&"] | Reference)* '"'
459  // | "'" ([^<&'] | Reference)* "'"
460  uchar QCh=Ch;
461  if ((QCh!='"')&&(QCh!='\'')){EThrow("Invalid attribute-value start.");}
462  TChA ValChA; GetCh();
463  forever {
464  if ((Ch=='<')||(!ChDef.IsChar(Ch))){
465  EThrow("Invalid attribute-value character.");}
466  if (Ch==QCh){GetCh(); break;} // final quote
467  else if (Ch=='&'){GetCh(); ValChA+=GetReference();} // reference
468  else {ValChA+=Ch; GetCh();} // usual char
469  }
470  return ValChA;
471 }
bool IsChar(const uchar &Ch) const
Definition: xml.h:68
#define forever
Definition: bd.h:6
static TXmlChDef ChDef
Definition: xml.h:100
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
uchar GetCh()
Definition: xml.cpp:260
unsigned char uchar
Definition: bd.h:10
TStr GetReference()
Definition: xml.cpp:340
Definition: dt.h:201
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

void TXmlLx::GetCDSect ( )
private

Definition at line 733 of file xml.cpp.

References Ch, ChDef, TChA::Clr(), EThrow(), forever, GetCh(), TXmlChDef::IsChar(), TChA::LastCh(), TChA::LastLastCh(), TChA::Len(), TChA::Pop(), and TxtChA.

Referenced by GetSym().

733  {
734  // [18] CDSect ::= CDStart CData CDEnd
735  // [19] CDStart ::= '<![CDATA{{['}}
736  // [20] CData ::= (Char* - (Char* ']]>' Char*))
737  // [21] CDEnd ::= ']]>'
738  if (Ch=='['){GetCh();}
739  else {EThrow("Invalid start of CDATA section.");}
740  TxtChA.Clr();
741  forever {
742  if (!ChDef.IsChar(Ch)){EThrow("Invalid CDATA character.");}
743  if ((Ch=='>')&&(TxtChA.Len()>=2)&&
744  (TxtChA.LastLastCh()==']') && (TxtChA.LastCh()==']')){
745  GetCh(); TxtChA.Pop(); TxtChA.Pop(); break;
746  } else {
747  TxtChA+=Ch; GetCh();
748  }
749  }
750 }
bool IsChar(const uchar &Ch) const
Definition: xml.h:68
TChA TxtChA
Definition: xml.h:140
#define forever
Definition: bd.h:6
void Clr()
Definition: dt.h:258
int Len() const
Definition: dt.h:259
static TXmlChDef ChDef
Definition: xml.h:100
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
char LastLastCh() const
Definition: dt.h:282
uchar GetCh()
Definition: xml.cpp:260
char LastCh() const
Definition: dt.h:281
char Pop()
Definition: dt.h:265
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

uchar TXmlLx::GetCh ( )
private

Definition at line 260 of file xml.cpp.

References Ch, ChN, ChStack, EAssert, TChA::Empty(), TSIn::Eof(), TCh::EofCh, TSIn::GetCh(), TCh::LfCh, LnChN, LnN, TChA::Pop(), PrevCh, and RSIn.

Referenced by GetAttList(), GetAttValue(), GetCDSect(), GetComment(), GetDocTypeDecl(), GetElement(), GetEncName(), GetEntity(), GetEntityValue(), GetEq(), GetName(), GetNotation(), GetPEReference(), GetPI(), GetPubidLiteral(), GetReference(), GetStalVal(), GetSym(), GetSystemLiteral(), GetVersionNum(), GetWs(), GetXmlDecl(), SkipWs(), and TXmlLx().

260  {
262  PrevCh=Ch;
263  if (ChStack.Empty()){Ch=(RSIn.Eof()) ? TCh::EofCh : RSIn.GetCh();}
264  else {Ch=ChStack.Pop();}
265  ChN++; if (Ch==TCh::LfCh){LnN++; LnChN=0;} else {LnChN++;}
266  //putchar(Ch);
267  return Ch;
268 }
bool Empty() const
Definition: dt.h:260
TChA ChStack
Definition: xml.h:103
uchar PrevCh
Definition: xml.h:104
static const char EofCh
Definition: dt.h:1037
TSIn & RSIn
Definition: xml.h:102
virtual bool Eof()=0
int LnChN
Definition: xml.h:105
static const char LfCh
Definition: dt.h:1035
#define EAssert(Cond)
Definition: bd.h:280
int LnN
Definition: xml.h:105
virtual char GetCh()=0
int ChN
Definition: xml.h:105
char Pop()
Definition: dt.h:265
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TXmlLx::GetChRefFromYuEntRef ( const TStr YuEntRefStr)
static

Definition at line 1072 of file xml.cpp.

References TStr::ChangeStrAll().

1072  {
1073  TStr ChRefStr=YuEntRefStr;
1074  ChRefStr.ChangeStrAll("&ch;", "&#232;");
1075  ChRefStr.ChangeStrAll("&Ch;", "&#200;");
1076  ChRefStr.ChangeStrAll("&sh;", "&#154;");
1077  ChRefStr.ChangeStrAll("&Sh;", "&#138;");
1078  ChRefStr.ChangeStrAll("&zh;", "&#158;");
1079  ChRefStr.ChangeStrAll("&Zh;", "&#142;");
1080  ChRefStr.ChangeStrAll("&cs", "c");
1081  ChRefStr.ChangeStrAll("&Cs;", "C");
1082  ChRefStr.ChangeStrAll("&dz;", "dz");
1083  ChRefStr.ChangeStrAll("&Dz;", "Dz");
1084  return ChRefStr;
1085 }
int ChangeStrAll(const TStr &SrcStr, const TStr &DstStr, const bool &FromStartP=false)
Definition: dt.cpp:1141
Definition: dt.h:412

Here is the call graph for this function:

void TXmlLx::GetComment ( )
private

Definition at line 436 of file xml.cpp.

References Ch, ChDef, TChA::Clr(), EThrow(), forever, GetCh(), TXmlChDef::IsChar(), and TxtChA.

Referenced by GetSym().

436  {
437  // [15] Comment ::= {{'<!-}}-' ((Char - '-') | ('-' (Char - '-')))* '-->'
438  if (GetCh()!='-'){EThrow("Invalid comment start.");}
439  TxtChA.Clr();
440  forever {
441  GetCh();
442  if (!ChDef.IsChar(Ch)){EThrow("Invalid comment character.");}
443  if (Ch=='-'){
444  if (GetCh()=='-'){
445  if (GetCh()=='>'){GetCh(); break;} // final bracket
446  else {EThrow("Invalid comment end.");}
447  } else {
448  if (!ChDef.IsChar(Ch)){EThrow("Invalid comment character.");}
449  TxtChA+='-'; TxtChA+=Ch; // special case if single '-'
450  }
451  } else {
452  TxtChA+=Ch; // usual char
453  }
454  }
455 }
bool IsChar(const uchar &Ch) const
Definition: xml.h:68
TChA TxtChA
Definition: xml.h:140
#define forever
Definition: bd.h:6
void Clr()
Definition: dt.h:258
static TXmlChDef ChDef
Definition: xml.h:100
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
uchar GetCh()
Definition: xml.cpp:260
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

void TXmlLx::GetDocTypeDecl ( )
private

Definition at line 627 of file xml.cpp.

References Ch, ChDef, EThrow(), GetCh(), GetExternalId(), GetName(), GetPEReference(), GetSym(), GetWs(), TXmlChDef::IsWs(), and TagNm.

Referenced by GetSym().

627  {
628  // [28] doctypedecl ::= {{'<!DOCTYPE'}} S Name (S ExternalID)? S?
629  // ('[' (markupdecl | PEReference | S)* ']' S?)? '>'
630  GetWs(true);
631  TStr DocTypeDeclNm=GetName();
632  GetWs(false);
633  if (Ch=='>'){GetCh(); return;}
634  if (Ch!='['){GetExternalId();}
635  GetWs(false);
636  if (Ch=='['){
637  GetCh();
638  // [28] (markupdecl | PEReference | S)*
639  GetWs(false);
640  while (Ch!=']'){
641  if (ChDef.IsWs(Ch)){GetWs(true);}
642  else if (Ch=='%'){GetPEReference();}
643  else {
644  GetSym();
645  }
646  }
647  GetCh();
648  }
649  GetWs(false);
650  // '>'
651  if (Ch=='>'){GetCh();}
652  else {EThrow("Invalid end-of-tag in document-type-declaration.");}
653  TagNm=DocTypeDeclNm;
654 }
TXmlLxSym GetSym()
Definition: xml.cpp:757
TStr TagNm
Definition: xml.h:141
TStr GetName()
Definition: xml.cpp:416
void GetWs(const bool &IsRq)
Definition: xml.cpp:331
static TXmlChDef ChDef
Definition: xml.h:100
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
uchar GetCh()
Definition: xml.cpp:260
void GetExternalId()
Definition: xml.cpp:609
Definition: dt.h:412
TStr GetPEReference()
Definition: xml.cpp:397
bool IsWs(const uchar &Ch) const
Definition: xml.h:76
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

void TXmlLx::GetElement ( )
private

Definition at line 656 of file xml.cpp.

References Ch, ChDef, TChA::Clr(), EThrow(), GetCh(), TXmlChDef::IsChar(), and TxtChA.

Referenced by GetSym().

656  {
657  TxtChA.Clr();
658  while (Ch!='>'){
659  if (!ChDef.IsChar(Ch)){EThrow("Invalid Element character.");}
660  TxtChA+=Ch; GetCh();
661  }
662  GetCh();
663 }
bool IsChar(const uchar &Ch) const
Definition: xml.h:68
TChA TxtChA
Definition: xml.h:140
void Clr()
Definition: dt.h:258
static TXmlChDef ChDef
Definition: xml.h:100
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
uchar GetCh()
Definition: xml.cpp:260
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TXmlLx::GetEncName ( )
private

Definition at line 493 of file xml.cpp.

References Ch, EThrow(), and GetCh().

Referenced by GetXmlDecl().

493  {
494  // [80] EncodingDecl ::= {{S 'encoding' Eq}} ('"' EncName '"' | "'" EncName "'" )
495  // [81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
496  char QCh=Ch;
497  if ((Ch!='\'')&&(Ch!='"')){EThrow("Quote character (' or \") expected.");}
498  TChA EncNmChA;
499  GetCh();
500  if ((('a'<=Ch)&&(Ch<='z'))||(('A'<=Ch)&&(Ch<='Z'))){EncNmChA+=Ch;}
501  else {EThrow("Invalid encoding-name character.");}
502  GetCh();
503  while (Ch!=QCh){
504  if ((('a'<=Ch)&&(Ch<='z'))||(('A'<=Ch)&&(Ch<='Z'))||
505  (('0'<=Ch)&&(Ch<='9'))||(Ch=='.')||(Ch=='_')||(Ch=='-')){EncNmChA+=Ch;}
506  else {EThrow("Invalid version-number character.");}
507  GetCh();
508  }
509  GetCh();
510  return EncNmChA;
511 }
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
uchar GetCh()
Definition: xml.cpp:260
Definition: dt.h:201
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

void TXmlLx::GetEntity ( )
private

Definition at line 690 of file xml.cpp.

References Ch, EThrow(), GetCh(), GetEntityValue(), GetExternalId(), GetName(), GetNData(), GetWs(), PutEntityVal(), PutPEntityVal(), and TagNm.

Referenced by GetSym().

690  {
691  // [70] EntityDecl ::= GEDecl | PEDecl
692  // [71] GEDecl ::= '<!ENTITY' S Name S EntityDef S? '>'
693  // [72] PEDecl ::= '<!ENTITY' S '%' S Name S PEDef S? '>'
694  GetWs(true); TStr EntityNm;
695  if (Ch=='%'){
696  GetCh(); GetWs(true); EntityNm=GetName(); GetWs(true);
697  // [74] PEDef ::= EntityValue | ExternalID
698  if ((Ch=='\"')||(Ch=='\'')){
699  TStr EntityVal=GetEntityValue();
700  PutPEntityVal(EntityNm, EntityVal);
701  } else {
702  GetExternalId();
703  GetWs(false);
704  if (Ch!='>'){GetNData();}
705  }
706  } else {
707  EntityNm=GetName(); GetWs(true);
708  // [73] EntityDef ::= EntityValue | (ExternalID NDataDecl?)
709  if ((Ch=='\"')||(Ch=='\'')){
710  TStr EntityVal=GetEntityValue();
711  PutEntityVal(EntityNm, EntityVal);
712  } else {
713  GetExternalId();
714  }
715  }
716  GetWs(false);
717  if (Ch=='>'){GetCh();}
718  else {EThrow("Invalid end-of-tag in entity-declaration.");}
719  TagNm=EntityNm;
720 }
TStr TagNm
Definition: xml.h:141
void GetNData()
Definition: xml.cpp:622
TStr GetName()
Definition: xml.cpp:416
void GetWs(const bool &IsRq)
Definition: xml.cpp:331
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
void PutEntityVal(const TStr &Nm, const TStr &Val)
Definition: xml.h:177
uchar GetCh()
Definition: xml.cpp:260
void GetExternalId()
Definition: xml.cpp:609
void PutPEntityVal(const TStr &Nm, const TStr &Val)
Definition: xml.h:181
Definition: dt.h:412
uchar Ch
Definition: xml.h:104
TStr GetEntityValue()
Definition: xml.cpp:674

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TXmlLx::GetEntityValue ( )
private

Definition at line 674 of file xml.cpp.

References Ch, ChDef, EThrow(), forever, GetCh(), GetPEReference(), GetReference(), and TXmlChDef::IsChar().

Referenced by GetEntity().

674  {
675  // [9] EntityValue ::= '"' ([^%&"] | PEReference | Reference)* '"'
676  // | "'" ([^%&'] | PEReference | Reference)* "'"
677  uchar QCh=Ch;
678  if ((QCh!='"')&&(QCh!='\'')){EThrow("Invalid entity-value start.");}
679  TChA ValChA; GetCh();
680  forever {
681  if (!ChDef.IsChar(Ch)){EThrow("Invalid entity-value character.");}
682  if (Ch==QCh){GetCh(); break;} // final quote
683  else if (Ch=='&'){GetCh(); ValChA+=GetReference();} // reference
684  else if (Ch=='%'){GetCh(); ValChA+=GetPEReference();} // pereference
685  else {ValChA+=Ch; GetCh();} // usual char
686  }
687  return ValChA;
688 }
bool IsChar(const uchar &Ch) const
Definition: xml.h:68
#define forever
Definition: bd.h:6
static TXmlChDef ChDef
Definition: xml.h:100
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
uchar GetCh()
Definition: xml.cpp:260
unsigned char uchar
Definition: bd.h:10
TStr GetReference()
Definition: xml.cpp:340
Definition: dt.h:201
TStr GetPEReference()
Definition: xml.cpp:397
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

void TXmlLx::GetEq ( )
private

Definition at line 408 of file xml.cpp.

References Ch, EThrow(), GetCh(), and GetWs().

Referenced by GetSym(), and GetXmlDecl().

408  {
409  // [25] Eq ::= S? '=' S?
410  GetWs(false);
411  if (Ch=='='){GetCh();}
412  else {EThrow("Equality ('=') character expected.");}
413  GetWs(false);
414 }
void GetWs(const bool &IsRq)
Definition: xml.cpp:331
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
uchar GetCh()
Definition: xml.cpp:260
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

void TXmlLx::GetExternalId ( )
private

Definition at line 609 of file xml.cpp.

References EThrow(), GetName(), GetPubidLiteral(), GetSystemLiteral(), and GetWs().

Referenced by GetDocTypeDecl(), and GetEntity().

609  {
610  // ExternalID ::= 'SYSTEM' S SystemLiteral
611  // | 'PUBLIC' S PubidLiteral S SystemLiteral
612  TStr ExtIdNm=GetName();
613  if (ExtIdNm=="SYSTEM"){
614  GetWs(true); GetSystemLiteral();
615  } else if (ExtIdNm=="PUBLIC"){
616  GetWs(true); GetPubidLiteral(); GetWs(true); GetSystemLiteral();
617  } else {
618  EThrow("Invalid external-id ('SYSTEM' or 'PUBLIC' expected).");
619  }
620 }
TStr GetName()
Definition: xml.cpp:416
void GetWs(const bool &IsRq)
Definition: xml.cpp:331
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
Definition: dt.h:412
TStr GetSystemLiteral()
Definition: xml.cpp:583
TStr GetPubidLiteral()
Definition: xml.cpp:596

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TXmlLx::GetFPosStr ( ) const

Definition at line 895 of file xml.cpp.

References TSBase::GetSNm(), TInt::GetStr(), LnChN, LnN, and SIn.

895  {
896  TChA FPosChA;
897  FPosChA+=" [File:"; FPosChA+=SIn->GetSNm();
898  FPosChA+=" Line:"; FPosChA+=TInt::GetStr(LnN);
899  FPosChA+=" Char:"; FPosChA+=TInt::GetStr(LnChN);
900  FPosChA+="]";
901  return FPosChA;
902 }
TStr GetStr() const
Definition: dt.h:1197
PSIn SIn
Definition: xml.h:101
int LnChN
Definition: xml.h:105
Definition: dt.h:201
virtual TStr GetSNm() const
Definition: fl.cpp:20
int LnN
Definition: xml.h:105

Here is the call graph for this function:

TStr TXmlLx::GetName ( )
private

Definition at line 416 of file xml.cpp.

References Ch, ChDef, EThrow(), GetCh(), TXmlChDef::IsFirstNameCh(), and TXmlChDef::IsName().

Referenced by GetDocTypeDecl(), GetEntity(), GetExternalId(), GetName(), GetNData(), GetPEReference(), GetReference(), GetSym(), and GetXmlDecl().

416  {
417  // [5] Name ::= (Letter | '_' | ':') (NameChar)*
418  TChA NmChA;
419  if (ChDef.IsFirstNameCh(Ch)){
420  do {NmChA+=Ch;} while (ChDef.IsName(GetCh()));
421  } else {
422  EThrow("Invalid first name character.");
423  // EThrow(TStr::Fmt("Invalid first name character [%u:'%c%c%c%c%c'].",
424  // uint(Ch), Ch, RSIn.GetCh(), RSIn.GetCh(), RSIn.GetCh(), RSIn.GetCh()));
425  }
426  return NmChA;
427 }
bool IsFirstNameCh(const uchar &Ch) const
Definition: xml.h:78
static TXmlChDef ChDef
Definition: xml.h:100
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
uchar GetCh()
Definition: xml.cpp:260
Definition: dt.h:201
bool IsName(const uchar &Ch) const
Definition: xml.h:73
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TXmlLx::GetName ( const TStr RqNm)
private

Definition at line 429 of file xml.cpp.

References EThrow(), Fail, and GetName().

429  {
430  TStr Nm=GetName();
431  // test if the name is equal to the required name
432  if (Nm==RqNm){return RqNm;}
433  else {EThrow(TStr("Name '")+RqNm+"' expected."); Fail; return TStr();}
434 }
#define Fail
Definition: bd.h:238
TStr GetName()
Definition: xml.cpp:416
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
Definition: dt.h:412

Here is the call graph for this function:

void TXmlLx::GetNData ( )
private

Definition at line 622 of file xml.cpp.

References GetName(), and GetWs().

Referenced by GetEntity().

622  {
623  // [76] NDataDecl ::= S 'NDATA' S Name
624  GetName("NDATA"); GetWs(true); GetName();
625 }
TStr GetName()
Definition: xml.cpp:416
void GetWs(const bool &IsRq)
Definition: xml.cpp:331

Here is the call graph for this function:

Here is the caller graph for this function:

void TXmlLx::GetNotation ( )
private

Definition at line 722 of file xml.cpp.

References Ch, ChDef, TChA::Clr(), EThrow(), GetCh(), TXmlChDef::IsChar(), and TxtChA.

Referenced by GetSym().

722  {
723  // [82] NotationDecl ::= '<!NOTATION' S Name S (ExternalID | PublicID) S? '>'
724  // [83] PublicID ::= 'PUBLIC' S PubidLiteral
725  TxtChA.Clr();
726  while (Ch!='>'){
727  if (!ChDef.IsChar(Ch)){EThrow("Invalid Element character.");}
728  TxtChA+=Ch; GetCh();
729  }
730  GetCh();
731 }
bool IsChar(const uchar &Ch) const
Definition: xml.h:68
TChA TxtChA
Definition: xml.h:140
void Clr()
Definition: dt.h:258
static TXmlChDef ChDef
Definition: xml.h:100
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
uchar GetCh()
Definition: xml.cpp:260
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TXmlLx::GetPEReference ( )
private

Definition at line 397 of file xml.cpp.

References Ch, TStr::Empty(), EThrow(), GetCh(), GetName(), and IsPEntityNm().

Referenced by GetDocTypeDecl(), and GetEntityValue().

397  {
398  // [69] PEReference ::= '%' Name ';'
399  TStr EntityNm=GetName();
400  if ((EntityNm.Empty())||(Ch!=';')){EThrow("Invalid PEntity-Reference.");}
401  GetCh();
402  TStr EntityVal;
403  if (IsPEntityNm(EntityNm, EntityVal)){/*intentionaly empty*/}
404  else {EThrow(TStr("PEntity-Reference (")+EntityNm+") does not exist.");}
405  return EntityVal;
406 }
bool IsPEntityNm(const TStr &EntityNm, TStr &EntityVal) const
Definition: xml.h:179
TStr GetName()
Definition: xml.cpp:416
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
uchar GetCh()
Definition: xml.cpp:260
Definition: dt.h:412
bool Empty() const
Definition: dt.h:488
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

void TXmlLx::GetPI ( )
private

Definition at line 562 of file xml.cpp.

References Ch, ChDef, TChA::Clr(), EThrow(), forever, GetCh(), GetWs(), TXmlChDef::IsChar(), and TxtChA.

Referenced by GetSym().

562  {
563  // [16] PI ::= {{'<?' PITarget}} (S (Char* - (Char* '?>' Char*)))? '?>'
564  // [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))
565  GetWs(false);
566  TxtChA.Clr();
567  forever {
568  if (!ChDef.IsChar(Ch)){EThrow("Invalid PI character.");}
569  if (Ch=='?'){
570  if (GetCh()=='>'){
571  GetCh(); break;
572  } else {
573  if (!ChDef.IsChar(Ch)){EThrow("Invalid PI character.");}
574  TxtChA+='?'; TxtChA+=Ch; // special case if single '?'
575  }
576  } else {
577  TxtChA+=Ch; // usual char
578  }
579  GetCh();
580  }
581 }
bool IsChar(const uchar &Ch) const
Definition: xml.h:68
TChA TxtChA
Definition: xml.h:140
#define forever
Definition: bd.h:6
void Clr()
Definition: dt.h:258
void GetWs(const bool &IsRq)
Definition: xml.cpp:331
static TXmlChDef ChDef
Definition: xml.h:100
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
uchar GetCh()
Definition: xml.cpp:260
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TXmlLx::GetPlainStrFromXmlStr ( const TStr XmlStr)
static

Definition at line 991 of file xml.cpp.

References Ch, TChA::Empty(), TUnicode::EncodeUtf8(), TChRet::Eof(), forever, TChRet::GetCh(), TCh::GetHex(), TCh::GetNum(), TCh::IsHex(), TCh::IsNum(), and TStrIn::New().

Referenced by GetUsAsciiStrFromXmlStr().

991  {
992  TChA PlainChA;
993  TChRet Ch(TStrIn::New(XmlStr));
994  Ch.GetCh();
995  while (!Ch.Eof()){
996  if (Ch()!='&'){
997  PlainChA+=Ch(); Ch.GetCh();
998  } else {
999  // [67] Reference ::= EntityRef | CharRef
1000  if (Ch.GetCh()=='#'){
1001  // [66] CharRef ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'
1002  TChA RefChA; int RefCd=0;
1003  if (Ch.GetCh()=='x'){
1004  // hex-decimal character code
1005  forever {
1006  Ch.GetCh();
1007  if (TCh::IsHex(Ch())){
1008  RefChA+=Ch();
1009  RefCd=RefCd*16+TCh::GetHex(Ch());
1010  } else {
1011  break;
1012  }
1013  }
1014  } else {
1015  // decimal character code
1016  forever {
1017  if (TCh::IsNum(Ch())){
1018  RefChA+=Ch();
1019  RefCd=RefCd*10+TCh::GetNum(Ch());
1020  } else {
1021  break;
1022  }
1023  Ch.GetCh();
1024  }
1025  }
1026  if ((!RefChA.Empty())&&(Ch()==';')){
1027  Ch.GetCh();
1028  if (RefCd < 0x80) {
1029  // ascii character
1030  uchar RefCh=uchar(RefCd);
1031  PlainChA+=RefCh;
1032  } else {
1033  // unicode
1034  TUnicode::EncodeUtf8(RefCd, PlainChA);
1035  }
1036  }
1037  } else {
1038  // [68] EntityRef ::= '&' Name ';'
1039  TChA EntityNm;
1040  while ((!Ch.Eof())&&(Ch()!=';')){
1041  EntityNm+=Ch(); Ch.GetCh();}
1042  if ((!EntityNm.Empty())&&(Ch()==';')){
1043  Ch.GetCh();
1044  if (EntityNm=="quot"){PlainChA+='"';}
1045  else if (EntityNm=="amp"){PlainChA+='&';}
1046  else if (EntityNm=="apos"){PlainChA+='\'';}
1047  else if (EntityNm=="lt"){PlainChA+='<';}
1048  else if (EntityNm=="gt"){PlainChA+='>';}
1049  }
1050  }
1051  }
1052  }
1053  return PlainChA;
1054 }
static bool IsHex(const char &Ch)
Definition: dt.h:1067
static bool IsNum(const char &Ch)
Definition: dt.h:1064
#define forever
Definition: bd.h:6
bool Empty() const
Definition: dt.h:260
static int GetHex(const char &Ch)
Definition: dt.h:1069
static PSIn New(const TStr &Str)
Definition: dt.h:708
static int GetNum(const char &Ch)
Definition: dt.h:1066
unsigned char uchar
Definition: bd.h:10
Definition: dt.h:201
int EncodeUtf8(const TIntV &src, TIntV &dest) const
Definition: unicode.h:1792
uchar Ch
Definition: xml.h:104
Definition: fl.h:535

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TXmlLx::GetPubidLiteral ( )
private

Definition at line 596 of file xml.cpp.

References Ch, ChDef, EThrow(), GetCh(), and TXmlChDef::IsPubid().

Referenced by GetExternalId().

596  {
597  // [12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"
598  char QCh=Ch;
599  if ((Ch!='\'')&&(Ch!='"')){EThrow("Quote character (' or \") expected.");}
600  TChA LitChA; GetCh();
601  while (Ch!=QCh){
602  if (!ChDef.IsPubid(Ch)){EThrow("Invalid Public-Id-Literal character.");}
603  LitChA+=Ch; GetCh();
604  }
605  GetCh();
606  return LitChA;
607 }
static TXmlChDef ChDef
Definition: xml.h:100
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
uchar GetCh()
Definition: xml.cpp:260
bool IsPubid(const uchar &Ch) const
Definition: xml.h:74
Definition: dt.h:201
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TXmlLx::GetReference ( )
private

Definition at line 340 of file xml.cpp.

References Ch, ChDef, TChA::Empty(), TStr::Empty(), TUnicode::EncodeUtf8(), EThrow(), Fail, forever, GetCh(), TCh::GetHex(), GetName(), TCh::GetNum(), TXmlChDef::IsEntityNm(), IsEntityNm(), TCh::IsHex(), and TCh::IsNum().

Referenced by GetAttValue(), GetEntityValue(), and GetSym().

340  {
341  // [67] Reference ::= EntityRef | CharRef
342  if (Ch=='#'){
343  // [66] CharRef ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'
344  TChA RefChA; int RefCd=0;
345  if (GetCh()=='x'){
346  // hex-decimal character code
347  forever {
348  GetCh();
349  if (TCh::IsHex(Ch)){
350  RefChA+=Ch;
351  RefCd=RefCd*16+TCh::GetHex(Ch);
352  } else {
353  break;
354  }
355  }
356  } else {
357  // decimal character code
358  forever {
359  if (TCh::IsNum(Ch)){
360  RefChA+=Ch;
361  RefCd=RefCd*10+TCh::GetNum(Ch);
362  } else {
363  break;
364  }
365  GetCh();
366  }
367  }
368  if ((!RefChA.Empty())&&(Ch==';')){
369  GetCh();
370  if (RefCd < 0x80) {
371  // 8-bit char
372  uchar RefCh=uchar(RefCd);
373  return TStr(RefCh);
374  } else {
375  TStr ResStr = TUnicode::EncodeUtf8(RefCd);
376  return ResStr;
377  }
378  } else {
379  EThrow("Invalid Char-Reference."); Fail; return TStr();
380  }
381  } else {
382  // [68] EntityRef ::= '&' Name ';'
383  TStr EntityNm=GetName();
384  if ((!EntityNm.Empty())&&(Ch==';')){
385  GetCh();
386  TStr EntityVal;
387  if (IsEntityNm(EntityNm, EntityVal)){/*intentionaly empty*/}
388  else if (ChDef.IsEntityNm(EntityNm, EntityVal)){/*intentionaly empty*/}
389  else {EThrow(TStr("Entity-Reference (")+EntityNm+") does not exist.");}
390  return EntityVal;
391  } else {
392  EThrow("Invalid Entity-Reference."); Fail; return TStr();
393  }
394  }
395 }
static bool IsHex(const char &Ch)
Definition: dt.h:1067
static bool IsNum(const char &Ch)
Definition: dt.h:1064
#define forever
Definition: bd.h:6
bool Empty() const
Definition: dt.h:260
#define Fail
Definition: bd.h:238
TStr GetName()
Definition: xml.cpp:416
static int GetHex(const char &Ch)
Definition: dt.h:1069
bool IsEntityNm(const TStr &EntityNm, TStr &EntityVal) const
Definition: xml.h:83
static TXmlChDef ChDef
Definition: xml.h:100
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
uchar GetCh()
Definition: xml.cpp:260
static int GetNum(const char &Ch)
Definition: dt.h:1066
unsigned char uchar
Definition: bd.h:10
Definition: dt.h:201
Definition: dt.h:412
bool Empty() const
Definition: dt.h:488
bool IsEntityNm(const TStr &EntityNm, TStr &EntityVal) const
Definition: xml.h:175
int EncodeUtf8(const TIntV &src, TIntV &dest) const
Definition: unicode.h:1792
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TXmlLx::GetStalVal ( )
private

Definition at line 513 of file xml.cpp.

References Ch, EThrow(), Fail, and GetCh().

Referenced by GetXmlDecl().

513  {
514  // [32] SDDecl ::= {{S 'standalone' Eq}}
515  // (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"'))
516  char QCh=Ch;
517  if ((Ch!='\'')&&(Ch!='"')){EThrow("Quote character (' or \") expected.");}
518  TChA StalChA;
519  GetCh();
520  while (Ch!=QCh){
521  if (('a'<=Ch)&&(Ch<='z')){StalChA+=Ch;}
522  else {EThrow("Invalid standalone-value character.");}
523  GetCh();
524  }
525  GetCh();
526  TStr StalVal=StalChA;
527  if ((StalVal=="yes")||(StalVal=="no")){return StalVal;}
528  else {EThrow("Invalid standalone-value."); Fail; return TStr();}
529 }
#define Fail
Definition: bd.h:238
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
uchar GetCh()
Definition: xml.cpp:260
Definition: dt.h:201
Definition: dt.h:412
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

TXmlLxSym TXmlLx::GetSym ( )

Definition at line 757 of file xml.cpp.

References AddArg(), Ch, ChDef, TChA::Clr(), ClrArgV(), TCh::EofCh, EThrow(), forever, GetAttList(), GetAttValue(), GetCDSect(), GetCh(), GetComment(), GetDocTypeDecl(), GetElement(), GetEntity(), GetEq(), TStr::GetLc(), GetName(), GetNotation(), GetPI(), GetReference(), TUInt::GetStr(), GetWs(), GetXmlDecl(), TXmlChDef::IsChar(), TXmlChDef::IsWs(), TChA::LastCh(), TChA::LastLastCh(), TChA::Len(), SkipWs(), Spacing, Sym, TagNm, ToNrSpacing(), TxtChA, xspTruncate, xsyAttList, xsyComment, xsyDocTypeDecl, xsyElement, xsyEntity, xsyEof, xsyETag, xsyNotation, xsyPI, xsyQStr, xsySETag, xsySTag, xsyStr, xsyWs, and xsyXmlDecl.

Referenced by GetDocTypeDecl(), TStrUtil::GetXmlTagNmVal(), TStrUtil::GetXmlTagNmVal2(), TStrUtil::GetXmlTagVal(), TSnap::LoadDyNet(), TSnap::LoadDyNetGraphV(), TXmlDoc::LoadTxt(), TXmlDoc::LoadTxtElement(), TXmlDoc::LoadTxtMiscStar(), and TXmlDoc::SkipTopTag().

757  {
758  if (Ch=='<'){
759  GetCh(); ClrArgV();
760  if (Ch=='?'){
761  GetCh(); TagNm=GetName();
762  if (TagNm.GetLc()=="xml"){Sym=xsyXmlDecl; GetXmlDecl();}
763  else {Sym=xsyPI; GetPI();}
764  } else
765  if (Ch=='!'){
766  GetCh();
767  if (Ch=='['){
768  GetCh(); TagNm=GetName();
769  if (TagNm=="CDATA"){Sym=xsyQStr; GetCDSect();}
770  else {EThrow(TStr("Invalid tag after '<![' (")+TagNm+").");}
771  } else
772  if (Ch=='-'){
774  } else {
775  TagNm=GetName();
776  if (TagNm=="DOCTYPE"){GetDocTypeDecl(); Sym=xsyDocTypeDecl;}
777  else if (TagNm=="ELEMENT"){GetElement(); Sym=xsyElement;}
778  else if (TagNm=="ATTLIST"){GetAttList(); Sym=xsyAttList;}
779  else if (TagNm=="ENTITY"){GetEntity(); Sym=xsyEntity;}
780  else if (TagNm=="NOTATION"){GetNotation(); Sym=xsyNotation;}
781  else {EThrow(TStr("Invalid tag (")+TagNm+").");}
782  }
783  } else
784  if (Ch=='/'){
785  // xsyETag
786  GetCh(); Sym=xsyETag; TagNm=GetName(); GetWs(false);
787  if (Ch=='>'){GetCh();}
788  else {EThrow("Invalid End-Tag.");}
789  } else {
790  // xsySTag or xsySETag
791  TagNm=GetName(); GetWs(false);
792  while ((Ch!='>')&&(Ch!='/')){
793  TStr AttrNm=GetName();
794  GetEq();
795  TStr AttrVal=GetAttValue();
796  GetWs(false);
797  AddArg(AttrNm, AttrVal);
798  }
799  if (Ch=='/'){
800  if (GetCh()=='>'){Sym=xsySETag; GetCh();}
801  else {EThrow("Invalid Empty-Element-Tag.");}
802  } else {
803  Sym=xsySTag; GetCh();
804  }
805  }
806  if (Spacing==xspTruncate){SkipWs();}
807  } else
808  if (ChDef.IsWs(Ch)){
809  Sym=xsyWs; GetWs(true); ToNrSpacing();
810  if (Spacing==xspTruncate){GetSym();}
811  } else
812  if (Ch==TCh::EofCh){
813  Sym=xsyEof;
814  } else {
815  Sym=xsyStr; TxtChA.Clr();
816  // [14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)
817  forever {
818  if (!ChDef.IsChar(Ch)){
819  EThrow(TUInt::GetStr(Ch, "Invalid character (%d)."));}
820  // GetCh(); continue; // skip invalid characters
821  if (Ch=='<'){break;} // tag
822  if (Ch=='&'){GetCh(); TxtChA+=GetReference();} // reference
823  else {
824  if ((Ch=='>')&&(TxtChA.Len()>=2)&&
825  (TxtChA.LastLastCh()==']')&&(TxtChA.LastCh()==']')){
826  EThrow("Forbidden substring ']]>' in character data.");}
827  TxtChA+=Ch; GetCh(); // usual char
828  }
829  }
830  ToNrSpacing();
831  }
832  return Sym;
833 }
TXmlLxSym GetSym()
Definition: xml.cpp:757
TStr TagNm
Definition: xml.h:141
bool IsChar(const uchar &Ch) const
Definition: xml.h:68
void GetXmlDecl()
Definition: xml.cpp:531
TChA TxtChA
Definition: xml.h:140
Definition: xml.h:93
void GetEntity()
Definition: xml.cpp:690
Definition: xml.h:91
Definition: xml.h:94
void AddArg(const TStr &ArgNm, const TStr &ArgVal)
Definition: xml.h:161
#define forever
Definition: bd.h:6
void GetEq()
Definition: xml.cpp:408
TStr GetName()
Definition: xml.cpp:416
void Clr()
Definition: dt.h:258
void GetWs(const bool &IsRq)
Definition: xml.cpp:331
Definition: xml.h:90
int Len() const
Definition: dt.h:259
static TXmlChDef ChDef
Definition: xml.h:100
void GetAttList()
Definition: xml.cpp:665
void GetPI()
Definition: xml.cpp:562
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
void ToNrSpacing()
Definition: xml.cpp:270
char LastLastCh() const
Definition: dt.h:282
static const char EofCh
Definition: dt.h:1037
uchar GetCh()
Definition: xml.cpp:260
Definition: xml.h:93
TStr GetStr() const
Definition: dt.h:1279
char LastCh() const
Definition: dt.h:281
Definition: xml.h:92
TStr GetLc() const
Definition: dt.h:499
Definition: xml.h:93
Definition: xml.h:93
TStr GetReference()
Definition: xml.cpp:340
Definition: xml.h:93
void GetNotation()
Definition: xml.cpp:722
Definition: dt.h:412
Definition: xml.h:92
void GetCDSect()
Definition: xml.cpp:733
TXmlSpacing Spacing
Definition: xml.h:106
Definition: xml.h:92
TStr GetAttValue()
Definition: xml.cpp:457
void GetElement()
Definition: xml.cpp:656
void ClrArgV()
Definition: xml.h:160
Definition: xml.h:90
void SkipWs()
Definition: xml.cpp:752
TXmlLxSym Sym
Definition: xml.h:139
void GetDocTypeDecl()
Definition: xml.cpp:627
void GetComment()
Definition: xml.cpp:436
bool IsWs(const uchar &Ch) const
Definition: xml.h:76
uchar Ch
Definition: xml.h:104
Definition: xml.h:91

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TXmlLx::GetSymStr ( ) const

Definition at line 835 of file xml.cpp.

References TChA::Empty(), Fail, GetArg(), GetArgs(), GetArgValQCh(), TStr::GetHex(), Sym, TagNm, TxtChA, xsyComment, xsyDocTypeDecl, xsyEof, xsyETag, xsyPI, xsyQStr, xsySETag, xsySTag, xsyStr, xsyUndef, xsyWs, and xsyXmlDecl.

835  {
836  TChA SymChA;
837  switch (Sym){
838  case xsyUndef:
839  SymChA="{Undef}"; break;
840  case xsyWs:
841  SymChA+="{Space:'"; SymChA+=TStr(TxtChA).GetHex(); SymChA+="'}"; break;
842  case xsyComment:
843  SymChA+="<!--"; SymChA+=TxtChA; SymChA+="-->"; break;
844  case xsyXmlDecl:{
845  SymChA+="<?"; SymChA+=TagNm;
846  for (int ArgN=0; ArgN<GetArgs(); ArgN++){
847  TStr ArgNm; TStr ArgVal; GetArg(ArgN, ArgNm, ArgVal);
848  char ArgValQCh=GetArgValQCh(ArgVal);
849  SymChA+=' '; SymChA+=ArgNm; SymChA+='=';
850  SymChA+=ArgValQCh; SymChA+=ArgVal; SymChA+=ArgValQCh;
851  }
852  SymChA+="?>"; break;}
853  case xsyPI:
854  SymChA+="<?"; SymChA+=TagNm;
855  if (!TxtChA.Empty()){SymChA+=' '; SymChA+=TxtChA;}
856  SymChA+="?>"; break;
857  case xsyDocTypeDecl:
858  SymChA+="<!DOCTYPE "; SymChA+=TagNm; SymChA+=">"; break;
859  case xsySTag:
860  case xsySETag:{
861  SymChA+="<"; SymChA+=TagNm;
862  for (int ArgN=0; ArgN<GetArgs(); ArgN++){
863  TStr ArgNm; TStr ArgVal; GetArg(ArgN, ArgNm, ArgVal);
864  char ArgValQCh=GetArgValQCh(ArgVal);
865  SymChA+=' '; SymChA+=ArgNm; SymChA+='=';
866  SymChA+=ArgValQCh; SymChA+=ArgVal; SymChA+=ArgValQCh;
867  }
868  if (Sym==xsySTag){SymChA+=">";}
869  else if (Sym==xsySETag){SymChA+="/>";}
870  else {Fail;}
871  break;}
872  case xsyETag:
873  SymChA+="</"; SymChA+=TagNm; SymChA+=">"; break;
874  case xsyStr:
875  SymChA="{String:'"; SymChA+=TxtChA; SymChA+="'}"; break;
876  case xsyQStr:
877  SymChA="{QString:'"; SymChA+=TxtChA; SymChA+="'}"; break;
878  case xsyEof:
879  SymChA="{Eof}"; break;
880  default: Fail;
881  }
882  return SymChA;
883 }
TStr TagNm
Definition: xml.h:141
TChA TxtChA
Definition: xml.h:140
Definition: xml.h:93
Definition: xml.h:91
void GetArg(const int &ArgN, TStr &ArgNm, TStr &ArgVal) const
Definition: xml.h:166
Definition: xml.h:94
bool Empty() const
Definition: dt.h:260
#define Fail
Definition: bd.h:238
Definition: xml.h:90
Definition: xml.h:93
Definition: xml.h:93
static char GetArgValQCh(const TStr &ArgVal)
Definition: xml.h:171
Definition: xml.h:90
Definition: xml.h:93
int GetArgs() const
Definition: xml.h:165
Definition: xml.h:93
Definition: dt.h:201
Definition: dt.h:412
TStr GetHex() const
Definition: dt.h:512
Definition: xml.h:90
TXmlLxSym Sym
Definition: xml.h:139
Definition: xml.h:91

Here is the call graph for this function:

TStr TXmlLx::GetSystemLiteral ( )
private

Definition at line 583 of file xml.cpp.

References Ch, ChDef, EThrow(), GetCh(), and TXmlChDef::IsChar().

Referenced by GetExternalId().

583  {
584  // [11] SystemLiteral ::= ('"' [^"]* '"') | ("'" [^']* "'")
585  char QCh=Ch;
586  if ((Ch!='\'')&&(Ch!='"')){EThrow("Quote character (' or \") expected.");}
587  TChA LitChA; GetCh();
588  while (Ch!=QCh){
589  if (!ChDef.IsChar(Ch)){EThrow("Invalid System-Literal character.");}
590  LitChA+=Ch; GetCh();
591  }
592  GetCh();
593  return LitChA;
594 }
bool IsChar(const uchar &Ch) const
Definition: xml.h:68
static TXmlChDef ChDef
Definition: xml.h:100
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
uchar GetCh()
Definition: xml.cpp:260
Definition: dt.h:201
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TXmlLx::GetUsAsciiStrFromXmlStr ( const TStr EntRefStr)
static

Definition at line 1056 of file xml.cpp.

References Ch, TStr::ChangeStrAll(), ChN, GetPlainStrFromXmlStr(), TChA::Len(), and TChA::PutCh().

1056  {
1057  TStr UsAsciiStr=XmlStr;
1058  UsAsciiStr.ChangeStrAll("&#232;", "c");
1059  UsAsciiStr.ChangeStrAll("&#200;", "C");
1060  UsAsciiStr.ChangeStrAll("&#154;", "s");
1061  UsAsciiStr.ChangeStrAll("&#138;", "S");
1062  UsAsciiStr.ChangeStrAll("&#158;", "z");
1063  UsAsciiStr.ChangeStrAll("&#142;", "Z");
1064  TChA UsAsciiChA=TXmlLx::GetPlainStrFromXmlStr(UsAsciiStr);
1065  for (int ChN=0; ChN<UsAsciiChA.Len(); ChN++){
1066  char Ch=UsAsciiChA[ChN];
1067  if ((Ch<' ')||('~'<Ch)){UsAsciiChA.PutCh(ChN, 'x');}
1068  }
1069  return UsAsciiChA;
1070 }
void PutCh(const int &ChN, const char &Ch)
Definition: dt.h:278
static TStr GetPlainStrFromXmlStr(const TStr &XmlStr)
Definition: xml.cpp:991
int Len() const
Definition: dt.h:259
int ChangeStrAll(const TStr &SrcStr, const TStr &DstStr, const bool &FromStartP=false)
Definition: dt.cpp:1141
Definition: dt.h:201
Definition: dt.h:412
int ChN
Definition: xml.h:105
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

TStr TXmlLx::GetVersionNum ( )
private

Definition at line 473 of file xml.cpp.

References Ch, EThrow(), and GetCh().

Referenced by GetXmlDecl().

473  {
474  // [24] VersionInfo ::= {{S 'version' Eq}} (' VersionNum ' | " VersionNum ")
475  // [26] VersionNum ::= ([a-zA-Z0-9_.:] | '-')+
476  char QCh=Ch;
477  if ((Ch!='\'')&&(Ch!='"')){EThrow("Quote character (' or \") expected.");}
478  TChA VerNumChA;
479  GetCh();
480  do {
481  if ((('a'<=Ch)&&(Ch<='z'))||(('A'<=Ch)&&(Ch<='Z'))||
482  (('0'<=Ch)&&(Ch<='9'))||(Ch=='_')||(Ch=='.')||(Ch==':')||(Ch=='-')){
483  VerNumChA+=Ch;
484  } else {
485  EThrow("Invalid version-number character.");
486  }
487  GetCh();
488  } while (Ch!=QCh);
489  GetCh();
490  return VerNumChA;
491 }
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
uchar GetCh()
Definition: xml.cpp:260
Definition: dt.h:201
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

void TXmlLx::GetWs ( const bool &  IsRq)
private

Definition at line 331 of file xml.cpp.

References Ch, ChDef, TChA::Clr(), EThrow(), GetCh(), TXmlChDef::IsWs(), and TxtChA.

Referenced by GetDocTypeDecl(), GetEntity(), GetEq(), GetExternalId(), GetNData(), GetPI(), GetSym(), and GetXmlDecl().

331  {
332  // [3] S ::= (#x20 | #x9 | #xD | #xA)+
333  int WSpaces=0; TxtChA.Clr();
334  while (ChDef.IsWs(Ch)){
335  WSpaces++; TxtChA+=Ch; GetCh();}
336  if (IsRq&&(WSpaces==0)){
337  EThrow("White-space required.");}
338 }
TChA TxtChA
Definition: xml.h:140
void Clr()
Definition: dt.h:258
static TXmlChDef ChDef
Definition: xml.h:100
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
uchar GetCh()
Definition: xml.cpp:260
bool IsWs(const uchar &Ch) const
Definition: xml.h:76
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

void TXmlLx::GetXmlDecl ( )
private

Definition at line 531 of file xml.cpp.

References AddArg(), Ch, EThrow(), GetCh(), GetEncName(), GetEq(), GetName(), GetStalVal(), GetVersionNum(), and GetWs().

Referenced by GetSym().

531  {
532  // [23] XMLDecl ::= {{'<?xml'}}... VersionInfo EncodingDecl? SDDecl? S? '?>'
533  // [24] VersionInfo ::= S 'version' Eq (' VersionNum ' | " VersionNum ")
534  GetWs(true);
535  TStr VerNm=GetName("version"); GetEq(); TStr VerVal=GetVersionNum();
536  if (VerVal!="1.0"){EThrow("Invalid XML version.");}
537  AddArg(VerNm, VerVal);
538  GetWs(false);
539  if (Ch!='?'){
540  // EncodingDecl ::= {{S}} 'encoding' Eq
541  // ('"' EncName '"' | "'" EncName "'" )
542  TStr EncNm=GetName("encoding"); GetEq(); TStr EncVal=GetEncName();
543  AddArg(EncNm, EncVal);
544  }
545  GetWs(false);
546  if (Ch!='?'){
547  // SDDecl ::= {{S}} 'standalone' Eq
548  // (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"'))
549  TStr StalNm=GetName("standalone"); GetEq(); TStr StalVal=GetStalVal();
550  AddArg(StalNm, StalVal);
551  }
552  GetWs(false);
553  if (Ch=='?'){
554  GetCh();
555  if (Ch=='>'){GetCh();}
556  else {EThrow("Invalid end-of-tag in XML-declaration.");}
557  } else {
558  EThrow("Invalid end-of-tag in XML-declaration.");
559  }
560 }
void AddArg(const TStr &ArgNm, const TStr &ArgVal)
Definition: xml.h:161
void GetEq()
Definition: xml.cpp:408
TStr GetName()
Definition: xml.cpp:416
void GetWs(const bool &IsRq)
Definition: xml.cpp:331
void EThrow(const TStr &MsgStr) const
Definition: xml.cpp:885
TStr GetStalVal()
Definition: xml.cpp:513
uchar GetCh()
Definition: xml.cpp:260
TStr GetVersionNum()
Definition: xml.cpp:473
TStr GetEncName()
Definition: xml.cpp:493
Definition: dt.h:412
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TXmlLx::GetXmlLxSymStr ( const TXmlLxSym XmlLxSym)
static

Definition at line 904 of file xml.cpp.

References xsyAttList, xsyComment, xsyDocTypeDecl, xsyElement, xsyEntity, xsyEof, xsyETag, xsyNotation, xsyPI, xsyQStr, xsySETag, xsySTag, xsyStr, xsyTag, xsyUndef, xsyWs, and xsyXmlDecl.

Referenced by TXmlTok::GetSymStr().

904  {
905  switch (XmlLxSym){
906  case xsyUndef: return "Undef";
907  case xsyWs: return "White-Space";
908  case xsyComment: return "Comment";
909  case xsyXmlDecl: return "Declaration";
910  case xsyPI: return "PI";
911  case xsyDocTypeDecl: return "Document-Type";
912  case xsyElement: return "Element";
913  case xsyAttList: return "Attribute-List";
914  case xsyEntity: return "Entity";
915  case xsyNotation: return "Notation";
916  case xsyTag: return "Tag";
917  case xsySTag: return "Start-Tag";
918  case xsyETag: return "End-Tag";
919  case xsySETag: return "Start-End-Tag";
920  case xsyStr: return "String";
921  case xsyQStr: return "Quoted-String";
922  case xsyEof: return "Eon-Of-File";
923  default: return "Undef";
924  }
925 }
Definition: xml.h:93
Definition: xml.h:91
Definition: xml.h:93
Definition: xml.h:94
Definition: xml.h:90
Definition: xml.h:93
Definition: xml.h:92
Definition: xml.h:93
Definition: xml.h:90
Definition: xml.h:93
Definition: xml.h:93
Definition: xml.h:92
Definition: xml.h:92
Definition: xml.h:90
Definition: xml.h:91

Here is the caller graph for this function:

TStr TXmlLx::GetXmlStrFromPlainMem ( const TMem PlainMem)
static

Definition at line 945 of file xml.cpp.

References Ch, ChN, TUInt::GetStr(), and TMem::Len().

Referenced by TMem::SaveXml().

945  {
946  TChA XmlChA;
947  for (int ChN=0; ChN<PlainMem.Len(); ChN++){
948  uchar Ch=PlainMem[ChN];
949  if ((' '<=Ch)&&(Ch<='~')){
950  switch (Ch){
951  case '"': XmlChA+="&quot;"; break;
952  case '&': XmlChA+="&amp;"; break;
953  case '\'': XmlChA+="&apos;"; break;
954  case '<': XmlChA+="&lt;"; break;
955  case '>': XmlChA+="&gt;"; break;
956  default: XmlChA+=Ch;
957  }
958  } else
959  if ((Ch=='\r')||(Ch=='\n')){
960  XmlChA+=Ch;
961  } else {
962  XmlChA+='&'; XmlChA+='#'; XmlChA+=TUInt::GetStr(Ch); XmlChA+=';';
963  }
964  }
965  return XmlChA;
966 }
int Len() const
Definition: dt.h:134
TStr GetStr() const
Definition: dt.h:1279
unsigned char uchar
Definition: bd.h:10
Definition: dt.h:201
int ChN
Definition: xml.h:105
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TXmlLx::GetXmlStrFromPlainStr ( const TChA PlainChA)
static

Definition at line 968 of file xml.cpp.

References Ch, ChN, TUInt::GetStr(), and TChA::Len().

Referenced by TXmlTok::AddTokToChA(), THtmlDoc::GetTxtLnDoc(), THtmlDoc::SaveHtmlToXml(), TChA::SaveXml(), and TStr::SaveXml().

968  {
969  TChA XmlChA;
970  for (int ChN=0; ChN<PlainChA.Len(); ChN++){
971  uchar Ch=PlainChA[ChN];
972  if ((' '<=Ch)&&(Ch<='~')){
973  switch (Ch){
974  case '"': XmlChA+="&quot;"; break;
975  case '&': XmlChA+="&amp;"; break;
976  case '\'': XmlChA+="&apos;"; break;
977  case '<': XmlChA+="&lt;"; break;
978  case '>': XmlChA+="&gt;"; break;
979  default: XmlChA+=Ch;
980  }
981  } else
982  if ((Ch=='\r')||(Ch=='\n')){
983  XmlChA+=Ch;
984  } else {
985  XmlChA+='&'; XmlChA+='#'; XmlChA+=TUInt::GetStr(Ch); XmlChA+=';';
986  }
987  }
988  return XmlChA;
989 }
int Len() const
Definition: dt.h:259
TStr GetStr() const
Definition: dt.h:1279
unsigned char uchar
Definition: bd.h:10
Definition: dt.h:201
int ChN
Definition: xml.h:105
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

bool TXmlLx::IsArgNm ( const TStr ArgNm) const
inline

Definition at line 163 of file xml.h.

References ArgNmValKdV, and TVec< TVal, TSizeTy >::IsIn().

163  {
164  return ArgNmValKdV.IsIn(TStrKd(ArgNm));}
bool IsIn(const TVal &Val) const
Checks whether element Val is a member of the vector.
Definition: ds.h:828
TStrKdV ArgNmValKdV
Definition: xml.h:142
TKeyDat< TStr, TStr > TStrKd
Definition: ds.h:405

Here is the call graph for this function:

bool TXmlLx::IsEntityNm ( const TStr EntityNm,
TStr EntityVal 
) const
inline

Definition at line 175 of file xml.h.

References EntityNmToValH, and THash< TKey, TDat, THashFunc >::IsKeyGetDat().

Referenced by GetReference().

175  {
176  return EntityNmToValH.IsKeyGetDat(EntityNm, EntityVal);}
TStrStrH EntityNmToValH
Definition: xml.h:113
bool IsKeyGetDat(const TKey &Key, TDat &Dat) const
Definition: hash.h:274

Here is the call graph for this function:

Here is the caller graph for this function:

bool TXmlLx::IsPEntityNm ( const TStr EntityNm,
TStr EntityVal 
) const
inline

Definition at line 179 of file xml.h.

References THash< TKey, TDat, THashFunc >::IsKeyGetDat(), and PEntityNmToValH.

Referenced by GetPEReference().

179  {
180  return PEntityNmToValH.IsKeyGetDat(EntityNm, EntityVal);}
bool IsKeyGetDat(const TKey &Key, TDat &Dat) const
Definition: hash.h:274
TStrStrH PEntityNmToValH
Definition: xml.h:113

Here is the call graph for this function:

Here is the caller graph for this function:

bool TXmlLx::IsTagNm ( const TStr Str)
static

Definition at line 927 of file xml.cpp.

References ChN, and TChA::Len().

927  {
928  TChA ChA=Str;
929  if (ChA.Len()>0){
930  if (TXmlLx::ChDef.IsFirstNameCh(ChA[0])){
931  for (int ChN=1; ChN<ChA.Len(); ChN++){
932  if (!TXmlLx::ChDef.IsName(ChA[ChN])){
933  return false;
934  }
935  }
936  return true;
937  } else {
938  return false;
939  }
940  } else {
941  return false;
942  }
943 }
int Len() const
Definition: dt.h:259
static TXmlChDef ChDef
Definition: xml.h:100
Definition: dt.h:201
int ChN
Definition: xml.h:105

Here is the call graph for this function:

TXmlLx& TXmlLx::operator= ( const TXmlLx )
inline

Definition at line 152 of file xml.h.

References Fail.

152 {Fail; return *this;}
#define Fail
Definition: bd.h:238
void TXmlLx::PutCh ( const uchar _Ch)
inlineprivate

Definition at line 108 of file xml.h.

References Ch, ChStack, and TChA::Push().

Referenced by PutStr().

108 {ChStack.Push(Ch); Ch=_Ch;}
TChA ChStack
Definition: xml.h:103
void Push(const char &Ch)
Definition: dt.h:264
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

void TXmlLx::PutEntityVal ( const TStr Nm,
const TStr Val 
)
inline

Definition at line 177 of file xml.h.

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

Referenced by GetEntity().

177  {
178  EntityNmToValH.AddDat(Nm, Val);}
TStrStrH EntityNmToValH
Definition: xml.h:113
TDat & AddDat(const TKey &Key)
Definition: hash.h:238

Here is the call graph for this function:

Here is the caller graph for this function:

void TXmlLx::PutPEntityVal ( const TStr Nm,
const TStr Val 
)
inline

Definition at line 181 of file xml.h.

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

Referenced by GetEntity().

181  {
182  PEntityNmToValH.AddDat(Nm, Val);}
TStrStrH PEntityNmToValH
Definition: xml.h:113
TDat & AddDat(const TKey &Key)
Definition: hash.h:238

Here is the call graph for this function:

Here is the caller graph for this function:

void TXmlLx::PutStr ( const TStr Str)
inlineprivate

Definition at line 109 of file xml.h.

References ChN, TStr::Len(), and PutCh().

109  {
110  for (int ChN=Str.Len()-1; ChN>=0; ChN--){PutCh(Str[ChN]);}}
int Len() const
Definition: dt.h:487
void PutCh(const uchar &_Ch)
Definition: xml.h:108
int ChN
Definition: xml.h:105

Here is the call graph for this function:

void TXmlLx::SkipWs ( )

Definition at line 752 of file xml.cpp.

References Ch, ChDef, GetCh(), and TXmlChDef::IsWs().

Referenced by GetSym(), and TXmlDoc::LoadTxt().

752  {
753  // [3] S ::= (#x20 | #x9 | #xD | #xA)+
754  while (ChDef.IsWs(Ch)){GetCh();}
755 }
static TXmlChDef ChDef
Definition: xml.h:100
uchar GetCh()
Definition: xml.cpp:260
bool IsWs(const uchar &Ch) const
Definition: xml.h:76
uchar Ch
Definition: xml.h:104

Here is the call graph for this function:

Here is the caller graph for this function:

void TXmlLx::ToNrSpacing ( )
private

Definition at line 270 of file xml.cpp.

References ChDef, TCh::CrCh, Fail, TXmlChDef::IsWs(), TChA::LastCh(), TChA::Len(), TCh::LfCh, TChA::Pop(), TChA::PutCh(), Spacing, TChA::Trunc(), TxtChA, xspIntact, xspPreserve, xspSeparate, and xspTruncate.

Referenced by GetSym().

270  {
271  if (Spacing==xspIntact){
272  } else
273  if (Spacing==xspPreserve){
274  int SrcChN=0; int DstChN=0;
275  while (SrcChN<TxtChA.Len()){
276  if (TxtChA[SrcChN]==TCh::CrCh){
277  TxtChA.PutCh(DstChN, TCh::LfCh); SrcChN++; DstChN++;
278  if ((SrcChN<TxtChA.Len())&&(TxtChA[SrcChN]==TCh::LfCh)){SrcChN++;}
279  } else {
280  if (SrcChN!=DstChN){
281  TxtChA.PutCh(DstChN, TxtChA[SrcChN]);}
282  SrcChN++; DstChN++;
283  }
284  }
285  TxtChA.Trunc(DstChN);
286  } else
287  if (Spacing==xspSeparate){
288  // squeeze series of white-spaces to single space
289  int SrcChN=0; int DstChN=0;
290  while (SrcChN<TxtChA.Len()){
291  if (ChDef.IsWs(TxtChA[SrcChN])){
292  if ((DstChN>0)&&(TxtChA[DstChN-1]==' ')){
293  SrcChN++;
294  } else {
295  TxtChA.PutCh(DstChN, ' ');
296  SrcChN++; DstChN++;
297  }
298  } else {
299  TxtChA.PutCh(DstChN, TxtChA[SrcChN]);
300  SrcChN++; DstChN++;
301  }
302  }
303  TxtChA.Trunc(DstChN);
304  } else
305  if (Spacing==xspTruncate){
306  // cut leading and trailing white-spaces and
307  // squeeze series of white-spaces to single space
308  int SrcChN=0; int DstChN=0;
309  while (SrcChN<TxtChA.Len()){
310  if (ChDef.IsWs(TxtChA[SrcChN])){
311  if ((DstChN>0)&&(TxtChA[DstChN-1]==' ')){
312  SrcChN++;
313  } else {
314  TxtChA.PutCh(DstChN, ' ');
315  SrcChN++; DstChN++;
316  }
317  } else {
318  TxtChA.PutCh(DstChN, TxtChA[SrcChN]);
319  SrcChN++; DstChN++;
320  }
321  }
322  TxtChA.Trunc(DstChN);
323  // delete trailing white-spaces
324  while ((TxtChA.Len()>0)&&(ChDef.IsWs(TxtChA.LastCh()))){
325  TxtChA.Pop();}
326  } else {
327  Fail;
328  }
329 }
TChA TxtChA
Definition: xml.h:140
#define Fail
Definition: bd.h:238
void PutCh(const int &ChN, const char &Ch)
Definition: dt.h:278
int Len() const
Definition: dt.h:259
static TXmlChDef ChDef
Definition: xml.h:100
Definition: xml.h:96
char LastCh() const
Definition: dt.h:281
void Trunc()
Definition: dt.cpp:420
static const char LfCh
Definition: dt.h:1035
TXmlSpacing Spacing
Definition: xml.h:106
static const char CrCh
Definition: dt.h:1036
char Pop()
Definition: dt.h:265
bool IsWs(const uchar &Ch) const
Definition: xml.h:76

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

TStrKdV TXmlLx::ArgNmValKdV

Definition at line 142 of file xml.h.

Referenced by AddArg(), ClrArgV(), GetArg(), GetArgs(), GetArgVal(), TXmlTok::GetTok(), and IsArgNm().

int TXmlLx::ChN
private
TChA TXmlLx::ChStack
private

Definition at line 103 of file xml.h.

Referenced by GetCh(), and PutCh().

TStrStrH TXmlLx::EntityNmToValH
private

Definition at line 113 of file xml.h.

Referenced by IsEntityNm(), and PutEntityVal().

int TXmlLx::LnChN
private

Definition at line 105 of file xml.h.

Referenced by EThrow(), GetCh(), and GetFPosStr().

int TXmlLx::LnN
private

Definition at line 105 of file xml.h.

Referenced by EThrow(), GetCh(), and GetFPosStr().

TStrStrH TXmlLx::PEntityNmToValH
private

Definition at line 113 of file xml.h.

Referenced by IsPEntityNm(), and PutPEntityVal().

uchar TXmlLx::PrevCh
private

Definition at line 104 of file xml.h.

Referenced by GetCh().

TSIn& TXmlLx::RSIn
private

Definition at line 102 of file xml.h.

Referenced by GetCh().

PSIn TXmlLx::SIn
private

Definition at line 101 of file xml.h.

Referenced by EThrow(), and GetFPosStr().

TXmlSpacing TXmlLx::Spacing
private

Definition at line 106 of file xml.h.

Referenced by GetSym(), and ToNrSpacing().


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