diff options
author | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2013-03-13 11:34:09 +0100 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2013-03-13 11:34:09 +0100 |
commit | c9e541d3ad9ff4b3d1847ddb48190e373e033c92 (patch) | |
tree | 1f96450b8967e1b88379fb9835442bc74ec5ef86 | |
parent | 0e52a90e5bab43ea1132fbd70f194ffdf13e4908 (diff) |
put hbtree in a namespace
Change-Id: Ibf9ea22d79b362872075cf219f112bfa5e865b76
-rw-r--r-- | src/hbtree/hbtree.cpp | 4 | ||||
-rw-r--r-- | src/hbtree/hbtree.h | 5 | ||||
-rw-r--r-- | src/hbtree/hbtree.pri | 1 | ||||
-rw-r--r-- | src/hbtree/hbtree_p.h | 13 | ||||
-rw-r--r-- | src/hbtree/hbtreeassert.cpp | 4 | ||||
-rw-r--r-- | src/hbtree/hbtreeassert_p.h | 6 | ||||
-rw-r--r-- | src/hbtree/hbtreecursor.cpp | 4 | ||||
-rw-r--r-- | src/hbtree/hbtreecursor.h | 6 | ||||
-rw-r--r-- | src/hbtree/hbtreeglobal.h | 65 | ||||
-rw-r--r-- | src/hbtree/hbtreetransaction.cpp | 4 | ||||
-rw-r--r-- | src/hbtree/hbtreetransaction.h | 6 | ||||
-rw-r--r-- | src/hbtree/orderedlist_p.h | 6 | ||||
-rw-r--r-- | src/partition/jsondbbtree.cpp | 2 | ||||
-rw-r--r-- | src/partition/jsondbbtree.h | 2 | ||||
-rw-r--r-- | tests/auto/hbtree/main.cpp | 6 | ||||
-rw-r--r-- | tests/benchmarks/btrees/main.cpp | 6 |
16 files changed, 133 insertions, 7 deletions
diff --git a/src/hbtree/hbtree.cpp b/src/hbtree/hbtree.cpp index a387355..d9c7984 100644 --- a/src/hbtree/hbtree.cpp +++ b/src/hbtree/hbtree.cpp @@ -75,6 +75,8 @@ #define HBTREE_ERROR_LAST(msg) do {lastErrorMessage_ = QLatin1String(msg); (qCritical().nospace() << "ERROR! HBtree(" << fileName_ << ") " << __FUNCTION__ << " =>").space() << msg;} while (0) +QT_BEGIN_NAMESPACE_HBTREE + // NOTES: // What happens when marker revision overflows? Maybe you need to reset revisions from time to time? @@ -3288,3 +3290,5 @@ void HBtreePrivate::NodePage::clearHistory() history.clear(); meta.historySize = 0; } + +QT_END_NAMESPACE_HBTREE diff --git a/src/hbtree/hbtree.h b/src/hbtree/hbtree.h index c350108..4b320ec 100644 --- a/src/hbtree/hbtree.h +++ b/src/hbtree/hbtree.h @@ -49,6 +49,9 @@ #include "hbtreetransaction.h" #include "hbtreecursor.h" +#include "hbtreeglobal.h" + +QT_BEGIN_NAMESPACE_HBTREE extern bool gDebugHBtree; @@ -199,4 +202,6 @@ inline QDebug operator << (QDebug dbg, const HBtree::Stat &stats) return dbg.space(); } +QT_END_NAMESPACE_HBTREE + #endif // HBTREE_H diff --git a/src/hbtree/hbtree.pri b/src/hbtree/hbtree.pri index 7634002..97fab17 100644 --- a/src/hbtree/hbtree.pri +++ b/src/hbtree/hbtree.pri @@ -3,6 +3,7 @@ INCLUDEPATH += $$PWD/ include($$PWD/../3rdparty/zlib/zlib.pri) HEADERS += \ + $$PWD/hbtreeglobal.h \ $$PWD/orderedlist_p.h \ $$PWD/hbtree.h \ $$PWD/hbtreetransaction.h \ diff --git a/src/hbtree/hbtree_p.h b/src/hbtree/hbtree_p.h index dd9b7ff..4914759 100644 --- a/src/hbtree/hbtree_p.h +++ b/src/hbtree/hbtree_p.h @@ -46,6 +46,7 @@ #include "hbtreetransaction.h" #include "hbtreecursor.h" #include "orderedlist_p.h" +#include "hbtreeglobal.h" #include <QDebug> #include <QMap> @@ -59,6 +60,8 @@ #define HBTREE_ATTRIBUTE_PACKED #endif +QT_BEGIN_NAMESPACE_HBTREE + class HBtreePrivate { Q_DECLARE_PUBLIC(HBtree) @@ -416,10 +419,6 @@ public: mutable QString lastErrorMessage_; }; -QT_BEGIN_NAMESPACE -Q_DECLARE_TYPEINFO(HBtreePrivate::NodeKey, Q_MOVABLE_TYPE); -QT_END_NAMESPACE - QDebug operator << (QDebug dbg, const HBtreePrivate::Spec &p); QDebug operator << (QDebug dbg, const HBtreePrivate::PageInfo &pi); QDebug operator << (QDebug dbg, const HBtreePrivate::Page &page); @@ -479,4 +478,10 @@ bool HBtreePrivate::NodeKey::operator > (const HBtreePrivate::NodeKey &rhs) cons return compare(rhs) > 0; } +QT_END_NAMESPACE_HBTREE + +QT_BEGIN_NAMESPACE +Q_DECLARE_TYPEINFO(QT_PREPEND_NAMESPACE_HBTREE(HBtreePrivate::NodeKey), Q_MOVABLE_TYPE); +QT_END_NAMESPACE + #endif // HBTREE_P_H diff --git a/src/hbtree/hbtreeassert.cpp b/src/hbtree/hbtreeassert.cpp index 7e8f93e..2ef1794 100644 --- a/src/hbtree/hbtreeassert.cpp +++ b/src/hbtree/hbtreeassert.cpp @@ -44,6 +44,8 @@ #undef HBTREE_ASSERT_A #undef HBTREE_ASSERT_B +QT_BEGIN_NAMESPACE_HBTREE + HBtreeAssert::~HBtreeAssert() { if (copied_) @@ -67,3 +69,5 @@ HBtreeAssert &HBtreeAssert::operator ()(const char *expr, const char *file, cons qDebug().nospace() << "CONDITION FAILURE: "; return *this; } + +QT_END_NAMESPACE_HBTREE diff --git a/src/hbtree/hbtreeassert_p.h b/src/hbtree/hbtreeassert_p.h index 3dd5587..b28aabb 100644 --- a/src/hbtree/hbtreeassert_p.h +++ b/src/hbtree/hbtreeassert_p.h @@ -42,12 +42,16 @@ #ifndef HBTREEASSERT_P_H #define HBTREEASSERT_P_H +#include "hbtreeglobal.h" + #include <QDebug> #if !defined(QT_NO_DEBUG) || defined(QT_FORCE_ASSERTS) # define USE_HBTREE_ASSERT #endif +QT_BEGIN_NAMESPACE_HBTREE + class HBtreeAssert { public: @@ -102,4 +106,6 @@ private: HBtreeAssert __hbtree_assert = HBtreeAssert()(#expr, __FILE__, __FUNCTION__, __LINE__).HBTREE_ASSERT_A #endif +QT_END_NAMESPACE_HBTREE + #endif diff --git a/src/hbtree/hbtreecursor.cpp b/src/hbtree/hbtreecursor.cpp index c597319..92cbee2 100644 --- a/src/hbtree/hbtreecursor.cpp +++ b/src/hbtree/hbtreecursor.cpp @@ -44,6 +44,8 @@ #include "hbtreecursor.h" +QT_BEGIN_NAMESPACE_HBTREE + HBtreeCursor::HBtreeCursor() : transaction_(0), btree_(0), lastLeaf_(0xFFFFFFFF), valid_(false) { @@ -127,3 +129,5 @@ bool HBtreeCursor::seekRange(const QByteArray &key, RangePolicy policy) Q_ASSERT(btree_); return btree_->doCursorOp(this, FuzzyMatch, key, policy); } + +QT_END_NAMESPACE_HBTREE diff --git a/src/hbtree/hbtreecursor.h b/src/hbtree/hbtreecursor.h index c946245..75331f8 100644 --- a/src/hbtree/hbtreecursor.h +++ b/src/hbtree/hbtreecursor.h @@ -42,9 +42,13 @@ #ifndef HBTREECURSOR_H #define HBTREECURSOR_H +#include "hbtreeglobal.h" + #include <QByteArray> #include <QStack> +QT_BEGIN_NAMESPACE_HBTREE + class HBtree; class HBtreeTransaction; class HBtreeCursor @@ -98,4 +102,6 @@ private: bool doOp(Op op, const QByteArray &key = QByteArray()); }; +QT_END_NAMESPACE_HBTREE + #endif // HBTREECURSOR_H diff --git a/src/hbtree/hbtreeglobal.h b/src/hbtree/hbtreeglobal.h new file mode 100644 index 0000000..7fcb0c1 --- /dev/null +++ b/src/hbtree/hbtreeglobal.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtAddOn.JsonDb module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef HBTREE_GLOBAL_H +#define HBTREE_GLOBAL_H + +#include <QtCore/qglobal.h> + +#if defined(QT_NAMESPACE) +# define QT_BEGIN_NAMESPACE_HBTREE namespace QT_NAMESPACE { namespace HbTree { +# define QT_END_NAMESPACE_HBTREE } } +# define QT_USE_NAMESPACE_HBTREE using namespace QT_NAMESPACE::HbTree; +# define QT_PREPEND_NAMESPACE_HBTREE(name) QT_NAMESPACE::HbTree::name +#else +# define QT_BEGIN_NAMESPACE_HBTREE namespace HbTree { +# define QT_END_NAMESPACE_HBTREE } +# define QT_USE_NAMESPACE_HBTREE using namespace HbTree; +# define QT_PREPEND_NAMESPACE_HBTREE(name) HbTree::name +#endif + +// a workaround for moc - if there is a header file that doesn't use jsondb +// namespace, we still force moc to do "using namespace" but the namespace have to +// be defined, so let's define an empty namespace here +QT_BEGIN_NAMESPACE_HBTREE +QT_END_NAMESPACE_HBTREE + +#endif // HBTREE_GLOBAL_H diff --git a/src/hbtree/hbtreetransaction.cpp b/src/hbtree/hbtreetransaction.cpp index 07832d9..a1aea13 100644 --- a/src/hbtree/hbtreetransaction.cpp +++ b/src/hbtree/hbtreetransaction.cpp @@ -43,6 +43,8 @@ #include "hbtree.h" #include "hbtreetransaction.h" +QT_BEGIN_NAMESPACE_HBTREE + HBtreeTransaction::HBtreeTransaction(HBtree *btree, HBtreeTransaction::Type type) : btree_(btree), type_(type), rootPage_(0xFFFFFFFF), tag_(0), revision_(0) { @@ -97,3 +99,5 @@ void HBtreeTransaction::abort() Q_ASSERT(btree_); btree_->abort(this); } + +QT_END_NAMESPACE_HBTREE diff --git a/src/hbtree/hbtreetransaction.h b/src/hbtree/hbtreetransaction.h index a058705..3872017 100644 --- a/src/hbtree/hbtreetransaction.h +++ b/src/hbtree/hbtreetransaction.h @@ -42,9 +42,13 @@ #ifndef HBtreeTRANSACTION_H #define HBtreeTRANSACTION_H +#include "hbtreeglobal.h" + #include <QByteArray> #include <QScopedPointer> +QT_BEGIN_NAMESPACE_HBTREE + class HBtree; class HBtreeTransactionPrivate; class HBtreeTransaction @@ -88,4 +92,6 @@ private: quint32 revision_; }; +QT_END_NAMESPACE_HBTREE + #endif // HBtreeTRANSACTION_H diff --git a/src/hbtree/orderedlist_p.h b/src/hbtree/orderedlist_p.h index cd94155..09a8e6d 100644 --- a/src/hbtree/orderedlist_p.h +++ b/src/hbtree/orderedlist_p.h @@ -42,11 +42,15 @@ #ifndef ORDERED_LIST_P_H #define ORDERED_LIST_P_H +#include "hbtreeglobal.h" + #include <QList> #include <QPair> #include <QtAlgorithms> #include <QDebug> +QT_BEGIN_NAMESPACE_HBTREE + template <typename Key, typename Value, typename LessThan = qLess<Key> > class OrderedList { @@ -236,4 +240,6 @@ inline QDebug operator << (QDebug dbg, const OrderedList<Key, Value, LessThan> & return dbg.space(); } +QT_END_NAMESPACE_HBTREE + #endif // ORDERED_LIST_P_H diff --git a/src/partition/jsondbbtree.cpp b/src/partition/jsondbbtree.cpp index 8b79b34..4b2148b 100644 --- a/src/partition/jsondbbtree.cpp +++ b/src/partition/jsondbbtree.cpp @@ -48,6 +48,8 @@ QT_BEGIN_NAMESPACE_JSONDB_PARTITION +QT_USE_NAMESPACE_HBTREE + JsonDbBtree::JsonDbBtree() : mBtree(new Btree()) { diff --git a/src/partition/jsondbbtree.h b/src/partition/jsondbbtree.h index afd5102..86f356b 100644 --- a/src/partition/jsondbbtree.h +++ b/src/partition/jsondbbtree.h @@ -64,7 +64,7 @@ public: }; Q_DECLARE_FLAGS(OpenFlags, OpenFlag) - typedef HBtree Btree; + typedef QT_PREPEND_NAMESPACE_HBTREE(HBtree) Btree; typedef Btree::CursorType Cursor; typedef Btree::TransactionType Transaction; diff --git a/tests/auto/hbtree/main.cpp b/tests/auto/hbtree/main.cpp index b0f3d03..5982379 100644 --- a/tests/auto/hbtree/main.cpp +++ b/tests/auto/hbtree/main.cpp @@ -54,6 +54,8 @@ #include "hbtree_p.h" #include "orderedlist_p.h" +QT_BEGIN_NAMESPACE_HBTREE + const int numTable[] = { 848189692, 10993076, 645053843, 409500027, 984193993, 476551019, 863168763, 189550775, 620531785, 882318228, 974619333, 104980108, 429916131, 425358349, @@ -2843,5 +2845,7 @@ void TestHBtree::failedCommits() txn->abort(); } -QTEST_MAIN(TestHBtree) +QT_END_NAMESPACE_HBTREE + +QTEST_MAIN(QT_PREPEND_NAMESPACE_HBTREE(TestHBtree)) #include "main.moc" diff --git a/tests/benchmarks/btrees/main.cpp b/tests/benchmarks/btrees/main.cpp index 8078db3..9c0bdc1 100644 --- a/tests/benchmarks/btrees/main.cpp +++ b/tests/benchmarks/btrees/main.cpp @@ -49,6 +49,8 @@ #include "hbtree_p.h" #include "hbtreetransaction.h" +QT_BEGIN_NAMESPACE_HBTREE + class TestBtrees: public QObject { Q_OBJECT @@ -448,5 +450,7 @@ void TestBtrees::cursorPrevious() } } -QTEST_MAIN(TestBtrees) +QT_END_NAMESPACE_HBTREE + +QTEST_MAIN(QT_PREPEND_NAMESPACE_HBTREE(TestBtrees)) #include "main.moc" |