WebKit/chromium/src/WebIDBKey.cpp
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     1 /*
       
     2  * Copyright (C) 2010 Google Inc. All rights reserved.
       
     3  *
       
     4  * Redistribution and use in source and binary forms, with or without
       
     5  * modification, are permitted provided that the following conditions are
       
     6  * met:
       
     7  *
       
     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
       
    13  * distribution.
       
    14  *
       
    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.
       
    26  */
       
    27 
       
    28 #include "config.h"
       
    29 #include "WebIDBKey.h"
       
    30 
       
    31 #if ENABLE(INDEXED_DATABASE)
       
    32 
       
    33 #include "IDBKey.h"
       
    34 
       
    35 using namespace WebCore;
       
    36 
       
    37 namespace WebKit {
       
    38 
       
    39 WebIDBKey WebIDBKey::createNull()
       
    40 {
       
    41     WebIDBKey key;
       
    42     key.assignNull();
       
    43     return key;
       
    44 }
       
    45 
       
    46 WebIDBKey WebIDBKey::createInvalid()
       
    47 {
       
    48     WebIDBKey key;
       
    49     key.assignInvalid();
       
    50     return key;
       
    51 }
       
    52 
       
    53 void WebIDBKey::assign(const WebIDBKey& value)
       
    54 {
       
    55     m_private = value.m_private;
       
    56 }
       
    57 
       
    58 void WebIDBKey::assignNull()
       
    59 {
       
    60     m_private = IDBKey::create();
       
    61 }
       
    62 
       
    63 void WebIDBKey::assign(const WebString& string)
       
    64 {
       
    65     m_private = IDBKey::create(string);
       
    66 }
       
    67 
       
    68 void WebIDBKey::assign(int32_t number)
       
    69 {
       
    70     m_private = IDBKey::create(number);
       
    71 }
       
    72 
       
    73 void WebIDBKey::assignInvalid()
       
    74 {
       
    75     m_private = 0;
       
    76 }
       
    77 
       
    78 void WebIDBKey::reset()
       
    79 {
       
    80     m_private.reset();
       
    81 }
       
    82 
       
    83 WebIDBKey::Type WebIDBKey::type() const
       
    84 {
       
    85     if (!m_private.get())
       
    86         return InvalidType;
       
    87     return Type(m_private->type());
       
    88 }
       
    89 
       
    90 WebString WebIDBKey::string() const
       
    91 {
       
    92     return m_private->string();
       
    93 }
       
    94 
       
    95 int32_t WebIDBKey::number() const
       
    96 {
       
    97     return m_private->number();
       
    98 }
       
    99 
       
   100 WebIDBKey::WebIDBKey(const PassRefPtr<IDBKey>& value)
       
   101     : m_private(value)
       
   102 {
       
   103 }
       
   104 
       
   105 WebIDBKey& WebIDBKey::operator=(const PassRefPtr<IDBKey>& value)
       
   106 {
       
   107     m_private = value;
       
   108     return *this;
       
   109 }
       
   110 
       
   111 WebIDBKey::operator PassRefPtr<IDBKey>() const
       
   112 {
       
   113     return m_private.get();
       
   114 }
       
   115 
       
   116 } // namespace WebKit
       
   117 
       
   118 #endif // ENABLE(INDEXED_DATABASE)