PTLib  Version 2.18.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PXML Class Reference

#include <pxml.h>

Inheritance diagram for PXML:
Collaboration diagram for PXML:

Classes

struct  ValidationContext
 
struct  ValidationInfo
 

Public Types

enum  ValidationOp {
  EndOfValidationList, DocType, ElementName, RequiredAttribute,
  RequiredNonEmptyAttribute, RequiredAttributeWithValue, RequiredElement, Subtree,
  RequiredAttributeWithValueMatching, RequiredElementWithBodyMatching, OptionalElement, OptionalAttribute,
  OptionalNonEmptyAttribute, OptionalAttributeWithValue, OptionalAttributeWithValueMatching, OptionalElementWithBodyMatching,
  SetDefaultNamespace, SetNamespace, RequiredAttributeWithValueMatchingEx = RequiredAttributeWithValueMatching + 0x8000, OptionalAttributeWithValueMatchingEx = OptionalAttributeWithValueMatching + 0x8000,
  RequiredElementWithBodyMatchingEx = RequiredElementWithBodyMatching + 0x8000, OptionalElementWithBodyMatchingEx = OptionalElementWithBodyMatching + 0x8000
}
 
- Public Types inherited from PXMLBase
enum  { DEFAULT_MAX_ENTITY_LENGTH = 65536 }
 
enum  StandAloneType { UninitialisedStandAlone = -2, UnknownStandAlone = -1, NotStandAlone, IsStandAlone }
 
- Public Types inherited from PObject
enum  Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }
 Result of the comparison operation performed by the Compare() function. More...
 

Public Member Functions

 PXML (Options options=NoOptions, const char *noIndentElements=NULL, const char *defaultEncoding=NULL)
 
 PXML (const PXML &xml)
 
 ~PXML ()
 
void ReadFrom (istream &strm)
 Input the contents of the object from the stream. More...
 
void PrintOn (ostream &strm) const
 Output the contents of the object to the stream. More...
 
PString AsString () const
 
bool IsDirty () const
 
bool Load (const PString &data)
 
bool Load (const PString &data, Options options, const char *defaultEncoding=NULL)
 
bool LoadFile (const PFilePath &fn)
 
bool LoadFile (const PFilePath &fn, Options options)
 
virtual bool OnLoadProgress (unsigned) const
 
virtual void OnLoaded ()
 
bool Save ()
 
bool Save (Options options)
 
PString AsString ()
 
PString AsString (Options options)
 
bool SaveFile (const PFilePath &fn)
 
bool SaveFile (const PFilePath &fn, Options options)
 
virtual bool OnSaveProgress (unsigned) const
 
virtual bool OutputProgress () const
 
virtual PINDEX GetObjectCount () const
 
void RemoveAll ()
 
virtual PBoolean IsNoIndentElement (const PString &elementName) const
 
virtual PXMLElementCreateElement (const PCaselessString &name, const char *data=NULL)
 
virtual PXMLRootElementCreateRootElement (const PCaselessString &name)
 
PXMLElementGetElement (const PCaselessString &name, const PCaselessString &attr, const PString &attrval) const
 
PXMLElementGetElement (const PCaselessString &name, PINDEX idx=0) const
 
PXMLElementGetElement (PINDEX idx) const
 
PINDEX GetNumElements () const
 
PXMLElementSetRootElement (PXMLRootElement *root)
 
PXMLElementSetRootElement (const PString &documentType)
 
bool Validate (const ValidationInfo *validator)
 
bool ValidateElements (ValidationContext &context, PXMLElement *baseElement, const ValidationInfo *elements)
 
bool ValidateElement (ValidationContext &context, PXMLElement *element, const ValidationInfo *elements)
 
bool LoadAndValidate (const PString &body, const PXML::ValidationInfo *validator, PString &error, Options options=NoOptions)
 
const PCaselessStringGetVersion () const
 
const PCaselessStringGetEncoding () const
 
StandAloneType GetStandAlone () const
 
bool IsLoaded () const
 
PXMLRootElementGetRootElement () const
 
PCaselessString GetDocumentType () const
 
const PCaselessStringGetDocType () const
 
const PCaselessStringGetPubicIdentifier () const
 
const PCaselessStringGetDtdURI () const
 
PString GetErrorString () const
 
unsigned GetErrorColumn () const
 
unsigned GetErrorLine () const
 
- Public Member Functions inherited from PXMLBase
 P_DECLARE_BITWISE_ENUM_EX (Options, 8,(NoOptions, Indent, IndentWithTabs, NewLineAfterElement, NoIgnoreWhiteSpace, CloseExtended, WithNS, FragmentOnly, ExpandEntities), AllOptions=(1<< 8)-1)
 
 PXMLBase (Options opts=NoOptions)
 
void SetOptions (Options opts)
 
Options GetOptions () const
 
void SetMaxEntityLength (unsigned len)
 
unsigned GetMaxEntityLength () const
 
bool OutputIndent (ostream &strm, int indent, const PString &elementName=PString::Empty()) const
 
- Public Member Functions inherited from PObject
__inline unsigned GetTraceContextIdentifier () const
 Get PTRACE context identifier. More...
 
__inline void SetTraceContextIdentifier (unsigned id)
 
__inline void SetTraceContextIdentifier (const PObject &obj)
 
__inline void SetTraceContextIdentifier (const PObject *obj)
 
__inline void CopyTraceContextIdentifier (PObject &obj) const
 
__inline void CopyTraceContextIdentifier (PObject *obj) const
 
virtual ~PObject ()
 
__inline const char * GetClass () const
 
__inline bool IsClass (const char *name) const
 
__inline const PObjectPTraceObjectInstance () const
 
virtual PObjectClone () const
 Create a copy of the class on the heap. More...
 
template<class CLS >
CLS * CloneAs () const
 As for Clone() but converts to specified type. More...
 
virtual PINDEX HashFunction () const
 This function yields a hash value required by the PDictionary class. More...
 
virtual Comparison Compare (const PObject &obj) const
 Compare the two objects and return their relative rank. More...
 
virtual Comparison CompareObjectMemoryDirect (const PObject &obj) const
 Determine the byte wise comparison of two objects. More...
 
bool operator== (const PObject &obj) const
 Compare the two objects. More...
 
bool operator!= (const PObject &obj) const
 Compare the two objects. More...
 
bool operator< (const PObject &obj) const
 Compare the two objects. More...
 
bool operator> (const PObject &obj) const
 Compare the two objects. More...
 
bool operator<= (const PObject &obj) const
 Compare the two objects. More...
 
bool operator>= (const PObject &obj) const
 Compare the two objects. More...
 

Static Public Member Functions

static PString EscapeSpecialChars (const PString &string)
 
- Static Public Member Functions inherited from PObject
static __inline void CopyTraceContextIdentifier (PObject &to, const PObject &from)
 
static __inline void CopyTraceContextIdentifier (PObject &to, const PObject *from)
 
static __inline void CopyTraceContextIdentifier (PObject *to, const PObject &from)
 
static __inline void CopyTraceContextIdentifier (PObject *to, const PObject *from)
 
static __inline const char * Class ()
 
static __inline const PObjectPTraceObjectInstance (const char *)
 
static __inline const PObjectPTraceObjectInstance (const PObject *obj)
 
template<typename T >
static Comparison Compare2 (T v1, T v2)
 Compare two types, returning Comparison type. More...
 
static Comparison InternalCompareObjectMemoryDirect (const PObject *obj1, const PObject *obj2, PINDEX size)
 Internal function caled from CompareObjectMemoryDirect() More...
 

Protected Attributes

PFilePath m_loadFilename
 
PCaselessString m_version
 
PCaselessString m_encoding
 
StandAloneType m_standAlone
 
PCaselessString m_docType
 
PCaselessString m_publicId
 
PCaselessString m_dtdURI
 
PXMLRootElementm_rootElement
 
PStringStream m_errorString
 
unsigned m_errorLine
 
unsigned m_errorColumn
 
PSortedStringList m_noIndentElements
 
PCaselessString m_defaultNameSpace
 
PINDEX m_totalObjects
 
PINDEX m_savedObjects
 
unsigned m_percent
 
- Protected Attributes inherited from PXMLBase
Options m_options
 
unsigned m_maxEntityLength
 
- Protected Attributes inherited from PObject
unsigned m_traceContextIdentifier
 

Additional Inherited Members

- Protected Member Functions inherited from PObject
 PObject ()
 Constructor for PObject, made protected so cannot ever create one on its own. More...
 

Member Enumeration Documentation

Enumerator
EndOfValidationList 
DocType 
ElementName 
RequiredAttribute 
RequiredNonEmptyAttribute 
RequiredAttributeWithValue 
RequiredElement 
Subtree 
RequiredAttributeWithValueMatching 
RequiredElementWithBodyMatching 
OptionalElement 
OptionalAttribute 
OptionalNonEmptyAttribute 
OptionalAttributeWithValue 
OptionalAttributeWithValueMatching 
OptionalElementWithBodyMatching 
SetDefaultNamespace 
SetNamespace 
RequiredAttributeWithValueMatchingEx 
OptionalAttributeWithValueMatchingEx 
RequiredElementWithBodyMatchingEx 
OptionalElementWithBodyMatchingEx 

Constructor & Destructor Documentation

PXML::PXML ( Options  options = NoOptions,
const char *  noIndentElements = NULL,
const char *  defaultEncoding = NULL 
)
PXML::PXML ( const PXML xml)
PXML::~PXML ( )

Member Function Documentation

PString PXML::AsString ( ) const
PString PXML::AsString ( )
PString PXML::AsString ( Options  options)
virtual PXMLElement* PXML::CreateElement ( const PCaselessString name,
const char *  data = NULL 
)
virtual
virtual PXMLRootElement* PXML::CreateRootElement ( const PCaselessString name)
virtual
static PString PXML::EscapeSpecialChars ( const PString string)
static
const PCaselessString& PXML::GetDocType ( ) const
inline

References m_docType.

PCaselessString PXML::GetDocumentType ( ) const
const PCaselessString& PXML::GetDtdURI ( ) const
inline

References m_dtdURI.

PXMLElement* PXML::GetElement ( const PCaselessString name,
const PCaselessString attr,
const PString attrval 
) const
PXMLElement* PXML::GetElement ( const PCaselessString name,
PINDEX  idx = 0 
) const
PXMLElement* PXML::GetElement ( PINDEX  idx) const
const PCaselessString& PXML::GetEncoding ( ) const
inline

References m_encoding.

unsigned PXML::GetErrorColumn ( ) const
inline

References m_errorColumn.

unsigned PXML::GetErrorLine ( ) const
inline

References m_errorLine.

PString PXML::GetErrorString ( ) const
inline

References m_errorString.

PINDEX PXML::GetNumElements ( ) const
virtual PINDEX PXML::GetObjectCount ( ) const
virtual
const PCaselessString& PXML::GetPubicIdentifier ( ) const
inline

References m_publicId.

PXMLRootElement* PXML::GetRootElement ( ) const
inline

References m_rootElement.

StandAloneType PXML::GetStandAlone ( ) const
inline

References m_standAlone.

const PCaselessString& PXML::GetVersion ( ) const
inline

References m_version.

bool PXML::IsDirty ( ) const
bool PXML::IsLoaded ( ) const
inline

References m_rootElement.

virtual PBoolean PXML::IsNoIndentElement ( const PString elementName) const
virtual

Reimplemented from PXMLBase.

bool PXML::Load ( const PString data)
bool PXML::Load ( const PString data,
Options  options,
const char *  defaultEncoding = NULL 
)
bool PXML::LoadAndValidate ( const PString body,
const PXML::ValidationInfo validator,
PString error,
Options  options = NoOptions 
)
bool PXML::LoadFile ( const PFilePath fn)
bool PXML::LoadFile ( const PFilePath fn,
Options  options 
)
virtual void PXML::OnLoaded ( )
inlinevirtual
virtual bool PXML::OnLoadProgress ( unsigned  ) const
inlinevirtual
virtual bool PXML::OnSaveProgress ( unsigned  ) const
inlinevirtual
virtual bool PXML::OutputProgress ( ) const
virtual

Reimplemented from PXMLBase.

void PXML::PrintOn ( ostream &  strm) const
virtual

Output the contents of the object to the stream.

The exact output is dependent on the exact semantics of the descendent class. This is primarily used by the standard operator<< function.

The default behaviour is to print the class name.

Reimplemented from PObject.

void PXML::ReadFrom ( istream &  strm)
virtual

Input the contents of the object from the stream.

The exact input is dependent on the exact semantics of the descendent class. This is primarily used by the standard operator>> function.

The default behaviour is to do nothing.

Reimplemented from PObject.

void PXML::RemoveAll ( )
bool PXML::Save ( )
bool PXML::Save ( Options  options)
bool PXML::SaveFile ( const PFilePath fn)
bool PXML::SaveFile ( const PFilePath fn,
Options  options 
)
PXMLElement* PXML::SetRootElement ( PXMLRootElement root)
PXMLElement* PXML::SetRootElement ( const PString documentType)
bool PXML::Validate ( const ValidationInfo validator)
bool PXML::ValidateElement ( ValidationContext context,
PXMLElement element,
const ValidationInfo elements 
)
bool PXML::ValidateElements ( ValidationContext context,
PXMLElement baseElement,
const ValidationInfo elements 
)

Member Data Documentation

PCaselessString PXML::m_defaultNameSpace
protected
PCaselessString PXML::m_docType
protected

Referenced by GetDocType().

PCaselessString PXML::m_dtdURI
protected

Referenced by GetDtdURI().

PCaselessString PXML::m_encoding
protected

Referenced by GetEncoding().

unsigned PXML::m_errorColumn
protected

Referenced by GetErrorColumn().

unsigned PXML::m_errorLine
protected

Referenced by GetErrorLine().

PStringStream PXML::m_errorString
protected

Referenced by GetErrorString().

PFilePath PXML::m_loadFilename
protected
PSortedStringList PXML::m_noIndentElements
protected
unsigned PXML::m_percent
mutableprotected
PCaselessString PXML::m_publicId
protected

Referenced by GetPubicIdentifier().

PXMLRootElement* PXML::m_rootElement
protected

Referenced by GetRootElement(), and IsLoaded().

PINDEX PXML::m_savedObjects
mutableprotected
StandAloneType PXML::m_standAlone
protected

Referenced by GetStandAlone().

PINDEX PXML::m_totalObjects
protected
PCaselessString PXML::m_version
protected

Referenced by GetVersion().


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