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
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #include "public/platform/WebIDBKeyPath.h"
29 #include "modules/indexeddb/IDBKeyPath.h"
30 #include "public/platform/WebString.h"
31 #include "public/platform/WebVector.h"
32 #include "wtf/Vector.h"
34 using namespace WebCore;
38 WebIDBKeyPath WebIDBKeyPath::create(const WebString& keyPath)
40 return WebIDBKeyPath(IDBKeyPath(keyPath));
43 WebIDBKeyPath WebIDBKeyPath::create(const WebVector<WebString>& keyPath)
45 Vector<String> strings;
46 for (size_t i = 0; i < keyPath.size(); ++i)
47 strings.append(keyPath[i]);
48 return WebIDBKeyPath(IDBKeyPath(strings));
51 WebIDBKeyPath WebIDBKeyPath::createNull()
53 return WebIDBKeyPath(IDBKeyPath());
56 void WebIDBKeyPath::assign(const WebIDBKeyPath& keyPath)
58 ASSERT(keyPath.m_private.get());
59 m_private.reset(new IDBKeyPath(keyPath));
62 void WebIDBKeyPath::reset()
67 bool WebIDBKeyPath::isValid() const
69 ASSERT(m_private.get());
70 return m_private->isValid();
73 WebIDBKeyPathType WebIDBKeyPath::keyPathType() const
75 ASSERT(m_private.get());
76 return static_cast<WebIDBKeyPathType>(m_private->type());
79 WebVector<WebString> WebIDBKeyPath::array() const
81 ASSERT(m_private.get());
82 ASSERT(m_private->type() == IDBKeyPath::ArrayType);
83 return m_private->array();
86 WebString WebIDBKeyPath::string() const
88 ASSERT(m_private.get());
89 ASSERT(m_private->type() == IDBKeyPath::StringType);
90 return m_private->string();
93 WebIDBKeyPath::WebIDBKeyPath(const WebCore::IDBKeyPath& value)
94 : m_private(new IDBKeyPath(value))
96 ASSERT(m_private.get());
99 WebIDBKeyPath& WebIDBKeyPath::operator=(const WebCore::IDBKeyPath& value)
101 ASSERT(m_private.get());
102 m_private.reset(new IDBKeyPath(value));
106 WebIDBKeyPath::operator const WebCore::IDBKeyPath&() const
108 ASSERT(m_private.get());
109 return *(m_private.get());