#include
#include
#include "qnamepool_p.h"
#include "qxmlname.h"
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QAbstractMessageHandler;
class QSourceLocation;
class QString;
namespace QPatternist
{
class SourceLocationReflection;
/**
* @short A callback for reporting errors.
*
* ReportContext receives messages of various severity and type via its
* functions warning() and error(). In turn, ReportContext create Message instances
* and submit them to the QAbstractMessageHandler instance returned by messageHandler().
*
* The Message attributes are set as follows:
*
* - Message::description() - A translated, human-readable description
* - Message::type() - Message::Error if a static, dynamic or type error was encountered
* that halted compilation or evaluation, or Message::Warning in case of a warning
* - Message::identifier() - This is a URI consisting of the error namespace with the
* error code as fragment. For example, a Message representing a syntax error
* would return the type "http://www.w3.org/2005/xqt-errors#XPST0003". The convenience
* function codeFromURI() can be used to extract the error code. The error namespace
* is typically the namespace for XPath and XQuery errors(as in the previous example), but
* can also be user defined.
*
* @see XML Path Language
* (XPath) 2.0, 2.3.2 Identifying and Reporting Errors
* @see XQuery 1.0 and
* XPath 2.0 Functions and Operators, 3 The Error Function
* @author Frans Englich
* @warning This file is auto-generated from extractErrorCodes.xsl. Any
* modifications done to this file are lost.
*/
class Q_AUTOTEST_EXPORT ReportContext : public QSharedData
{
public:
typedef QHash LocationHash;
/**
* A smart pointer wrapping ReportContext instances.
*/
typedef QExplicitlySharedDataPointer Ptr;
/**
* @short Default constructors.
*
* For some reason GCC fails to synthesize it, so we provide an empty
* one here.
*/
inline ReportContext() {}
virtual ~ReportContext();
/**
* Error codes that corresponds to the error codes defined in the
* relevant specifications. They are used throughout the API for
* identifying error conditions.
*
* While strings could have been used for identifying errors, enums
* reduces bugs by providing type safety.
*
* @see XML
* Path Language (XPath) 2.0, 2.3 Error Handling
* @see XQuery 1.0
* and XPath 2.0 Functions and Operators, C Error Summary
* @see XSL Transformations
* (XSLT) Version 2.0, E Summary of Error Conditions (Non-Normative)
* @note The enumerator values' Doxygen documentation is copied from the
* W3C documents
* XQuery 1.0 and XPath
* 2.0 Functions and Operators,
* XML Path Language (XPath) 2.0, and
* XSL Transformations (XSLT)
* Version 2.0, respectively. The doxygen documentation is therefore covered
* by the following legal notice:
* "Copyright @ 2005 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability,
* trademark and
* document
* use rules apply."
* @warning This enumerator is auto-generated from the relevant specifications
* by the XSL-T stylesheet extractErrorCodes.xsl. Hence, any modifications
* done to this file, in contrary to the stylesheet, are therefore lost.
*/]]>
enum ErrorCode
{
};
XML Path Language (XPath) 2.0,
* 2.3 Error Handling
* @param message the message to be read by the user.
* @param sourceLocation the location of where the warning originates from.
*/
void warning(const QString &message, const QSourceLocation &sourceLocation = QSourceLocation());
/**
* Issues an error. May be used at the static analysis phase or
* the dynamic evaluation phase.
*
* For SourceLocationReflection instances, the overload taking an SouourceLocationReflection should be used.
*
* @see XML Path Language (XPath) 2.0,
* 2.3 Error Handling
* @param message the message to be read by the user.
* @param errorCode identifies the error condition, as described
* @param sourceLocation the location of where the error originates from
* in "XML Path Language (XPath) 2.0" section "G Error Conditions"
*/
void error(const QString &message,
const ReportContext::ErrorCode errorCode,
const QSourceLocation &sourceLocation);
/**
* Overload.
*
* Same as the above, but passes the SourceLocationReflection as reference for error reporting.
*/
void error(const QString &message,
const ReportContext::ErrorCode errorCode,
const SourceLocationReflection *reflection);
/**
* Issues an error which is not identified in the XPath specifications. This function
* is among other things used for implementing the fn:error() function.
*/
void error(const QString &message,
const QXmlName qName,
const SourceLocationReflection *const r);
/**
* @return the QAbstractMessageHandler which functions such as warning() and
* error() should submit messages to. This function
* may never return @c null; a valid QAbstractMessageHandler pointer must always be returned.
*/
virtual QAbstractMessageHandler *messageHandler() const = 0;
virtual NamePool::Ptr namePool() const = 0;
/**
* Returns a string representation of the error code @p code.
*
* @see ReportContext::ErrorCode
* @param errorCode identifies the error condition, as described
* in XML Path
* Language (XPath) 2.0, G Error Conditions
*/
static QString codeToString(const ReportContext::ErrorCode errorCode);
/**
* @returns the error code part of @p typeURI and sets @p uri to the error namespace. Note
* that the error namespace not necessarily is the namespace for XPath and
* XQuery errors, http://www.w3.org/2005/xqt-errors, but can be user defined.
*/
static QString codeFromURI(const QString &typeURI,
QString &uri);
/**
* @short Returns the source location applying for @p reflection.
*/
virtual QSourceLocation locationFor(const SourceLocationReflection *const reflection) const = 0;
/**
* Resolves @p relative against @p baseURI, possibly using a URI resolver.
*/
QUrl resolveURI(const QUrl &relative,
const QUrl &baseURI) const;
/**
* @short The URI resolver in use.
*
* If no URI resolver is in use, a @c null pointer is returned.
*
* @note You should probably use resolveURI(), which handles the case of
* when uriResolver() is @c null.
*/
virtual QAbstractUriResolver *uriResolver() const = 0;
private:
void createError(const QString &description,
const QtMsgType type,
const QUrl &id,
const QSourceLocation &sourceLocation) const;
static inline QString finalizeDescription(const QString &desc);
QSourceLocation lookupSourceLocation(const SourceLocationReflection *const ref) const;
Q_DISABLE_COPY(ReportContext)
};
/**
* @short This is the class type that is being thrown when a query error occur.
*
* @relates ReportContext
*/
typedef bool Exception;
}
QT_END_NAMESPACE
QT_END_HEADER
#endif]]>
/**
*/
,
/**
*/
,
/**
*/
,
/**
*/
,
*
*