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,
'_');
15 while ((XmlTagChA.
Len()>0)&&(XmlTagChA.
LastCh()==
'_')){
29 if (!XmlTok->
IsTag()){
30 TStr ArgStr1=
"Expected: Tag";
36 if (!XmlTok->
IsTag(Nm)){
43 if (TypeArgVal!=TypeNm){
44 TStr ArgStr1=
TStr(
"Expected: ")+TypeNm;
45 TStr ArgStr2=
TStr(
"Found: ")+TypeArgVal;
51 if (!XmlTok->
IsTag(TypeNm)){
52 TStr ArgStr1=
TStr(
"Expected: ")+TypeNm;
61 if (XmlTok->
IsArg(Nm, ValStr)){
76 if (XmlTok->
IsArg(Nm, ValStr)){
78 if (ValStr.
IsInt(Val)){
91 if (XmlTok->
IsArg(Nm, ValStr)){
96 TExcept::Throw(
"Invalid Xml-Argument Integer64-Value", Nm, ValStr);
106 if (XmlTok->
IsArg(Nm, ValStr)){
108 if (ValStr.
IsFlt(Val)){
122 TSOut& _SOut,
const bool& ETagP,
124 const TStr& ArgNm,
const TStr& ArgVal):
125 TagNm(), SOut(&_SOut){
145 TSOut& _SOut,
const bool& ETagP,
147 const TStr& ArgNm1,
const TStr& ArgVal1,
148 const TStr& ArgNm2,
const TStr& ArgVal2,
149 const TStr& ArgNm3,
const TStr& ArgVal3,
150 const TStr& ArgNm4,
const TStr& ArgVal4):
151 TagNm(), SOut(&_SOut){
160 if (!ArgNm1.
Empty()){
164 if (!ArgNm2.
Empty()){
168 if (!ArgNm3.
Empty()){
172 if (!ArgNm4.
Empty()){
191 IAssert((0<=MnCh)&&((MxCh==-1)||((MnCh<=MxCh)&&(MxCh<
Chs))));
193 for (
int Ch=MnCh+1; Ch<=MxCh; Ch++){
198 for (
int ChN=0; ChN<Str.
Len(); ChN++){
210 CharChSet(), CombChSet(), ExtChSet(),
211 LetterChSet(), DigitChSet(), NameChSet(), PubidChSet(),
228 SetChTy(BaseChSet, 0xF8, 0xFF);
274 int SrcChN=0;
int DstChN=0;
289 int SrcChN=0;
int DstChN=0;
292 if ((DstChN>0)&&(
TxtChA[DstChN-1]==
' ')){
308 int SrcChN=0;
int DstChN=0;
311 if ((DstChN>0)&&(
TxtChA[DstChN-1]==
' ')){
336 if (IsRq&&(WSpaces==0)){
337 EThrow(
"White-space required.");}
344 TChA RefChA;
int RefCd=0;
368 if ((!RefChA.
Empty())&&(
Ch==
';')){
384 if ((!EntityNm.
Empty())&&(
Ch==
';')){
389 else {
EThrow(
TStr(
"Entity-Reference (")+EntityNm+
") does not exist.");}
400 if ((EntityNm.
Empty())||(
Ch!=
';')){
EThrow(
"Invalid PEntity-Reference.");}
404 else {
EThrow(
TStr(
"PEntity-Reference (")+EntityNm+
") does not exist.");}
412 else {
EThrow(
"Equality ('=') character expected.");}
422 EThrow(
"Invalid first name character.");
432 if (Nm==RqNm){
return RqNm;}
438 if (
GetCh()!=
'-'){
EThrow(
"Invalid comment start.");}
446 else {
EThrow(
"Invalid comment end.");}
461 if ((QCh!=
'"')&&(QCh!=
'\'')){
EThrow(
"Invalid attribute-value start.");}
465 EThrow(
"Invalid attribute-value character.");}
477 if ((
Ch!=
'\'')&&(
Ch!=
'"')){
EThrow(
"Quote character (' or \") expected.");}
481 if (((
'a'<=
Ch)&&(
Ch<=
'z'))||((
'A'<=
Ch)&&(
Ch<=
'Z'))||
482 ((
'0'<=
Ch)&&(
Ch<=
'9'))||(
Ch==
'_')||(
Ch==
'.')||(
Ch==
':')||(
Ch==
'-')){
485 EThrow(
"Invalid version-number character.");
497 if ((
Ch!=
'\'')&&(
Ch!=
'"')){
EThrow(
"Quote character (' or \") expected.");}
500 if (((
'a'<=
Ch)&&(
Ch<=
'z'))||((
'A'<=
Ch)&&(
Ch<=
'Z'))){EncNmChA+=
Ch;}
501 else {
EThrow(
"Invalid encoding-name character.");}
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.");}
517 if ((
Ch!=
'\'')&&(
Ch!=
'"')){
EThrow(
"Quote character (' or \") expected.");}
521 if ((
'a'<=
Ch)&&(
Ch<=
'z')){StalChA+=
Ch;}
522 else {
EThrow(
"Invalid standalone-value character.");}
526 TStr StalVal=StalChA;
527 if ((StalVal==
"yes")||(StalVal==
"no")){
return StalVal;}
536 if (VerVal!=
"1.0"){
EThrow(
"Invalid XML version.");}
556 else {
EThrow(
"Invalid end-of-tag in XML-declaration.");}
558 EThrow(
"Invalid end-of-tag in XML-declaration.");
586 if ((
Ch!=
'\'')&&(
Ch!=
'"')){
EThrow(
"Quote character (' or \") expected.");}
599 if ((
Ch!=
'\'')&&(
Ch!=
'"')){
EThrow(
"Quote character (' or \") expected.");}
613 if (ExtIdNm==
"SYSTEM"){
615 }
else if (ExtIdNm==
"PUBLIC"){
618 EThrow(
"Invalid external-id ('SYSTEM' or 'PUBLIC' expected).");
652 else {
EThrow(
"Invalid end-of-tag in document-type-declaration.");}
678 if ((QCh!=
'"')&&(QCh!=
'\'')){
EThrow(
"Invalid entity-value start.");}
698 if ((
Ch==
'\"')||(
Ch==
'\'')){
709 if ((
Ch==
'\"')||(
Ch==
'\'')){
718 else {
EThrow(
"Invalid end-of-tag in entity-declaration.");}
739 else {
EThrow(
"Invalid start of CDATA section.");}
788 else {
EThrow(
"Invalid End-Tag.");}
792 while ((
Ch!=
'>')&&(
Ch!=
'/')){
801 else {
EThrow(
"Invalid Empty-Element-Tag.");}
826 EThrow(
"Forbidden substring ']]>' in character data.");}
839 SymChA=
"{Undef}";
break;
843 SymChA+=
"<!--"; SymChA+=
TxtChA; SymChA+=
"-->";
break;
845 SymChA+=
"<?"; SymChA+=
TagNm;
846 for (
int ArgN=0; ArgN<
GetArgs(); ArgN++){
849 SymChA+=
' '; SymChA+=ArgNm; SymChA+=
'=';
850 SymChA+=ArgValQCh; SymChA+=ArgVal; SymChA+=ArgValQCh;
852 SymChA+=
"?>";
break;}
854 SymChA+=
"<?"; SymChA+=
TagNm;
858 SymChA+=
"<!DOCTYPE "; SymChA+=
TagNm; SymChA+=
">";
break;
861 SymChA+=
"<"; SymChA+=
TagNm;
862 for (
int ArgN=0; ArgN<
GetArgs(); ArgN++){
865 SymChA+=
' '; SymChA+=ArgNm; SymChA+=
'=';
866 SymChA+=ArgValQCh; SymChA+=ArgVal; SymChA+=ArgValQCh;
873 SymChA+=
"</"; SymChA+=
TagNm; SymChA+=
">";
break;
875 SymChA=
"{String:'"; SymChA+=
TxtChA; SymChA+=
"'}";
break;
877 SymChA=
"{QString:'"; SymChA+=
TxtChA; SymChA+=
"'}";
break;
879 SymChA=
"{Eof}";
break;
887 FPosChA+=
" [File:"; FPosChA+=
SIn->
GetSNm();
891 TStr FullMsgStr=MsgStr+FPosChA;
897 FPosChA+=
" [File:"; FPosChA+=
SIn->
GetSNm();
907 case xsyWs:
return "White-Space";
910 case xsyPI:
return "PI";
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";
930 if (TXmlLx::ChDef.IsFirstNameCh(ChA[0])){
932 if (!TXmlLx::ChDef.IsName(ChA[
ChN])){
949 if ((
' '<=Ch)&&(Ch<=
'~')){
951 case '"': XmlChA+=
""";
break;
952 case '&': XmlChA+=
"&";
break;
953 case '\'': XmlChA+=
"'";
break;
954 case '<': XmlChA+=
"<";
break;
955 case '>': XmlChA+=
">";
break;
959 if ((Ch==
'\r')||(Ch==
'\n')){
962 XmlChA+=
'&'; XmlChA+=
'#'; XmlChA+=
TUInt::GetStr(Ch); XmlChA+=
';';
972 if ((
' '<=Ch)&&(Ch<=
'~')){
974 case '"': XmlChA+=
""";
break;
975 case '&': XmlChA+=
"&";
break;
976 case '\'': XmlChA+=
"'";
break;
977 case '<': XmlChA+=
"<";
break;
978 case '>': XmlChA+=
">";
break;
982 if ((Ch==
'\r')||(Ch==
'\n')){
985 XmlChA+=
'&'; XmlChA+=
'#'; XmlChA+=
TUInt::GetStr(Ch); XmlChA+=
';';
1000 if (Ch.
GetCh()==
'#'){
1002 TChA RefChA;
int RefCd=0;
1003 if (Ch.
GetCh()==
'x'){
1026 if ((!RefChA.
Empty())&&(
Ch()==
';')){
1040 while ((!Ch.
Eof())&&(
Ch()!=
';')){
1042 if ((!EntityNm.
Empty())&&(
Ch()==
';')){
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+=
'>';}
1057 TStr UsAsciiStr=XmlStr;
1066 char Ch=UsAsciiChA[
ChN];
1067 if ((Ch<
' ')||(
'~'<
Ch)){UsAsciiChA.
PutCh(
ChN,
'x');}
1073 TStr ChRefStr=YuEntRefStr;
1095 const TStr& ArgNm,
const TStr& TrueVal,
const bool& DfVal)
const {
1097 return (ArgN==-1) ? DfVal : (
ArgNmValV[ArgN].Dat==TrueVal);
1101 const TStr& TrueVal,
const TStr& FalseVal,
const bool& DfVal)
const {
1103 if (ArgN==-1){
return DfVal;}
1105 if (ArgVal==TrueVal){
return true;}
1106 IAssert(ArgVal == FalseVal);
return false;
1115 if (
ArgNmValV[ArgN].Dat.IsInt(Val)){
return Val;}
else {
return DfVal;}
1125 if (
ArgNmValV[ArgN].Dat.IsFlt(Val)){
return Val;}
else {
return DfVal;}
1131 return (ArgN==-1) ? DfVal :
ArgNmValV[ArgN].Dat;
1143 if (TagPath.
Empty()){
1148 for (
int SubTokN=0; SubTokN<
SubTokV.
Len(); SubTokN++){
1153 if ((SubTok.
Empty())||(RestTagPath.
Empty())){
return SubTok;}
1154 else {
return SubTok->
GetTagTok(RestTagPath);}
1163 for (
int SubTokN=0; SubTokN<Tok->
GetSubToks(); SubTokN++){
1166 XmlTokV.
Add(SubTok);}
1175 for (
int SubTokN=0; SubTokN<
GetSubToks(); SubTokN++){
1182 if (ValV.
Len()>0){
return ValV[0];}
else {
return "";}
1192 if (XmlP){ChA+=
"<![CDATA[";}
1194 if (XmlP){ChA+=
"]]>";}
break;
1198 for (
int ArgN=0; ArgN<
GetArgs(); ArgN++){
1202 ChA+=
' '; ChA+=ArgNm; ChA+=
'=';
1203 ChA+=ArgValQCh; ChA+=ArgVal; ChA+=ArgValQCh;
1207 if (XmlP){ChA+=
"/>";}
1209 if (XmlP){ChA+=
">";}
1210 for (
int SubTokN=0; SubTokN<
GetSubToks(); SubTokN++){
1212 if (XmlP){ChA+=
"</"; ChA+=
Str; ChA+=
'>';}
1221 for (
int TokN=0; TokN<TokV.
Len(); TokN++){
1222 if (TokN>0){TokVChA+=
' ';}
1223 TokVChA+=TokV[TokN]->GetTokStr(XmlP);
1237 default:
Fail;
return NULL;
1264 "' ('"+Tok->
GetStr()+
"' expected).";
1280 default: Lx.
EThrow(
"Content or End-Tag expected.");
1282 if (!SubTok.
Empty()){
1289 TStr(
"Xml-Element (Start-Tag or Empty-Element-Tag) required.")+
1293 Lx.
EThrow(
"Xml-Element (Start-Tag or Empty-Element-Tag) required.");
1299 if (TagPath.
Empty()){
1304 if (RestTagPath.
Empty()){
return Tok;}
1324 for (
int SubTokN=0; SubTokN<Tok->
GetSubToks(); SubTokN++){
1327 XmlTokV.
Add(SubTok);}
1333 const TStr& TagPath,
const TStr& ArgNm,
const bool& DfVal)
const {
1337 else {
return DfVal;}
1341 const TStr& TagPath,
const TStr& ArgNm,
const int& DfVal)
const {
1345 else {
return DfVal;}
1349 const TStr& TagPath,
const TStr& ArgNm,
const double& DfVal)
const {
1353 else {
return DfVal;}
1357 const TStr& TagPath,
const TStr& ArgNm,
const TStr& DfVal)
const {
1361 else {
return DfVal;}
1367 for (
int ChN=0; ChN<ChA.
Len(); ChN++){
1369 if ((
' '<=Ch)&&(Ch<=
'~')){
1370 if (Ch==
'&'){XmlChA+=
"&";}
1371 else if (Ch==
'>'){XmlChA+=
"<";}
1372 else if (Ch==
'<'){XmlChA+=
">";}
1373 else if (Ch==
'\''){XmlChA+=
"'";}
1374 else if (Ch==
'\"'){XmlChA+=
""";}
1413 Doc->Ok=
true; Doc->MsgStr=
"Ok";
1416 Doc->Ok=
false; Doc->MsgStr=Except->GetMsgStr();
1438 if (XmlDoc->IsOk()){XmlDocV.
Add(XmlDoc);}
1473 if (StrLen > 1 &&
SymStr[StrLen-1] ==
'/') {
1532 static TChA EntityNm;
1534 const char *Ch = XmlStr.
CStr();
1536 if (*Ch!=
'&'){ PlainChA+=*Ch; Ch++; }
1539 TChA RefChA;
int RefCd=0;
1547 else {
break; } Ch++; }
1549 if ((!RefChA.
Empty())&&(*Ch==
';')){
1550 Ch++;
const uchar RefCh=
uchar(RefCd); PlainChA+=RefCh; }
1553 while ((*Ch)&&(*Ch!=
';')){EntityNm+=*Ch; Ch++;}
1554 if ((!EntityNm.
Empty())&&(*Ch==
';')){ Ch++;
1555 if (EntityNm==
"quot"){PlainChA+=
'"';}
1556 else if (EntityNm==
"amp"){PlainChA+=
'&';}
1557 else if (EntityNm==
"apos"){PlainChA+=
'\'';}
1558 else if (EntityNm==
"lt"){PlainChA+=
'<';}
1559 else if (EntityNm==
"gt"){PlainChA+=
'>';}
static bool IsHex(const char &Ch)
void SaveTxt(const PSOut &SOut)
void SkipTillTag(const TChA &_SymStr)
void PutSubTok(const PXmlTok &Tok, const int &SubTokN=-1)
bool IsChar(const uchar &Ch) const
void GetTagValV(const TStr &TagNm, const bool &XmlP, TStrV &ValV) const
void GetArg(const int &ArgN, TStr &ArgNm, TStr &ArgVal) const
void GetArg(const int &ArgN, TStr &ArgNm, TStr &ArgVal) const
bool IsInt(const bool &Check, const int &MnVal, const int &MxVal, int &Val) const
TStr GetTagTokStrArgVal(const TStr &TagPath, const TStr &ArgNm, const TStr &DfVal=TStr()) const
bool GetTagTokBoolArgVal(const TStr &TagPath, const TStr &ArgNm, const bool &DfVal=false) const
bool IsPEntityNm(const TStr &EntityNm, TStr &EntityVal) const
static TStr GetChRefFromYuEntRef(const TStr &YuEntRefStr)
static bool IsNum(const char &Ch)
static TStr GetXmlLxSymStr(const TXmlLxSym &XmlLxSym)
virtual int PutCh(const char &Ch)=0
static TStr GetUsAsciiStrFromXmlStr(const TStr &EntRefStr)
void AddArg(const TStr &ArgNm, const TStr &ArgVal)
static TStr GetTagNm(const TStr &TypeNm)
void PutCh(const int &ChN, const char &Ch)
void GetWs(const bool &IsRq)
TSizeTy Len() const
Returns the number of elements in the vector.
double GetFltArgVal(const TStr &ArgNm, const double &DfVal=0) const
static TStr GetPlainStrFromXmlStr(const TStr &XmlStr)
static TStr GetXmlStrFromPlainMem(const TMem &PlainMem)
static int GetHex(const char &Ch)
bool IsEntityNm(const TStr &EntityNm, TStr &EntityVal) const
bool IsFirstNameCh(const uchar &Ch) const
PXmlTok GetSubTok(const int &SubTokN) const
static int64 GetInt64Arg(const PXmlTok &XmlTok, const TStr &Nm)
void SetChTy(TBSet &ChSet, const int &MnCh, const int &MxCh=-1)
int GetTagTokIntArgVal(const TStr &TagPath, const TStr &ArgNm, const int &DfVal=0) const
static PSOut New(const int &MxBfL=1024)
void GetTagTokV(const TStr &TagPath, TXmlTokV &XmlTokV) const
void EThrow(const TStr &MsgStr) const
static PXmlDoc LoadStr(const TStr &Str)
bool IsTagTok(const TStr &TagPath, PXmlTok &TagTok) const
TStr GetTokStr(const bool &XmlP=true) const
void PutEntityVal(const TStr &Nm, const TStr &Val)
void SplitOnCh(TStr &LStr, const char &SplitCh, TStr &RStr) const
double GetTagTokFltArgVal(const TStr &TagPath, const TStr &ArgNm, const double &DfVal=0) const
static bool GetBoolArg(const PXmlTok &XmlTok, const TStr &Nm)
void Incl(const int &BitN)
static PSIn New(const TStr &FNm)
bool IsPubid(const uchar &Ch) const
static bool IsWs(const char &Ch)
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
int ChangeStrAll(const TStr &SrcStr, const TStr &DstStr, const bool &FromStartP=false)
TXmlLxSym GetTag(const TChA &TagStr)
void AddSubTok(const PXmlTok &Tok)
static void Throw(const TStr &MsgStr)
bool IsBool(bool &Val) const
void AddTokToChA(const bool &XmlP, TChA &ChA) const
static PSIn New(const TStr &Str)
static int GetNum(const char &Ch)
static TStr GetTokVStr(const TXmlTokV &TokV, const bool &XmlP=true)
TXmlObjSerTagNm(TSOut &_SOut, const bool &ETagP, const TStr &Nm, const TStr &TypeNm, const TStr &ArgNm="", const TStr &ArgVal="")
static double GetFltArg(const PXmlTok &XmlTok, const TStr &Nm)
int GetIntArgVal(const TStr &ArgNm, const int &DfVal=0) const
void PutPEntityVal(const TStr &Nm, const TStr &Val)
void SetEntityVal(const TStr &Nm, const TStr &Val)
static char GetArgValQCh(const TStr &ArgVal)
void Gen(const int &_Bits)
bool IsArg(const TStr &ArgNm) const
bool GetBoolArgVal(const TStr &ArgNm, const bool &DfVal=false) const
PXmlTok GetTagTok(const TStr &TagPath) const
static PXmlTok GetTok(TXmlLx &Lx)
static int GetIntArg(const PXmlTok &XmlTok, const TStr &Nm)
bool IsName(const uchar &Ch) const
static TStr GetXmlStr(const TStr &Str)
bool IsFlt(const bool &Check, const double &MnVal, const double &MxVal, double &Val, const char &DecDelimCh='.') const
PXmlTok GetTagTok(const TStr &TagPath) const
static bool IsTagNm(const TStr &Str)
static bool SkipTopTag(const PSIn &SIn)
static TStr Fmt(const char *FmtStr,...)
int PutStr(const char *CStr)
void GetTagTokV(const TStr &TagPath, TXmlTokV &XmlTokV) const
TSizeTy SearchForw(const TVal &Val, const TSizeTy &BValN=0) const
Returns the position of an element with value Val.
#define EAssertR(Cond, MsgStr)
static PXmlDoc LoadTxt(TXmlLx &Lx)
static void GetPlainStrFromXmlStr(const TChA &XmlStr, TChA &PlainChA)
virtual TStr GetSNm() const
void Push(const char &Ch)
static PXmlTok LoadTxtElement(TXmlLx &Lx)
void PutTagTokStr(const TStr &TagPath, const TStr &TokStr) const
bool IsEntityNm(const TStr &EntityNm, TStr &EntityVal) const
int EncodeUtf8(const TIntV &src, TIntV &dest) const
TStr GetTagVal(const TStr &TagNm, const bool &XmlP) const
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
void SplitOnLastCh(TStr &LStr, const char &SplitCh, TStr &RStr) const
static void AssertXmlHd(const PXmlTok &XmlTok, const TStr &Nm, const TStr &TypeNm)
static void LoadTxtMiscStar(TXmlLx &Lx)
bool IsWs(const uchar &Ch) const
static const TStr TrueStr
TDat & AddDat(const TKey &Key)
bool IsInt64(const bool &Check, const int64 &MnVal, const int64 &MxVal, int64 &Val) const
static TStrStrH TypeNmToTagNmH
TKeyDat< TStr, TStr > TStrKd
void GetTagVal(const TChA &TagStr, TChA &TagVal)
TStr GetStrArgVal(const TStr &ArgNm, const TStr &DfVal=TStr()) const
static TStr GetXmlStrFromPlainStr(const TChA &PlainChA)