37 static inline char*
Name(
void* arg) {
return (
char*)arg +
sizeof(SXmlAttr_t); }
54 SXmlNode_t *fLastChild;
58 static inline char*
Name(
void* arg) {
return (
char*)arg +
sizeof(SXmlNode_t); }
62 SXmlNode_t *fRootNode;
67 class TXMLOutputStream {
78 TXMLOutputStream(
const char* filename,
Int_t bufsize = 20000)
80 fOut =
new std::ofstream(filename);
94 fBuf = (
char*)
malloc(bufsize);
96 fMaxAddr = fBuf + bufsize;
97 fLimitAddr = fBuf + int(bufsize*0.75);
100 virtual ~TXMLOutputStream()
102 if (fCurrent!=fBuf) OutputCurrent();
109 if (fCurrent!=fBuf) {
111 fOut->write(fBuf, fCurrent-fBuf);
113 fOutStr->
Append(fBuf, fCurrent-fBuf);
118 void OutputChar(
char symb)
120 if (fOut!=0) fOut->put(symb);
else
121 if (fOutStr!=0) fOutStr->
Append(symb);
124 void Write(
const char* str)
126 int len = strlen(str);
127 if (fCurrent+len>=fMaxAddr) {
129 fOut->write(str,len);
132 *fCurrent++ = *str++;
133 if (fCurrent>fLimitAddr)
138 void Put(
char symb,
Int_t cnt=1)
140 if (fCurrent+cnt>=fMaxAddr)
142 if (fCurrent+cnt>=fMaxAddr)
148 if (fCurrent>fLimitAddr)
154 class TXMLEntity :
public TNamed {
159 Bool_t IsSystem()
const {
return fSystem; }
163 class TXMLInputStream {
185 TXMLInputStream(
Bool_t isfilename,
const char* filename,
Int_t ibufsize) :
199 fInp =
new std::ifstream(filename);
205 fInpStrLen = filename==0 ? 0 : strlen(filename);
209 fBuf = (
char*)
malloc(fBufSize);
214 int len = DoRead(fBuf, fBufSize);
217 fLimitAddr = fBuf + int(len*0.75);
225 virtual ~TXMLInputStream()
227 delete fInp; fInp = 0;
228 free(fBuf); fBuf = 0;
231 inline Bool_t EndOfFile() {
return (fInp!=0) ? fInp->eof() : (fInpStrLen<=0); }
233 inline Bool_t EndOfStream() {
return EndOfFile() && (fCurrent>=fMaxAddr); }
235 void AddEntity(TXMLEntity* ent) { fEntities.
Add(ent); }
237 Int_t NumEntities()
const {
return fEntities.
GetLast() + 1; }
239 TXMLEntity* FindEntity(
const char* beg,
Int_t len)
241 if (len<=0)
return 0;
243 TXMLEntity* entity = (TXMLEntity*) fEntities[
n];
244 if ((
Int_t) strlen(entity->GetName()) != len)
continue;
245 if (strncmp(beg, entity->GetName(), len)==0)
return entity;
251 int DoRead(
char* buf,
int maxsize)
253 if (EndOfFile())
return 0;
255 fInp->get(buf, maxsize, 0);
256 maxsize = strlen(buf);
258 if (maxsize>fInpStrLen) maxsize = fInpStrLen;
259 strncpy(buf, fInpStr, maxsize);
268 if (EndOfFile())
return kFALSE;
270 int curlength = fMaxAddr - fBuf;
271 char* newbuf = (
char*) realloc(fBuf, fBufSize);
272 if (newbuf==0)
return kFALSE;
274 fMaxAddr = newbuf + (fMaxAddr - fBuf);
275 fCurrent = newbuf + (fCurrent - fBuf);
276 fLimitAddr = newbuf + (fLimitAddr - fBuf);
279 int len = DoRead(fMaxAddr, fBufSize-curlength);
280 if (len==0)
return kFALSE;
282 fLimitAddr += int(len*0.75);
288 if (fCurrent<fLimitAddr)
return kTRUE;
289 if (EndOfFile())
return kTRUE;
290 int rest_len = fMaxAddr - fCurrent;
291 memmove(fBuf, fCurrent, rest_len);
292 int read_len = DoRead(fBuf + rest_len, fBufSize - rest_len);
295 fMaxAddr = fBuf + rest_len + read_len;
296 fLimitAddr = fBuf + int((rest_len + read_len)*0.75);
300 Int_t TotalPos() {
return fTotalPos; }
302 Int_t CurrentLine() {
return fCurrentLine; }
306 for(
int n=0;
n<sz;
n++) {
307 if (*fCurrent==10) fCurrentLine++;
308 if (fCurrent>=fLimitAddr) {
310 if (fCurrent>=fMaxAddr)
return kFALSE;
320 while (fCurrent<fMaxAddr) {
321 char symb = *fCurrent;
322 if ((symb>26) && (symb!=
' '))
return kTRUE;
324 if (!ShiftCurrent())
return kFALSE;
326 if (tillendl && (symb==10))
return kTRUE;
331 Bool_t CheckFor(
const char* str)
334 int len = strlen(str);
335 while (fCurrent+len>fMaxAddr)
336 if (!ExpandStream())
return kFALSE;
337 char* curr = fCurrent;
339 if (*str++ != *curr++)
return kFALSE;
340 return ShiftCurrent(len);
343 Int_t SearchFor(
const char* str)
347 int len = strlen(str);
349 char* curr = fCurrent;
353 while (curr+len>fMaxAddr)
354 if (!ExpandStream())
return -1;
356 const char* chk = str;
359 if (*chk++ != *chk0++) { find =
kFALSE;
break; }
361 if (find)
return curr - fCurrent;
362 }
while (curr<fMaxAddr);
366 #define GoodStartSymbol(symb) \
367 (((symb>='a') && (symb<='z')) || ((symb>='A') && (symb<='Z')) || (symb=='_') || \
368 ((symb>=0xc0) && (symb<=0xd6)) || ((symb>=0xd8) && (symb<=0xf6)) || (symb>0xf8))
370 Int_t LocateIdentifier()
372 unsigned char symb = (
unsigned char) *fCurrent;
377 char* curr = fCurrent;
382 if (!ExpandStream())
return 0;
383 symb = (
unsigned char) *curr;
385 ((symb>=
'0') && (symb<=
'9')) || (symb==
':') || (symb==
'-') || (symb==
'.') || (symb==0xb7);
386 if (!ok)
return curr-fCurrent;
387 }
while (curr<fMaxAddr);
391 Int_t LocateContent()
393 char* curr = fCurrent;
394 while (curr<fMaxAddr) {
396 if (symb==
'<')
return curr - fCurrent;
399 if (!ExpandStream())
return -1;
404 Int_t LocateValue(
char* start,
bool withequalsign =
true)
408 if (!ExpandStream())
return 0;
410 if (*curr!=
'=')
return 0;
413 if (!ExpandStream())
return 0;
415 if ((*curr!=
'\"') && (*curr!=
'\''))
return 0;
420 if (!ExpandStream())
return 0;
421 if (*curr==quote)
return curr-start+1;
422 }
while (curr<fMaxAddr);
448 if ((xmlnode==0) || (name==0))
return kFALSE;
449 SXmlAttr_t*
attr = ((SXmlNode_t*)xmlnode)->fAttr;
462 if (xmlnode==0)
return 0;
463 SXmlAttr_t*
attr = ((SXmlNode_t*)xmlnode)->fAttr;
477 if (xmlnode==0)
return 0;
480 if (attr) sscanf(attr,
"%d", &res);
491 if (xmlnode==0)
return 0;
493 int namelen(name != 0 ? strlen(name) : 0);
494 int valuelen(value != 0 ? strlen(value) : 0);
499 strncpy(attrname, name, namelen+1);
502 attrname += (namelen + 1);
504 strncpy(attrname, value, valuelen+1);
519 sprintf(sbuf,
"%d",value);
520 return NewAttr(xmlnode, 0, name, sbuf);
528 if (xmlnode==0)
return;
529 SXmlAttr_t*
attr = ((SXmlNode_t*) xmlnode)->fAttr;
530 SXmlAttr_t* prev = 0;
534 prev->fNext = attr->fNext;
536 ((SXmlNode_t*) xmlnode)->fAttr = attr->fNext;
552 if (xmlnode==0)
return;
554 SXmlNode_t* node = (SXmlNode_t*) xmlnode;
555 SXmlAttr_t*
attr = node->fAttr;
557 SXmlAttr_t*
next = attr->fNext;
570 if (xmlnode==0)
return 0;
571 SXmlNode_t* node = (SXmlNode_t*) xmlnode;
573 SXmlAttr_t*
attr = node->fAttr;
574 if ((attr!=0) && (node->fNs==
attr)) attr = attr->fNext;
584 if (xmlattr==0)
return 0;
594 if (xmlattr==0)
return 0;
605 if (xmlattr==0)
return 0;
608 return attrname + strlen(attrname) + 1;
615 const char*
name,
const char* content)
617 int namelen(name!=0 ? strlen(name) : 0);
619 SXmlNode_t* node = (SXmlNode_t*)
AllocateNode(namelen, parent);
626 node->fNs = (SXmlAttr_t*) ns;
627 int contlen = (content!=0) ? strlen(content) : 0;
629 SXmlNode_t* contnode = (SXmlNode_t*)
AllocateNode(contlen, node);
643 SXmlNode_t* node = (SXmlNode_t*) xmlnode;
645 int namelen = strlen(name);
646 char* nsname =
new char[namelen+7];
647 snprintf(nsname, namelen+7,
"xmlns:%s", name);
649 SXmlAttr_t* first = node->fAttr;
652 SXmlAttr_t* nsattr = (SXmlAttr_t*)
NewAttr(xmlnode, 0, nsname, reference);
654 node->fAttr = nsattr;
655 nsattr->fNext = first;
667 if (xmlnode==0)
return 0;
668 SXmlNode_t* node = (SXmlNode_t*) xmlnode;
680 if ((nsname!=0) && (strncmp(nsname,
"xmlns:",6)==0)) nsname+=6;
699 if ((parent==0) || (child==0))
return;
700 SXmlNode_t* pnode = (SXmlNode_t*) parent;
701 SXmlNode_t* cnode = (SXmlNode_t*) child;
702 cnode->fParent = pnode;
703 if (pnode->fLastChild==0) {
704 pnode->fChild = cnode;
705 pnode->fLastChild = cnode;
709 pnode->fLastChild->fNext = cnode;
710 pnode->fLastChild = cnode;
719 if ((parent==0) || (child==0))
return;
720 SXmlNode_t* pnode = (SXmlNode_t*) parent;
721 SXmlNode_t* cnode = (SXmlNode_t*) child;
722 cnode->fParent = pnode;
724 cnode->fNext = pnode->fChild;
725 pnode->fChild = cnode;
727 if (pnode->fLastChild==0) pnode->fLastChild = cnode;
736 if ((xmlnode==0) || (comment==0))
return kFALSE;
738 int commentlen = strlen(comment);
740 SXmlNode_t* node = (SXmlNode_t*)
AllocateNode(commentlen, xmlnode);
752 if (xmldoc==0)
return kFALSE;
771 if ((xmlnode==0) || (line==0))
return kFALSE;
773 int linelen = strlen(line);
774 SXmlNode_t* node = (SXmlNode_t*)
AllocateNode(linelen, xmlnode);
816 if ((xmlnode==0) || (href==0) || (type==0))
return kFALSE;
818 const char* nodename =
"xml-stylesheet";
819 int nodenamelen = strlen(nodename);
821 SXmlNode_t* node = (SXmlNode_t*)
AllocateNode(nodenamelen, xmlnode);
826 NewAttr(node, 0,
"alternate", (alternate>0) ?
"yes" :
"no");
828 if (title!=0)
NewAttr(node, 0,
"title", title);
830 NewAttr(node, 0,
"href", href);
831 NewAttr(node, 0,
"type", type);
833 if (media!=0)
NewAttr(node, 0,
"media", media);
834 if (charset!=0)
NewAttr(node, 0,
"charset", charset);
851 if (xmldoc==0)
return kFALSE;
857 href,type,title,alternate,media,charset);
869 if (xmlnode==0)
return;
870 SXmlNode_t* node = (SXmlNode_t*) xmlnode;
872 SXmlNode_t* parent = node->fParent;
874 if (parent==0)
return;
876 if (parent->fChild==node) {
877 parent->fChild = node->fNext;
878 if (parent->fLastChild==node)
879 parent->fLastChild = node->fNext;
881 SXmlNode_t* ch = parent->fChild;
882 while (ch->fNext!=node) ch = ch->fNext;
883 ch->fNext = node->fNext;
884 if (parent->fLastChild == node)
885 parent->fLastChild = ch;
895 if (xmlnode==0)
return;
896 SXmlNode_t* node = (SXmlNode_t*) xmlnode;
898 SXmlNode_t* child = node->fChild;
900 SXmlNode_t*
next = child->fNext;
905 SXmlAttr_t*
attr = node->fAttr;
907 SXmlAttr_t*
next = attr->fNext;
940 if (xmlnode==0)
return 0;
941 SXmlNode_t* node = (SXmlNode_t*) xmlnode;
942 if (node->fChild == 0)
return 0;
955 if (xmlnode==0)
return;
956 SXmlNode_t* node = (SXmlNode_t*) xmlnode;
957 if ((node->fChild != 0) && (node->fChild->fType ==
kXML_CONTENT))
960 if (content==0)
return;
961 if (len<=0) len = strlen(content);
963 SXmlNode_t* contnode = (SXmlNode_t*)
AllocateNode(len, 0);
966 strncpy(nameptr, content, len);
979 if ((xmlnode==0) || (content==0))
return;
980 if (len<=0) len = strlen(content);
982 SXmlNode_t* contnode = (SXmlNode_t*)
AllocateNode(len, xmlnode);
985 strncpy(nameptr, content, len);
1006 return xmlnode==0 ? 0 : (
XMLNodePointer_t) ((SXmlNode_t*) xmlnode)->fParent;
1016 xmlnode = xmlnode==0 ? 0 : (
XMLNodePointer_t) ((SXmlNode_t*) xmlnode)->fNext;
1017 if ((xmlnode==0) || !realnode)
return xmlnode;
1018 }
while (((SXmlNode_t*) xmlnode)->fType !=
kXML_NODE);
1030 xmlnode = xmlnode==0 ? 0 : (
XMLNodePointer_t) ((SXmlNode_t*) xmlnode)->fNext;
1031 if ((xmlnode==0) || !realnode)
return;
1032 }
while (((SXmlNode_t*) xmlnode)->fType !=
kXML_NODE);
1040 return xmlnode==0 ?
kFALSE : (((SXmlNode_t*) xmlnode)->fType ==
kXML_NODE);
1048 return xmlnode==0 ?
kTRUE : (((SXmlNode_t*) xmlnode)->fType !=
kXML_NODE);
1082 if (xmlnode==0)
return;
1083 SXmlNode_t* node = (SXmlNode_t*) xmlnode;
1085 SXmlNode_t* child = node->fChild;
1087 SXmlNode_t*
next = child->fNext;
1093 node->fLastChild = 0;
1101 SXmlDoc_t* doc =
new SXmlDoc_t;
1102 doc->fRootNode = (SXmlNode_t*)
NewChild(0, 0,
"??DummyTopNode??", 0);
1107 NewAttr(vernode, 0,
"version", version);
1120 if (xmldoc==0)
return;
1121 SXmlDoc_t* doc = (SXmlDoc_t*) xmldoc;
1122 delete[] doc->fDtdName;
1123 doc->fDtdName =
Makestr(dtdname);
1124 delete[] doc->fDtdRoot;
1125 doc->fDtdRoot =
Makestr(rootname);
1133 if (xmldoc==0)
return;
1134 SXmlDoc_t* doc = (SXmlDoc_t*) xmldoc;
1136 delete[] doc->fDtdName;
1137 delete[] doc->fDtdRoot;
1150 if (xmldoc==0)
return;
1152 SXmlDoc_t* doc = (SXmlDoc_t*) xmldoc;
1154 TXMLOutputStream
out(filename, 100000);
1170 if (xmldoc==0)
return;
1182 if (xmldoc==0)
return 0;
1198 if ((filename==0) || (strlen(filename)==0))
return 0;
1199 if (maxbuf < 100000) maxbuf = 100000;
1200 TXMLInputStream inp(
true, filename, maxbuf);
1209 if ((xmlstring==0) || (strlen(xmlstring)==0))
return 0;
1210 TXMLInputStream inp(
false, xmlstring, 2*strlen(xmlstring) );
1219 if (inp == 0)
return 0;
1228 ReadNode(((SXmlDoc_t*) xmldoc)->fRootNode, inp, resvalue);
1230 if (resvalue!=2)
break;
1233 if (!inp->EndOfStream()) inp->SkipSpaces();
1235 if (inp->EndOfStream()) {
1255 if (xmldoc==0)
return kFALSE;
1258 if (vernode==0)
return kFALSE;
1264 if (value==0)
return kFALSE;
1265 if (version==0) version =
"1.0";
1267 return strcmp(version,value)==0;
1279 if ((res==0) || (xmlnode==0))
return;
1281 TXMLOutputStream
out(res, 10000);
1283 SaveNode(xmlnode, &out, layout, 0);
1291 if (src==0)
return 0;
1293 TXMLInputStream inp(
false, src, 10000);
1313 if (str==0)
return 0;
1314 int len = strlen(str);
1315 if (len==0)
return 0;
1316 char* res =
new char[len+1];
1317 strncpy(res, str, len+1);
1326 if ((str==0) || (len==0))
return 0;
1327 char* res =
new char[len+1];
1328 strncpy(res, str, len);
1340 SXmlNode_t* node = (SXmlNode_t*)
malloc(
sizeof(SXmlNode_t) + namelen + 1);
1347 node->fLastChild = 0;
1363 SXmlAttr_t*
attr = (SXmlAttr_t*)
malloc(
sizeof(SXmlAttr_t) + namelen + 1 + valuelen + 1);
1365 SXmlNode_t* node = (SXmlNode_t*) xmlnode;
1372 SXmlAttr_t* d = node->fAttr;
1373 while (d->fNext!=0) d = d->fNext;
1385 SXmlNode_t* node = (SXmlNode_t*) xmlnode;
1389 if (strcmp(nsname, name)==0)
return node->fNs;
1391 node = node->fParent;
1401 SXmlNode_t* node = (SXmlNode_t*) xmlnode;
1402 if (node==0)
return;
1404 if (colon==0)
return;
1409 *(copyname++) = *(++colon);
1420 if ((srclen>3) && (*(source+1)==
'l') && (*(source+2)==
't') && (*(source+3)==
';')) {
1421 *target++ =
'<'; source+=4; srclen-=4;
1423 if ((srclen>3) && (*(source+1)==
'g') && (*(source+2)==
't') && (*(source+3)==
';')) {
1424 *target++ =
'>'; source+=4; srclen-=4;
1426 if ((srclen>4) && (*(source+1)==
'a') && (*(source+2)==
'm') && (*(source+3)==
'p') && (*(source+4)==
';')) {
1427 *target++ =
'&'; source+=5; srclen-=5;
1429 if ((srclen>5) && (*(source+1)==
'q') && (*(source+2)==
'u') && (*(source+3)==
'o') && (*(source+4)==
't') && (*(source+5)==
';')) {
1430 *target++ =
'\"'; source+=6; srclen-=6;
1432 if ((srclen>5) && (*(source+1)==
'a') && (*(source+2)==
'p') && (*(source+3)==
'o') && (*(source+4)==
's') && (*(source+5)==
';')) {
1433 *target++ =
'\''; source+=6; srclen-=6;
1435 *target++ = *source++; srclen--;
1438 *target++ = *source++;
1452 if (value==0)
return;
1456 while ((find=strpbrk(last,
"<&>\"")) !=0 ) {
1462 if (symb==
'<') out->Write(
"<");
1463 else if (symb==
'>') out->Write(
">");
1464 else if (symb==
'&') out->Write(
"&");
1465 else if (symb==
'\'') out->Write(
"'");
1466 else out->Write(
""");
1477 if (xmlnode==0)
return;
1478 SXmlNode_t* node = (SXmlNode_t*) xmlnode;
1480 Bool_t issingleline = (node->fChild==0);
1482 if (layout>0) out->Put(
' ', level);
1488 if (layout>0) out->Put(
'\n');
1493 if (layout>0) out->Put(
'\n');
1498 if (layout>0) out->Put(
'\n');
1506 if ((node->fNs!=0) && (node->fNs!=node->fAttr)) {
1512 SXmlAttr_t*
attr = node->fAttr;
1516 out->Write(attrname);
1518 attrname += strlen(attrname) + 1;
1527 else out->Write(
"/>");
1528 if (layout>0) out->Put(
'\n');
1534 SXmlNode_t* child = node->fChild;
1536 if ((child!=0) && (child->fType ==
kXML_CONTENT) && (child->fNext == 0)) {
1540 if (layout>0) out->Put(
'\n');
1543 child = child->fNext;
1546 if (layout>0) out->Put(
' ',level);
1551 if ((node->fNs!=0) && (node->fNs!=node->fAttr)) {
1557 if (layout>0) out->Put(
'\n');
1571 if (inp==0)
return 0;
1572 if (!inp->SkipSpaces()) { resvalue = -1;
return 0; }
1573 SXmlNode_t* parent = (SXmlNode_t*) xmlparent;
1575 SXmlNode_t* node = 0;
1578 while (inp->CheckFor(
"<!--")) {
1579 Int_t commentlen = inp->SearchFor(
"-->");
1580 if (commentlen<=0) { resvalue = -10;
return 0; }
1583 node = (SXmlNode_t*)
AllocateNode(commentlen, xmlparent);
1586 strncpy(nameptr, inp->fCurrent, commentlen);
1587 nameptr+=commentlen;
1591 if (!inp->ShiftCurrent(commentlen+3)) { resvalue = -1;
return node; }
1592 if (!inp->SkipSpaces()) { resvalue = -1;
return node; }
1598 if (*inp->fCurrent!=
'<') {
1601 if (parent==0) { resvalue = -2;
return 0; }
1602 int contlen = inp->LocateContent();
1603 if (contlen<0)
return 0;
1605 SXmlNode_t* contnode = (SXmlNode_t*)
AllocateNode(contlen, xmlparent);
1609 if (!inp->ShiftCurrent(contlen))
return 0;
1611 if (inp->NumEntities() <= 0) {
1618 const char* beg(0), *lastentity(0), *curr(contptr);
1620 while (*curr != 0) {
1621 if ((beg==0) && (*curr==
'&')) beg = curr;
1622 if ((beg==0) || (*curr!=
';')) { curr++;
continue; }
1624 TXMLEntity* entity = inp->FindEntity(beg+1, curr - beg - 1);
1628 if (lastentity==0) {
1629 lastentity = contptr;
1633 if (lastentity!=beg)
1637 if (entity->IsSystem()) {
1639 if (entitydoc == 0) {
1646 while (topnode!=0) {
1663 if (lastentity!=0) {
1675 if (!inp->ShiftCurrent())
return 0;
1678 if (*inp->fCurrent==
'/') {
1680 if (!inp->ShiftCurrent())
return 0;
1681 if (!inp->SkipSpaces())
return 0;
1682 Int_t len = inp->LocateIdentifier();
1683 if (len<=0) { resvalue = -3;
return 0; }
1685 if (parent==0) { resvalue = -4;
return 0; }
1692 if (!inp->ShiftCurrent(len))
return 0;
1694 if (!inp->SkipSpaces())
return 0;
1695 if (*inp->fCurrent!=
'>')
return 0;
1696 if (!inp->ShiftCurrent())
return 0;
1701 inp->SkipSpaces(
kTRUE);
1706 if (*inp->fCurrent==
'!') {
1708 if (!inp->ShiftCurrent())
return 0;
1709 if (!inp->CheckFor(
"DOCTYPE")) { resvalue = -12;
return 0; }
1710 if (!inp->SkipSpaces()) { resvalue = -13;
return 0; }
1713 Int_t len = inp->LocateIdentifier();
1714 if (len<=0) { resvalue = -13;
return 0; }
1715 if (!inp->ShiftCurrent(len)) { resvalue = -13;
return 0; }
1716 if (!inp->SkipSpaces()) { resvalue = -13;
return 0; }
1719 if (inp->CheckFor(
"[")) {
1720 if (!inp->SkipSpaces())
return 0;
1722 if (inp->CheckFor(
"<!ENTITY")) {
1724 if (!inp->SkipSpaces()) { resvalue = -13;
return 0; }
1725 Int_t namelen = inp->LocateIdentifier();
1726 if (namelen<=0) { resvalue = -13;
return 0; }
1727 TString entity_name(inp->fCurrent, namelen);
1728 if (!inp->ShiftCurrent(namelen)) { resvalue = -13;
return 0; }
1729 if (!inp->SkipSpaces()) { resvalue = -13;
return 0; }
1731 if (inp->CheckFor(
"SYSTEM")) {
1732 if (!inp->SkipSpaces()) { resvalue = -13;
return 0; }
1736 char* valuestart = inp->fCurrent;
1737 Int_t valuelen = inp->LocateValue(valuestart,
false);
1738 if (valuelen < 2) { resvalue = -13;
return 0; }
1740 TString entity_value(valuestart+1, valuelen-2);
1742 if (!inp->ShiftCurrent(valuelen)) { resvalue = -13;
return 0; }
1744 if (*inp->fCurrent!=
'>') { resvalue = -13;
return 0; }
1745 if (!inp->ShiftCurrent()) { resvalue = -13;
return 0; }
1748 inp->AddEntity(
new TXMLEntity(entity_name, entity_value, is_system));
1754 if (inp->CheckFor(
"<!ELEMENT")) {
1756 if (!inp->SkipSpaces()) { resvalue = -13;
return 0; }
1757 Int_t namelen = inp->LocateIdentifier();
1758 if (namelen<=0) { resvalue = -13;
return 0; }
1760 if (!inp->ShiftCurrent(namelen)) { resvalue = -13;
return 0; }
1761 if (!inp->SkipSpaces()) { resvalue = -13;
return 0; }
1763 if (!inp->CheckFor(
"(")) { resvalue = -13;
return 0; }
1764 if (inp->SearchFor(
")")<=0) { resvalue = -13;
return 0; }
1767 if (*inp->fCurrent!=
'>') { resvalue = -13;
return 0; }
1768 if (!inp->ShiftCurrent()) { resvalue = -13;
return 0; }
1777 if (!inp->CheckFor(
"]")) { resvalue = -13;
return 0; }
1780 if (!inp->CheckFor(
">")) { resvalue = -13;
return 0; }
1789 Bool_t canhaschildren =
true;
1790 char endsymbol =
'/';
1793 if (*inp->fCurrent==
'?') {
1794 if (!inp->ShiftCurrent())
return 0;
1796 canhaschildren =
false;
1800 if (!inp->SkipSpaces())
return 0;
1801 Int_t len = inp->LocateIdentifier();
1802 if (len<=0)
return 0;
1805 node->fType = nodetype;
1807 strncpy(nameptr, inp->fCurrent, len);
1812 if ((colon!=0) && (parent!=0)) {
1818 if (!inp->ShiftCurrent(len))
return 0;
1821 if (!inp->SkipSpaces())
return 0;
1823 char nextsymb = *inp->fCurrent;
1825 if (nextsymb==endsymbol) {
1826 if (!inp->ShiftCurrent())
return 0;
1827 if (*inp->fCurrent==
'>') {
1828 if (!inp->ShiftCurrent())
return 0;
1833 inp->SkipSpaces(
kTRUE);
1838 if (nextsymb==
'>') {
1839 if (!canhaschildren) { resvalue = -11;
return 0; }
1841 if (!inp->ShiftCurrent())
return 0;
1845 }
while (resvalue==2);
1852 Int_t attrlen = inp->LocateIdentifier();
1853 if (attrlen<=0) { resvalue = -6;
return 0; }
1855 char* valuestart = inp->fCurrent+attrlen;
1857 int valuelen = inp->LocateValue(valuestart,
true);
1858 if (valuelen<3) { resvalue = -7;
return 0; }
1863 strncpy(attrname, inp->fCurrent, attrlen);
1869 if (!inp->ShiftCurrent(attrlen+valuelen))
return 0;
1873 if ((strlen(attrname)>6) && (strstr(attrname,
"xmlns:")==attrname)) {
1896 case -14:
Error(
"ParseFile",
"Error include external XML file at line %d", linenumber);
break;
1897 case -13:
Error(
"ParseFile",
"Error processing DTD part of XML file at line %d", linenumber);
break;
1898 case -12:
Error(
"ParseFile",
"DOCTYPE missing after <! at line %d", linenumber);
break;
1899 case -11:
Error(
"ParseFile",
"Node cannot be closed with > symbol at line %d, for instance <?xml ... ?> node", linenumber);
break;
1900 case -10:
Error(
"ParseFile",
"Error in xml comments definition at line %d, must be <!-- comments -->", linenumber);
break;
1901 case -9:
Error(
"ParseFile",
"Multiple name space definitions not allowed, line %d", linenumber);
break;
1902 case -8:
Error(
"ParseFile",
"Invalid namespace specification, line %d", linenumber);
break;
1903 case -7:
Error(
"ParseFile",
"Invalid attribute value, line %d", linenumber);
break;
1904 case -6:
Error(
"ParseFile",
"Invalid identifier for node attribute, line %d", linenumber);
break;
1905 case -5:
Error(
"ParseFile",
"Mismatch between open and close nodes, line %d", linenumber);
break;
1906 case -4:
Error(
"ParseFile",
"Unexpected close node, line %d", linenumber);
break;
1907 case -3:
Error(
"ParseFile",
"Valid identifier for close node is missing, line %d", linenumber);
break;
1908 case -2:
Error(
"ParseFile",
"No multiple content entries allowed, line %d", linenumber);
break;
1909 case -1:
Error(
"ParseFile",
"Unexpected end of xml file");
break;
1910 default:
Error(
"ParseFile",
"XML syntax error at line %d", linenumber);
break;
char * Makestr(const char *str)
creates char* variable with copy of provided string
XMLDocPointer_t ParseStream(TXMLInputStream *input)
parses content of the stream and tries to produce xml structures
void FreeAttr(XMLNodePointer_t xmlnode, const char *name)
remove attribute from xmlnode
XMLNsPointer_t GetNS(XMLNodePointer_t xmlnode)
return namespace attribute (if exists)
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
Int_t GetLast() const
Return index of last object in array.
void SaveNode(XMLNodePointer_t xmlnode, TXMLOutputStream *out, Int_t layout, Int_t level)
stream data of xmlnode to output
Bool_t AddStyleSheet(XMLNodePointer_t parent, const char *href, const char *type="text/css", const char *title=0, int alternate=-1, const char *media=0, const char *charset=0)
Adds style sheet definition to the specified node Creates
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
XMLDocPointer_t NewDoc(const char *version="1.0")
creates new xml document with provided version
#define GoodStartSymbol(symb)
static const char * filename()
TXMLEngine()
if true, do not create comments nodes in document during parsing
XMLNodePointer_t GetNext(XMLNodePointer_t xmlnode, Bool_t realnode=kTRUE)
return next to xmlnode node if realnode==kTRUE, any special nodes in between will be skipped ...
Bool_t AddComment(XMLNodePointer_t parent, const char *comment)
Adds comment line to the node.
XMLNsPointer_t FindNs(XMLNodePointer_t xmlnode, const char *nsname)
define if namespace of that name exists for xmlnode
XMLAttrPointer_t GetNextAttr(XMLAttrPointer_t xmlattr)
return next attribute in the list
void FreeDoc(XMLDocPointer_t xmldoc)
frees allocated document data and deletes document itself
void UnlinkFreeNode(XMLNodePointer_t xmlnode)
combined operation. Unlink node and free used memory
XMLAttrPointer_t NewIntAttr(XMLNodePointer_t xmlnode, const char *name, Int_t value)
create node attribute with integer value
const char * GetNodeContent(XMLNodePointer_t xmlnode)
get contents (if any) of xml node
void DisplayError(Int_t error, Int_t linenumber)
Displays xml parsing error.
void FreeAllAttr(XMLNodePointer_t xmlnode)
Free all attributes of the node.
Vc_ALWAYS_INLINE void free(T *p)
Frees memory that was allocated with Vc::malloc.
The TNamed class is the base class for all named ROOT classes.
void DocSetRootElement(XMLDocPointer_t xmldoc, XMLNodePointer_t xmlnode)
set main (root) node for document
void Init(TClassEdit::TInterpreterLookupHelper *helper)
XMLNsPointer_t NewNS(XMLNodePointer_t xmlnode, const char *reference, const char *name=0)
create namespace attribute for xmlnode.
TString & Append(const char *cs)
XMLDocPointer_t ParseString(const char *xmlstring)
parses content of string and tries to produce xml structures
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Bool_t IsEmptyNode(XMLNodePointer_t xmlnode)
return kTRUE is this is node with special data like comments to data processing instructions ...
const char * GetNodeName(XMLNodePointer_t xmlnode)
returns name of xmlnode
XMLAttrPointer_t AllocateAttr(int namelen, int valuelen, XMLNodePointer_t xmlnode)
Allocate new attribute with specified name length and value length.
void SaveDoc(XMLDocPointer_t xmldoc, const char *filename, Int_t layout=1)
store document content to file if layout<=0, no any spaces or newlines will be placed between xmlnode...
void AddChild(XMLNodePointer_t parent, XMLNodePointer_t child)
add child element to xmlnode
void ShiftToNext(XMLNodePointer_t &xmlnode, Bool_t realnode=kTRUE)
shifts specified node to next if realnode==kTRUE, any special nodes in between will be skipped ...
Bool_t AddRawLine(XMLNodePointer_t parent, const char *line)
Add just line into xml file Line should has correct xml syntax that later it can be decoded by xml pa...
void SetNodeContent(XMLNodePointer_t xmlnode, const char *content, Int_t len=0)
set content of the xml node if old node content was exists, it will be replaced
char * Makenstr(const char *start, int len)
creates char* variable with copy of len symbols from provided string
Bool_t IsCommentNode(XMLNodePointer_t xmlnode)
return kTRUE is this is special node with content
const char * GetAttrValue(XMLAttrPointer_t xmlattr)
return value of attribute
XMLAttrPointer_t GetFirstAttr(XMLNodePointer_t xmlnode)
return first attribute in the list, namespace (if exists) will be skiped
Bool_t AddDocStyleSheet(XMLDocPointer_t xmldoc, const char *href, const char *type="text/css", const char *title=0, int alternate=-1, const char *media=0, const char *charset=0)
Add style sheet definition on the top of document.
void SkipEmpty(XMLNodePointer_t &xmlnode)
Skip all current empty nodes and locate on first "true" node.
Bool_t IsXmlNode(XMLNodePointer_t xmlnode)
return kTRUE is this is normal xml node
Bool_t HasAttr(XMLNodePointer_t xmlnode, const char *name)
checks if node has attribute of specified name
Bool_t AddDocRawLine(XMLDocPointer_t xmldoc, const char *line)
Add just line on the top of xml document Line should has correct xml syntax that later it can be deco...
XMLDocPointer_t ParseFile(const char *filename, Int_t maxbuf=100000)
Parses content of file and tries to produce xml structures.
void AddChildFirst(XMLNodePointer_t parent, XMLNodePointer_t child)
add node as first child
XMLAttrPointer_t NewAttr(XMLNodePointer_t xmlnode, XMLNsPointer_t, const char *name, const char *value)
creates new attribute for xmlnode, namespaces are not supported for attributes
void CleanNode(XMLNodePointer_t xmlnode)
remove all children node from xmlnode
const char * GetAttr(XMLNodePointer_t xmlnode, const char *name)
returns value of attribute for xmlnode
void SaveSingleNode(XMLNodePointer_t xmlnode, TString *res, Int_t layout=1)
convert single xml node (and its child node) to string if layout<=0, no any spaces or newlines will b...
Bool_t AddDocComment(XMLDocPointer_t xmldoc, const char *comment)
add comment line to the top of the document
void TruncateNsExtension(XMLNodePointer_t xmlnode)
removes namespace extension of nodename
void FreeNode(XMLNodePointer_t xmlnode)
release all memory, allocated fro this node and destroyes node itself
XMLNodePointer_t ReadNode(XMLNodePointer_t xmlparent, TXMLInputStream *inp, Int_t &resvalue)
Tries to construct xml node from input stream.
Bool_t ValidateVersion(XMLDocPointer_t doc, const char *version=0)
check that first node is xml processing instruction with correct xml version number ...
XMLNodePointer_t GetChild(XMLNodePointer_t xmlnode, Bool_t realnode=kTRUE)
returns first child of xml node
XMLNodePointer_t GetParent(XMLNodePointer_t xmlnode)
returns parent of xmlnode
void UnpackSpecialCharacters(char *target, const char *source, int srclen)
unpack special symbols, used in xml syntax to code characters these symbols: '<' - <, '>' - >, '&' - &, '"...
const char * GetNSName(XMLNsPointer_t ns)
return name id of namespace
XMLNodePointer_t NewChild(XMLNodePointer_t parent, XMLNsPointer_t ns, const char *name, const char *content=0)
create new child element for parent node
XMLNodePointer_t DocGetRootElement(XMLDocPointer_t xmldoc)
returns root node of document
void UnlinkNode(XMLNodePointer_t node)
unlink (dettach) xml node from parent
Int_t GetIntAttr(XMLNodePointer_t node, const char *name)
returns value of attribute as integer
Bool_t IsContentNode(XMLNodePointer_t xmlnode)
return kTRUE is this is special node with content
void AddNodeContent(XMLNodePointer_t xmlnode, const char *content, Int_t len=0)
add new content of the xml node old content will be preserved, one could mix content with child nodes...
XMLNodePointer_t ReadSingleNode(const char *src)
read single xml node from provided string
virtual ~TXMLEngine()
destructor for TXMLEngine object
void OutputValue(char *value, TXMLOutputStream *out)
output value to output stream if symbols '<' '&' '>' '"' ''' appears in the string, they will be encoded to appropriate xml symbols: <, &, >, ", &apos
Vc_ALWAYS_INLINE_L T *Vc_ALWAYS_INLINE_R malloc(size_t n)
Allocates memory on the Heap with alignment and padding suitable for vectorized access.
const char * GetAttrName(XMLAttrPointer_t xmlattr)
return name of the attribute
XMLNodePointer_t AllocateNode(int namelen, XMLNodePointer_t parent)
Allocates new xml node with specified namelength.
const char * GetNSReference(XMLNsPointer_t ns)
return reference id of namespace
void AssignDtd(XMLDocPointer_t xmldoc, const char *dtdname, const char *rootname)
assignes dtd filename to document