WebKit/chromium/public/WebIDBKey.h
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
       
     6  * are met:
       
     7  *
       
     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.
       
    13  *
       
    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.
       
    24  */
       
    25 
       
    26 #ifndef WebIDBKey_h
       
    27 #define WebIDBKey_h
       
    28 
       
    29 #include "WebCommon.h"
       
    30 #include "WebPrivatePtr.h"
       
    31 #include "WebString.h"
       
    32 
       
    33 namespace WebCore { class IDBKey; }
       
    34 
       
    35 namespace WebKit {
       
    36 
       
    37 class WebIDBKey {
       
    38 public:
       
    39     ~WebIDBKey() { reset(); }
       
    40   
       
    41     WEBKIT_API static WebIDBKey createNull();
       
    42     WEBKIT_API static WebIDBKey createInvalid();
       
    43 
       
    44     WebIDBKey(const WebString& string) { assign(string); }
       
    45     WebIDBKey(int32_t number) { assign(number); }
       
    46     WebIDBKey(const WebIDBKey& e) { assign(e); }
       
    47     WebIDBKey& operator=(const WebIDBKey& e)
       
    48     {
       
    49         assign(e);
       
    50         return *this;
       
    51     }
       
    52 
       
    53     WEBKIT_API void assign(const WebIDBKey&);
       
    54     WEBKIT_API void assignNull();
       
    55     WEBKIT_API void assign(const WebString&);
       
    56     WEBKIT_API void assign(int32_t);
       
    57     WEBKIT_API void assignInvalid();
       
    58     WEBKIT_API void reset();
       
    59 
       
    60     enum Type {
       
    61         NullType = 0,
       
    62         StringType,
       
    63         NumberType,
       
    64         // Types not in WebCore::IDBKey:
       
    65         InvalidType
       
    66     };
       
    67 
       
    68     WEBKIT_API Type type() const;
       
    69     WEBKIT_API WebString string() const; // Only valid for StringType.
       
    70     WEBKIT_API int32_t number() const; // Only valid for numberType.
       
    71 
       
    72 #if WEBKIT_IMPLEMENTATION
       
    73     WebIDBKey(const WTF::PassRefPtr<WebCore::IDBKey>&);
       
    74     WebIDBKey& operator=(const WTF::PassRefPtr<WebCore::IDBKey>&);
       
    75     operator WTF::PassRefPtr<WebCore::IDBKey>() const;
       
    76 #endif
       
    77 
       
    78 private:
       
    79     WebIDBKey() { }
       
    80 
       
    81     WebPrivatePtr<WebCore::IDBKey> m_private;
       
    82 };
       
    83 
       
    84 } // namespace WebKit
       
    85 
       
    86 #endif // WebIDBKey_h