PTLib  Version 2.18.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pxml.h
Go to the documentation of this file.
1 /*
2  * pxml.h
3  *
4  * XML parser support
5  *
6  * Portable Windows Library
7  *
8  * Copyright (c) 2002 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Portable Windows Library.
21  *
22  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23  *
24  * Contributor(s): ______________________________________.
25  */
26 
27 #ifndef PTLIB_PXML_H
28 #define PTLIB_PXML_H
29 
30 #ifdef P_USE_PRAGMA
31 #pragma interface
32 #endif
33 
34 #include <ptlib.h>
35 
36 #ifdef P_EXPAT
37 
38 #include <ptlib/bitwise_enum.h>
39 #include <ptclib/http.h>
40 
41 
42 class PXMLElement;
43 class PXMLRootElement;
44 
45 
47 
48 class PXMLBase : public PObject
49 {
50  PCLASSINFO(PXMLBase, PObject);
51  public:
52  enum {
54  };
55 
57  Options,
58  8,
59  (
60  NoOptions,
61  Indent,
62  IndentWithTabs,
63  NewLineAfterElement,
64  NoIgnoreWhiteSpace,
65  CloseExtended,
66  WithNS,
67  FragmentOnly,
68  ExpandEntities
69  ),
70  AllOptions = (1<<8)-1
71  );
72 
78  };
79 
80  PXMLBase(Options opts = NoOptions);
81 
82  void SetOptions(Options opts) { m_options = opts; }
83  Options GetOptions() const { return m_options; }
84 
85  void SetMaxEntityLength(unsigned len) { m_maxEntityLength = len; }
86  unsigned GetMaxEntityLength() const { return m_maxEntityLength; }
87 
88  virtual PBoolean IsNoIndentElement(const PString & /*elementName*/) const
89  { return false; }
90 
91  virtual bool OutputProgress() const { return true; }
92 
93  bool OutputIndent(ostream & strm, int indent, const PString & elementName = PString::Empty()) const;
94 
95  protected:
96  Options m_options;
98 };
99 
100 
101 class PXML : public PXMLBase
102 {
103  PCLASSINFO(PXML, PXMLBase);
104  public:
105  PXML(
106  Options options = NoOptions,
107  const char * noIndentElements = NULL,
108  const char * defaultEncoding = NULL
109  );
110  PXML(const PXML & xml);
111  ~PXML();
112 
113  void ReadFrom(istream & strm);
114  void PrintOn(ostream & strm) const;
115  PString AsString() const;
116 
117  bool IsDirty() const;
118 
119  bool Load(const PString & data);
120  bool Load(const PString & data, Options options, const char * defaultEncoding = NULL);
121  bool LoadFile(const PFilePath & fn);
122  bool LoadFile(const PFilePath & fn, Options options);
123 
124  virtual bool OnLoadProgress(unsigned /*percent*/) const { return true; }
125  virtual void OnLoaded() { }
126 
127  bool Save();
128  bool Save(Options options);
129  PString AsString();
130  PString AsString(Options options);
131  bool SaveFile(const PFilePath & fn);
132  bool SaveFile(const PFilePath & fn, Options options);
133  virtual bool OnSaveProgress(unsigned /*percent*/) const { return true; }
134  virtual bool OutputProgress() const;
135 
136  virtual PINDEX GetObjectCount() const;
137 
138  void RemoveAll();
139 
140  virtual PBoolean IsNoIndentElement(
141  const PString & elementName
142  ) const;
143 
144 
145  virtual PXMLElement * CreateElement(const PCaselessString & name, const char * data = NULL);
146  virtual PXMLRootElement * CreateRootElement(const PCaselessString & name);
147 
148  PXMLElement * GetElement(const PCaselessString & name, const PCaselessString & attr, const PString & attrval) const;
149  PXMLElement * GetElement(const PCaselessString & name, PINDEX idx = 0) const;
150  PXMLElement * GetElement(PINDEX idx) const;
151  PINDEX GetNumElements() const;
153  PXMLElement * SetRootElement(const PString & documentType);
154 
155 
175 
180  };
181 
185  };
186 
187  struct ValidationInfo {
189  const char * m_name;
190 
191  union {
192  const void * m_placeHolder;
193  const char * m_attributeValues;
195  const char * m_namespace;
196  };
197 
198  PINDEX m_minCount;
199  PINDEX m_maxCount;
200  };
201 
202  bool Validate(const ValidationInfo * validator);
203  bool ValidateElements(ValidationContext & context, PXMLElement * baseElement, const ValidationInfo * elements);
204  bool ValidateElement(ValidationContext & context, PXMLElement * element, const ValidationInfo * elements);
205  bool LoadAndValidate(const PString & body, const PXML::ValidationInfo * validator, PString & error, Options options = NoOptions);
206 
207  const PCaselessString & GetVersion() const { return m_version; }
208  const PCaselessString & GetEncoding() const { return m_encoding; }
210 
211  bool IsLoaded() const { return m_rootElement != NULL; }
213 
215  const PCaselessString & GetDocType() const { return m_docType; }
216  const PCaselessString & GetPubicIdentifier() const { return m_publicId; }
217  const PCaselessString & GetDtdURI() const { return m_dtdURI; }
218 
220  unsigned GetErrorColumn() const { return m_errorColumn; }
221  unsigned GetErrorLine() const { return m_errorLine; }
222 
223  static PString EscapeSpecialChars(const PString & string);
224 
225  protected:
227 
234 
236 
238  unsigned m_errorLine;
239  unsigned m_errorColumn;
240 
242 
244 
246  mutable PINDEX m_savedObjects;
247  mutable unsigned m_percent;
248 
249  friend class PXMLParser;
250 };
251 
252 
253 #if P_HTTP
254 class PXML_HTTP : public PXML
255 {
256  PCLASSINFO(PXML_HTTP, PXML);
257  public:
258  PXML_HTTP(
259  Options options = NoOptions,
260  const char * noIndentElements = NULL
261  );
262 
263  bool StartAutoReloadURL(
264  const PURL & url,
265  const PTimeInterval & timeout,
266  const PTimeInterval & refreshTime,
267  Options options = NoOptions
268  );
269  bool StopAutoReloadURL();
271  bool AutoLoadURL();
272  virtual void OnAutoLoad(PBoolean ok);
273 
274  bool LoadURL(const PURL & url);
275  bool LoadURL(const PURL & url, const PTimeInterval & timeout, Options options = NoOptions);
276  bool LoadURL(const PURL & url, const PURL::LoadParams & params, Options options = NoOptions);
277 
278  protected:
279  PDECLARE_NOTIFIER(PTimer, PXML_HTTP, AutoReloadTimeout);
280  PDECLARE_NOTIFIER(PThread, PXML_HTTP, AutoReloadThread);
281 
285  PDECLARE_MUTEX(m_autoLoadMutex);
287 };
288 #endif // P_HTTP
289 
290 
292 
293 class PConfig; // stupid gcc 4 does not recognize PConfig as a class
294 
295 class PXMLSettings : public PXML
296 {
297  PCLASSINFO(PXMLSettings, PXML);
298  public:
299  PXMLSettings(Options options = NewLineAfterElement);
300 
301  void SetAttribute(const PCaselessString & section, const PString & key, const PString & value);
302 
303  PString GetAttribute(const PCaselessString & section, const PString & key) const;
304  bool HasAttribute(const PCaselessString & section, const PString & key) const;
305 
306  void ToConfig(PConfig & cfg) const;
307  void FromConfig(const PConfig & cfg);
308 };
309 
310 
312 
313 class PXMLObject : public PObject
314 {
315  PCLASSINFO(PXMLObject, PObject);
316  protected:
317  PXMLObject();
318 
319  public:
321  { return m_parent; }
322 
323  bool SetParent(PXMLElement * parent);
324 
325  virtual PINDEX GetObjectCount() const { return 1; }
326 
327  PXMLObject * GetNextObject() const;
328 
329  PString AsString() const;
330 
331  virtual void Output(ostream & strm, const PXMLBase & xml, int indent) const = 0;
332 
333  virtual PBoolean IsElement() const = 0;
334 
335  void SetDirty();
336  bool IsDirty() const { return m_dirty; }
337 
338  void GetFilePosition(unsigned & col, unsigned & line) const { col = m_column; line = m_lineNumber; }
339  void SetFilePosition(unsigned col, unsigned line) { m_column = col; m_lineNumber = line; }
340 
341  virtual PXMLObject * Clone() const = 0;
342 
343 #if PTRACING
344  struct PrintTraceClass
345  {
346  const PXMLObject * m_object;
347  PrintTraceClass(const PXMLObject * object) : m_object(object) { }
348  };
349  friend ostream & operator<<(ostream & strm, const PrintTraceClass & e);
350  PrintTraceClass PrintTrace() { return PXMLObject::PrintTraceClass(this); }
351  static PrintTraceClass PrintTrace(PXMLObject * obj) { return PrintTraceClass(obj); }
352 #endif
353 
354  protected:
356  bool m_dirty;
357  unsigned m_lineNumber;
358  unsigned m_column;
359 #if PTRACING
360  virtual void InternalPrintTrace(ostream & strm) const = 0;
361 #endif
362 
364 };
365 
366 PARRAY(PXMLObjectArray, PXMLObject);
367 
369 
370 class PXMLData : public PXMLObject
371 {
372  PCLASSINFO(PXMLData, PXMLObject);
373  public:
374  PXMLData(const PString & data);
375  PXMLData(const char * data, int len);
376 
377  PBoolean IsElement() const { return false; }
378 
379  void SetString(const PString & str, bool dirty = true);
380 
381  const PString & GetString() const { return m_value; }
382 
383  void Output(ostream & strm, const PXMLBase & xml, int indent) const;
384 
385  PXMLObject * Clone() const;
386 
387  protected:
389 
390 #if PTRACING
391  virtual void InternalPrintTrace(ostream & strm) const;
392 #endif
393 };
394 
395 
397 
398 class PXMLElement : public PXMLObject
399 {
400  PCLASSINFO(PXMLElement, PXMLObject);
401  protected:
402  PXMLElement(const PXMLElement & copy);
403  public:
404  PXMLElement(const char * name = NULL, const char * data = NULL);
405 
406  virtual PINDEX GetObjectCount() const;
407 
408  PBoolean IsElement() const { return true; }
409 
410  void PrintOn(ostream & strm) const;
411  void Output(ostream & strm, const PXMLBase & xml, int indent) const;
412 
413  const PCaselessString & GetName() const
414  { return m_name; }
415 
416  void SetName(const PString & v)
417  { m_name = v; }
418 
424 
425  PINDEX GetSize() const
426  { return m_subObjects.GetSize(); }
427 
428  PINDEX FindObject(const PXMLObject * ptr) const;
429 
430  bool HasSubObjects() const
431  { return !m_subObjects.IsEmpty(); }
432 
433  virtual PXMLObject * AddSubObject(PXMLObject * elem, bool dirty = true);
434  bool RemoveSubObject(PINDEX idx, bool dispose = true);
435 
436  virtual PXMLElement * CreateElement(const PCaselessString & name, const char * data = NULL);
437 
438  PXMLElement * AddElement(const char * name);
439  PXMLElement * AddElement(const PString & name, const PString & data);
440  PXMLElement * AddElement(const PString & name, const PString & attrName, const PString & attrVal);
441 
442  void SetAttribute(const PCaselessString & key,
443  const PString & value,
444  bool setDirty = true);
445 
446  PString GetAttribute(const PCaselessString & key) const;
447  bool HasAttribute(const PCaselessString & key) const;
448  bool HasAttributes() const { return m_attributes.GetSize() > 0; }
449  const PStringToString & GetAttributes() const { return m_attributes; }
450 
451  PXMLObject * GetSubObject(PINDEX idx) const;
452  PXMLElement * GetElement(PINDEX idx = 0) const;
453  PXMLElement * GetElement(const PCaselessString & name, PINDEX idx = 0) const;
454  PXMLElement * GetElement(const PCaselessString & name, const PCaselessString & attr, const PString & attrval) const;
455 
456  template <class T> T * GetElementAs(PINDEX idx = 0) const { return dynamic_cast<T *>(GetElement(idx)); }
457  template <class T> T * GetElementAs(const PCaselessString & name, PINDEX idx = 0) const { return dynamic_cast<T *>(GetElement(name, idx)); }
458  template <class T> T * GetElementAs(const PCaselessString & name, const PCaselessString & attr, const PString & attrval) const { return dynamic_cast<T *>(GetElement(name, attr, attrval)); }
459 
460  PString GetData(bool trim = true) const;
461 
462  PXMLObjectArray GetSubObjects() const
463  { return m_subObjects; }
464 
465  void SetData(const PString & data);
466  virtual PXMLData * AddData(const PString & data);
467  virtual void EndData() { }
468 
469  PXMLObject * Clone() const;
470 
471  void AddNamespace(const PString & prefix, const PString & uri);
472  void RemoveNamespace(const PString & prefix);
473 
474  bool GetDefaultNamespace(PCaselessString & str) const;
475  bool GetNamespace(const PCaselessString & prefix, PCaselessString & str) const;
477  bool GetURIForNamespace(const PCaselessString & prefix, PCaselessString & uri) const;
478 
479  protected:
484 
486 
487 #if PTRACING
488  virtual void InternalPrintTrace(ostream & strm) const;
489 #endif
490 };
491 
492 
494 
496 {
497  PCLASSINFO(PXMLRootElement, PXMLElement);
498  public:
499  PXMLRootElement(PXML & doc, const char * name = NULL)
500  : PXMLElement(name)
501  , m_document(doc)
502  { }
503 
504  PXMLRootElement(PXML & doc, const PXMLElement & copy)
505  : PXMLElement(copy)
506  , m_document(doc)
507  { }
508 
509  virtual PObject * Clone();
510  virtual PXMLElement * CreateElement(const PCaselessString & name, const char * data = NULL);
511 
512  protected:
514 };
515 
516 
518 
520 {
521  protected:
522  PXMLParserBase(PXMLBase::Options options, const char * encoding);
523 
524  public:
525  ~PXMLParserBase();
526 
527  bool Parse(istream & strm);
528  bool Parse(const char * data, size_t dataLen, bool final);
529 
530  virtual void StartDocTypeDecl(const char * docType, const char * sysid, const char * pubid, int hasInternalSubSet);
531  virtual void EndDocTypeDecl();
532  virtual void XmlDecl(const char * version, const char * encoding, int standAlone);
533  virtual void StartNamespaceDeclHandler(const char * prefix, const char * uri);
534  virtual void EndNamespaceDeclHandler(const char * prefix);
535  virtual void StartElement(const char * name, const char **attrs) = 0;
536  virtual void EndElement(const char * name) = 0;
537  virtual void AddCharacterData(const char * data, int len) = 0;
538  virtual void Entity(const char *entityName,
539  int is_parameter_entity,
540  const char *value,
541  int value_length,
542  const char *base,
543  const char *systemId,
544  const char *publicId,
545  const char *notationName);
546 
547  virtual bool Progress() { return true; }
548 
549  void GetFilePosition(unsigned & col, unsigned & line) const;
550  void GetErrorInfo(PString & errorString, unsigned & errorCol, unsigned & errorLine) const;
551 
552  bool IsParsing() const { return m_parsing; }
553 
554  protected:
555  void * m_context;
556  bool m_parsing;
557  off_t m_total;
558  off_t m_consumed;
559  unsigned m_percent;
562 };
563 
564 
566 
567 class PXMLParser : public PXMLBase, public PXMLParserBase
568 {
569  PCLASSINFO(PXMLParser, PXMLBase);
570  public:
571  PXMLParser(
572  PXML & doc,
573  Options options,
574  off_t progressTotal
575  );
576 
577  virtual void StartDocTypeDecl(const char * docType, const char * sysid, const char * pubid, int hasInternalSubSet);
578  virtual void XmlDecl(const char * version, const char * encoding, int standAlone);
579  virtual void StartNamespaceDeclHandler(const char * prefix, const char * uri);
580  virtual void StartElement(const char * name, const char **attrs);
581  virtual void EndElement(const char * name);
582  virtual void AddCharacterData(const char * data, int len);
583 
584  virtual bool Progress();
585 
586  PXML & GetDocument() const { return m_document; }
587 
588  protected:
590 
594 };
595 
596 
598 
600 {
601  PCLASSINFO(PXMLStreamParser, PXMLParser);
602  public:
603  PXMLStreamParser(PXML & doc, Options options = NoOptions);
604 
605  virtual void EndElement(const char * name);
606  virtual PXMLElement * Read(PChannel * channel);
607 
608  protected:
610 };
611 
612 
613 #else
614 
615 namespace PXML {
616  extern PString EscapeSpecialChars(const PString & str);
617 };
618 
619 #endif // P_EXPAT
620 
621 #endif // PTLIB_PXML_H
622 
623 
624 // End Of File ///////////////////////////////////////////////////////////////
PString AsString() const
virtual PBoolean IsEmpty() const
Determine if the container is empty.
PXMLElement * m_parent
Definition: pxml.h:355
bool Save()
PXML & GetDocument() const
Definition: pxml.h:586
virtual PXMLObject * AddSubObject(PXMLObject *elem, bool dirty=true)
PCaselessString GetDocumentType() const
PXMLObject * Clone() const
Create a copy of the class on the heap.
PDECLARE_MUTEX(m_autoLoadMutex)
virtual bool Progress()
Definition: pxml.h:547
bool RemoveSubObject(PINDEX idx, bool dispose=true)
void SetFilePosition(unsigned col, unsigned line)
Definition: pxml.h:339
Definition: pxml.h:173
unsigned m_maxEntityLength
Definition: pxml.h:97
Definition: pxml.h:164
PTimer m_autoLoadTimer
Definition: pxml.h:282
const PCaselessString & GetDtdURI() const
Definition: pxml.h:217
Definition: pxml.h:169
PINDEX m_totalObjects
Definition: pxml.h:245
const PStringToString & GetAttributes() const
Definition: pxml.h:449
unsigned m_errorLine
Definition: pxml.h:238
PCaselessString PrependNamespace(const PCaselessString &name) const
This class defines an arbitrary time interval to millisecond accuracy.
Definition: timeint.h:51
void SetData(const PString &data)
virtual PINDEX GetSize() const
Get size of array.
virtual bool OnSaveProgress(unsigned) const
Definition: pxml.h:133
Definition: pxml.h:599
Definition: pxml.h:519
Definition: pxml.h:48
unsigned m_lineNumber
Definition: pxml.h:357
void FromConfig(const PConfig &cfg)
void GetFilePosition(unsigned &col, unsigned &line) const
Definition: pxml.h:338
const PCaselessString & GetName() const
Definition: pxml.h:413
virtual PXMLObject * Clone() const =0
Create a copy of the class on the heap.
unsigned GetErrorColumn() const
Definition: pxml.h:220
PFilePath m_loadFilename
Definition: pxml.h:226
PXMLObject * GetNextObject() const
void Output(ostream &strm, const PXMLBase &xml, int indent) const
unsigned GetErrorLine() const
Definition: pxml.h:221
ValidationOp m_op
Definition: pxml.h:188
virtual void AddCharacterData(const char *data, int len)=0
Definition: pxml.h:174
bool OutputIndent(ostream &strm, int indent, const PString &elementName=PString::Empty()) const
T * GetElementAs(const PCaselessString &name, const PCaselessString &attr, const PString &attrval) const
Definition: pxml.h:458
void SetAttribute(const PCaselessString &key, const PString &value, bool setDirty=true)
bool HasAttributes() const
Definition: pxml.h:448
PXMLObject * GetSubObject(PINDEX idx) const
Definition: pxml.h:158
PINDEX m_maxCount
Definition: pxml.h:199
void SetAttribute(const PCaselessString &section, const PString &key, const PString &value)
virtual void Output(ostream &strm, const PXMLBase &xml, int indent) const =0
const PCaselessString & GetEncoding() const
Definition: pxml.h:208
PString m_value
Definition: pxml.h:388
Definition: pxml.h:370
A class representing a configuration for the application.
Definition: config.h:62
ValidationOp
Definition: pxml.h:156
This class is a standard C++ stream class descendent for reading or writing streamed data to or from ...
Definition: pstring.h:2188
PString AsString() const
PINDEX m_minCount
Definition: pxml.h:198
This is a dictionary collection class of PString objects, keyed by another string.
Definition: pstring.h:3151
This class describes a full description for a file on the particular platform.
Definition: filepath.h:61
virtual void StartElement(const char *name, const char **attrs)=0
virtual PXMLElement * CreateElement(const PCaselessString &name, const char *data=NULL)
This class is a variation of a string that ignores case.
Definition: pstring.h:2012
Definition: pxml.h:182
PXMLBase(Options opts=NoOptions)
Definition: pxml.h:567
PXMLElement * AddElement(const char *name)
const PCaselessString & GetVersion() const
Definition: pxml.h:207
virtual void XmlDecl(const char *version, const char *encoding, int standAlone)
Definition: pxml.h:170
virtual PObject * Clone()
bool Validate(const ValidationInfo *validator)
PSortedStringList m_noIndentElements
Definition: pxml.h:241
off_t m_consumed
Definition: pxml.h:558
Options m_options
Definition: pxml.h:96
const char * m_attributeValues
Definition: pxml.h:193
Definition: pxml.h:187
bool m_expandEntities
Definition: pxml.h:561
ValidationInfo * m_subElement
Definition: pxml.h:194
StandAloneType m_standAlone
Definition: pxml.h:230
virtual void StartDocTypeDecl(const char *docType, const char *sysid, const char *pubid, int hasInternalSubSet)
virtual PINDEX GetObjectCount() const
PCaselessString m_docType
Definition: pxml.h:231
P_DECLARE_BITWISE_ENUM_EX(Options, 8,(NoOptions, Indent, IndentWithTabs, NewLineAfterElement, NoIgnoreWhiteSpace, CloseExtended, WithNS, FragmentOnly, ExpandEntities), AllOptions=(1<< 8)-1)
PXMLElement * GetElement(const PCaselessString &name, const PCaselessString &attr, const PString &attrval) const
PCaselessString m_dtdURI
Definition: pxml.h:233
PCaselessString m_publicId
Definition: pxml.h:232
virtual void Entity(const char *entityName, int is_parameter_entity, const char *value, int value_length, const char *base, const char *systemId, const char *publicId, const char *notationName)
PXMLElement * SetRootElement(PXMLRootElement *root)
bool StartAutoReloadURL(const PURL &url, const PTimeInterval &timeout, const PTimeInterval &refreshTime, Options options=NoOptions)
virtual void XmlDecl(const char *version, const char *encoding, int standAlone)
bool IsDirty() const
Definition: pxml.h:336
PINDEX GetSize() const
Definition: pxml.h:425
Definition: pxml.h:101
bool HasSubObjects() const
Definition: pxml.h:430
Definition: pxml.h:161
T * GetElementAs(const PCaselessString &name, PINDEX idx=0) const
Definition: pxml.h:457
PArray< PXMLObject > m_subObjects
Definition: pxml.h:485
virtual PXMLRootElement * CreateRootElement(const PCaselessString &name)
PINDEX FindObject(const PXMLObject *ptr) const
const char * m_name
Definition: pxml.h:189
PString m_autoLoadError
Definition: pxml.h:286
virtual void EndDocTypeDecl()
const PString & GetString() const
Definition: pxml.h:381
bool LoadAndValidate(const PString &body, const PXML::ValidationInfo *validator, PString &error, Options options=NoOptions)
PString GetAttribute(const PCaselessString &key) const
Definition: pxml.h:76
PXMLParser(PXML &doc, Options options, off_t progressTotal)
virtual void StartNamespaceDeclHandler(const char *prefix, const char *uri)
bool GetDefaultNamespace(PCaselessString &str) const
static PString EscapeSpecialChars(const PString &string)
PXMLRootElement(PXML &doc, const char *name=NULL)
Definition: pxml.h:499
PXMLRootElement * m_rootElement
Definition: pxml.h:235
PXMLRootElement * GetRootElement() const
Definition: pxml.h:212
virtual void StartDocTypeDecl(const char *docType, const char *sysid, const char *pubid, int hasInternalSubSet)
PStringToString m_nameSpaces
Definition: pxml.h:593
virtual void EndElement(const char *name)=0
Definition: pxml.h:295
bool IsDirty() const
PStringToString m_nameSpaces
Definition: pxml.h:184
This is a sorted list collection class of PString objects.
Definition: pstring.h:2703
PXMLSettings(Options options=NewLineAfterElement)
bool Load(const PString &data)
Definition: pxml.h:157
void RemoveAll()
bool m_userAborted
Definition: pxml.h:560
PXMLData(const PString &data)
PString GetData(bool trim=true) const
virtual void EndData()
Definition: pxml.h:467
friend ostream & operator<<(ostream &strm, const PObject &obj)
Global function for using the standard &lt;&lt; operator on objects descended from PObject.
Definition: object.h:2387
virtual bool OutputProgress() const
PXMLElement * GetElement(PINDEX idx=0) const
void ReadFrom(istream &strm)
Input the contents of the object from the stream.
Abstract class defining I/O channel semantics.
Definition: channel.h:103
virtual PBoolean IsNoIndentElement(const PString &) const
Definition: pxml.h:88
bool AutoLoadURL()
unsigned GetMaxEntityLength() const
Definition: pxml.h:86
void GetErrorInfo(PString &errorString, unsigned &errorCol, unsigned &errorLine) const
bool Parse(istream &strm)
virtual PINDEX GetSize() const
Get the current size of the container.
PXML(Options options=NoOptions, const char *noIndentElements=NULL, const char *defaultEncoding=NULL)
Definition: pxml.h:159
bool PBoolean
Definition: object.h:174
bool LoadURL(const PURL &url)
void RemoveNamespace(const PString &prefix)
PURL m_autoloadURL
Definition: pxml.h:283
virtual bool OnLoadProgress(unsigned) const
Definition: pxml.h:124
bool HasAttribute(const PCaselessString &section, const PString &key) const
void AddNamespace(const PString &prefix, const PString &uri)
#define PARRAY(cls, T)
Declare an array to a specific type of object.
Definition: array.h:985
PCaselessString m_defaultNameSpace
Definition: pxml.h:243
PCaselessString GetPathName() const
Get the completely qualified name for the element inside the XML tree, for example &quot;root:trunk:branch...
bool SaveFile(const PFilePath &fn)
PString GetErrorString() const
Definition: pxml.h:219
bool m_dirty
Definition: pxml.h:356
Definition: pxml.h:167
PXMLElement * GetParent() const
Definition: pxml.h:320
The character string class.
Definition: pstring.h:108
off_t m_total
Definition: pxml.h:557
PINDEX GetNumElements() const
void GetFilePosition(unsigned &col, unsigned &line) const
PCaselessString m_name
Definition: pxml.h:480
virtual PXMLElement * CreateElement(const PCaselessString &name, const char *data=NULL)
const PCaselessString & GetDocType() const
Definition: pxml.h:215
virtual void AddCharacterData(const char *data, int len)
PTimeInterval m_autoLoadWaitTime
Definition: pxml.h:284
void SetName(const PString &v)
Definition: pxml.h:416
void SetDirty()
Definition: pxml.h:398
PDECLARE_NOTIFIER(PTimer, PXML_HTTP, AutoReloadTimeout)
virtual void StartNamespaceDeclHandler(const char *prefix, const char *uri)
unsigned m_percent
Definition: pxml.h:247
virtual void StartElement(const char *name, const char **attrs)
const void * m_placeHolder
Definition: pxml.h:192
unsigned m_column
Definition: pxml.h:358
virtual void OnAutoLoad(PBoolean ok)
virtual void EndNamespaceDeclHandler(const char *prefix)
PXML & m_document
Definition: pxml.h:513
PXMLObject * Clone() const
Create a copy of the class on the heap.
This class defines a thread of execution in the system.
Definition: thread.h:66
bool IsLoaded() const
Definition: pxml.h:211
bool IsParsing() const
Definition: pxml.h:552
virtual void OnLoaded()
Definition: pxml.h:125
PXMLElement * m_currentElement
Definition: pxml.h:591
static const PString & Empty()
Return an empty string.
PXMLObjectArray GetSubObjects() const
Definition: pxml.h:462
virtual bool OutputProgress() const
Definition: pxml.h:91
virtual bool Progress()
bool LoadFile(const PFilePath &fn)
bool HasAttribute(const PCaselessString &key) const
PXML_HTTP(Options options=NoOptions, const char *noIndentElements=NULL)
PQueue< PXMLElement > messages
Definition: pxml.h:609
StandAloneType
Definition: pxml.h:73
PXMLElement(const PXMLElement &copy)
Definition: pxml.h:162
virtual PBoolean IsElement() const =0
PCaselessString m_defaultNamespace
Definition: pxml.h:483
void * m_context
Definition: pxml.h:555
PXMLStreamParser(PXML &doc, Options options=NoOptions)
bool ValidateElement(ValidationContext &context, PXMLElement *element, const ValidationInfo *elements)
PINDEX m_savedObjects
Definition: pxml.h:246
PXML & m_document
Definition: pxml.h:589
void Output(ostream &strm, const PXMLBase &xml, int indent) const
Definition: pxml.h:75
virtual PINDEX GetObjectCount() const
Definition: pxml.h:325
StandAloneType GetStandAlone() const
Definition: pxml.h:209
PXMLData * m_lastData
Definition: pxml.h:592
void SetMaxEntityLength(unsigned len)
Definition: pxml.h:85
virtual void EndElement(const char *name)
void ToConfig(PConfig &cfg) const
PBoolean IsElement() const
Definition: pxml.h:377
Options GetOptions() const
Definition: pxml.h:83
bool StopAutoReloadURL()
const PCaselessString & GetPubicIdentifier() const
Definition: pxml.h:216
virtual PBoolean IsNoIndentElement(const PString &elementName) const
Definition: pxml.h:168
PString GetAttribute(const PCaselessString &section, const PString &key) const
void SetOptions(Options opts)
Definition: pxml.h:82
virtual void EndElement(const char *name)
void SetString(const PString &str, bool dirty=true)
bool m_parsing
Definition: pxml.h:556
unsigned m_percent
Definition: pxml.h:559
Definition: pxml.h:77
Definition: pxml.h:163
PCaselessString m_version
Definition: pxml.h:228
PXMLParserBase(PXMLBase::Options options, const char *encoding)
PString GetAutoReloadStatus() const
P_REMOVE_VIRTUAL(PXMLObject *, Clone(PXMLElement *) const, 0)
PXMLRootElement(PXML &doc, const PXMLElement &copy)
Definition: pxml.h:504
PStringToString m_attributes
Definition: pxml.h:481
const char * m_namespace
Definition: pxml.h:195
Ultimate parent class for all objects in the class library.
Definition: object.h:2204
bool SetParent(PXMLElement *parent)
PCaselessString m_encoding
Definition: pxml.h:229
Definition: pxml.h:160
PStringStream m_errorString
Definition: pxml.h:237
bool GetNamespace(const PCaselessString &prefix, PCaselessString &str) const
This class describes a Universal Resource Locator.
Definition: url.h:56
void PrintOn(ostream &strm) const
Output the contents of the object to the stream.
bool ValidateElements(ValidationContext &context, PXMLElement *baseElement, const ValidationInfo *elements)
Definition: pxml.h:254
Definition: pxml.h:495
PString m_defaultNameSpace
Definition: pxml.h:183
Definition: pxml.h:313
PStringToString m_nameSpaces
Definition: pxml.h:482
virtual PXMLElement * Read(PChannel *channel)
Definition: url.h:345
virtual PINDEX GetObjectCount() const
T * GetElementAs(PINDEX idx=0) const
Definition: pxml.h:456
PBoolean IsElement() const
Definition: pxml.h:408
bool GetURIForNamespace(const PCaselessString &prefix, PCaselessString &uri) const
void PrintOn(ostream &strm) const
Output the contents of the object to the stream.
virtual PXMLData * AddData(const PString &data)
unsigned m_errorColumn
Definition: pxml.h:239
virtual PXMLElement * CreateElement(const PCaselessString &name, const char *data=NULL)