2 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include "WebIDBKey.h"
31 #if ENABLE(INDEXED_DATABASE)
33 #include "IDBBindingUtilities.h"
35 #include "IDBKeyPath.h"
36 #include "SerializedScriptValue.h"
37 #include "WebIDBKeyPath.h"
38 #include "WebSerializedScriptValue.h"
40 using namespace WebCore;
44 WebIDBKey WebIDBKey::createNull()
51 WebIDBKey WebIDBKey::createString(const WebString& string)
54 key.assignString(string);
58 WebIDBKey WebIDBKey::createDate(double date)
65 WebIDBKey WebIDBKey::createNumber(double number)
68 key.assignNumber(number);
72 WebIDBKey WebIDBKey::createInvalid()
79 WebIDBKey WebIDBKey::createFromValueAndKeyPath(const WebSerializedScriptValue& serializedScriptValue, const WebIDBKeyPath& idbKeyPath)
81 if (serializedScriptValue.isNull())
82 return WebIDBKey::createInvalid();
83 return createIDBKeyFromSerializedValueAndKeyPath(serializedScriptValue, idbKeyPath);
86 WebSerializedScriptValue WebIDBKey::injectIDBKeyIntoSerializedValue(const WebIDBKey& key, const WebSerializedScriptValue& value, const WebIDBKeyPath& path)
88 return WebCore::injectIDBKeyIntoSerializedValue(key, value, path);
91 void WebIDBKey::assign(const WebIDBKey& value)
93 m_private = value.m_private;
96 void WebIDBKey::assignNull()
98 m_private = IDBKey::createNull();
101 void WebIDBKey::assignString(const WebString& string)
103 m_private = IDBKey::createString(string);
106 void WebIDBKey::assignDate(double date)
108 m_private = IDBKey::createDate(date);
111 void WebIDBKey::assignNumber(double number)
113 m_private = IDBKey::createNumber(number);
116 void WebIDBKey::assignInvalid()
121 void WebIDBKey::reset()
126 WebIDBKey::Type WebIDBKey::type() const
128 if (!m_private.get())
130 return Type(m_private->type());
133 WebString WebIDBKey::string() const
135 return m_private->string();
138 double WebIDBKey::date() const
140 return m_private->date();
143 double WebIDBKey::number() const
145 return m_private->number();
148 WebIDBKey::WebIDBKey(const PassRefPtr<IDBKey>& value)
153 WebIDBKey& WebIDBKey::operator=(const PassRefPtr<IDBKey>& value)
159 WebIDBKey::operator PassRefPtr<IDBKey>() const
161 return m_private.get();
164 } // namespace WebKit
166 #endif // ENABLE(INDEXED_DATABASE)