diff options
author | aavit <qt-info@nokia.com> | 2011-09-27 07:11:18 (GMT) |
---|---|---|
committer | aavit <qt-info@nokia.com> | 2011-09-27 07:11:18 (GMT) |
commit | fef5d7b0cbfba93ca108ce9f0785826c0a4ff829 (patch) | |
tree | 1676c6739ddbdd029ac6083b1afbef3f0e5fd7e3 /src | |
parent | e05734987594f0e54f58a2ab3037cdf4956e9036 (diff) | |
parent | d7489680a80df5d77fbc032b1bc656a8dab1a986 (diff) | |
download | Qt-fef5d7b0cbfba93ca108ce9f0785826c0a4ff829.zip Qt-fef5d7b0cbfba93ca108ce9f0785826c0a4ff829.tar.gz Qt-fef5d7b0cbfba93ca108ce9f0785826c0a4ff829.tar.bz2 |
Merge remote-tracking branch 'qt-mainline/4.8'
Diffstat (limited to 'src')
24 files changed, 2342 insertions, 280 deletions
diff --git a/src/3rdparty/webkit/Source/WebCore/WebCore.pri b/src/3rdparty/webkit/Source/WebCore/WebCore.pri index 82311d2..d8ba8a6 100644 --- a/src/3rdparty/webkit/Source/WebCore/WebCore.pri +++ b/src/3rdparty/webkit/Source/WebCore/WebCore.pri @@ -153,7 +153,7 @@ symbian { CONFIG += do_not_build_as_thumb CONFIG(release, debug|release): QMAKE_CXXFLAGS.ARMCC += -OTime -O3 - # Symbian plugin support + # Symbian plugin support. LIBS += -lefsrv !CONFIG(QTDIR_build) { @@ -303,7 +303,7 @@ win32-* { } # Remove whole program optimizations due to miscompilations -win32-msvc2005|win32-msvc2008|wince*:{ +win32-msvc2005|win32-msvc2008|win32-msvc2010|wince*:{ QMAKE_CFLAGS_RELEASE -= -GL QMAKE_CXXFLAGS_RELEASE -= -GL diff --git a/src/3rdparty/webkit/Source/WebCore/bindings/js/JSExceptionBase.h b/src/3rdparty/webkit/Source/WebCore/bindings/js/JSExceptionBase.h index 01c6ac2..a9366ed 100644 --- a/src/3rdparty/webkit/Source/WebCore/bindings/js/JSExceptionBase.h +++ b/src/3rdparty/webkit/Source/WebCore/bindings/js/JSExceptionBase.h @@ -1,43 +1,43 @@ -/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef JSExceptionBase_h
-#define JSExceptionBase_h
-
-namespace JSC {
-
-class JSValue;
-
-} // namespace JSC
-
-namespace WebCore {
-
-class ExceptionBase;
-
-ExceptionBase* toExceptionBase(JSC::JSValue);
-
-} // namespace WebCore
-
-#endif // JSExceptionBase_h
+/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JSExceptionBase_h +#define JSExceptionBase_h + +namespace JSC { + +class JSValue; + +} // namespace JSC + +namespace WebCore { + +class ExceptionBase; + +ExceptionBase* toExceptionBase(JSC::JSValue); + +} // namespace WebCore + +#endif // JSExceptionBase_h diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index 5e8533e..817cd38 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -880,7 +880,12 @@ Q_AUTOTEST_EXPORT QString qt_tildeExpansion(const QString &path, bool *expanded passwd *tmpPw; char buf[200]; const int bufSize = sizeof(buf); - int err = getpwnam_r(userName.toLocal8Bit().constData(), &pw, buf, bufSize, &tmpPw); + int err = 0; +#if defined(Q_OS_SOLARIS) && (_POSIX_C_SOURCE - 0 < 199506L) + tmpPw = getpwnam_r(userName.toLocal8Bit().constData(), &pw, buf, bufSize); +#else + err = getpwnam_r(userName.toLocal8Bit().constData(), &pw, buf, bufSize, &tmpPw); +#endif if (err || !tmpPw) return ret; const QString homePath = QString::fromLocal8Bit(pw.pw_dir); diff --git a/src/gui/inputmethod/qcoefepinputcontext_p.h b/src/gui/inputmethod/qcoefepinputcontext_p.h index 8c30838..8ef9726 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_p.h +++ b/src/gui/inputmethod/qcoefepinputcontext_p.h @@ -63,13 +63,36 @@ #include <fepbase.h> #include <aknedsts.h> +#include <eikccpu.h> QT_BEGIN_NAMESPACE +class QCoeFepInputMaskHandler +{ +public: + QCoeFepInputMaskHandler(const QString &mask); + ~QCoeFepInputMaskHandler(); + bool canPasteClipboard(const QString &text); +private: + bool isValidInput(QChar key, QChar mask) const; +private: + struct MaskInputData { + enum Casemode { NoCaseMode, Upper, Lower }; + QChar maskChar; + bool separator; + Casemode caseMode; + }; + int m_maxLength; + QChar m_blank; + MaskInputData *m_maskData; +}; + class Q_AUTOTEST_EXPORT QCoeFepInputContext : public QInputContext, public MCoeFepAwareTextEditor, public MCoeFepAwareTextEditor_Extension1, - public MObjectProvider + public MObjectProvider, + public MEikCcpuEditor + { Q_OBJECT @@ -135,6 +158,25 @@ private: void DoCommitFepInlineEditL(); MCoeFepAwareTextEditor_Extension1* Extension1(TBool& aSetToTrue); void ReportAknEdStateEvent(MAknEdStateObserver::EAknEdwinStateEvent aEventType); + void enableSymbianCcpuSupport(); + void changeCBA(bool showCopyAndOrPaste); + void copyOrCutTextToClipboard(const char *operation); + + //From MEikCcpuEditor interface +public: + TBool CcpuIsFocused() const; + TBool CcpuCanCut() const; + void CcpuCutL(); + TBool CcpuCanCopy() const; + void CcpuCopyL(); + TBool CcpuCanPaste() const; + void CcpuPasteL(); + TBool CcpuCanUndo() const; + void CcpuUndoL(); + +private slots: + void copy(); + void paste(); // From MCoeFepAwareTextEditor_Extension1 public: @@ -167,6 +209,12 @@ private: Qt::WindowStates m_splitViewPreviousWindowStates; QRectF m_transformation; + CAknCcpuSupport *m_ccpu; + QAction *m_copyAction; + QAction *m_pasteAction; + QPointer<QWidget> m_lastFocusedEditor; + QPointer<QObject> m_lastFocusedObject; + friend class tst_QInputContext; }; diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index 56338b2..9025221 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -57,6 +57,21 @@ #include <e32property.h> #include <limits.h> + +#include <eikccpu.h> +#include <aknedsts.h> +#include <coeinput.h> +#include <w32std.h> +#include <akndiscreetpopup.h> + +#include <qtextedit.h> +#include <qplaintextedit.h> +#include <qlineedit.h> +#include <qclipboard.h> +#include <qvalidator.h> +#include <qgraphicsproxywidget.h> +#include <qgraphicsitem.h> + // You only find these enumerations on SDK 5 onwards, so we need to provide our own // to remain compatible with older releases. They won't be called by pre-5.0 SDKs. @@ -79,8 +94,253 @@ #define QT_EPSUidAknFep 0x100056de #define QT_EAknFepTouchInputActive 0x00000004 +_LIT(KAvkonResourceFile, "z:\\resource\\avkon.rsc" ); + QT_BEGIN_NAMESPACE +static QWidget* getFocusedChild(const QList<QObject*>& objectList) +{ + for (int j = 0; j < objectList.count(); j++) { + if (QWidget* ow = qobject_cast<QWidget *>(objectList[j])) { + if (ow->hasFocus()) { + return ow; + } else { + if (QWidget* rw = getFocusedChild(ow->children())) + return rw; + } + } + } + return 0; +} + +// A generic method for invoking "cut", "copy", and "paste" slots on editor +// All supported editors are expected to have these. +static bool ccpuInvokeSlot(QObject *obj, QObject *focusObject, const char *member) +{ + QObject *invokeTarget = obj; + if (focusObject) + invokeTarget = focusObject; + + return QMetaObject::invokeMethod(invokeTarget, member, Qt::DirectConnection); +} + +// focusObject is used to return a pointer to focused graphics object, if any +static QWidget *getQWidgetFromQGraphicsView(QWidget *widget, QObject **focusObject = 0) +{ + if (focusObject) + *focusObject = 0; + + if (!widget) + return 0; + + if (QGraphicsView* qgv = qobject_cast<QGraphicsView *>(widget)) { + QGraphicsItem *focusItem = 0; + if (qgv->scene()) + focusItem = qgv->scene()->focusItem(); + if (focusItem) { + if (focusObject) + *focusObject = focusItem->toGraphicsObject(); + if (QGraphicsProxyWidget* const qgpw = qgraphicsitem_cast<QGraphicsProxyWidget* const>(focusItem)) { + if (QWidget* w = qgpw->widget()) { + if (w->layout()) { + if (QWidget* rw = getFocusedChild(w->children())) + return rw; + } else { + return w; + } + } + } + } + } + return widget; +} + +QCoeFepInputMaskHandler::QCoeFepInputMaskHandler(const QString &mask) +{ + QString inputMask; + int delimiter = mask.indexOf(QLatin1Char(';')); + if (mask.isEmpty() || delimiter == 0) + return; + + if (delimiter == -1) { + m_blank = QLatin1Char(' '); + inputMask = mask; + } else { + inputMask = mask.left(delimiter); + m_blank = (delimiter + 1 < mask.length()) ? mask[delimiter + 1] : QLatin1Char(' '); + } + + // Calculate m_maxLength / m_maskData length + m_maxLength = 0; + QChar c = 0; + for (int i = 0; i < inputMask.length(); i++) { + c = inputMask.at(i); + if (i > 0 && inputMask.at(i - 1) == QLatin1Char('\\')) { + m_maxLength++; + continue; + } + if (c != QLatin1Char('\\') && c != QLatin1Char('!') + && c != QLatin1Char('<') && c != QLatin1Char('>') + && c != QLatin1Char('{') && c != QLatin1Char('}') + && c != QLatin1Char('[') && c != QLatin1Char(']')) { + m_maxLength++; + } + } + + m_maskData = new MaskInputData[m_maxLength]; + + MaskInputData::Casemode m = MaskInputData::NoCaseMode; + c = 0; + bool s = false; + bool escape = false; + int index = 0; + for (int i = 0; i < inputMask.length(); i++) { + c = inputMask.at(i); + if (escape) { + s = true; + m_maskData[index].maskChar = c; + m_maskData[index].separator = s; + m_maskData[index].caseMode = m; + index++; + escape = false; + } else if (c == QLatin1Char('<')) { + m = MaskInputData::Lower; + } else if (c == QLatin1Char('>')) { + m = MaskInputData::Upper; + } else if (c == QLatin1Char('!')) { + m = MaskInputData::NoCaseMode; + } else if (c != QLatin1Char('{') && c != QLatin1Char('}') && c != QLatin1Char('[') && c != QLatin1Char(']')) { + switch (c.unicode()) { + case 'A': + case 'a': + case 'N': + case 'n': + case 'X': + case 'x': + case '9': + case '0': + case 'D': + case 'd': + case '#': + case 'H': + case 'h': + case 'B': + case 'b': + s = false; + break; + case '\\': + escape = true; + break; + default: + s = true; + break; + } + + if (!escape) { + m_maskData[index].maskChar = c; + m_maskData[index].separator = s; + m_maskData[index].caseMode = m; + index++; + } + } + } +} + +QCoeFepInputMaskHandler::~QCoeFepInputMaskHandler() +{ + if (m_maskData) + delete[] m_maskData; +} + +bool QCoeFepInputMaskHandler::canPasteClipboard(const QString &text) +{ + if (!m_maskData) + return true; + + if (text.length() > m_maxLength) + return false; + int limit = qMin(m_maxLength, text.length()); + for (int i = 0; i < limit; ++i) { + if (m_maskData[i].separator) { + if (text.at(i) != m_maskData[i].maskChar) + return false; + } else { + if (!isValidInput(text.at(i), m_maskData[i].maskChar)) + return false; + } + } + return true; +} + +bool QCoeFepInputMaskHandler::isValidInput(QChar key, QChar mask) const +{ + switch (mask.unicode()) { + case 'A': + if (key.isLetter()) + return true; + break; + case 'a': + if (key.isLetter() || key == m_blank) + return true; + break; + case 'N': + if (key.isLetterOrNumber()) + return true; + break; + case 'n': + if (key.isLetterOrNumber() || key == m_blank) + return true; + break; + case 'X': + if (key.isPrint()) + return true; + break; + case 'x': + if (key.isPrint() || key == m_blank) + return true; + break; + case '9': + if (key.isNumber()) + return true; + break; + case '0': + if (key.isNumber() || key == m_blank) + return true; + break; + case 'D': + if (key.isNumber() && key.digitValue() > 0) + return true; + break; + case 'd': + if ((key.isNumber() && key.digitValue() > 0) || key == m_blank) + return true; + break; + case '#': + if (key.isNumber() || key == QLatin1Char('+') || key == QLatin1Char('-') || key == m_blank) + return true; + break; + case 'B': + if (key == QLatin1Char('0') || key == QLatin1Char('1')) + return true; + break; + case 'b': + if (key == QLatin1Char('0') || key == QLatin1Char('1') || key == m_blank) + return true; + break; + case 'H': + if (key.isNumber() || (key >= QLatin1Char('a') && key <= QLatin1Char('f')) || (key >= QLatin1Char('A') && key <= QLatin1Char('F'))) + return true; + break; + case 'h': + if (key.isNumber() || (key >= QLatin1Char('a') && key <= QLatin1Char('f')) || (key >= QLatin1Char('A') && key <= QLatin1Char('F')) || key == m_blank) + return true; + break; + default: + break; + } + return false; +} + Q_GUI_EXPORT void qt_s60_setPartialScreenInputMode(bool enable) { S60->partial_keyboard = enable; @@ -116,7 +376,8 @@ QCoeFepInputContext::QCoeFepInputContext(QObject *parent) m_pointerHandler(0), m_hasTempPreeditString(false), m_splitViewResizeBy(0), - m_splitViewPreviousWindowStates(Qt::WindowNoState) + m_splitViewPreviousWindowStates(Qt::WindowNoState), + m_ccpu(0) { m_fepState->SetObjectProvider(this); int defaultFlags = EAknEditorFlagDefault; @@ -133,6 +394,29 @@ QCoeFepInputContext::QCoeFepInputContext(QObject *parent) m_fepState->SetPermittedCases( EAknEditorAllCaseModes ); m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG); m_fepState->SetNumericKeymap(EAknEditorAlphanumericNumberModeKeymap); + enableSymbianCcpuSupport(); + + //adding softkeys + QString copyLabel = QLatin1String("Copy"); + QString pasteLabel = QLatin1String("Paste"); + TRAP_IGNORE( + CEikonEnv* coe = CEikonEnv::Static(); + if (coe) { + HBufC* copyBuf = coe->AllocReadResourceLC(R_TEXT_SOFTKEY_COPY); + copyLabel = qt_TDesC2QString(*copyBuf); + CleanupStack::PopAndDestroy(copyBuf); + HBufC* pasteBuf = coe->AllocReadResourceLC(R_TEXT_SOFTKEY_PASTE); + pasteLabel = qt_TDesC2QString(*pasteBuf); + CleanupStack::PopAndDestroy(pasteBuf); + } + ) + + m_copyAction = new QAction(copyLabel, QApplication::desktop()); + m_pasteAction = new QAction(pasteLabel, QApplication::desktop()); + m_copyAction->setSoftKeyRole(QAction::PositiveSoftKey); + m_pasteAction->setSoftKeyRole(QAction::NegativeSoftKey); + connect(m_copyAction, SIGNAL(triggered()), this, SLOT(copy())); + connect(m_pasteAction, SIGNAL(triggered()), this, SLOT(paste())); } QCoeFepInputContext::~QCoeFepInputContext() @@ -145,8 +429,8 @@ QCoeFepInputContext::~QCoeFepInputContext() // but is synchronous, rather than asynchronous. CCoeEnv::Static()->SyncNotifyFocusObserversOfChangeInFocus(); - if (m_fepState) - delete m_fepState; + delete m_fepState; + delete m_ccpu; } void QCoeFepInputContext::reset() @@ -347,6 +631,12 @@ bool QCoeFepInputContext::filterEvent(const QEvent *event) sControl = focusWidget()->effectiveWinId()->MopGetObject(sControl); Q_ASSERT(sControl); + // Store last focused widget and object in case of fullscreen VKB + QObject *focusObject = 0; + m_lastFocusedEditor = getQWidgetFromQGraphicsView(focusWidget(), &focusObject); + m_lastFocusedObject = focusObject; // Can be null + Q_ASSERT(m_lastFocusedEditor); + // The FEP UI temporarily steals focus when it shows up the first time, causing // all sorts of weird effects on the focused widgets. Since it will immediately give // back focus to us, we temporarily disable focus handling until the job's done. @@ -369,28 +659,66 @@ bool QCoeFepInputContext::filterEvent(const QEvent *event) bool QCoeFepInputContext::symbianFilterEvent(QWidget *keyWidget, const QSymbianEvent *event) { Q_UNUSED(keyWidget); + if (event->type() == QSymbianEvent::WindowServerEvent) { + const TWsEvent* wsEvent = event->windowServerEvent(); + TInt eventType = 0; + if (wsEvent) + eventType = wsEvent->Type(); + + if (eventType == EEventKey) { + TKeyEvent* keyEvent = wsEvent->Key(); + if (keyEvent) { + switch (keyEvent->iScanCode) { + case EEikCmdEditCopy: + CcpuCopyL(); + break; + case EEikCmdEditCut: + CcpuCutL(); + break; + case EEikCmdEditPaste: + CcpuPasteL(); + break; + case EStdKeyF21: + changeCBA(true); + break; + default: + break; + } + switch (keyEvent->iCode) { + case EKeyLeftArrow: + case EKeyRightArrow: + case EKeyUpArrow: + case EKeyDownArrow: + if (CcpuCanCopy() && ((keyEvent->iModifiers & EModifierShift) == EModifierShift)) + changeCBA(true); + break; + default: + break; + } + } + } else if (eventType == EEventKeyUp) { + if (wsEvent->Key() && wsEvent->Key()->iScanCode == EStdKeyLeftShift) + changeCBA(false); + } else if (eventType == EEventWindowVisibilityChanged && S60->splitViewLastWidget) { + QGraphicsView *gv = qobject_cast<QGraphicsView*>(S60->splitViewLastWidget); + const bool alwaysResize = (gv && gv->verticalScrollBarPolicy() != Qt::ScrollBarAlwaysOff); + + if (alwaysResize) { + TUint visibleFlags = event->windowServerEvent()->VisibilityChanged()->iFlags; + if (visibleFlags & TWsVisibilityChangedEvent::EPartiallyVisible) + ensureFocusWidgetVisible(S60->splitViewLastWidget); + if (visibleFlags & TWsVisibilityChangedEvent::ENotVisible) + resetSplitViewWidget(true); + } + } + } + if (event->type() == QSymbianEvent::CommandEvent) // A command basically means the same as a button being pushed. With Qt buttons // that would normally result in a reset of the input method due to the focus change. // This should also happen for commands. reset(); - if (event->type() == QSymbianEvent::WindowServerEvent - && event->windowServerEvent() - && event->windowServerEvent()->Type() == EEventWindowVisibilityChanged - && S60->splitViewLastWidget) { - - QGraphicsView *gv = qobject_cast<QGraphicsView*>(S60->splitViewLastWidget); - const bool alwaysResize = (gv && gv->verticalScrollBarPolicy() != Qt::ScrollBarAlwaysOff); - - if (alwaysResize) { - TUint visibleFlags = event->windowServerEvent()->VisibilityChanged()->iFlags; - if (visibleFlags & TWsVisibilityChangedEvent::EPartiallyVisible) - ensureFocusWidgetVisible(S60->splitViewLastWidget); - if (visibleFlags & TWsVisibilityChangedEvent::ENotVisible) - resetSplitViewWidget(true); - } - } if (event->type() == QSymbianEvent::ResourceChangeEvent && (event->resourceChangeType() == KEikMessageFadeAllWindows @@ -1231,6 +1559,71 @@ void QCoeFepInputContext::GetScreenCoordinatesForFepL(TPoint& aLeftSideOfBaseLin aAscent = metrics.ascent(); } +void QCoeFepInputContext::enableSymbianCcpuSupport() +{ + if (!m_ccpu) { + QT_TRAP_THROWING( + m_ccpu = new (ELeave) CAknCcpuSupport(this); + m_ccpu->SetMopParent(this); + CleanupStack::PushL(m_ccpu); + m_ccpu->ConstructL(); + CleanupStack::Pop(m_ccpu); + ); + Q_ASSERT(m_fepState); + if (m_fepState) + m_fepState->SetCcpuState(this); + } +} + +void QCoeFepInputContext::changeCBA(bool showCopyAndOrPaste) +{ + QWidget *w = focusWidget(); + if (!w) + w = m_lastFocusedEditor; + + if (w) { + if (showCopyAndOrPaste) { + if (CcpuCanCopy()) + w->addAction(m_copyAction); + if (CcpuCanPaste()) + w->addAction(m_pasteAction); + } else { + w->removeAction(m_copyAction); + w->removeAction(m_pasteAction); + } + } +} + +void QCoeFepInputContext::copyOrCutTextToClipboard(const char *operation) +{ + bool hasText = false; + + QWidget *w = focusWidget(); + QObject *focusObject = 0; + if (!w) { + w = m_lastFocusedEditor; + focusObject = m_lastFocusedObject; + } else { + w = getQWidgetFromQGraphicsView(w, &focusObject); + } + + if (w) { + int cursor = w->inputMethodQuery(Qt::ImCursorPosition).toInt(); + int anchor = w->inputMethodQuery(Qt::ImAnchorPosition).toInt(); + + if (cursor != anchor) { + if (ccpuInvokeSlot(w, focusObject, operation)) { + TRAP_IGNORE( + CAknDiscreetPopup::ShowGlobalPopupL( + R_AVKON_DISCREET_POPUP_TEXT_COPIED, + KAvkonResourceFile); + ) + } + } + } +} + + void QCoeFepInputContext::DoCommitFepInlineEditL() { commitCurrentString(false); @@ -1295,6 +1688,142 @@ MCoeFepAwareTextEditor_Extension1::CState* QCoeFepInputContext::State(TUid /*aTy return m_fepState; } +TBool QCoeFepInputContext::CcpuIsFocused() const +{ + return focusWidget() != 0; +} + +TBool QCoeFepInputContext::CcpuCanCut() const +{ + bool retval = false; + QWidget *w = focusWidget(); + if (!w) + w = m_lastFocusedEditor; + else + w = getQWidgetFromQGraphicsView(w); + if (w) { + int cursor = w->inputMethodQuery(Qt::ImCursorPosition).toInt(); + int anchor = w->inputMethodQuery(Qt::ImAnchorPosition).toInt(); + retval = cursor != anchor; + } + return retval; +} + +void QCoeFepInputContext::CcpuCutL() +{ + copyOrCutTextToClipboard("cut"); +} + +TBool QCoeFepInputContext::CcpuCanCopy() const +{ + return CcpuCanCut(); +} + +void QCoeFepInputContext::CcpuCopyL() +{ + copyOrCutTextToClipboard("copy"); +} + +TBool QCoeFepInputContext::CcpuCanPaste() const +{ + bool canPaste = false; + QString textToPaste = QApplication::clipboard()->text(); + if (!textToPaste.isEmpty()) { + QWidget *w = focusWidget(); + QObject *focusObject = 0; + if (!w) { + w = m_lastFocusedEditor; + focusObject = m_lastFocusedObject; + } else { + w = getQWidgetFromQGraphicsView(w, &focusObject); + } + if (w) { + // First, check if we are dealing with standard Qt editors (QLineEdit, QTextEdit, or QPlainTextEdit), + // as they do not have queryable property. + if (QTextEdit* tedit = qobject_cast<QTextEdit *>(w)) { + canPaste = tedit->canPaste(); + } else if (QPlainTextEdit* ptedit = qobject_cast<QPlainTextEdit *>(w)) { + canPaste = ptedit->canPaste(); + } else if (QLineEdit* ledit = qobject_cast<QLineEdit *>(w)) { + QString fullText = ledit->text(); + if (ledit->hasSelectedText()) { + fullText.remove(ledit->selectionStart(), ledit->selectedText().length()); + fullText.insert(ledit->selectionStart(), textToPaste); + } else { + fullText.insert(ledit->cursorPosition(), textToPaste); + } + + if (fullText.length() > ledit->maxLength()) { + canPaste = false; + } else { + const QValidator* validator = ledit->validator(); + if (validator) { + int pos = 0; + if (validator->validate(fullText, pos) == QValidator::Invalid) + canPaste = false; + else + canPaste = true; + } else { + QString mask(ledit->inputMask()); + if (!mask.isEmpty()) { + QCoeFepInputMaskHandler maskhandler(mask); + if (maskhandler.canPasteClipboard(fullText)) + canPaste = true; + else + canPaste = false; + } else { + canPaste = true; + } + } + } + } else { + // Unknown editor (probably a QML one); Request the "canPaste" property. + QObject *invokeTarget = w; + if (focusObject) + invokeTarget = focusObject; + + canPaste = invokeTarget->property("canPaste").toBool(); + } + } + } + return canPaste; +} + +void QCoeFepInputContext::CcpuPasteL() +{ + QWidget *w = focusWidget(); + QObject *focusObject = 0; + if (!w) { + w = m_lastFocusedEditor; + focusObject = m_lastFocusedObject; + } else { + w = getQWidgetFromQGraphicsView(w, &focusObject); + } + if (w) + ccpuInvokeSlot(w, focusObject, "paste"); +} + +TBool QCoeFepInputContext::CcpuCanUndo() const +{ + //not supported + return EFalse; +} + +void QCoeFepInputContext::CcpuUndoL() +{ + //not supported +} + +void QCoeFepInputContext::copy() +{ + QT_TRAP_THROWING(CcpuCopyL()); +} + +void QCoeFepInputContext::paste() +{ + QT_TRAP_THROWING(CcpuPasteL()); +} + TTypeUid::Ptr QCoeFepInputContext::MopSupplyObject(TTypeUid /*id*/) { return TTypeUid::Null(); diff --git a/src/gui/widgets/qlabel.cpp b/src/gui/widgets/qlabel.cpp index ab88f38..c0be3e1 100644 --- a/src/gui/widgets/qlabel.cpp +++ b/src/gui/widgets/qlabel.cpp @@ -59,6 +59,10 @@ #include <qaccessible.h> #endif +#ifdef Q_OS_SYMBIAN +#include "qt_s60_p.h" +#endif + QT_BEGIN_NAMESPACE /*! @@ -698,7 +702,11 @@ QSize QLabelPrivate::sizeForWidth(int w) const bool tryWidth = (w < 0) && (align & Qt::TextWordWrap); if (tryWidth) +#ifdef Q_OS_SYMBIAN + w = qMin(S60->clientRect().Width(), q->maximumSize().width()); +#else w = qMin(fm.averageCharWidth() * 80, q->maximumSize().width()); +#endif else if (w < 0) w = 2000; w -= (hextra + contentsMargin.width()); diff --git a/src/plugins/accessible/widgets/qaccessiblemenu.cpp b/src/plugins/accessible/widgets/qaccessiblemenu.cpp index 4ae1d15..e9e5ca8 100644 --- a/src/plugins/accessible/widgets/qaccessiblemenu.cpp +++ b/src/plugins/accessible/widgets/qaccessiblemenu.cpp @@ -93,7 +93,7 @@ int QAccessibleMenu::childAt(int x, int y) const QString QAccessibleMenu::text(Text t, int child) const { QString tx = QAccessibleWidgetEx::text(t, child); - if (tx.size()) + if (!child && tx.size()) return tx; switch (t) { diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index fc65b86..a7dad2b 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -1377,6 +1377,9 @@ void QNetworkSessionPrivateImpl::handleSymbianConnectionStatusChange(TInt aConne newState(QNetworkSession::Closing,accessPointId); break; + // Connection stopped + case KConfigDaemonFinishedDeregistrationStop: //this comes if this is the last session, instead of KLinkLayerClosed + case KConfigDaemonFinishedDeregistrationPreserve: // Connection closed case KConnectionClosed: case KLinkLayerClosed: diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index fdfe94a..ee80297 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -329,7 +329,27 @@ void SymbianEngine::updateConfigurationsL() cpPriv->connectionId = 0; cpPriv->state = QNetworkConfiguration::Defined; cpPriv->type = QNetworkConfiguration::ServiceNetwork; - cpPriv->purpose = QNetworkConfiguration::UnknownPurpose; + + // determine purpose of this SNAP + TUint32 purpose = CMManager::ESnapPurposeUnknown; + TRAP_IGNORE(purpose = destination.MetadataL(CMManager::ESnapMetadataPurpose)); + switch (purpose) { + case CMManager::ESnapPurposeInternet: + cpPriv->purpose = QNetworkConfiguration::PublicPurpose; + break; + case CMManager::ESnapPurposeIntranet: + cpPriv->purpose = QNetworkConfiguration::PrivatePurpose; + break; + case CMManager::ESnapPurposeMMS: + case CMManager::ESnapPurposeOperator: + cpPriv->purpose = QNetworkConfiguration::ServiceSpecificPurpose; + break; + case CMManager::ESnapPurposeUnknown: + default: + cpPriv->purpose = QNetworkConfiguration::UnknownPurpose; + break; + } + cpPriv->roamingSupported = false; QNetworkConfigurationPrivatePointer ptr(cpPriv); @@ -482,9 +502,39 @@ void SymbianEngine::updateConfigurationsL() #ifdef SNAP_FUNCTIONALITY_AVAILABLE updateStatesToSnaps(); + updatePurposeToIaps(); #endif } +//copy purpose from SNAP to child IAPs, unless child is contained in more than one SNAP with conflicting purposes. +void SymbianEngine::updatePurposeToIaps() +{ + QMutexLocker lock(&mutex); + QHash<QString,int> purposes; + foreach (QNetworkConfigurationPrivatePointer snap, snapConfigurations.values()) { + QMutexLocker snaplock(&snap->mutex); + foreach (QNetworkConfigurationPrivatePointer iap, snap->serviceNetworkMembers.values()) { + QMutexLocker iaplock(&iap->mutex); + QString id = iap->id; + if (purposes.contains(id) && purposes.value(id) != snap->purpose) + purposes[id] = -1; //conflict detected + else + purposes[id] = snap->purpose; + } + } + + for (QHash<QString,int>::const_iterator it = purposes.constBegin(); it != purposes.constEnd(); ++it) { + if (accessPointConfigurations.contains(it.key())) { + QNetworkConfigurationPrivatePointer iap = accessPointConfigurations.value(it.key()); + QMutexLocker iaplock(&iap->mutex); + int purpose = it.value(); + if (purpose == -1) //resolve conflicts as unknown + purpose = QNetworkConfiguration::UnknownPurpose; + iap->purpose = (QNetworkConfiguration::Purpose)purpose; + } + } +} + #ifdef SNAP_FUNCTIONALITY_AVAILABLE SymbianNetworkConfigurationPrivate *SymbianEngine::configFromConnectionMethodL( RCmConnectionMethod& connectionMethod) diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h index a205c97..b75f27e 100644 --- a/src/plugins/bearer/symbian/symbianengine.h +++ b/src/plugins/bearer/symbian/symbianengine.h @@ -155,6 +155,7 @@ public Q_SLOTS: private: void updateStatesToSnaps(); + void updatePurposeToIaps(); bool changeConfigurationStateTo(QNetworkConfigurationPrivatePointer ptr, QNetworkConfiguration::StateFlags newState); bool changeConfigurationStateAtMinTo(QNetworkConfigurationPrivatePointer ptr, diff --git a/src/plugins/sqldrivers/symsql/main.cpp b/src/plugins/sqldrivers/symsql/main.cpp new file mode 100644 index 0000000..5dfa9f4 --- /dev/null +++ b/src/plugins/sqldrivers/symsql/main.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtSql module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qsqldriverplugin.h> +#include <QStringList> +#include "../../../sql/drivers/symsql/qsql_symsql.h" + +QT_BEGIN_NAMESPACE + +class QSymSQLDriverPlugin : public QSqlDriverPlugin +{ +public: + QSymSQLDriverPlugin(); + + QSqlDriver* create(const QString &); + QStringList keys() const; +}; + +QSymSQLDriverPlugin::QSymSQLDriverPlugin() + : QSqlDriverPlugin() +{ +} + +QSqlDriver* QSymSQLDriverPlugin::create(const QString &name) +{ + if (name == QLatin1String("QSYMSQL")) { + QSymSQLDriver* driver = new QSymSQLDriver(); + return driver; + } + return 0; +} + +QStringList QSymSQLDriverPlugin::keys() const +{ + QStringList l; + l.append(QLatin1String("QSYMSQL")); + return l; +} + +Q_EXPORT_STATIC_PLUGIN(QSymSQLDriverPlugin) +Q_EXPORT_PLUGIN2(qsymsql, QSymSQLDriverPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/sqldrivers/symsql/symsql.pro b/src/plugins/sqldrivers/symsql/symsql.pro new file mode 100644 index 0000000..8b8434c --- /dev/null +++ b/src/plugins/sqldrivers/symsql/symsql.pro @@ -0,0 +1,13 @@ +TARGET = qsymsql +PLUGIN_TYPE = sqldrivers +SOURCES = main.cpp + +include(../../../sql/drivers/symsql/qsql_symsql.pri) +include(../qsqldriverbase.pri) + +symbian: { +pluginDep.sources = $${TARGET}.dll +pluginDep.path = $${QT_PLUGINS_BASE_DIR}/$${PLUGIN_TYPE} +DEPLOYMENT += pluginDep +} + diff --git a/src/sql/drivers/symsql/qsql_symsql.cpp b/src/sql/drivers/symsql/qsql_symsql.cpp new file mode 100644 index 0000000..4ceac9b --- /dev/null +++ b/src/sql/drivers/symsql/qsql_symsql.cpp @@ -0,0 +1,1185 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtSql module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qsql_symsql.h" + + +#define SYMBIAN_ENABLE_PUBLIC_PLATFORM_HEADER_SPLIT + +#include <qcoreapplication.h> +#include <qvariant.h> +#include <qsqlerror.h> +#include <qsqlfield.h> +#include <qsqlindex.h> +#include <qsqlquery.h> +#include <qstringlist.h> +#include <qvector.h> +#include <qdebug.h> +#include "../../../corelib/kernel/qcore_symbian_p.h" + +#if defined Q_OS_WIN +# include <qt_windows.h> +#else +# include <unistd.h> +#endif + +#include <sqldb.h> +#include <e32capability.h> + +const char* qCapabilityNames[ECapability_Limit] = +{ + "TCB", + "CommDD", + "PowerMgmt", + "MultimediaDD", + "ReadDeviceData", + "WriteDeviceData", + "DRM", + "TrustedUI", + "ProtServ", + "DiskAdmin", + "NetworkControl", + "AllFiles", + "SwEvent", + "NetworkServices", + "LocalServices", + "ReadUserData", + "WriteUserData", + "Location", + "SurroundingsDD", + "UserEnvironment" +}; + +const char qCapabilityNone[] = "None"; + + +Q_DECLARE_METATYPE(RSqlDatabase) +Q_DECLARE_METATYPE(RSqlStatement) + +QT_BEGIN_NAMESPACE + +const QString valueSeparator(QLatin1String("=")); +const QString fieldSeparator(QLatin1String(",")); + +static QString _q_escapeIdentifier(const QString &identifier) +{ + QString res = identifier; + if (!identifier.isEmpty() + && identifier.left(1) != QString(QLatin1Char('"')) + && identifier.right(1) != QString(QLatin1Char('"'))) { + res.replace(QLatin1Char('"'), QLatin1String("\"\"")); + res.prepend(QLatin1Char('"')).append(QLatin1Char('"')); + res.replace(QLatin1Char('.'), QLatin1String("\".\"")); + } + return res; +} + +static QVariant::Type qGetColumnType(const TSqlColumnType coltype) +{ + switch(coltype){ + case ESqlInt: + case ESqlInt64: + return QVariant::Int; + case ESqlReal: + return QVariant::Double; + case ESqlBinary: + return QVariant::ByteArray; + case ESqlText: + case ESqlNull: + default: + return QVariant::String; + } +} + +static QVariant::Type qGetColumnType(const QString &tpName) +{ + const QString typeName = tpName.toLower(); + + if (typeName == QLatin1String("integer") + || typeName == QLatin1String("int")) + return QVariant::Int; + if (typeName == QLatin1String("double") + || typeName == QLatin1String("float") + || typeName == QLatin1String("real") + || typeName.startsWith(QLatin1String("numeric"))) + return QVariant::Double; + if (typeName == QLatin1String("blob")) + return QVariant::ByteArray; + return QVariant::String; +} + +static QSqlError qMakeError(RSqlDatabase& access, + const QString &descr, + QSqlError::ErrorType type, + int errorCode = -1) +{ + return QSqlError(descr, + QString::fromUtf16(static_cast<const ushort *>(access.LastErrorMessage().Ptr())), + type, + errorCode); +} + + +static QSqlError gMakeErrorOpen(const QString &descr, + QSqlError::ErrorType type, + TInt errorCode) +{ + return QSqlError(descr, QLatin1String(""), type, errorCode); +} + +class QSymSQLDriverPrivate +{ +public: + inline QSymSQLDriverPrivate() {} + RSqlDatabase access; +}; + +class QSymSQLResultPrivate +{ +public: + QSymSQLResultPrivate(QSymSQLResult *res); + void cleanup(); + bool fetchNext(bool initialFetch); + // initializes the recordInfo + void initColumns(QSqlRecord& rec); + void finalize(); + + QSymSQLResult* q; + RSqlDatabase access; + RSqlStatement stmt; + bool skipRow; // skip the next fetchNext()? + bool skippedStatus; // the status of the fetchNext() that's skipped + bool prepareCalled; +}; + +QSymSQLResultPrivate::QSymSQLResultPrivate(QSymSQLResult* res) : q(res), + skipRow(false), + skippedStatus(false), + prepareCalled(false) +{ +} + +void QSymSQLResultPrivate::cleanup() +{ + finalize(); + skippedStatus = false; + skipRow = false; + q->setAt(QSql::BeforeFirstRow); + q->setActive(false); +} + +void QSymSQLResultPrivate::finalize() +{ + prepareCalled = false; + stmt.Close(); +} + +void QSymSQLResultPrivate::initColumns(QSqlRecord& rec) +{ + int nCols = stmt.ColumnCount(); + if (nCols <= 0) { + q->setLastError(qMakeError(access, QCoreApplication::translate("QSymSQLResult", + "Error retreving column count"), QSqlError::UnknownError, nCols)); + return; + } + + for (int i = 0; i < nCols; ++i) { + TPtrC cName; + TInt err = stmt.ColumnName(i, cName); + + if (err != KErrNone) { + q->setLastError(qMakeError(access, QCoreApplication::translate("QSymSQLResult", + "Error retreving column name"), QSqlError::UnknownError, err)); + return; + } + + QString colName = qt_TDesC2QString(cName); + + // must use typeName for resolving the type to match QSymSQLDriver::record + TPtrC tName; + TSqlColumnType decColType; + err = stmt.DeclaredColumnType(i, decColType); + + if (err != KErrNone) { + q->setLastError(qMakeError(access, QCoreApplication::translate("QSymSQLResult", + "Error retreving column type"), QSqlError::UnknownError, err)); + return; + } + + int dotIdx = colName.lastIndexOf(QLatin1Char('.')); + QSqlField fld(colName.mid(dotIdx == -1 ? 0 : dotIdx + 1), qGetColumnType(decColType)); + + rec.append(fld); + } +} + +bool QSymSQLResultPrivate::fetchNext(bool initialFetch) +{ + int res; + + if (skipRow) { + // already fetched + Q_ASSERT(!initialFetch); + skipRow = false; + return skippedStatus; + } + + skipRow = initialFetch; + res = stmt.Next(); + + switch(res) { + case KSqlAtRow: + return true; + case KSqlAtEnd: + stmt.Reset(); + return false; + case KSqlErrGeneral: + // KSqlErrGeneral is a generic error code and we must call stmt.Reset() + // to get the specific error message. + stmt.Reset(); + q->setLastError(qMakeError(access, QCoreApplication::translate("QSymSQLResult", + "Unable to fetch row"), QSqlError::ConnectionError, res)); + q->setAt(QSql::AfterLastRow); + return false; + case KSqlErrMisuse: + case KSqlErrBusy: + default: + // something wrong, don't get col info, but still return false + q->setLastError(qMakeError(access, QCoreApplication::translate("QSymSQLResult", + "Unable to fetch row"), QSqlError::ConnectionError, res)); + stmt.Reset(); + q->setAt(QSql::AfterLastRow); + return false; + } + return false; +} + +////////////////////////////////// QSymSQLResult ///////////////////////////////////////////////// + +QSymSQLResult::QSymSQLResult(const QSymSQLDriver* db) + : QSqlResult(db) +{ + d = new QSymSQLResultPrivate(this); + d->access = db->d->access; +} + + +QSymSQLResult::~QSymSQLResult() +{ + d->cleanup(); + delete d; +} + +bool QSymSQLResult::reset(const QString &query) +{ + if (!prepare(query)) + return false; + + return exec(); +} + +bool QSymSQLResult::prepare(const QString &query) +{ + if (!driver() || !driver()->isOpen() || driver()->isOpenError()) + return false; + + d->cleanup(); + setSelect(false); + + TInt res = d->stmt.Prepare(d->access, qt_QString2TPtrC(query)); + + if (res != KErrNone) { + setLastError(qMakeError(d->access, QCoreApplication::translate("QSymSQLResult", + "Unable to execute statement"), QSqlError::StatementError, res)); + d->finalize(); + return false; + } + + d->prepareCalled = true; + + return true; +} + +bool QSymSQLResult::exec() +{ + if (d->prepareCalled == false) { + setLastError(qMakeError(d->access, QCoreApplication::translate("QSymSQLResult", + "Statement is not prepared"), QSqlError::StatementError, KErrGeneral)); + return false; + } + + const QVector<QVariant> values = boundValues(); + + d->skippedStatus = false; + d->skipRow = false; + setAt(QSql::BeforeFirstRow); + setLastError(QSqlError()); + int res = d->stmt.Reset(); + + if (res != KErrNone) { + setLastError(qMakeError(d->access, QCoreApplication::translate("QSymSQLResult", + "Unable to reset statement"), QSqlError::StatementError, res)); + d->finalize(); + return false; + } + TPtrC tmp; + TInt paramCount = 0; + while (d->stmt.ParamName(paramCount, tmp) == KErrNone) + paramCount++; + + if (paramCount == values.count()) { + for (int i = 0; i < paramCount; ++i) { + res = KErrNone; + const QVariant value = values.at(i); + + if (value.isNull()) { + res = d->stmt.BindNull(i); //replaced i + 1 with i + } else { + switch (value.type()) { + case QVariant::ByteArray: { + const QByteArray *ba = static_cast<const QByteArray*>(value.constData()); + TPtrC8 data(reinterpret_cast<const TUint8 *>(ba->constData()), ba->length()); + res = d->stmt.BindBinary(i, data); //replaced i + 1 with i + break; } + case QVariant::Int: + res = d->stmt.BindInt(i, value.toInt()); //replaced i + 1 with i + break; + case QVariant::Double: + res = d->stmt.BindReal(i, value.toDouble()); //replaced i + 1 with i + + break; + case QVariant::UInt: + case QVariant::LongLong: + res = d->stmt.BindReal(i, value.toLongLong()); //replaced i + 1 with i + break; + + case QVariant::String: { + // lifetime of string == lifetime of its qvariant + const QString *str = static_cast<const QString*>(value.constData()); + res = d->stmt.BindText(i, qt_QString2TPtrC(*str)); // replaced i + 1 with i + break; } + default: { + QString str = value.toString(); + res = d->stmt.BindText(i, qt_QString2TPtrC(str)); //replaced i + 1 with i + break; } + } + } + if (res != KErrNone) { + setLastError(qMakeError(d->access, QCoreApplication::translate("QSymSQLResult", + "Unable to bind parameters"), QSqlError::StatementError, res)); + d->finalize(); + return false; + } + } + } else { + setLastError(QSqlError(QCoreApplication::translate("QSymSQLResult", + "Parameter count mismatch"), QString(), QSqlError::StatementError)); + return false; + } + + d->skippedStatus = d->fetchNext(true); + + if (lastError().isValid()) { + setSelect(false); + setActive(false); + return false; + } + + if (d->stmt.ColumnCount() > 0) { + //If there is something, it has to be select + setSelect(true); + } else { + //If there isn't it might be just bad query, let's check manually whether we can find SELECT + QString query = this->lastQuery(); + query = query.trimmed(); + query = query.toLower(); + + //Just check whether there is one in the beginning, don't know if this is enough + //Comments should be at the end of line if those are passed + //For some reason, case insensitive indexOf didn't work for me + if (query.indexOf(QLatin1String("select")) == 0) { + setSelect(true); + } else { + setSelect(false); + } + } + + setActive(true); + return true; +} + + +int QSymSQLResult::size() +{ + return -1; +} + +int QSymSQLResult::numRowsAffected() +{ + return -1; +} + +QVariant QSymSQLResult::lastInsertId() const +{ + if (isActive()) { + qint64 id = static_cast<qint64>(d->access.LastInsertedRowId()); + if (id) + return id; + } + + return QVariant(); +} + +QSqlRecord QSymSQLResult::record() const +{ + if (!isActive() || !isSelect()) + return QSqlRecord(); + + QSqlRecord res; + d->initColumns(res); + + return res; +} + +QVariant QSymSQLResult::handle() const +{ + return qVariantFromValue(d->stmt); +} + + +void QSymSQLResult::virtual_hook(int id, void *data) +{ + switch (id) + { + case QSqlResult::DetachFromResultSet: + d->stmt.Reset(); + break; + default: + QSqlResult::virtual_hook(id, data); + } +} + +QVariant QSymSQLResult::data(int idx) +{ + QVariant r; + + switch (d->stmt.ColumnType(idx)) { + case ESqlBinary: + { + TPtrC8 data; + d->stmt.ColumnBinary(idx, data); + return QByteArray(reinterpret_cast<const char *>(data.Ptr()), data.Length()); + break; + } + case ESqlInt: + r = QVariant(d->stmt.ColumnInt(idx)); + break; + case ESqlInt64: + r = QVariant(d->stmt.ColumnInt64(idx)); + break; + case ESqlReal: + switch(numericalPrecisionPolicy()) { + case QSql::LowPrecisionInt32: + r = QVariant(d->stmt.ColumnInt(idx)); + break; + case QSql::LowPrecisionInt64: + r = QVariant(d->stmt.ColumnInt64(idx)); + break; + case QSql::LowPrecisionDouble: + r = QVariant(d->stmt.ColumnReal(idx)); + break; + case QSql::HighPrecision: + default: + TPtrC res; + d->stmt.ColumnText(idx, res); + r = QVariant(qt_TDesC2QString(res)); + break; + }; + break; + case ESqlNull: + r = QVariant(QVariant::String); + break; + default: + TPtrC res; + d->stmt.ColumnText(idx, res); + r = QVariant(qt_TDesC2QString(res)); + break; + } + + return r; +} + +bool QSymSQLResult::isNull(int i) +{ + return d->stmt.IsNull(i); +} + +bool QSymSQLResult::fetch(int i) +{ + //Single return point modified according to review + bool retVal = true; + + if (i < 0 || !isActive()) { + retVal = false; + } else { + if (at() <= -1 || i < at()) { + d->stmt.Reset(); + setAt(-1); + d->skipRow = false; + } + + while (at() < i) { + if (!d->fetchNext(false)) { + retVal = false; + break; + } + + setAt(at() + 1); + } + } + + return retVal; +} + +bool QSymSQLResult::fetchNext() +{ + bool res = d->fetchNext(false); + if (res) { + setAt(at()+1); + } + + return res; +} + +bool QSymSQLResult::fetchPrevious() +{ + return QSqlResult::fetchPrevious(); +} + +bool QSymSQLResult::fetchFirst() +{ + return fetch(0); +} + +bool QSymSQLResult::fetchLast() +{ + if (!isActive()) + return false; + + if (at() <= -1) { + if (!fetchFirst()) + return false; + } + + TInt res; + + do { + res = d->stmt.Next(); + setAt(at()+1); + } while (res == KSqlAtRow); + + if (res != KSqlAtEnd) + return false; + + d->skippedStatus = false; + d->skipRow = false; + + return fetchPrevious(); +} +////////////////////////////////// QSymSQLDriver ////////////////////////////////////////// + +QSymSQLDriver::QSymSQLDriver(QObject * parent) + : QSqlDriver(parent) +{ + d = new QSymSQLDriverPrivate(); +} + +QSymSQLDriver::QSymSQLDriver(RSqlDatabase& connection, QObject *parent) + : QSqlDriver(parent) +{ + d = new QSymSQLDriverPrivate(); + d->access = connection; + setOpen(true); + setOpenError(false); +} + + +QSymSQLDriver::~QSymSQLDriver() +{ + d->access.Close(); + delete d; +} + +bool QSymSQLDriver::hasFeature(DriverFeature f) const +{ + switch (f) { + case BLOB: + case Transactions: + case Unicode: + case PreparedQueries: + case PositionalPlaceholders: + case SimpleLocking: + case FinishQuery: + case LowPrecisionNumbers: + case LastInsertId: + case NamedPlaceholders: + return true; + case QuerySize: + case BatchOperations: + case EventNotifications: + case MultipleResultSets: + return false; + } + return false; +} + +/*! + Converts capability string to TCapability +*/ +TCapability qMatchCapStr(QString& str) +{ + TCapability cap = ECapability_HardLimit; + + for (int i = 0; i < static_cast<int>(ECapability_Limit); i++) { + if (str.compare(QLatin1String(qCapabilityNames[i]), Qt::CaseInsensitive) == 0) { + cap = static_cast<TCapability>(i); + break; + } + } + + //Special case, we allow ECapability_None to be defined + if (cap == ECapability_HardLimit + && str.compare(QLatin1String(qCapabilityNone), Qt::CaseInsensitive) == 0) + cap = ECapability_None; + + return cap; +} + +bool qExtractSecurityPolicyFromString(const QString &string, TSecurityPolicy &policy) +{ + int startPos = string.indexOf(QLatin1Char('=')); + QStringList values; + bool ret = false; + + if (startPos == -1) { + values = string.split(QLatin1Char(','), QString::SkipEmptyParts); + } else { + values = string.mid(startPos + 1).split(QLatin1Char(','), QString::SkipEmptyParts); + } + + if (values.count() > 0) { + const QString findVid(QLatin1String("vid[")); + const QString findSid(QLatin1String("sid[")); + const int MaxCapCount = 7; + const int VidMaxCount = 3; + const int SidMaxCount = 3; + + TCapability capList[MaxCapCount] = { ECapability_None,ECapability_None,ECapability_None, + ECapability_None,ECapability_None,ECapability_None,ECapability_None }; + + bool isVID = false; + bool isSID = false; + + QString idString(QLatin1String("")); + int maxAllowed = MaxCapCount; + + if (values[0].contains(findVid, Qt::CaseInsensitive)) { + idString = values[0].remove(findVid, Qt::CaseInsensitive); + idString = idString.remove(QLatin1Char(']')); + values.removeAt(0); + isVID = true; + maxAllowed = VidMaxCount; + + } else if (values[0].contains(findSid, Qt::CaseInsensitive)) { + idString = values[0].remove(findSid, Qt::CaseInsensitive); + idString = idString.remove(QLatin1Char(']')); + values.removeAt(0); + isSID = true; + maxAllowed = SidMaxCount; + } + + if (values.count() <= maxAllowed) { + bool wasSuccesful = true; + + for (int i = 0; i < values.count(); i++) { + capList[i] = qMatchCapStr(values[i]); + + if (capList[i] == ECapability_HardLimit) { + wasSuccesful = false; + break; + } + } + + if (wasSuccesful) { + if (isVID || isSID){ + bool ok = true; + quint32 id = idString.toUInt(&ok, 16); + + if (ok) { + if (isVID) { + TVendorId vid(id); + policy = TSecurityPolicy(vid, capList[0], capList[1], capList[2]); + } else { + TSecureId sid(id); + policy = TSecurityPolicy(sid, capList[0], capList[1], capList[2]); + } + + ret = true; //Everything is fine + } + } else { + policy = TSecurityPolicy(capList[0], capList[1], capList[2], capList[3], + capList[4], capList[5], capList[6]); + + ret = true; //Everything is fine + } + } + } + } + + return ret; +} + +/*! + Opens the database connection using the given connection options. Returns true on success; otherwise returns false. + Error information can be retrieved using the lastError() function. Symbian SQL dbs have no \a user, \a password, \a host + or \a port just file names. + + \a connOpts Connection options hold definition for security policies and all parameters that does not contain "POLICY_" will be + passed to RSqlDatabase. Policy will be filled according to parsed values. + + Value in database wide parameters starts by definition which can be vendorId or secureId. These come directly from TSecurityPolicy class in Symbian. + + POLICY_DB_DEFAULT + Default security policy which will be used for the database and all database objects. POLICY_DB_DEFAULT must be + defined before any other policy definitions can be used. + POLICY_DB_READ + Read database security policy. An application with read database security policy can read from database. + POLICY_DB_WRITE: + Write database security policy. An application with write database security policy can write to database. + POLICY_DB_SCHEMA: + Schema database security policy. An application with schema database security policy can modify + the database schema, write to database, read from database. + + Format: + POLICY_DB_DEFAULT=cap1,cap2,cap3,cap4,cap5,cap6,cap7 (Up to 7 capabilities) + POLICY_DB_READ=cap1,cap2,cap3,cap4,cap5,cap6,cap7 (Up to 7 capabilities) + POLICY_DB_WRITE=vendorid,cap1,cap2,cap3 (Vendor ID and up to 3 capabilities) + POLICY_DB_SCHEMA=secureid,cap1,cap2,cap3 (Secure ID and up to 3 capabilities) + + Table policies does not support schema policy as database level does. + + Table specific parameters would be as: + POLICY_TABLE_WRITE=tablename,cap1,cap2,cap3,cap4,cap5,cap6,cap7 + POLICY_TABLE_READ=tablename,cap1,cap2,cap3,cap4,cap5,cap6,cap7 + + Vendor Id and Secure id format: + vid[0x12345678] (Hex) + sid[0x12345678] (Hex) + + Example: + \code + QSqlDatabase database = QSqlDatabase::addDatabase("QSYMSQL", "MyConnection"); + database.setConnectOptions("POLICY_DB_DEFAULT=ReadDeviceData"); + database.setDatabaseName("[12345678]myDatabase"); + bool ok = database.open(); + \encode + + \code + QSqlDatabase database = QSqlDatabase::addDatabase("QSYMSQL", "MyConnection"); + database.setConnectOptions("POLICY_DB_DEFAULT=None; POLICY_DB_WRITE=sid[0x12345678], WriteDeviceData"); + database.setDatabaseName("[12345678]myDatabase"); + bool ok = database.open(); + \encode + + FOREIGN KEY: + Enabling foreign key support from underlying SQLite + add: "foreign_keys = ON" to your connection options string. This will be passes to SQLite. + + Foreign key Example: + \code + QSqlDatabase database = QSqlDatabase::addDatabase("QSYMSQL", "MyConnection"); + database.setDatabaseName("[12345678]myDatabase"); + database.setConnectOptions("foreign_keys = ON"); + bool ok = database.open(); + \encode + + More information about Symbian Security Policy can be found from Symbian documentation. + +*/ +bool QSymSQLDriver::open(const QString & db, const QString &, const QString &, const QString &, int, const QString &conOpts) +{ + if (isOpen()) + close(); + if (db.isEmpty()) + return false; + + //Separating our parameters from Symbian ones and construct new connection options + const QString itemSeparator(QLatin1String(";")); + QRegExp isOurOption(QLatin1String("POLICY_*"), Qt::CaseInsensitive, QRegExp::Wildcard); + + QStringList optionList = conOpts.split(itemSeparator, QString::SkipEmptyParts); + QStringList symbianList; + + for (int i = optionList.count() - 1; i >= 0; i--) { + if (!optionList[i].contains(isOurOption)) { + symbianList.append(optionList[i]); + optionList.removeAt(i); + } else { + //Removing whitespace + QString formatted = optionList[i]; + formatted = formatted.remove(QLatin1Char(' ')); + formatted = formatted.remove(QLatin1Char('\t')); + formatted = formatted.remove(QLatin1Char('\n')); + formatted = formatted.remove(QLatin1Char('\r')); + optionList[i] = formatted; + } + } + + QString symbianOpt; + + for (int i = 0; i < symbianList.count(); i++) { + symbianOpt += symbianList[i]; + symbianOpt += itemSeparator; + } + + TPtrC dbName(qt_QString2TPtrC(db)); + QByteArray conOpts8 = symbianOpt.toUtf8(); + const TPtrC8 config(reinterpret_cast<const TUint8*>(conOpts8.constData()), (conOpts8.length())); + + TInt res = d->access.Open(dbName, &config); + + if (res == KErrNotFound) { + + QRegExp findDefault(QLatin1String("POLICY_DB_DEFAULT=*"), Qt::CaseInsensitive, QRegExp::Wildcard); + QRegExp findRead(QLatin1String("POLICY_DB_READ=*"), Qt::CaseInsensitive, QRegExp::Wildcard); + QRegExp findWrite(QLatin1String("POLICY_DB_WRITE=*"), Qt::CaseInsensitive, QRegExp::Wildcard); + QRegExp findSchema(QLatin1String("POLICY_DB_SCHEMA=*"), Qt::CaseInsensitive, QRegExp::Wildcard); + QRegExp findTableRead(QLatin1String("POLICY_TABLE_READ=*"), Qt::CaseInsensitive, QRegExp::Wildcard); + QRegExp findTableWrite(QLatin1String("POLICY_TABLE_WRITE=*"), Qt::CaseInsensitive, QRegExp::Wildcard); + + int policyIndex = optionList.indexOf(findDefault); + + if (policyIndex != -1) { + QString defaultPolicyString = optionList[policyIndex]; + optionList.removeAt(policyIndex); + + TSecurityPolicy policyItem; + + if (qExtractSecurityPolicyFromString(defaultPolicyString, policyItem)) { + RSqlSecurityPolicy policy; + res = policy.Create(policyItem); + + if (res == KErrNone) { + for (int i = 0; i < optionList.count(); i++) { + QString option = optionList[i]; + + if (option.contains(findRead)) { + if (qExtractSecurityPolicyFromString(option, policyItem)) { + res = policy.SetDbPolicy(RSqlSecurityPolicy::EReadPolicy, policyItem); + } else { + res = KErrArgument; + } + } else if (option.contains(findWrite)) { + if (qExtractSecurityPolicyFromString(option, policyItem)) { + res = policy.SetDbPolicy(RSqlSecurityPolicy::EWritePolicy, policyItem); + } else { + res = KErrArgument; + } + } else if (option.contains(findSchema)) { + if (qExtractSecurityPolicyFromString(option, policyItem)) { + res = policy.SetDbPolicy(RSqlSecurityPolicy::ESchemaPolicy, policyItem); + } else { + res = KErrArgument; + } + } else if (option.contains(findTableWrite)) { + QString tableOption = option.mid(option.indexOf(QLatin1Char('=')) + 1); + int firstComma = tableOption.indexOf(QLatin1Char(',')); + + if (firstComma != -1) { + QString tableName = tableOption.left(firstComma); + tableOption = tableOption.mid(firstComma + 1); + + if (qExtractSecurityPolicyFromString(tableOption, policyItem)) { + TPtrC symTableName(qt_QString2TPtrC(tableName)); + + res = policy.SetPolicy(RSqlSecurityPolicy::ETable, symTableName, + RSqlSecurityPolicy::EWritePolicy, policyItem); + } else { + res = KErrArgument; + } + } else { + res = KErrArgument; + } + } else if (option.contains(findTableRead)) { + QString tableOption = option.mid(option.indexOf(QLatin1Char('=')) + 1); + int firstComma = tableOption.indexOf(QLatin1Char(',')); + + if (firstComma != -1) { + QString tableName = tableOption.left(firstComma); + tableOption = tableOption.mid(firstComma + 1); + + if (qExtractSecurityPolicyFromString(tableOption, policyItem)) { + TPtrC symTableName(qt_QString2TPtrC(tableName)); + + res = policy.SetPolicy(RSqlSecurityPolicy::ETable, symTableName, + RSqlSecurityPolicy::EReadPolicy, policyItem); + } else { + res = KErrArgument; + } + } else { + res = KErrArgument; + } + } else { + res = KErrArgument; + } + + if (res != KErrNone) { + setLastError(gMakeErrorOpen(tr("Invalid option: ") + option, QSqlError::ConnectionError, res)); + break; + } + } + + if (res == KErrNone) { + res = d->access.Create(dbName, policy, &config); + policy.Close(); + + if (res != KErrNone) + setLastError(gMakeErrorOpen(tr("Error opening database"), QSqlError::ConnectionError, res)); + } + } + + } else { + res = KErrArgument; + setLastError(gMakeErrorOpen(tr("Invalid option: ") + defaultPolicyString, QSqlError::ConnectionError, res)); + } + + } else { + //Check whether there is some of our options, fail if so. + policyIndex = optionList.indexOf(isOurOption); + + if (policyIndex == -1) { + res = d->access.Create(dbName, &config); + + if (res != KErrNone) + setLastError(gMakeErrorOpen(tr("Error opening database"), QSqlError::ConnectionError, res)); + } else { + res = KErrArgument; + setLastError(gMakeErrorOpen(tr("POLICY_DB_DEFAULT must be defined before any other POLICY definitions can be used"), QSqlError::ConnectionError, res)); + } + } + } + + if (res == KErrNone) { + setOpen(true); + setOpenError(false); + return true; + } else { + setOpenError(true); + return false; + } +} + +void QSymSQLDriver::close() +{ + if (isOpen()) { + d->access.Close(); + setOpen(false); + setOpenError(false); + } +} + +QSqlResult *QSymSQLDriver::createResult() const +{ + return new QSymSQLResult(this); +} + +bool QSymSQLDriver::beginTransaction() +{ + if (!isOpen() || isOpenError()) + return false; + + TInt err = d->access.Exec(_L("BEGIN")); + if (err < KErrNone) { + setLastError(QSqlError(tr("Unable to begin transaction"), + qt_TDesC2QString(d->access.LastErrorMessage()), QSqlError::TransactionError, err)); + return false; + } + + return true; +} + +bool QSymSQLDriver::commitTransaction() +{ + if (!isOpen() || isOpenError()) + return false; + + TInt err = d->access.Exec(_L("COMMIT")); + if (err < KErrNone) { + setLastError(QSqlError(tr("Unable to commit transaction"), + qt_TDesC2QString(d->access.LastErrorMessage()), QSqlError::TransactionError, err)); + return false; + } + + return true; +} + +bool QSymSQLDriver::rollbackTransaction() +{ + if (!isOpen() || isOpenError()) + return false; + + TInt err = d->access.Exec(_L("ROLLBACK")); + if (err < KErrNone) { + setLastError(QSqlError(tr("Unable to rollback transaction"), + qt_TDesC2QString(d->access.LastErrorMessage()), QSqlError::TransactionError, err)); + return false; + } + + return true; +} + +QStringList QSymSQLDriver::tables(QSql::TableType type) const +{ + QStringList res; + if (!isOpen()) + return res; + + QSqlQuery q(createResult()); + q.setForwardOnly(true); + + QString sql = QLatin1String("SELECT name FROM sqlite_master WHERE %1 " + "UNION ALL SELECT name FROM sqlite_temp_master WHERE %1"); + if ((type & QSql::Tables) && (type & QSql::Views)) + sql = sql.arg(QLatin1String("type='table' OR type='view'")); + else if (type & QSql::Tables) + sql = sql.arg(QLatin1String("type='table'")); + else if (type & QSql::Views) + sql = sql.arg(QLatin1String("type='view'")); + else + sql.clear(); + + if (!sql.isEmpty() && q.exec(sql)) { + while (q.next()) + res.append(q.value(0).toString()); + } + + if (type & QSql::SystemTables) + // there are no internal tables beside this one: + res.append(QLatin1String("sqlite_master")); + + return res; +} + +static QSqlIndex qGetTableInfo(QSqlQuery &q, QString &tableName, bool onlyPIndex = false) +{ + QString dbName; + QString table(tableName); + int indexOfSeparator = tableName.indexOf(QLatin1Char('.')); + if (indexOfSeparator > -1) { + dbName = tableName.left(indexOfSeparator +1 ); + table = tableName.mid(indexOfSeparator + 1); + } + q.exec(QLatin1String("PRAGMA ") + dbName + QLatin1String("table_info (") + _q_escapeIdentifier(table) + QLatin1String(")")); + + const int NAME_IDX = 1; + const int TYPE_IDX = 2; + const int NOTNULL_IDX = 3; + const int DFLT_VALUE_IDX = 4; + const int PK_IDX = 5; + + QSqlIndex ind; + while (q.next()) { + bool isPk = q.value(PK_IDX).toInt(); + if (onlyPIndex && !isPk) + continue; + QString typeName = q.value(TYPE_IDX).toString().toLower(); + QSqlField fld(q.value(NAME_IDX).toString(), qGetColumnType(typeName)); + if (isPk && (typeName == QLatin1String("integer"))) + // INTEGER PRIMARY KEY fields are auto-generated in sqlite + // INT PRIMARY KEY is not the same as INTEGER PRIMARY KEY! + fld.setAutoValue(true); + fld.setRequired(q.value(NOTNULL_IDX).toInt() != 0); + fld.setDefaultValue(q.value(DFLT_VALUE_IDX)); + ind.append(fld); + } + return ind; +} + +QSqlIndex QSymSQLDriver::primaryIndex(const QString &tblname) const +{ + if (!isOpen()) + return QSqlIndex(); + + QString table = tblname; + if (isIdentifierEscaped(table, QSqlDriver::TableName)) + table = stripDelimiters(table, QSqlDriver::TableName); + + QSqlQuery q(createResult()); + q.setForwardOnly(true); + return qGetTableInfo(q, table, true); +} + +QSqlRecord QSymSQLDriver::record(const QString &tbl) const +{ + if (!isOpen()) + return QSqlRecord(); + + QString table = tbl; + if (isIdentifierEscaped(table, QSqlDriver::TableName)) + table = stripDelimiters(table, QSqlDriver::TableName); + + QSqlQuery q(createResult()); + q.setForwardOnly(true); + return qGetTableInfo(q, table); +} + +QVariant QSymSQLDriver::handle() const +{ + return qVariantFromValue(d->access); +} + +QString QSymSQLDriver::escapeIdentifier(const QString &identifier, IdentifierType type) const +{ + Q_UNUSED(type); + return _q_escapeIdentifier(identifier); +} + +QT_END_NAMESPACE diff --git a/src/sql/drivers/symsql/qsql_symsql.h b/src/sql/drivers/symsql/qsql_symsql.h new file mode 100644 index 0000000..7fdc10f --- /dev/null +++ b/src/sql/drivers/symsql/qsql_symsql.h @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtSql module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSQL_SYMSQL_H +#define QSQL_SYMSQL_H + +#include <QtSql/qsqldriver.h> +#include <QtSql/qsqlresult.h> +#include <QtSql/private/qsqlcachedresult_p.h> + + + +#ifdef QT_PLUGIN +#define Q_EXPORT_SQLDRIVER_SYMSQL +#else +#define Q_EXPORT_SQLDRIVER_SYMSQL Q_SQL_EXPORT +#endif + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE +class QSymSQLDriverPrivate; +class QSymSQLResultPrivate; +class QSymSQLDriver; +class RSqlDatabase; + +class QSymSQLResult : public QSqlResult +{ + friend class QSymSQLDriver; + friend class QSymSQLResultPrivate; +public: + explicit QSymSQLResult(const QSymSQLDriver* db); + ~QSymSQLResult(); + QVariant handle() const; + +protected: + QVariant data(int field); + bool isNull(int i); + bool fetch(int i); + bool fetchNext(); + bool fetchPrevious(); + bool fetchFirst(); + bool fetchLast(); + + bool reset(const QString &query); + bool prepare(const QString &query); + bool exec(); + int size(); + int numRowsAffected(); + QSqlRecord record() const; + void virtual_hook(int id, void *data); + + QVariant lastInsertId() const; + +private: + QSymSQLResultPrivate* d; +}; + +class Q_EXPORT_SQLDRIVER_SYMSQL QSymSQLDriver : public QSqlDriver +{ + Q_OBJECT + friend class QSymSQLResult; +public: + explicit QSymSQLDriver(QObject *parent = 0); + explicit QSymSQLDriver(RSqlDatabase& connection, QObject *parent = 0); + ~QSymSQLDriver(); + bool hasFeature(DriverFeature f) const; + bool open(const QString & db, + const QString & user, + const QString & password, + const QString & host, + int port, + const QString & connOpts); + void close(); + QSqlResult *createResult() const; + bool beginTransaction(); + bool commitTransaction(); + bool rollbackTransaction(); + QStringList tables(QSql::TableType)const; + + QSqlRecord record(const QString& tablename) const; + QSqlIndex primaryIndex(const QString &table) const; + QVariant handle() const; + QString escapeIdentifier(const QString &identifier, IdentifierType) const; + +private: + QSymSQLDriverPrivate* d; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QSQL_SYMSQL_H diff --git a/src/sql/drivers/symsql/qsql_symsql.pri b/src/sql/drivers/symsql/qsql_symsql.pri new file mode 100644 index 0000000..e18cce9 --- /dev/null +++ b/src/sql/drivers/symsql/qsql_symsql.pri @@ -0,0 +1,5 @@ +HEADERS += $$PWD/qsql_symsql.h +SOURCES += $$PWD/qsql_symsql.cpp + +symbian::LIBS += -lsqldb + diff --git a/src/xmlpatterns/schema/qnamespacesupport.cpp b/src/xmlpatterns/schema/qnamespacesupport.cpp index cb0cbf7..5e0aea6 100644 --- a/src/xmlpatterns/schema/qnamespacesupport.cpp +++ b/src/xmlpatterns/schema/qnamespacesupport.cpp @@ -59,8 +59,8 @@ NamespaceSupport::NamespaceSupport() { } -NamespaceSupport::NamespaceSupport(const NamePool::Ptr &namePool) - : m_namePool(namePool) +NamespaceSupport::NamespaceSupport(NamePool &namePool) + : m_namePool(&namePool) { // the XML namespace m_ns.insert(StandardPrefixes::xml, StandardNamespaces::xml); diff --git a/src/xmlpatterns/schema/qnamespacesupport_p.h b/src/xmlpatterns/schema/qnamespacesupport_p.h index 656026e..b61bf19 100644 --- a/src/xmlpatterns/schema/qnamespacesupport_p.h +++ b/src/xmlpatterns/schema/qnamespacesupport_p.h @@ -97,7 +97,7 @@ namespace QPatternist * * @param namePool The name pool where all processed names are stored in. */ - NamespaceSupport(const NamePool::Ptr &namePool); + NamespaceSupport(NamePool &namePool); /** * Adds a new prefix-to-namespace binding. @@ -160,7 +160,7 @@ namespace QPatternist private: typedef QHash<QXmlName::PrefixCode, QXmlName::NamespaceCode> NamespaceHash; - NamePool::Ptr m_namePool; + NamePool *m_namePool; QStack<NamespaceHash> m_nsStack; NamespaceHash m_ns; }; diff --git a/src/xmlpatterns/schema/qxsdcomplextype.cpp b/src/xmlpatterns/schema/qxsdcomplextype.cpp index 32e420a..fe97f04 100644 --- a/src/xmlpatterns/schema/qxsdcomplextype.cpp +++ b/src/xmlpatterns/schema/qxsdcomplextype.cpp @@ -130,12 +130,12 @@ QString XsdComplexType::displayName(const NamePool::Ptr &np) const void XsdComplexType::setWxsSuperType(const SchemaType::Ptr &type) { - m_superType = type; + m_superType = type.data(); } SchemaType::Ptr XsdComplexType::wxsSuperType() const { - return m_superType; + return SchemaType::Ptr(m_superType); } void XsdComplexType::setContext(const NamedSchemaComponent::Ptr &component) diff --git a/src/xmlpatterns/schema/qxsdcomplextype_p.h b/src/xmlpatterns/schema/qxsdcomplextype_p.h index 1b90e5d..f6c512e 100644 --- a/src/xmlpatterns/schema/qxsdcomplextype_p.h +++ b/src/xmlpatterns/schema/qxsdcomplextype_p.h @@ -385,7 +385,7 @@ namespace QPatternist virtual bool isDefinedBySchema() const; private: - SchemaType::Ptr m_superType; + SchemaType *m_superType; NamedSchemaComponent *m_context; DerivationMethod m_derivationMethod; bool m_isAbstract; diff --git a/src/xmlpatterns/schema/qxsdelement.cpp b/src/xmlpatterns/schema/qxsdelement.cpp index dda0f54..ab2b873 100644 --- a/src/xmlpatterns/schema/qxsdelement.cpp +++ b/src/xmlpatterns/schema/qxsdelement.cpp @@ -128,12 +128,12 @@ bool XsdElement::isElement() const void XsdElement::setType(const SchemaType::Ptr &type) { - m_type = type; + m_type = type.data(); } SchemaType::Ptr XsdElement::type() const { - return m_type; + return SchemaType::Ptr(m_type); } void XsdElement::setScope(const Scope::Ptr &scope) diff --git a/src/xmlpatterns/schema/qxsdelement_p.h b/src/xmlpatterns/schema/qxsdelement_p.h index 3b9dd88..69fa769 100644 --- a/src/xmlpatterns/schema/qxsdelement_p.h +++ b/src/xmlpatterns/schema/qxsdelement_p.h @@ -382,7 +382,7 @@ namespace QPatternist XsdElement::WeakList substitutionGroups() const; private: - SchemaType::Ptr m_type; + SchemaType *m_type; Scope::Ptr m_scope; ValueConstraint::Ptr m_valueConstraint; TypeTable::Ptr m_typeTable; diff --git a/src/xmlpatterns/schema/qxsdschemaparser.cpp b/src/xmlpatterns/schema/qxsdschemaparser.cpp index 4281a41..0cb0153 100644 --- a/src/xmlpatterns/schema/qxsdschemaparser.cpp +++ b/src/xmlpatterns/schema/qxsdschemaparser.cpp @@ -251,13 +251,13 @@ inline static bool isValidUri(const QString &string) XsdSchemaParser::XsdSchemaParser(const XsdSchemaContext::Ptr &context, const XsdSchemaParserContext::Ptr &parserContext, QIODevice *device) : MaintainingReader<XsdSchemaToken, XsdTagScope::Type>(parserContext->elementDescriptions(), QSet<XsdSchemaToken::NodeName>(), context, device) - , m_context(context) - , m_parserContext(parserContext) - , m_namePool(m_parserContext->namePool()) - , m_namespaceSupport(m_namePool) + , m_context(context.data()) + , m_parserContext(parserContext.data()) + , m_namePool(m_parserContext->namePool().data()) + , m_namespaceSupport(*m_namePool) { - m_schema = m_parserContext->schema(); - m_schemaResolver = m_parserContext->resolver(); + m_schema = m_parserContext->schema().data(); + m_schemaResolver = m_parserContext->resolver().data(); m_idCache = XsdIdCache::Ptr(new XsdIdCache()); setupStateMachines(); @@ -365,7 +365,7 @@ void XsdSchemaParser::attributeContentError(const char *attributeName, const cha .arg(formatAttribute(attributeName)) .arg(formatElement(elementName)) .arg(formatData(value)) - .arg(formatType(m_namePool, type))); + .arg(formatType(NamePool::Ptr(m_namePool), type))); } else { error(QtXmlPatterns::tr("%1 attribute of %2 element contains invalid content: {%3}.") .arg(formatAttribute(attributeName)) @@ -520,7 +520,7 @@ void XsdSchemaParser::parseSchema(ParserType parserType) validateIdAttribute("schema"); - TagValidationHandler tagValidator(XsdTagScope::Schema, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Schema, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -601,10 +601,10 @@ void XsdSchemaParser::parseInclude() m_includedSchemas.insert(url); const AutoPtr<QNetworkReply> reply(AccelTreeResourceLoader::load(url, m_context->networkAccessManager(), - m_context, AccelTreeResourceLoader::ContinueOnError)); + XsdSchemaContext::Ptr(m_context), AccelTreeResourceLoader::ContinueOnError)); if (reply) { // parse the included schema by a different parser but with the same context - XsdSchemaParser parser(m_context, m_parserContext, reply.data()); + XsdSchemaParser parser(XsdSchemaContext::Ptr(m_context), XsdSchemaParserContext::Ptr(m_parserContext), reply.data()); parser.setDocumentURI(url); parser.setTargetNamespaceExtended(m_targetNamespace); parser.setIncludedSchemas(m_includedSchemas); @@ -623,7 +623,7 @@ void XsdSchemaParser::parseInclude() validateIdAttribute("include"); - TagValidationHandler tagValidator(XsdTagScope::Include, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Include, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -697,10 +697,10 @@ void XsdSchemaParser::parseImport() m_importedSchemas.insert(importNamespace); AutoPtr<QNetworkReply> reply(AccelTreeResourceLoader::load(url, m_context->networkAccessManager(), - m_context, AccelTreeResourceLoader::ContinueOnError)); + XsdSchemaContext::Ptr(m_context), AccelTreeResourceLoader::ContinueOnError)); if (reply) { // parse the included schema by a different parser but with the same context - XsdSchemaParser parser(m_context, m_parserContext, reply.data()); + XsdSchemaParser parser(XsdSchemaContext::Ptr(m_context), XsdSchemaParserContext::Ptr(m_parserContext), reply.data()); parser.setDocumentURI(url); parser.setTargetNamespace(importNamespace); parser.setIncludedSchemas(m_includedSchemas); @@ -724,7 +724,7 @@ void XsdSchemaParser::parseImport() QFile file(QString::fromLatin1(":") + importNamespace); if (file.open(QIODevice::ReadOnly)) { - XsdSchemaParser parser(m_context, m_parserContext, &file); + XsdSchemaParser parser(XsdSchemaContext::Ptr(m_context), XsdSchemaParserContext::Ptr(m_parserContext), &file); parser.setDocumentURI(importNamespace); parser.setTargetNamespace(importNamespace); parser.setIncludedSchemas(m_includedSchemas); @@ -747,7 +747,7 @@ void XsdSchemaParser::parseImport() validateIdAttribute("import"); - TagValidationHandler tagValidator(XsdTagScope::Import, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Import, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -785,7 +785,7 @@ void XsdSchemaParser::parseRedefine() const QString schemaLocation = readAttribute(QString::fromLatin1("schemaLocation")); - TagValidationHandler tagValidator(XsdTagScope::Redefine, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Redefine, this, NamePool::Ptr(m_namePool)); XsdSimpleType::List redefinedSimpleTypes; XsdComplexType::List redefinedComplexTypes; @@ -812,8 +812,8 @@ void XsdSchemaParser::parseRedefine() redefinedSimpleTypes.append(type); const QXmlName baseTypeName = m_parserContext->resolver()->baseTypeNameOfType(type); - if (baseTypeName != type->name(m_namePool)) { - error(QString::fromLatin1("redefined simple type %1 must have itself as base type").arg(formatType(m_namePool, type))); + if (baseTypeName != type->name(NamePool::Ptr(m_namePool))) { + error(QString::fromLatin1("redefined simple type %1 must have itself as base type").arg(formatType(NamePool::Ptr(m_namePool), type))); return; } } else if (isSchemaTag(XsdSchemaToken::ComplexType, token, namespaceToken)) { @@ -824,8 +824,8 @@ void XsdSchemaParser::parseRedefine() // 5 const QXmlName baseTypeName = m_parserContext->resolver()->baseTypeNameOfType(type); - if (baseTypeName != type->name(m_namePool)) { - error(QString::fromLatin1("redefined complex type %1 must have itself as base type").arg(formatType(m_namePool, type))); + if (baseTypeName != type->name(NamePool::Ptr(m_namePool))) { + error(QString::fromLatin1("redefined complex type %1 must have itself as base type").arg(formatType(NamePool::Ptr(m_namePool), type))); return; } } else if (isSchemaTag(XsdSchemaToken::Group, token, namespaceToken)) { @@ -855,7 +855,7 @@ void XsdSchemaParser::parseRedefine() } // we parse the schema given in the redefine tag into its own context - const XsdSchemaParserContext::Ptr redefinedContext(new XsdSchemaParserContext(m_namePool, m_context)); + const XsdSchemaParserContext::Ptr redefinedContext(new XsdSchemaParserContext(NamePool::Ptr(m_namePool), XsdSchemaContext::Ptr(m_context))); if (m_redefinedSchemas.contains(url)) { // we have redefined that file already, according to the schema spec we are @@ -863,11 +863,11 @@ void XsdSchemaParser::parseRedefine() } else { m_redefinedSchemas.insert(url); QNetworkReply *reply = AccelTreeResourceLoader::load(url, m_context->networkAccessManager(), - m_context, + XsdSchemaContext::Ptr(m_context), (locationMustResolve ? AccelTreeResourceLoader::FailOnError : AccelTreeResourceLoader::ContinueOnError)); if (reply) { // parse the included schema by a different parser but with the same context - XsdSchemaParser parser(m_context, redefinedContext, reply); + XsdSchemaParser parser(XsdSchemaContext::Ptr(m_context), redefinedContext, reply); parser.setDocumentURI(url); parser.setTargetNamespaceExtended(m_targetNamespace); parser.setIncludedSchemas(m_includedSchemas); @@ -904,7 +904,7 @@ void XsdSchemaParser::parseRedefine() for (int j = 0; j < contextSimpleTypes.count(); ++j) { XsdSimpleType::Ptr contextType = contextSimpleTypes.at(j); - if (redefinedType->name(m_namePool) == contextType->name(m_namePool)) { // we found the right type + if (redefinedType->name(NamePool::Ptr(m_namePool)) == contextType->name(NamePool::Ptr(m_namePool))) { // we found the right type found = true; // 1) set name of context type to empty name @@ -932,7 +932,7 @@ void XsdSchemaParser::parseRedefine() } if (!found) { - error(QString::fromLatin1("no matching type found to redefine simple type %1").arg(formatType(m_namePool, redefinedType))); + error(QString::fromLatin1("no matching type found to redefine simple type %1").arg(formatType(NamePool::Ptr(m_namePool), redefinedType))); return; } } @@ -953,7 +953,7 @@ void XsdSchemaParser::parseRedefine() for (int j = 0; j < contextComplexTypes.count(); ++j) { XsdComplexType::Ptr contextType = contextComplexTypes.at(j); - if (redefinedType->name(m_namePool) == contextType->name(m_namePool)) { // we found the right type + if (redefinedType->name(NamePool::Ptr(m_namePool)) == contextType->name(NamePool::Ptr(m_namePool))) { // we found the right type found = true; // 1) set name of context type to empty name @@ -981,7 +981,7 @@ void XsdSchemaParser::parseRedefine() } if (!found) { - error(QString::fromLatin1("no matching type found to redefine complex type %1").arg(formatType(m_namePool, redefinedType))); + error(QString::fromLatin1("no matching type found to redefine complex type %1").arg(formatType(NamePool::Ptr(m_namePool), redefinedType))); return; } } @@ -998,11 +998,11 @@ void XsdSchemaParser::parseRedefine() int sameNameCounter = 0; for (int i = 0; i < particles.count(); ++i) { const XsdReference::Ptr ref(particles.at(i)->term()); - if (ref->referenceName() == group->name(m_namePool)) { + if (ref->referenceName() == group->name(NamePool::Ptr(m_namePool))) { referencedParticle = particles.at(i); if (referencedParticle->minimumOccurs() != 1 || referencedParticle->maximumOccurs() != 1 || referencedParticle->maximumOccursUnbounded()) { // 6.1.2 - error(QString::fromLatin1("redefined group %1 can not contain reference to itself with minOccurs or maxOccurs != 1").arg(formatKeyword(group->displayName(m_namePool)))); + error(QString::fromLatin1("redefined group %1 can not contain reference to itself with minOccurs or maxOccurs != 1").arg(formatKeyword(group->displayName(NamePool::Ptr(m_namePool))))); return; } sameNameCounter++; @@ -1011,21 +1011,21 @@ void XsdSchemaParser::parseRedefine() // 6.1.1 if (sameNameCounter > 1) { - error(QString::fromLatin1("redefined group %1 can not contain multiple references to itself").arg(formatKeyword(group->displayName(m_namePool)))); + error(QString::fromLatin1("redefined group %1 can not contain multiple references to itself").arg(formatKeyword(group->displayName(NamePool::Ptr(m_namePool))))); return; } // search the group definition in the included schema (S2) XsdModelGroup::Ptr contextGroup; for (int j = 0; j < contextGroups.count(); ++j) { - if (group->name(m_namePool) == contextGroups.at(j)->name(m_namePool)) { + if (group->name(NamePool::Ptr(m_namePool)) == contextGroups.at(j)->name(NamePool::Ptr(m_namePool))) { contextGroup = contextGroups.at(j); break; } } if (!contextGroup) { // 6.2.1 - error(QString::fromLatin1("redefined group %1 has no occurrence in included schema").arg(formatKeyword(group->displayName(m_namePool)))); + error(QString::fromLatin1("redefined group %1 has no occurrence in included schema").arg(formatKeyword(group->displayName(NamePool::Ptr(m_namePool))))); return; } @@ -1034,7 +1034,7 @@ void XsdSchemaParser::parseRedefine() // group from the included schema // set a anonymous name to the group of the included schema - contextGroup->setName(m_parserContext->createAnonymousName(m_namePool->stringForNamespace(contextGroup->name(m_namePool).namespaceURI()))); + contextGroup->setName(m_parserContext->createAnonymousName(m_namePool->stringForNamespace(contextGroup->name(NamePool::Ptr(m_namePool)).namespaceURI()))); // replace the self-reference with the group from the included schema referencedParticle->setTerm(contextGroup); @@ -1050,7 +1050,7 @@ void XsdSchemaParser::parseRedefine() addElementGroup(group); // we have to add them, otherwise it is not resolved and we can't validate it later - contextGroup->setName(m_parserContext->createAnonymousName(m_namePool->stringForNamespace(contextGroup->name(m_namePool).namespaceURI()))); + contextGroup->setName(m_parserContext->createAnonymousName(m_namePool->stringForNamespace(contextGroup->name(NamePool::Ptr(m_namePool)).namespaceURI()))); addElementGroup(contextGroup); m_schemaResolver->addRedefinedGroups(group, contextGroup); @@ -1075,13 +1075,13 @@ void XsdSchemaParser::parseRedefine() if (attributeUse->isReference()) { const XsdAttributeReference::Ptr reference(attributeUse); if (reference->type() == XsdAttributeReference::AttributeGroup) { - if (group->name(m_namePool) == reference->referenceName()) + if (group->name(NamePool::Ptr(m_namePool)) == reference->referenceName()) sameNameCounter++; } } } if (sameNameCounter > 1) { - error(QString::fromLatin1("redefined attribute group %1 can not contain multiple references to itself").arg(formatKeyword(group->displayName(m_namePool)))); + error(QString::fromLatin1("redefined attribute group %1 can not contain multiple references to itself").arg(formatKeyword(group->displayName(NamePool::Ptr(m_namePool))))); return; } @@ -1089,14 +1089,14 @@ void XsdSchemaParser::parseRedefine() XsdAttributeGroup::Ptr baseGroup; for (int j = 0; j < contextAttributeGroups.count(); ++j) { const XsdAttributeGroup::Ptr contextGroup(contextAttributeGroups.at(j)); - if (group->name(m_namePool) == contextGroup->name(m_namePool)) { + if (group->name(NamePool::Ptr(m_namePool)) == contextGroup->name(NamePool::Ptr(m_namePool))) { baseGroup = contextGroup; break; } } if (!baseGroup) { // 7.2.1 - error(QString::fromLatin1("redefined attribute group %1 has no occurrence in included schema").arg(formatKeyword(group->displayName(m_namePool)))); + error(QString::fromLatin1("redefined attribute group %1 has no occurrence in included schema").arg(formatKeyword(group->displayName(NamePool::Ptr(m_namePool))))); return; } @@ -1104,7 +1104,7 @@ void XsdSchemaParser::parseRedefine() // first set an anonymous name to the attribute group from the included // schema - baseGroup->setName(m_parserContext->createAnonymousName(m_namePool->stringForNamespace(baseGroup->name(m_namePool).namespaceURI()))); + baseGroup->setName(m_parserContext->createAnonymousName(m_namePool->stringForNamespace(baseGroup->name(NamePool::Ptr(m_namePool)).namespaceURI()))); // iterate over the attribute uses of the redefined attribute group // and replace the self-reference with the attribute group from the @@ -1114,8 +1114,8 @@ void XsdSchemaParser::parseRedefine() if (attributeUse->isReference()) { const XsdAttributeReference::Ptr reference(attributeUse); if (reference->type() == XsdAttributeReference::AttributeGroup) { - if (group->name(m_namePool) == reference->referenceName()) { - reference->setReferenceName(baseGroup->name(m_namePool)); + if (group->name(NamePool::Ptr(m_namePool)) == reference->referenceName()) { + reference->setReferenceName(baseGroup->name(NamePool::Ptr(m_namePool))); break; } } @@ -1132,7 +1132,7 @@ void XsdSchemaParser::parseRedefine() if (sameNameCounter == 0) { // 7.2 // we have to add them, otherwise it is not resolved and we can't validate it later - baseGroup->setName(m_parserContext->createAnonymousName(m_namePool->stringForNamespace(baseGroup->name(m_namePool).namespaceURI()))); + baseGroup->setName(m_parserContext->createAnonymousName(m_namePool->stringForNamespace(baseGroup->name(NamePool::Ptr(m_namePool)).namespaceURI()))); addAttributeGroup(baseGroup); m_schemaResolver->addRedefinedAttributeGroups(group, baseGroup); @@ -1191,7 +1191,7 @@ XsdAnnotation::Ptr XsdSchemaParser::parseAnnotation() // parse attributes validateIdAttribute("annotation"); - TagValidationHandler tagValidator(XsdTagScope::Annotation, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Annotation, this, NamePool::Ptr(m_namePool)); const XsdAnnotation::Ptr annotation(new XsdAnnotation()); @@ -1344,7 +1344,7 @@ void XsdSchemaParser::parseDefaultOpenContent() validateIdAttribute("defaultOpenContent"); - TagValidationHandler tagValidator(XsdTagScope::DefaultOpenContent, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::DefaultOpenContent, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -1392,7 +1392,7 @@ XsdSimpleType::Ptr XsdSchemaParser::parseGlobalSimpleType() validateIdAttribute("simpleType"); - TagValidationHandler tagValidator(XsdTagScope::GlobalSimpleType, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::GlobalSimpleType, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -1438,7 +1438,7 @@ XsdSimpleType::Ptr XsdSchemaParser::parseLocalSimpleType() validateIdAttribute("simpleType"); - TagValidationHandler tagValidator(XsdTagScope::LocalSimpleType, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::LocalSimpleType, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -1501,7 +1501,7 @@ void XsdSchemaParser::parseSimpleRestriction(const XsdSimpleType::Ptr &ptr) QList<XsdFacet::Ptr> enumerationFacets; QList<XsdFacet::Ptr> assertionFacets; - TagValidationHandler tagValidator(XsdTagScope::SimpleRestriction, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::SimpleRestriction, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -1659,7 +1659,7 @@ void XsdSchemaParser::parseList(const XsdSimpleType::Ptr &ptr) validateIdAttribute("list"); - TagValidationHandler tagValidator(XsdTagScope::List, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::List, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -1713,7 +1713,7 @@ void XsdSchemaParser::parseList(const XsdSimpleType::Ptr &ptr) const XsdFacet::Ptr defaultFacet(new XsdFacet()); defaultFacet->setType(XsdFacet::WhiteSpace); defaultFacet->setFixed(true); - defaultFacet->setValue(DerivedString<TypeString>::fromLexical(m_namePool, XsdSchemaToken::toString(XsdSchemaToken::Collapse))); + defaultFacet->setValue(DerivedString<TypeString>::fromLexical(NamePool::Ptr(m_namePool), XsdSchemaToken::toString(XsdSchemaToken::Collapse))); XsdFacet::Hash facets; facets.insert(defaultFacet->type(), defaultFacet); ptr->setFacets(facets); @@ -1756,7 +1756,7 @@ void XsdSchemaParser::parseUnion(const XsdSimpleType::Ptr &ptr) AnySimpleType::List memberTypes; - TagValidationHandler tagValidator(XsdTagScope::Union, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Union, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -1828,7 +1828,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMinExclusiveFacet() // as minExclusive can have a value of type anySimpleType, we just read // the string here and store it for later intepretation const QString value = readAttribute(QString::fromLatin1("value")); - DerivedString<TypeString>::Ptr string = DerivedString<TypeString>::fromLexical(m_namePool, value); + DerivedString<TypeString>::Ptr string = DerivedString<TypeString>::fromLexical(NamePool::Ptr(m_namePool), value); if (string->hasError()) { attributeContentError("value", "minExclusive", value, BuiltinTypes::xsAnySimpleType); return facet; @@ -1838,7 +1838,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMinExclusiveFacet() validateIdAttribute("minExclusive"); - TagValidationHandler tagValidator(XsdTagScope::MinExclusiveFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::MinExclusiveFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -1892,7 +1892,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMinInclusiveFacet() // as minInclusive can have a value of type anySimpleType, we just read // the string here and store it for later intepretation const QString value = readAttribute(QString::fromLatin1("value")); - DerivedString<TypeString>::Ptr string = DerivedString<TypeString>::fromLexical(m_namePool, value); + DerivedString<TypeString>::Ptr string = DerivedString<TypeString>::fromLexical(NamePool::Ptr(m_namePool), value); if (string->hasError()) { attributeContentError("value", "minInclusive", value, BuiltinTypes::xsAnySimpleType); return facet; @@ -1902,7 +1902,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMinInclusiveFacet() validateIdAttribute("minInclusive"); - TagValidationHandler tagValidator(XsdTagScope::MinInclusiveFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::MinInclusiveFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -1956,7 +1956,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMaxExclusiveFacet() // as maxExclusive can have a value of type anySimpleType, we just read // the string here and store it for later intepretation const QString value = readAttribute(QString::fromLatin1("value")); - DerivedString<TypeString>::Ptr string = DerivedString<TypeString>::fromLexical(m_namePool, value); + DerivedString<TypeString>::Ptr string = DerivedString<TypeString>::fromLexical(NamePool::Ptr(m_namePool), value); if (string->hasError()) { attributeContentError("value", "maxExclusive", value, BuiltinTypes::xsAnySimpleType); return facet; @@ -1966,7 +1966,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMaxExclusiveFacet() validateIdAttribute("maxExclusive"); - TagValidationHandler tagValidator(XsdTagScope::MaxExclusiveFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::MaxExclusiveFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2020,7 +2020,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMaxInclusiveFacet() // as maxInclusive can have a value of type anySimpleType, we just read // the string here and store it for later intepretation const QString value = readAttribute(QString::fromLatin1("value")); - DerivedString<TypeString>::Ptr string = DerivedString<TypeString>::fromLexical(m_namePool, value); + DerivedString<TypeString>::Ptr string = DerivedString<TypeString>::fromLexical(NamePool::Ptr(m_namePool), value); if (string->hasError()) { attributeContentError("value", "maxInclusive", value, BuiltinTypes::xsAnySimpleType); return facet; @@ -2030,7 +2030,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMaxInclusiveFacet() validateIdAttribute("maxInclusive"); - TagValidationHandler tagValidator(XsdTagScope::MaxInclusiveFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::MaxInclusiveFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2082,7 +2082,7 @@ XsdFacet::Ptr XsdSchemaParser::parseTotalDigitsFacet() } const QString value = readAttribute(QString::fromLatin1("value")); - DerivedInteger<TypePositiveInteger>::Ptr integer = DerivedInteger<TypePositiveInteger>::fromLexical(m_namePool, value); + DerivedInteger<TypePositiveInteger>::Ptr integer = DerivedInteger<TypePositiveInteger>::fromLexical(NamePool::Ptr(m_namePool), value); if (integer->hasError()) { attributeContentError("value", "totalDigits", value, BuiltinTypes::xsPositiveInteger); return facet; @@ -2092,7 +2092,7 @@ XsdFacet::Ptr XsdSchemaParser::parseTotalDigitsFacet() validateIdAttribute("totalDigits"); - TagValidationHandler tagValidator(XsdTagScope::TotalDigitsFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::TotalDigitsFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2144,7 +2144,7 @@ XsdFacet::Ptr XsdSchemaParser::parseFractionDigitsFacet() } const QString value = readAttribute(QString::fromLatin1("value")); - DerivedInteger<TypeNonNegativeInteger>::Ptr integer = DerivedInteger<TypeNonNegativeInteger>::fromLexical(m_namePool, value); + DerivedInteger<TypeNonNegativeInteger>::Ptr integer = DerivedInteger<TypeNonNegativeInteger>::fromLexical(NamePool::Ptr(m_namePool), value); if (integer->hasError()) { attributeContentError("value", "fractionDigits", value, BuiltinTypes::xsNonNegativeInteger); return facet; @@ -2154,7 +2154,7 @@ XsdFacet::Ptr XsdSchemaParser::parseFractionDigitsFacet() validateIdAttribute("fractionDigits"); - TagValidationHandler tagValidator(XsdTagScope::FractionDigitsFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::FractionDigitsFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2206,7 +2206,7 @@ XsdFacet::Ptr XsdSchemaParser::parseLengthFacet() } const QString value = readAttribute(QString::fromLatin1("value")); - DerivedInteger<TypeNonNegativeInteger>::Ptr integer = DerivedInteger<TypeNonNegativeInteger>::fromLexical(m_namePool, value); + DerivedInteger<TypeNonNegativeInteger>::Ptr integer = DerivedInteger<TypeNonNegativeInteger>::fromLexical(NamePool::Ptr(m_namePool), value); if (integer->hasError()) { attributeContentError("value", "length", value, BuiltinTypes::xsNonNegativeInteger); return facet; @@ -2216,7 +2216,7 @@ XsdFacet::Ptr XsdSchemaParser::parseLengthFacet() validateIdAttribute("length"); - TagValidationHandler tagValidator(XsdTagScope::LengthFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::LengthFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2268,7 +2268,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMinLengthFacet() } const QString value = readAttribute(QString::fromLatin1("value")); - DerivedInteger<TypeNonNegativeInteger>::Ptr integer = DerivedInteger<TypeNonNegativeInteger>::fromLexical(m_namePool, value); + DerivedInteger<TypeNonNegativeInteger>::Ptr integer = DerivedInteger<TypeNonNegativeInteger>::fromLexical(NamePool::Ptr(m_namePool), value); if (integer->hasError()) { attributeContentError("value", "minLength", value, BuiltinTypes::xsNonNegativeInteger); return facet; @@ -2278,7 +2278,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMinLengthFacet() validateIdAttribute("minLength"); - TagValidationHandler tagValidator(XsdTagScope::MinLengthFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::MinLengthFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2330,7 +2330,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMaxLengthFacet() } const QString value = readAttribute(QString::fromLatin1("value")); - DerivedInteger<TypeNonNegativeInteger>::Ptr integer = DerivedInteger<TypeNonNegativeInteger>::fromLexical(m_namePool, value); + DerivedInteger<TypeNonNegativeInteger>::Ptr integer = DerivedInteger<TypeNonNegativeInteger>::fromLexical(NamePool::Ptr(m_namePool), value); if (integer->hasError()) { attributeContentError("value", "maxLength", value, BuiltinTypes::xsNonNegativeInteger); return facet; @@ -2340,7 +2340,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMaxLengthFacet() validateIdAttribute("maxLength"); - TagValidationHandler tagValidator(XsdTagScope::MaxLengthFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::MaxLengthFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2384,7 +2384,7 @@ XsdFacet::Ptr XsdSchemaParser::parseEnumerationFacet() // as enumeration can have a value of type anySimpleType, we just read // the string here and store it for later intepretation - DerivedString<TypeString>::Ptr string = DerivedString<TypeString>::fromLexical(m_namePool, value); + DerivedString<TypeString>::Ptr string = DerivedString<TypeString>::fromLexical(NamePool::Ptr(m_namePool), value); if (string->hasError()) { attributeContentError("value", "enumeration", value); return facet; @@ -2397,7 +2397,7 @@ XsdFacet::Ptr XsdSchemaParser::parseEnumerationFacet() validateIdAttribute("enumeration"); - TagValidationHandler tagValidator(XsdTagScope::EnumerationFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::EnumerationFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2455,7 +2455,7 @@ XsdFacet::Ptr XsdSchemaParser::parseWhiteSpaceFacet() attributeContentError("value", "whiteSpace", value); return facet; } else { - DerivedString<TypeString>::Ptr string = DerivedString<TypeString>::fromLexical(m_namePool, value); + DerivedString<TypeString>::Ptr string = DerivedString<TypeString>::fromLexical(NamePool::Ptr(m_namePool), value); if (string->hasError()) { attributeContentError("value", "whiteSpace", value); return facet; @@ -2466,7 +2466,7 @@ XsdFacet::Ptr XsdSchemaParser::parseWhiteSpaceFacet() validateIdAttribute("whiteSpace"); - TagValidationHandler tagValidator(XsdTagScope::WhiteSpaceFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::WhiteSpaceFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2508,7 +2508,7 @@ XsdFacet::Ptr XsdSchemaParser::parsePatternFacet() // as pattern can have a value of type anySimpleType, we just read // the string here and store it for later intepretation const QString value = readAttribute(QString::fromLatin1("value")); - DerivedString<TypeString>::Ptr string = DerivedString<TypeString>::fromLexical(m_namePool, value); + DerivedString<TypeString>::Ptr string = DerivedString<TypeString>::fromLexical(NamePool::Ptr(m_namePool), value); if (string->hasError()) { attributeContentError("value", "pattern", value); return facet; @@ -2520,7 +2520,7 @@ XsdFacet::Ptr XsdSchemaParser::parsePatternFacet() validateIdAttribute("pattern"); - TagValidationHandler tagValidator(XsdTagScope::PatternFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::PatternFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2608,7 +2608,7 @@ XsdComplexType::Ptr XsdSchemaParser::parseGlobalComplexType() validateIdAttribute("complexType"); - TagValidationHandler tagValidator(XsdTagScope::GlobalComplexType, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::GlobalComplexType, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2763,7 +2763,7 @@ XsdComplexType::Ptr XsdSchemaParser::parseLocalComplexType() validateIdAttribute("complexType"); - TagValidationHandler tagValidator(XsdTagScope::LocalComplexType, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::LocalComplexType, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2926,7 +2926,7 @@ void XsdSchemaParser::parseSimpleContent(const XsdComplexType::Ptr &complexType) // parse attributes validateIdAttribute("simpleContent"); - TagValidationHandler tagValidator(XsdTagScope::SimpleContent, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::SimpleContent, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2976,7 +2976,7 @@ void XsdSchemaParser::parseSimpleContentRestriction(const XsdComplexType::Ptr &c QList<XsdFacet::Ptr> enumerationFacets; QList<XsdFacet::Ptr> assertionFacets; - TagValidationHandler tagValidator(XsdTagScope::SimpleContentRestriction, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::SimpleContentRestriction, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -3117,7 +3117,7 @@ void XsdSchemaParser::parseSimpleContentExtension(const XsdComplexType::Ptr &com validateIdAttribute("extension"); - TagValidationHandler tagValidator(XsdTagScope::SimpleContentExtension, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::SimpleContentExtension, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -3180,7 +3180,7 @@ void XsdSchemaParser::parseComplexContent(const XsdComplexType::Ptr &complexType validateIdAttribute("complexContent"); - TagValidationHandler tagValidator(XsdTagScope::ComplexContent, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::ComplexContent, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -3226,7 +3226,7 @@ void XsdSchemaParser::parseComplexContentRestriction(const XsdComplexType::Ptr & validateIdAttribute("restriction"); - TagValidationHandler tagValidator(XsdTagScope::ComplexContentRestriction, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::ComplexContentRestriction, this, NamePool::Ptr(m_namePool)); bool hasContent = false; while (!atEnd()) { @@ -3312,7 +3312,7 @@ void XsdSchemaParser::parseComplexContentExtension(const XsdComplexType::Ptr &co validateIdAttribute("extension"); - TagValidationHandler tagValidator(XsdTagScope::ComplexContentExtension, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::ComplexContentExtension, this, NamePool::Ptr(m_namePool)); bool hasContent = false; while (!atEnd()) { @@ -3401,7 +3401,7 @@ XsdAssertion::Ptr XsdSchemaParser::parseAssertion(const XsdSchemaToken::NodeName validateIdAttribute("assertion"); - TagValidationHandler tagValidator(tag, this, m_namePool); + TagValidationHandler tagValidator(tag, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -3456,7 +3456,7 @@ XsdComplexType::OpenContent::Ptr XsdSchemaParser::parseOpenContent() validateIdAttribute("openContent"); - TagValidationHandler tagValidator(XsdTagScope::OpenContent, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::OpenContent, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -3504,7 +3504,7 @@ XsdModelGroup::Ptr XsdSchemaParser::parseNamedGroup() validateIdAttribute("group"); - TagValidationHandler tagValidator(XsdTagScope::NamedGroup, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::NamedGroup, this, NamePool::Ptr(m_namePool)); XsdAnnotation::Ptr annotation; @@ -3566,7 +3566,7 @@ XsdTerm::Ptr XsdSchemaParser::parseReferredGroup(const XsdParticle::Ptr &particl validateIdAttribute("group"); - TagValidationHandler tagValidator(XsdTagScope::ReferredGroup, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::ReferredGroup, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -3605,7 +3605,7 @@ XsdModelGroup::Ptr XsdSchemaParser::parseAll(const NamedSchemaComponent::Ptr &pa validateIdAttribute("all"); - TagValidationHandler tagValidator(XsdTagScope::All, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::All, this, NamePool::Ptr(m_namePool)); XsdParticle::List particles; while (!atEnd()) { @@ -3682,7 +3682,7 @@ XsdModelGroup::Ptr XsdSchemaParser::parseLocalAll(const XsdParticle::Ptr &partic validateIdAttribute("all"); - TagValidationHandler tagValidator(XsdTagScope::LocalAll, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::LocalAll, this, NamePool::Ptr(m_namePool)); XsdParticle::List particles; while (!atEnd()) { @@ -3741,7 +3741,7 @@ XsdModelGroup::Ptr XsdSchemaParser::parseChoice(const NamedSchemaComponent::Ptr XsdParticle::List particles; - TagValidationHandler tagValidator(XsdTagScope::Choice, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Choice, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -3815,7 +3815,7 @@ XsdModelGroup::Ptr XsdSchemaParser::parseLocalChoice(const XsdParticle::Ptr &par XsdParticle::List particles; - TagValidationHandler tagValidator(XsdTagScope::LocalChoice, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::LocalChoice, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -3884,7 +3884,7 @@ XsdModelGroup::Ptr XsdSchemaParser::parseSequence(const NamedSchemaComponent::Pt XsdParticle::List particles; - TagValidationHandler tagValidator(XsdTagScope::Sequence, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Sequence, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -3958,7 +3958,7 @@ XsdModelGroup::Ptr XsdSchemaParser::parseLocalSequence(const XsdParticle::Ptr &p XsdParticle::List particles; - TagValidationHandler tagValidator(XsdTagScope::LocalSequence, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::LocalSequence, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -4082,7 +4082,7 @@ XsdAttribute::Ptr XsdSchemaParser::parseGlobalAttribute() validateIdAttribute("attribute"); - TagValidationHandler tagValidator(XsdTagScope::GlobalAttribute, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::GlobalAttribute, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -4314,7 +4314,7 @@ XsdAttributeUse::Ptr XsdSchemaParser::parseLocalAttribute(const NamedSchemaCompo validateIdAttribute("attribute"); - TagValidationHandler tagValidator(XsdTagScope::LocalAttribute, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::LocalAttribute, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -4383,7 +4383,7 @@ XsdAttributeGroup::Ptr XsdSchemaParser::parseNamedAttributeGroup() validateIdAttribute("attributeGroup"); - TagValidationHandler tagValidator(XsdTagScope::NamedAttributeGroup, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::NamedAttributeGroup, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -4443,7 +4443,7 @@ XsdAttributeUse::Ptr XsdSchemaParser::parseReferredAttributeGroup() validateIdAttribute("attributeGroup"); - TagValidationHandler tagValidator(XsdTagScope::ReferredAttributeGroup, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::ReferredAttributeGroup, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -4581,7 +4581,7 @@ XsdElement::Ptr XsdSchemaParser::parseGlobalElement() XsdAlternative::List alternatives; - TagValidationHandler tagValidator(XsdTagScope::GlobalElement, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::GlobalElement, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -4856,7 +4856,7 @@ XsdTerm::Ptr XsdSchemaParser::parseLocalElement(const XsdParticle::Ptr &particle XsdAlternative::List alternatives; - TagValidationHandler tagValidator(XsdTagScope::LocalElement, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::LocalElement, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -5015,7 +5015,7 @@ XsdIdentityConstraint::Ptr XsdSchemaParser::parseUnique() validateIdAttribute("unique"); - TagValidationHandler tagValidator(XsdTagScope::Unique, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Unique, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -5065,7 +5065,7 @@ XsdIdentityConstraint::Ptr XsdSchemaParser::parseKey() validateIdAttribute("key"); - TagValidationHandler tagValidator(XsdTagScope::Key, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Key, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -5120,7 +5120,7 @@ XsdIdentityConstraint::Ptr XsdSchemaParser::parseKeyRef(const XsdElement::Ptr &e validateIdAttribute("keyref"); - TagValidationHandler tagValidator(XsdTagScope::KeyRef, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::KeyRef, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -5171,7 +5171,7 @@ void XsdSchemaParser::parseSelector(const XsdIdentityConstraint::Ptr &ptr) validateIdAttribute("selector"); - TagValidationHandler tagValidator(XsdTagScope::Selector, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Selector, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -5213,7 +5213,7 @@ void XsdSchemaParser::parseField(const XsdIdentityConstraint::Ptr &ptr) validateIdAttribute("field"); - TagValidationHandler tagValidator(XsdTagScope::Field, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Field, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -5269,7 +5269,7 @@ XsdAlternative::Ptr XsdSchemaParser::parseAlternative() validateIdAttribute("alternative"); - TagValidationHandler tagValidator(XsdTagScope::Alternative, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Alternative, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -5339,7 +5339,7 @@ XsdNotation::Ptr XsdSchemaParser::parseNotation() if (hasAttribute(QString::fromLatin1("public"))) { const QString value = readAttribute(QString::fromLatin1("public")); if (!value.isEmpty()) { - const DerivedString<TypeToken>::Ptr publicId = DerivedString<TypeToken>::fromLexical(m_namePool, value); + const DerivedString<TypeToken>::Ptr publicId = DerivedString<TypeToken>::fromLexical(NamePool::Ptr(m_namePool), value); if (publicId->hasError()) { attributeContentError("public", "notation", value, BuiltinTypes::xsToken); return notation; @@ -5375,7 +5375,7 @@ XsdNotation::Ptr XsdSchemaParser::parseNotation() validateIdAttribute("notation"); - TagValidationHandler tagValidator(XsdTagScope::Notation, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Notation, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -5498,7 +5498,7 @@ XsdWildcard::Ptr XsdSchemaParser::parseAny(const XsdParticle::Ptr &particle) validateIdAttribute("any"); - TagValidationHandler tagValidator(XsdTagScope::Any, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Any, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -5610,7 +5610,7 @@ XsdWildcard::Ptr XsdSchemaParser::parseAnyAttribute() validateIdAttribute("anyAttribute"); - TagValidationHandler tagValidator(XsdTagScope::AnyAttribute, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::AnyAttribute, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -5684,7 +5684,7 @@ bool XsdSchemaParser::parseMinMaxConstraint(const XsdParticle::Ptr &particle, co if (hasAttribute(QString::fromLatin1("minOccurs"))) { const QString value = readAttribute(QString::fromLatin1("minOccurs")); - DerivedInteger<TypeNonNegativeInteger>::Ptr integer = DerivedInteger<TypeNonNegativeInteger>::fromLexical(m_namePool, value); + DerivedInteger<TypeNonNegativeInteger>::Ptr integer = DerivedInteger<TypeNonNegativeInteger>::fromLexical(NamePool::Ptr(m_namePool), value); if (integer->hasError()) { attributeContentError("minOccurs", elementName, value, BuiltinTypes::xsNonNegativeInteger); return false; @@ -5702,7 +5702,7 @@ bool XsdSchemaParser::parseMinMaxConstraint(const XsdParticle::Ptr &particle, co particle->setMaximumOccursUnbounded(true); } else { particle->setMaximumOccursUnbounded(false); - DerivedInteger<TypeNonNegativeInteger>::Ptr integer = DerivedInteger<TypeNonNegativeInteger>::fromLexical(m_namePool, value); + DerivedInteger<TypeNonNegativeInteger>::Ptr integer = DerivedInteger<TypeNonNegativeInteger>::fromLexical(NamePool::Ptr(m_namePool), value); if (integer->hasError()) { attributeContentError("maxOccurs", elementName, value, BuiltinTypes::xsNonNegativeInteger); return false; @@ -5963,7 +5963,7 @@ QString XsdSchemaParser::readXPathAttribute(const QString &attributeName, XPathT return QString(); } - QXmlNamePool namePool(m_namePool.data()); + QXmlNamePool namePool(NamePool::Ptr(m_namePool).data()); QXmlQuery::QueryLanguage language = QXmlQuery::XPath20; switch (type) { @@ -5994,7 +5994,7 @@ void XsdSchemaParser::validateIdAttribute(const char *elementName) { if (hasAttribute(QString::fromLatin1("id"))) { const QString value = readAttribute(QString::fromLatin1("id")); - DerivedString<TypeID>::Ptr id = DerivedString<TypeID>::fromLexical(m_namePool, value); + DerivedString<TypeID>::Ptr id = DerivedString<TypeID>::fromLexical(NamePool::Ptr(m_namePool), value); if (id->hasError()) { attributeContentError("id", elementName, value, BuiltinTypes::xsID); } else { @@ -6014,7 +6014,7 @@ bool XsdSchemaParser::isSchemaTag(XsdSchemaToken::NodeName tag, XsdSchemaToken:: void XsdSchemaParser::addElement(const XsdElement::Ptr &element) { - const QXmlName objectName = element->name(m_namePool); + const QXmlName objectName = element->name(NamePool::Ptr(m_namePool)); if (m_schema->element(objectName)) { error(QtXmlPatterns::tr("Element %1 already defined.").arg(formatElement(m_namePool->displayName(objectName)))); } else { @@ -6025,7 +6025,7 @@ void XsdSchemaParser::addElement(const XsdElement::Ptr &element) void XsdSchemaParser::addAttribute(const XsdAttribute::Ptr &attribute) { - const QXmlName objectName = attribute->name(m_namePool); + const QXmlName objectName = attribute->name(NamePool::Ptr(m_namePool)); if (m_schema->attribute(objectName)) { error(QtXmlPatterns::tr("Attribute %1 already defined.").arg(formatAttribute(m_namePool->displayName(objectName)))); } else { @@ -6037,12 +6037,12 @@ void XsdSchemaParser::addAttribute(const XsdAttribute::Ptr &attribute) void XsdSchemaParser::addType(const SchemaType::Ptr &type) { // we don't import redefinitions of builtin types, that just causes problems - if (m_builtinTypeNames.contains(type->name(m_namePool))) + if (m_builtinTypeNames.contains(type->name(NamePool::Ptr(m_namePool)))) return; - const QXmlName objectName = type->name(m_namePool); + const QXmlName objectName = type->name(NamePool::Ptr(m_namePool)); if (m_schema->type(objectName)) { - error(QtXmlPatterns::tr("Type %1 already defined.").arg(formatType(m_namePool, objectName))); + error(QtXmlPatterns::tr("Type %1 already defined.").arg(formatType(NamePool::Ptr(m_namePool), objectName))); } else { m_schema->addType(type); if (type->isSimpleType()) @@ -6063,9 +6063,9 @@ void XsdSchemaParser::addAnonymousType(const SchemaType::Ptr &type) void XsdSchemaParser::addAttributeGroup(const XsdAttributeGroup::Ptr &group) { - const QXmlName objectName = group->name(m_namePool); + const QXmlName objectName = group->name(NamePool::Ptr(m_namePool)); if (m_schema->attributeGroup(objectName)) { - error(QtXmlPatterns::tr("Attribute group %1 already defined.").arg(formatKeyword(m_namePool, objectName))); + error(QtXmlPatterns::tr("Attribute group %1 already defined.").arg(formatKeyword(NamePool::Ptr(m_namePool), objectName))); } else { m_schema->addAttributeGroup(group); m_componentLocationHash.insert(group, currentSourceLocation()); @@ -6074,9 +6074,9 @@ void XsdSchemaParser::addAttributeGroup(const XsdAttributeGroup::Ptr &group) void XsdSchemaParser::addElementGroup(const XsdModelGroup::Ptr &group) { - const QXmlName objectName = group->name(m_namePool); + const QXmlName objectName = group->name(NamePool::Ptr(m_namePool)); if (m_schema->elementGroup(objectName)) { - error(QtXmlPatterns::tr("Element group %1 already defined.").arg(formatKeyword(m_namePool, objectName))); + error(QtXmlPatterns::tr("Element group %1 already defined.").arg(formatKeyword(NamePool::Ptr(m_namePool), objectName))); } else { m_schema->addElementGroup(group); m_componentLocationHash.insert(group, currentSourceLocation()); @@ -6085,9 +6085,9 @@ void XsdSchemaParser::addElementGroup(const XsdModelGroup::Ptr &group) void XsdSchemaParser::addNotation(const XsdNotation::Ptr ¬ation) { - const QXmlName objectName = notation->name(m_namePool); + const QXmlName objectName = notation->name(NamePool::Ptr(m_namePool)); if (m_schema->notation(objectName)) { - error(QtXmlPatterns::tr("Notation %1 already defined.").arg(formatKeyword(m_namePool, objectName))); + error(QtXmlPatterns::tr("Notation %1 already defined.").arg(formatKeyword(NamePool::Ptr(m_namePool), objectName))); } else { m_schema->addNotation(notation); m_componentLocationHash.insert(notation, currentSourceLocation()); @@ -6096,9 +6096,9 @@ void XsdSchemaParser::addNotation(const XsdNotation::Ptr ¬ation) void XsdSchemaParser::addIdentityConstraint(const XsdIdentityConstraint::Ptr &constraint) { - const QXmlName objectName = constraint->name(m_namePool); + const QXmlName objectName = constraint->name(NamePool::Ptr(m_namePool)); if (m_schema->identityConstraint(objectName)) { - error(QtXmlPatterns::tr("Identity constraint %1 already defined.").arg(formatKeyword(m_namePool, objectName))); + error(QtXmlPatterns::tr("Identity constraint %1 already defined.").arg(formatKeyword(NamePool::Ptr(m_namePool), objectName))); } else { m_schema->addIdentityConstraint(constraint); m_componentLocationHash.insert(constraint, currentSourceLocation()); @@ -6109,7 +6109,7 @@ void XsdSchemaParser::addFacet(const XsdFacet::Ptr &facet, XsdFacet::Hash &facet { // @see http://www.w3.org/TR/xmlschema-2/#src-single-facet-value if (facets.contains(facet->type())) { - error(QtXmlPatterns::tr("Duplicated facets in simple type %1.").arg(formatType(m_namePool, type))); + error(QtXmlPatterns::tr("Duplicated facets in simple type %1.").arg(formatType(NamePool::Ptr(m_namePool), type))); return; } diff --git a/src/xmlpatterns/schema/qxsdschemaparser_p.h b/src/xmlpatterns/schema/qxsdschemaparser_p.h index 7054b87..93163de 100644 --- a/src/xmlpatterns/schema/qxsdschemaparser_p.h +++ b/src/xmlpatterns/schema/qxsdschemaparser_p.h @@ -704,12 +704,12 @@ namespace QPatternist */ inline bool isSchemaTag(XsdSchemaToken::NodeName tag, XsdSchemaToken::NodeName token, XsdSchemaToken::NodeName namespaceToken) const; - XsdSchemaContext::Ptr m_context; - XsdSchemaParserContext::Ptr m_parserContext; - NamePool::Ptr m_namePool; + XsdSchemaContext *m_context; + XsdSchemaParserContext *m_parserContext; + NamePool *m_namePool; NamespaceSupport m_namespaceSupport; - XsdSchemaResolver::Ptr m_schemaResolver; - XsdSchema::Ptr m_schema; + XsdSchemaResolver *m_schemaResolver; + XsdSchema *m_schema; QString m_targetNamespace; QString m_attributeFormDefault; diff --git a/src/xmlpatterns/schema/qxsdschemaparser_setup.cpp b/src/xmlpatterns/schema/qxsdschemaparser_setup.cpp index 35ededd..1757d25 100644 --- a/src/xmlpatterns/schema/qxsdschemaparser_setup.cpp +++ b/src/xmlpatterns/schema/qxsdschemaparser_setup.cpp @@ -260,8 +260,9 @@ using namespace QPatternist; void XsdSchemaParser::setupStateMachines() { + NamePool::Ptr namePool(m_namePool); { - XsdStateMachine<XsdSchemaToken::NodeName> machine(m_namePool); + XsdStateMachine<XsdSchemaToken::NodeName> machine(namePool); // setup state machine for (annotation?, simpleType?) : attribute const XsdStateMachine<XsdSchemaToken::NodeName>::StateId startState = machine.addState(XsdStateMachine<XsdSchemaToken::NodeName>::StartEndState); @@ -277,7 +278,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine<XsdSchemaToken::NodeName> machine(m_namePool); + XsdStateMachine<XsdSchemaToken::NodeName> machine(namePool); // setup state machine for (annotation?, ((simpleType | complexType)?, alternative*, (unique | key | keyref)*)) : element const XsdStateMachine<XsdSchemaToken::NodeName>::StateId startState = machine.addState(XsdStateMachine<XsdSchemaToken::NodeName>::StartEndState); @@ -320,7 +321,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine<XsdSchemaToken::NodeName> machine(m_namePool); + XsdStateMachine<XsdSchemaToken::NodeName> machine(namePool); // setup state machine for (annotation?, (simpleContent | complexContent | (openContent?, (group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?), assert*))) : complexType const XsdStateMachine<XsdSchemaToken::NodeName>::StateId startState = machine.addState(XsdStateMachine<XsdSchemaToken::NodeName>::StartEndState); @@ -385,7 +386,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine<XsdSchemaToken::NodeName> machine(m_namePool); + XsdStateMachine<XsdSchemaToken::NodeName> machine(namePool); // setup state machine for (annotation?, (restriction | extension)) : simpleContent/complexContent const XsdStateMachine<XsdSchemaToken::NodeName>::StateId startState = machine.addState(XsdStateMachine<XsdSchemaToken::NodeName>::StartState); @@ -404,7 +405,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine<XsdSchemaToken::NodeName> machine(m_namePool); + XsdStateMachine<XsdSchemaToken::NodeName> machine(namePool); // setup state machine for (annotation?, (simpleType?, (minExclusive | minInclusive | maxExclusive | maxInclusive | totalDigits | fractionDigits | length | minLength | maxLength | enumeration | whiteSpace | pattern | assertion)*)?, ((attribute | attributeGroup)*, anyAttribute?), assert*) : simpleContent restriction const XsdStateMachine<XsdSchemaToken::NodeName>::StateId startState = machine.addState(XsdStateMachine<XsdSchemaToken::NodeName>::StartEndState); @@ -503,7 +504,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine<XsdSchemaToken::NodeName> machine(m_namePool); + XsdStateMachine<XsdSchemaToken::NodeName> machine(namePool); // setup state machine for (annotation?, ((attribute | attributeGroup)*, anyAttribute?), assert*) : simple content extension const XsdStateMachine<XsdSchemaToken::NodeName>::StateId startState = machine.addState(XsdStateMachine<XsdSchemaToken::NodeName>::StartEndState); @@ -536,7 +537,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine<XsdSchemaToken::NodeName> machine(m_namePool); + XsdStateMachine<XsdSchemaToken::NodeName> machine(namePool); // setup state machine for (annotation?, openContent?, ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?), assert*)) : complex content restriction/complex content extension const XsdStateMachine<XsdSchemaToken::NodeName>::StateId startState = machine.addState(XsdStateMachine<XsdSchemaToken::NodeName>::StartEndState); @@ -596,7 +597,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine<XsdSchemaToken::NodeName> machine(m_namePool); + XsdStateMachine<XsdSchemaToken::NodeName> machine(namePool); // setup state machine for (annotation?, ((attribute | attributeGroup)*, anyAttribute?)) : named attribute group const XsdStateMachine<XsdSchemaToken::NodeName>::StateId startState = machine.addState(XsdStateMachine<XsdSchemaToken::NodeName>::StartEndState); @@ -621,7 +622,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine<XsdSchemaToken::NodeName> machine(m_namePool); + XsdStateMachine<XsdSchemaToken::NodeName> machine(namePool); // setup state machine for (annotation?, (all | choice | sequence)?) : group const XsdStateMachine<XsdSchemaToken::NodeName>::StateId startState = machine.addState(XsdStateMachine<XsdSchemaToken::NodeName>::StartEndState); @@ -642,7 +643,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine<XsdSchemaToken::NodeName> machine(m_namePool); + XsdStateMachine<XsdSchemaToken::NodeName> machine(namePool); // setup state machine for (annotation?, (element | any)*) : all const XsdStateMachine<XsdSchemaToken::NodeName>::StateId startState = machine.addState(XsdStateMachine<XsdSchemaToken::NodeName>::StartEndState); @@ -664,7 +665,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine<XsdSchemaToken::NodeName> machine(m_namePool); + XsdStateMachine<XsdSchemaToken::NodeName> machine(namePool); // setup state machine for (annotation?, (element | group | choice | sequence | any)*) : choice sequence const XsdStateMachine<XsdSchemaToken::NodeName>::StateId startState = machine.addState(XsdStateMachine<XsdSchemaToken::NodeName>::StartEndState); @@ -697,7 +698,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine<XsdSchemaToken::NodeName> machine(m_namePool); + XsdStateMachine<XsdSchemaToken::NodeName> machine(namePool); // setup state machine for (annotation?) : any/selector/field/notation/include/import/referred attribute group/anyAttribute/all facets/assert const XsdStateMachine<XsdSchemaToken::NodeName>::StateId startState = machine.addState(XsdStateMachine<XsdSchemaToken::NodeName>::StartEndState); @@ -730,7 +731,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine<XsdSchemaToken::NodeName> machine(m_namePool); + XsdStateMachine<XsdSchemaToken::NodeName> machine(namePool); // setup state machine for (annotation?, (selector, field+)) : unique/key/keyref const XsdStateMachine<XsdSchemaToken::NodeName>::StateId startState = machine.addState(XsdStateMachine<XsdSchemaToken::NodeName>::StartState); @@ -751,7 +752,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine<XsdSchemaToken::NodeName> machine(m_namePool); + XsdStateMachine<XsdSchemaToken::NodeName> machine(namePool); // setup state machine for (annotation?, (simpleType | complexType)?) : alternative const XsdStateMachine<XsdSchemaToken::NodeName>::StateId startState = machine.addState(XsdStateMachine<XsdSchemaToken::NodeName>::StartEndState); @@ -769,7 +770,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine<XsdSchemaToken::NodeName> machine(m_namePool); + XsdStateMachine<XsdSchemaToken::NodeName> machine(namePool); // setup state machine for (appinfo | documentation)* : annotation const XsdStateMachine<XsdSchemaToken::NodeName>::StateId startState = machine.addState(XsdStateMachine<XsdSchemaToken::NodeName>::StartEndState); @@ -785,7 +786,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine<XsdSchemaToken::NodeName> machine(m_namePool); + XsdStateMachine<XsdSchemaToken::NodeName> machine(namePool); // setup state machine for (annotation?, (restriction | list | union)) : simpleType const XsdStateMachine<XsdSchemaToken::NodeName>::StateId startState = machine.addState(XsdStateMachine<XsdSchemaToken::NodeName>::StartState); @@ -806,7 +807,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine<XsdSchemaToken::NodeName> machine(m_namePool); + XsdStateMachine<XsdSchemaToken::NodeName> machine(namePool); // setup state machine for (annotation?, (simpleType?, (minExclusive | minInclusive | maxExclusive | maxInclusive | totalDigits | fractionDigits | length | minLength | maxLength | enumeration | whiteSpace | pattern | assertion)*)) : simple type restriction const XsdStateMachine<XsdSchemaToken::NodeName>::StateId startState = machine.addState(XsdStateMachine<XsdSchemaToken::NodeName>::StartEndState); @@ -877,7 +878,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine<XsdSchemaToken::NodeName> machine(m_namePool); + XsdStateMachine<XsdSchemaToken::NodeName> machine(namePool); // setup state machine for (annotation?, simpleType?) : list const XsdStateMachine<XsdSchemaToken::NodeName>::StateId startState = machine.addState(XsdStateMachine<XsdSchemaToken::NodeName>::StartEndState); @@ -893,7 +894,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine<XsdSchemaToken::NodeName> machine(m_namePool); + XsdStateMachine<XsdSchemaToken::NodeName> machine(namePool); // setup state machine for (annotation?, simpleType*) : union const XsdStateMachine<XsdSchemaToken::NodeName>::StateId startState = machine.addState(XsdStateMachine<XsdSchemaToken::NodeName>::StartEndState); @@ -910,7 +911,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine<XsdSchemaToken::NodeName> machine(m_namePool); + XsdStateMachine<XsdSchemaToken::NodeName> machine(namePool); // setup state machine for ((include | import | redefine |i override | annotation)*, (defaultOpenContent, annotation*)?, (((simpleType | complexType | group | attributeGroup) | element | attribute | notation), annotation*)*) : schema const XsdStateMachine<XsdSchemaToken::NodeName>::StateId startState = machine.addState(XsdStateMachine<XsdSchemaToken::NodeName>::StartEndState); @@ -987,7 +988,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine<XsdSchemaToken::NodeName> machine(m_namePool); + XsdStateMachine<XsdSchemaToken::NodeName> machine(namePool); // setup state machine for (annotation?, any) : defaultOpenContent const XsdStateMachine<XsdSchemaToken::NodeName>::StateId startState = machine.addState(XsdStateMachine<XsdSchemaToken::NodeName>::StartEndState); @@ -1003,7 +1004,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine<XsdSchemaToken::NodeName> machine(m_namePool); + XsdStateMachine<XsdSchemaToken::NodeName> machine(namePool); // setup state machine for (annotation | (simpleType | complexType | group | attributeGroup))* : redefine const XsdStateMachine<XsdSchemaToken::NodeName>::StateId startState = machine.addState(XsdStateMachine<XsdSchemaToken::NodeName>::StartEndState); @@ -1025,7 +1026,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine<XsdSchemaToken::NodeName> machine(m_namePool); + XsdStateMachine<XsdSchemaToken::NodeName> machine(namePool); // setup state machine for (annotation | (simpleType | complexType | group | attributeGroup | element | attribute | notation))* : override const XsdStateMachine<XsdSchemaToken::NodeName>::StateId startState = machine.addState(XsdStateMachine<XsdSchemaToken::NodeName>::StartEndState); @@ -1055,56 +1056,57 @@ void XsdSchemaParser::setupStateMachines() void XsdSchemaParser::setupBuiltinTypeNames() { + NamePool::Ptr namePool(m_namePool); m_builtinTypeNames.reserve(48); - m_builtinTypeNames.insert(BuiltinTypes::xsAnyType->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsAnySimpleType->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsUntyped->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsAnyAtomicType->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsUntypedAtomic->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsDateTime->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsDate->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsTime->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsDuration->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsYearMonthDuration->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsDayTimeDuration->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsFloat->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsDouble->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsInteger->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsDecimal->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsNonPositiveInteger->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsNegativeInteger->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsLong->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsInt->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsShort->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsByte->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsNonNegativeInteger->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsUnsignedLong->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsUnsignedInt->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsUnsignedShort->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsUnsignedByte->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsPositiveInteger->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsGYearMonth->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsGYear->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsGMonthDay->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsGDay->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsGMonth->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsBoolean->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsBase64Binary->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsHexBinary->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsAnyURI->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsQName->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsString->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsNormalizedString->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsToken->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsLanguage->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsNMTOKEN->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsName->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsNCName->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsID->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsIDREF->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsENTITY->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsNOTATION->name(m_namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsAnyType->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsAnySimpleType->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsUntyped->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsAnyAtomicType->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsUntypedAtomic->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsDateTime->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsDate->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsTime->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsDuration->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsYearMonthDuration->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsDayTimeDuration->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsFloat->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsDouble->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsInteger->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsDecimal->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsNonPositiveInteger->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsNegativeInteger->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsLong->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsInt->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsShort->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsByte->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsNonNegativeInteger->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsUnsignedLong->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsUnsignedInt->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsUnsignedShort->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsUnsignedByte->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsPositiveInteger->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsGYearMonth->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsGYear->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsGMonthDay->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsGDay->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsGMonth->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsBoolean->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsBase64Binary->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsHexBinary->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsAnyURI->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsQName->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsString->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsNormalizedString->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsToken->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsLanguage->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsNMTOKEN->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsName->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsNCName->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsID->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsIDREF->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsENTITY->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsNOTATION->name(namePool)); } QT_END_NAMESPACE |