summaryrefslogtreecommitdiff
path: root/Source/WebCore/Modules/indexeddb/IDBKeyPath.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/Modules/indexeddb/IDBKeyPath.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/Modules/indexeddb/IDBKeyPath.h')
-rw-r--r--Source/WebCore/Modules/indexeddb/IDBKeyPath.h73
1 files changed, 21 insertions, 52 deletions
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 <wtf/Variant.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
-class KeyedDecoder;
-class KeyedEncoder;
+using IDBKeyPath = WTF::Variant<String, Vector<String>>;
+bool isIDBKeyPathValid(const IDBKeyPath&);
-enum IDBKeyPathParseError {
- IDBKeyPathParseErrorNone,
- IDBKeyPathParseErrorStart,
- IDBKeyPathParseErrorIdentifier,
- IDBKeyPathParseErrorDot,
+enum class IDBKeyPathParseError {
+ None,
+ Start,
+ Identifier,
+ Dot,
};
void IDBParseKeyPath(const String&, Vector<String>&, IDBKeyPathParseError&);
-
-class IDBKeyPath {
-public:
- IDBKeyPath() : m_type(NullType) { }
- explicit IDBKeyPath(const String&);
- explicit IDBKeyPath(const Vector<String>& array);
-
- enum Type {
- NullType = 0,
- StringType,
- ArrayType
- };
-
- Type type() const { return m_type; }
-
- const Vector<String>& 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<String> m_array;
-};
+IDBKeyPath isolatedCopy(const IDBKeyPath&);
+inline std::optional<IDBKeyPath> isolatedCopy(const std::optional<IDBKeyPath>& variant)
+{
+ if (!variant)
+ return { };
+ return isolatedCopy(variant.value());
+}
+
+#ifndef NDEBUG
+String loggingString(const IDBKeyPath&);
+#endif
} // namespace WebCore
#endif
-
-#endif // IDBKeyPath_h