nidas v1.2.3
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | List of all members
nidas::core::XMLCachingParser Class Reference

Derived class of XMLParser that keeps its DOMDocuments when parsing an XML disk file, and returns the cached DOMDocument if the file hasn't changed. More...

#include <XMLParser.h>

Inheritance diagram for nidas::core::XMLCachingParser:
Inheritance graph
[legend]

Public Member Functions

xercesc::DOMDocument * parse (const std::string &xmlFile)
 Parse from a file.
 
void setDOMValidation (bool val)
 DOMBuilder::setFilter is not yet implemented in xerces c++ 2.6.0 void setFilter(xercesc::DOMBuilderFilter* filter)
 
void setDOMValidateIfSchema (bool val)
 Enable/disable schema validation.
 
void setDOMNamespaces (bool val)
 Enable/disable namespace processing.
 
void setXercesSchema (bool val)
 Enable/disable schema support.
 
void setXercesSchemaFullChecking (bool val)
 Enable/disable full schema constraint checking, including checking which may be time-consuming or memory intensive.
 
void setDOMDatatypeNormalization (bool val)
 Enable/disable datatype normalization.
 
void setXercesUserAdoptsDOMDocument (bool val)
 Control who owns DOMDocument pointer.
 
void setXercesHandleMultipleImports (bool val)
 
void setXercesDoXInclude (bool val)
 
xercesc::DOMDocument * parse (const std::string &xmlFile, bool verbose=true)
 
xercesc::DOMDocument * parse (xercesc::InputSource &source)
 
xercesc::DOMDocument * parseString (const std::string &xml)
 Parse XML string into a document.
 

Static Public Member Functions

static XMLCachingParsergetInstance ()
 
static void destroyInstance ()
 
static time_t getFileModTime (const std::string &name)
 Parse from an InputSource.
 
static xercesc::DOMDocument * ParseString (const std::string &xml)
 Call parseString() on a default XMLParser instance.
 

Protected Member Functions

 XMLCachingParser ()
 
 ~XMLCachingParser ()
 

Protected Attributes

std::map< std::string, time_t_modTimeCache
 
std::map< std::string, xercesc::DOMDocument * > _docCache
 
nidas::util::Mutex _cacheLock
 
xercesc::DOMImplementation * _impl
 
xercesc::DOMLSParser * _parser
 
XMLErrorHandler _errorHandler
 

Static Protected Attributes

static XMLCachingParser_instance = 0
 
static nidas::util::Mutex _instanceLock
 

Private Member Functions

 XMLCachingParser (const XMLCachingParser &)
 No copying.
 
XMLCachingParseroperator= (const XMLCachingParser &)
 No assignment.
 

Detailed Description

Derived class of XMLParser that keeps its DOMDocuments when parsing an XML disk file, and returns the cached DOMDocument if the file hasn't changed.

Constructor & Destructor Documentation

◆ XMLCachingParser() [1/2]

XMLCachingParser::XMLCachingParser ( )
protected
Exceptions
nidas::core::XMLException

Referenced by getInstance().

◆ ~XMLCachingParser()

XMLCachingParser::~XMLCachingParser ( )
protected

◆ XMLCachingParser() [2/2]

nidas::core::XMLCachingParser::XMLCachingParser ( const XMLCachingParser & )
private

No copying.

Member Function Documentation

◆ destroyInstance()

void XMLCachingParser::destroyInstance ( )
static

◆ getFileModTime()

time_t XMLCachingParser::getFileModTime ( const std::string & name)
static

Parse from an InputSource.

This is not cached.

Exceptions
nidas::util::IOException

Referenced by parse().

◆ getInstance()

XMLCachingParser * XMLCachingParser::getInstance ( )
static

◆ operator=()

XMLCachingParser & nidas::core::XMLCachingParser::operator= ( const XMLCachingParser & )
private

No assignment.

◆ parse() [1/3]

xercesc::DOMDocument * XMLCachingParser::parse ( const std::string & xmlFile)

Parse from a file.

This will return the DOMDocument pointer of the a previous parse result if the file has not been modified since the last time it was parsed. The pointer to the DOMDocuemnt is owned by XMLCachingParser and the user should not call doc->release();

Exceptions
nidas::core::XMLException
nidas::util::IOException

References _cacheLock, _docCache, _modTimeCache, getFileModTime(), nidas::core::getSample(), and nidas::core::XMLParser::parse().

◆ parse() [2/3]

xercesc::DOMDocument * XMLParser::parse ( const std::string & xmlFile,
bool verbose = true )
inherited

◆ parse() [3/3]

xercesc::DOMDocument * XMLParser::parse ( xercesc::InputSource & source)
inherited

◆ parseString()

xercesc::DOMDocument * XMLParser::parseString ( const std::string & xml)
inherited

Parse XML string into a document.

The returned DOMDocument pointer needs to be deleted, and before the XMLImplementation is terminated.

Parameters
xml
Returns
xercesc::DOMDocument*

References nidas::core::getSample(), and nidas::core::XMLParser::parse().

◆ ParseString()

xercesc::DOMDocument * XMLParser::ParseString ( const std::string & xml)
staticinherited

Call parseString() on a default XMLParser instance.

Parameters
xml
Returns
xercesc::DOMDocument*

References nidas::core::getSample().

Referenced by DataPrep::run().

◆ setDOMDatatypeNormalization()

void XMLParser::setDOMDatatypeNormalization ( bool val)
inherited

Enable/disable datatype normalization.

See /link http://xml.apache.org/xerces-c/program-dom.html#DOMBuilderFeatures

Parameters
valIf true let the validation process do its datatype normalization that is defined in the used schema language. If false disable datatype normalization. The XML 1.0 attribute value normalization always occurs though.
Default: false.

References nidas::core::XMLParser::_parser.

◆ setDOMNamespaces()

void XMLParser::setDOMNamespaces ( bool val)
inherited

Enable/disable namespace processing.

See /link http://xml.apache.org/xerces-c/program-dom.html#DOMBuilderFeatures

Parameters
valIf true perform namespace processing. Default: false.

References nidas::core::XMLParser::_parser.

◆ setDOMValidateIfSchema()

void XMLParser::setDOMValidateIfSchema ( bool val)
inherited

Enable/disable schema validation.

See /link http://xml.apache.org/xerces-c/program-dom.html#DOMBuilderFeatures

Parameters
valIf true the parser will validate the document only if a grammar is specified. If false validation is determined by the state of the validation feature, see setDOMValidation().
Default: false.

References nidas::core::XMLParser::_parser.

◆ setDOMValidation()

void XMLParser::setDOMValidation ( bool val)
inherited

DOMBuilder::setFilter is not yet implemented in xerces c++ 2.6.0 void setFilter(xercesc::DOMBuilderFilter* filter)

Enable/disable validation. See /link http://xml.apache.org/xerces-c/program-dom.html#DOMBuilderFeatures

Parameters
valBoolean value specifying whether to report all validation errors. Default: false.

References nidas::core::XMLParser::_parser.

◆ setXercesDoXInclude()

void XMLParser::setXercesDoXInclude ( bool val)
inherited

◆ setXercesHandleMultipleImports()

void XMLParser::setXercesHandleMultipleImports ( bool val)
inherited

◆ setXercesSchema()

void XMLParser::setXercesSchema ( bool val)
inherited

Enable/disable schema support.

See /link http://xml.apache.org/xerces-c/program-dom.html#DOMBuilderFeatures

Parameters
valIf true enable the parser's schema support. Default: false.

References nidas::core::XMLParser::_parser.

◆ setXercesSchemaFullChecking()

void XMLParser::setXercesSchemaFullChecking ( bool val)
inherited

Enable/disable full schema constraint checking, including checking which may be time-consuming or memory intensive.

Currently, particle unique attribution constraint checking and particle derivation restriction checking are controlled by this option.
See /link http://xml.apache.org/xerces-c/program-dom.html#DOMBuilderFeatures

Parameters
valIf true enable schema constraint checking. Default: false.

References nidas::core::XMLParser::_parser.

◆ setXercesUserAdoptsDOMDocument()

void XMLParser::setXercesUserAdoptsDOMDocument ( bool val)
inherited

Control who owns DOMDocument pointer.

See /link http://xml.apache.org/xerces-c/program-dom.html#DOMBuilderFeatures

Parameters
valIf true the caller will adopt the DOMDocument that is returned from the parse method and thus is responsible to call DOMDocument::release() to release the associated memory. The parser will not release it. The ownership is transferred from the parser to the caller. If false the returned DOMDocument from the parse method is owned by the parser and thus will be deleted when the parser is released.

References nidas::core::XMLParser::_parser.

Referenced by nidas::core::XMLParser::XMLParser().

Member Data Documentation

◆ _cacheLock

nidas::util::Mutex nidas::core::XMLCachingParser::_cacheLock
protected

Referenced by parse(), and ~XMLCachingParser().

◆ _docCache

std::map<std::string,xercesc::DOMDocument*> nidas::core::XMLCachingParser::_docCache
protected

Referenced by parse(), and ~XMLCachingParser().

◆ _errorHandler

XMLErrorHandler nidas::core::XMLParser::_errorHandler
protectedinherited

◆ _impl

xercesc::DOMImplementation* nidas::core::XMLParser::_impl
protectedinherited

◆ _instance

XMLCachingParser * XMLCachingParser::_instance = 0
staticprotected

Referenced by destroyInstance(), and getInstance().

◆ _instanceLock

n_u::Mutex XMLCachingParser::_instanceLock
staticprotected

Referenced by destroyInstance(), and getInstance().

◆ _modTimeCache

std::map<std::string,time_t> nidas::core::XMLCachingParser::_modTimeCache
protected

Referenced by parse().

◆ _parser

xercesc::DOMLSParser* nidas::core::XMLParser::_parser
protectedinherited

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