From d8543bb6618c17b12da906afa77d216f58cf4058 Mon Sep 17 00:00:00 2001 From: Upstream Date: Mon, 12 Jan 1970 13:46:40 +0000 Subject: external/webkit r30707 --- WebCore/platform/DeprecatedValueList.h | 151 +++++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 WebCore/platform/DeprecatedValueList.h (limited to 'WebCore/platform/DeprecatedValueList.h') diff --git a/WebCore/platform/DeprecatedValueList.h b/WebCore/platform/DeprecatedValueList.h new file mode 100644 index 0000000..8c00b4b --- /dev/null +++ b/WebCore/platform/DeprecatedValueList.h @@ -0,0 +1,151 @@ +/* + * Copyright (C) 2004 Apple Computer, 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 COMPUTER, 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 COMPUTER, 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 DeprecatedValueList_h +#define DeprecatedValueList_h + +#include "DeprecatedValueListImpl.h" + +namespace WebCore { + +template class DeprecatedValueList; +template class DeprecatedValueListConstIterator; + +template class DeprecatedValueListNode : private DeprecatedValueListImplNode { +public: + DeprecatedValueListNode(const T &val) : value(val) { } + T value; + friend class DeprecatedValueList; +}; + +template class DeprecatedValueListIterator { +public: + DeprecatedValueListIterator() { } + + T& operator*() const { return ((DeprecatedValueListNode *)impl.node())->value; } + + DeprecatedValueListIterator &operator++() { ++impl; return *this; } + DeprecatedValueListIterator &operator--() { --impl; return *this; } + DeprecatedValueListIterator operator++(int) { return impl++; } + + bool operator==(const DeprecatedValueListIterator &other) { return impl == other.impl; } + bool operator!=(const DeprecatedValueListIterator &other) { return impl != other.impl; } + +private: + DeprecatedValueListIterator(const DeprecatedValueListImplIterator &pImp) : impl(pImp) { } + + DeprecatedValueListImplIterator impl; + + friend class DeprecatedValueList; + friend class DeprecatedValueListConstIterator; +}; + +template class DeprecatedValueListConstIterator { +public: + DeprecatedValueListConstIterator() { } + DeprecatedValueListConstIterator(const DeprecatedValueListIterator &it) : impl(it.impl) { } + + const T& operator*() const { return ((const DeprecatedValueListNode *)impl.node())->value; } + + DeprecatedValueListConstIterator &operator++() { ++impl; return *this; } + DeprecatedValueListConstIterator &operator--() { --impl; return *this; } + DeprecatedValueListConstIterator operator++(int) { return impl++; } + + bool operator==(const DeprecatedValueListConstIterator &other) { return impl == other.impl; } + bool operator!=(const DeprecatedValueListConstIterator &other) { return impl != other.impl; } + +private: + DeprecatedValueListConstIterator(const DeprecatedValueListImplIterator &pImp) : impl(pImp) { } + + DeprecatedValueListImplIterator impl; + + friend class DeprecatedValueList; +}; + +template bool operator==(const DeprecatedValueList &a, const DeprecatedValueList &b); + +template class DeprecatedValueList { +public: + typedef DeprecatedValueListIterator Iterator; + typedef DeprecatedValueListIterator iterator; + typedef DeprecatedValueListConstIterator ConstIterator; + typedef DeprecatedValueListConstIterator const_iterator; + + DeprecatedValueList() : impl(deleteNode, copyNode) { } + + void clear() { impl.clear(); } + unsigned count() const { return impl.count(); } + bool isEmpty() const { return impl.isEmpty(); } + + Iterator append(const T &val) { return impl.appendNode(new DeprecatedValueListNode(val)); } + Iterator prepend(const T &val) { return impl.prependNode(new DeprecatedValueListNode(val)); } + void remove(const T &val) { DeprecatedValueListNode node(val); impl.removeEqualNodes(&node, nodesEqual); } + unsigned contains(const T &val) const { DeprecatedValueListNode node(val); return impl.containsEqualNodes(&node, nodesEqual); } + Iterator find(const T &val) const { DeprecatedValueListNode node(val); return impl.findEqualNode(&node, nodesEqual); } + + Iterator insert(Iterator iter, const T& val) { return impl.insert(iter.impl, new DeprecatedValueListNode(val)); } + Iterator remove(Iterator iter) { return impl.removeIterator(iter.impl); } + Iterator fromLast() { return impl.fromLast(); } + + T& first() { return static_cast *>(impl.firstNode())->value; } + const T& first() const { return static_cast *>(impl.firstNode())->value; } + T& last() { return static_cast *>(impl.lastNode())->value; } + const T& last() const { return static_cast *>(impl.lastNode())->value; } + + Iterator begin() { return impl.begin(); } + Iterator end() { return impl.end(); } + + ConstIterator begin() const { return impl.begin(); } + ConstIterator end() const { return impl.end(); } + ConstIterator constBegin() const { return impl.begin(); } + ConstIterator constEnd() const { return impl.end(); } + ConstIterator fromLast() const { return impl.fromLast(); } + + T& operator[] (unsigned index) { return ((DeprecatedValueListNode *)impl.nodeAt(index))->value; } + const T& operator[] (unsigned index) const { return ((const DeprecatedValueListNode *)impl.nodeAt(index))->value; } + DeprecatedValueList &operator+=(const T &value) { impl.appendNode(new DeprecatedValueListNode(value)); return *this; } + DeprecatedValueList &operator<<(const T &value) { impl.appendNode(new DeprecatedValueListNode(value)); return *this; } + + friend bool operator==<>(const DeprecatedValueList &, const DeprecatedValueList &); + +private: + DeprecatedValueListImpl impl; + + static void deleteNode(DeprecatedValueListImplNode *node) { delete (DeprecatedValueListNode *)node; } + static bool nodesEqual(const DeprecatedValueListImplNode *a, const DeprecatedValueListImplNode *b) + { return ((DeprecatedValueListNode *)a)->value == ((DeprecatedValueListNode *)b)->value; } + static DeprecatedValueListImplNode *copyNode(DeprecatedValueListImplNode *node) + { return new DeprecatedValueListNode(((DeprecatedValueListNode *)node)->value); } +}; + +template +inline bool operator==(const DeprecatedValueList &a, const DeprecatedValueList &b) +{ + return a.impl.isEqual(b.impl, DeprecatedValueList::nodesEqual); +} + +} + +#endif -- cgit v1.1