From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- Source/WebCore/Modules/indexeddb/IDBKeyPath.h | 73 ++++++++------------------- 1 file changed, 21 insertions(+), 52 deletions(-) (limited to 'Source/WebCore/Modules/indexeddb/IDBKeyPath.h') diff --git a/Source/WebCore/Modules/indexeddb/IDBKeyPath.h b/Source/WebCore/Modules/indexeddb/IDBKeyPath.h index 6dcd7deac..c5a04b3d2 100644 --- a/Source/WebCore/Modules/indexeddb/IDBKeyPath.h +++ b/Source/WebCore/Modules/indexeddb/IDBKeyPath.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2010 Google Inc. All rights reserved. + * Copyright (C) 2016-2017 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,71 +24,39 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef IDBKeyPath_h -#define IDBKeyPath_h +#pragma once #if ENABLE(INDEXED_DATABASE) +#include #include #include namespace WebCore { -class KeyedDecoder; -class KeyedEncoder; +using IDBKeyPath = WTF::Variant>; +bool isIDBKeyPathValid(const IDBKeyPath&); -enum IDBKeyPathParseError { - IDBKeyPathParseErrorNone, - IDBKeyPathParseErrorStart, - IDBKeyPathParseErrorIdentifier, - IDBKeyPathParseErrorDot, +enum class IDBKeyPathParseError { + None, + Start, + Identifier, + Dot, }; void IDBParseKeyPath(const String&, Vector&, IDBKeyPathParseError&); - -class IDBKeyPath { -public: - IDBKeyPath() : m_type(NullType) { } - explicit IDBKeyPath(const String&); - explicit IDBKeyPath(const Vector& array); - - enum Type { - NullType = 0, - StringType, - ArrayType - }; - - Type type() const { return m_type; } - - const Vector& array() const - { - ASSERT(m_type == ArrayType); - return m_array; - } - - const String& string() const - { - ASSERT(m_type == StringType); - return m_string; - } - - bool isNull() const { return m_type == NullType; } - bool isValid() const; - bool operator==(const IDBKeyPath& other) const; - - IDBKeyPath isolatedCopy() const; - - void encode(KeyedEncoder&) const; - static bool decode(KeyedDecoder&, IDBKeyPath&); - -private: - Type m_type; - String m_string; - Vector m_array; -}; +IDBKeyPath isolatedCopy(const IDBKeyPath&); +inline std::optional isolatedCopy(const std::optional& variant) +{ + if (!variant) + return { }; + return isolatedCopy(variant.value()); +} + +#ifndef NDEBUG +String loggingString(const IDBKeyPath&); +#endif } // namespace WebCore #endif - -#endif // IDBKeyPath_h -- cgit v1.2.1