XMLValidator.hpp
Go to the documentation of this file.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: XMLValidator.hpp 932889 2010-04-11 13:10:10Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_XMLVALIDATOR_HPP
#include <xercesc/framework/XMLAttr.hpp>
#include <xercesc/framework/XMLValidityCodes.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class ReaderMgr;
class XMLBufferMgr;
class XMLElementDecl;
class XMLScanner;
class Grammar;
class XMLPARSER_EXPORT XMLValidator : public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors are hidden, just the virtual destructor is exposed
// -----------------------------------------------------------------------
virtual ~XMLValidator()
{
}
// -----------------------------------------------------------------------
// The virtual validator interface
// -----------------------------------------------------------------------
virtual bool checkContent
(
XMLElementDecl* const elemDecl
, QName** const children
, XMLSize_t childCount
, XMLSize_t* indexFailingChild
) = 0;
virtual void faultInAttr
(
XMLAttr& toFill
, const XMLAttDef& attDef
) const = 0;
virtual void preContentValidation(bool reuseGrammar,
bool validateDefAttr = false) = 0;
virtual void postParseValidation() = 0;
virtual void reset() = 0;
virtual bool requiresNamespaces() const = 0;
virtual void validateAttrValue
(
const XMLAttDef* attDef
, const XMLCh* const attrValue
, bool preValidation = false
, const XMLElementDecl* elemDecl = 0
) = 0;
virtual void validateElement
(
const XMLElementDecl* elemDef
) = 0;
virtual Grammar* getGrammar() const =0;
virtual void setGrammar(Grammar* aGrammar) =0;
// -----------------------------------------------------------------------
// Virtual DTD handler interface.
// -----------------------------------------------------------------------
virtual bool handlesDTD() const = 0;
// -----------------------------------------------------------------------
// Virtual Schema handler interface.
// -----------------------------------------------------------------------
virtual bool handlesSchema() const = 0;
// -----------------------------------------------------------------------
// Setter methods
//
// setScannerInfo() is called by the scanner to tell the validator
// about the stuff it needs to have access to.
// -----------------------------------------------------------------------
void setScannerInfo
(
XMLScanner* const owningScanner
, ReaderMgr* const readerMgr
, XMLBufferMgr* const bufMgr
);
void setErrorReporter
(
XMLErrorReporter* const errorReporter
);
// -----------------------------------------------------------------------
// Error emitter methods
// -----------------------------------------------------------------------
void emitError(const XMLValid::Codes toEmit);
void emitError
(
const XMLValid::Codes toEmit
, const XMLCh* const text1
, const XMLCh* const text2 = 0
, const XMLCh* const text3 = 0
, const XMLCh* const text4 = 0
);
void emitError
(
const XMLValid::Codes toEmit
, const char* const text1
, const char* const text2 = 0
, const char* const text3 = 0
, const char* const text4 = 0
);
void emitError
(
const XMLValid::Codes toEmit
, const XMLExcepts::Codes originalErrorCode
, const XMLCh* const text1 = 0
, const XMLCh* const text2 = 0
, const XMLCh* const text3 = 0
, const XMLCh* const text4 = 0
);
protected :
// -----------------------------------------------------------------------
// Hidden constructors
// -----------------------------------------------------------------------
XMLValidator
(
XMLErrorReporter* const errReporter = 0
);
// -----------------------------------------------------------------------
// Protected getters
// -----------------------------------------------------------------------
const XMLBufferMgr* getBufMgr() const;
XMLBufferMgr* getBufMgr();
const ReaderMgr* getReaderMgr() const;
ReaderMgr* getReaderMgr();
const XMLScanner* getScanner() const;
XMLScanner* getScanner();
private :
// -----------------------------------------------------------------------
// Unimplemented Constructors and Operators
// -----------------------------------------------------------------------
XMLValidator(const XMLValidator&);
XMLValidator& operator=(const XMLValidator&);
// -----------------------------------------------------------------------
// Private data members
//
// fErrorReporter
// The error reporter we are to use, if any.
//
// -----------------------------------------------------------------------
XMLBufferMgr* fBufMgr;
XMLErrorReporter* fErrorReporter;
ReaderMgr* fReaderMgr;
XMLScanner* fScanner;
};
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
inline void
XMLValidator::setScannerInfo(XMLScanner* const owningScanner
, ReaderMgr* const readerMgr
, XMLBufferMgr* const bufMgr)
{
// We don't own any of these, we just reference them
fScanner = owningScanner;
fReaderMgr = readerMgr;
fBufMgr = bufMgr;
}
inline void
XMLValidator::setErrorReporter(XMLErrorReporter* const errorReporter)
{
fErrorReporter = errorReporter;
}
// ---------------------------------------------------------------------------
// XMLValidator: Protected getter
// ---------------------------------------------------------------------------
inline const XMLBufferMgr* XMLValidator::getBufMgr() const
{
return fBufMgr;
}
inline XMLBufferMgr* XMLValidator::getBufMgr()
{
return fBufMgr;
}
inline const ReaderMgr* XMLValidator::getReaderMgr() const
{
return fReaderMgr;
}
inline ReaderMgr* XMLValidator::getReaderMgr()
{
return fReaderMgr;
}
inline const XMLScanner* XMLValidator::getScanner() const
{
return fScanner;
}
inline XMLScanner* XMLValidator::getScanner()
{
return fScanner;
}
XERCES_CPP_NAMESPACE_END
#endif
XMLValidator::getBufMgr
const XMLBufferMgr * getBufMgr() const
Definition: XMLValidator.hpp:394
XMLValidator::getReaderMgr
const ReaderMgr * getReaderMgr() const
Definition: XMLValidator.hpp:404
XMemory
This class makes it possible to override the C++ memory management by adding new/delete operators to ...
Definition: XMemory.hpp:40
XMLErrorReporter
This abstract class defines a callback mechanism for the scanner.
Definition: XMLErrorReporter.hpp:42
XMLPARSER_EXPORT
#define XMLPARSER_EXPORT
Definition: XercesDefs.hpp:163
XMLValid::Codes
Codes
Definition: XMLValidityCodes.hpp:15
XMLAttr
This class defines the information about an attribute that will come out of the scanner during parsin...
Definition: XMLAttr.hpp:53
XMLAttDef
Represents the core information of an attribute definition.
Definition: XMLAttDef.hpp:52
XMLElementDecl
This class defines the core information of an element declaration.
Definition: XMLElementDecl.hpp:51
XMLValidator::setScannerInfo
void setScannerInfo(XMLScanner *const owningScanner, ReaderMgr *const readerMgr, XMLBufferMgr *const bufMgr)
Definition: XMLValidator.hpp:374
XMLCh
uint16_t XMLCh
Definition: Xerces_autoconf_config.hpp:118
QName
Definition: QName.hpp:34
XERCES_CPP_NAMESPACE_BEGIN
#define XERCES_CPP_NAMESPACE_BEGIN
Definition: XercesDefs.hpp:112
XMLValidator::getScanner
const XMLScanner * getScanner() const
Definition: XMLValidator.hpp:414
XMLValidator
This abstract class provides the interface for all validators.
Definition: XMLValidator.hpp:52
XMLValidator::~XMLValidator
virtual ~XMLValidator()
The derived class should clean up its allocated data, then this class will do the same for data alloc...
Definition: XMLValidator.hpp:66
XMLSize_t
size_t XMLSize_t
Definition: Xerces_autoconf_config.hpp:110
XERCES_CPP_NAMESPACE_END
#define XERCES_CPP_NAMESPACE_END
Definition: XercesDefs.hpp:113
XMLValidator::setErrorReporter
void setErrorReporter(XMLErrorReporter *const errorReporter)
This method is called to set an error reporter on the validator via which it will report any errors i...
Definition: XMLValidator.hpp:385
XMLValidityCodes.hpp
XMLAttr.hpp