193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)/*
293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * Copyright (C) 2011 Google Inc. All rights reserved.
393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *
493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without
593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * modification, are permitted provided that the following conditions
693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * are met:
793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *
893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * 1.  Redistributions of source code must retain the above copyright
993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *     notice, this list of conditions and the following disclaimer.
1093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * 2.  Redistributions in binary form must reproduce the above copyright
1193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *     notice, this list of conditions and the following disclaimer in the
1293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *     documentation and/or other materials provided with the distribution.
1393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *
1493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
1593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
1893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
2193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) */
2593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
2693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#ifndef WebIDBKey_h
2793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#define WebIDBKey_h
2893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
2993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#include "WebCommon.h"
3051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)#include "WebData.h"
310019e4eead4d990e4304c54a9028aca9122fb256Ben Murdoch#include "WebIDBTypes.h"
3293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#include "WebPrivatePtr.h"
3393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#include "WebString.h"
3493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#include "WebVector.h"
3593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
3651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)namespace blink {
3793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
38e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)class IDBKey;
39e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)
4093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)class WebIDBKey {
4193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)public:
4293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    // Please use one of the factory methods. This is public only to allow WebVector.
4393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    WebIDBKey() { }
4493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    ~WebIDBKey() { reset(); }
4593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
4606f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    BLINK_EXPORT static WebIDBKey createArray(const WebVector<WebIDBKey>&);
4751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    BLINK_EXPORT static WebIDBKey createBinary(const WebData&);
4806f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    BLINK_EXPORT static WebIDBKey createString(const WebString&);
4906f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    BLINK_EXPORT static WebIDBKey createDate(double);
5006f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    BLINK_EXPORT static WebIDBKey createNumber(double);
5106f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    BLINK_EXPORT static WebIDBKey createInvalid();
5206f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    BLINK_EXPORT static WebIDBKey createNull();
5393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
5493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    WebIDBKey(const WebIDBKey& e) { assign(e); }
5593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    WebIDBKey& operator=(const WebIDBKey& e)
5693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    {
5793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        assign(e);
5893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        return *this;
5993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    }
6093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
6106f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    BLINK_EXPORT void assign(const WebIDBKey&);
6206f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    BLINK_EXPORT void assignArray(const WebVector<WebIDBKey>&);
6351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    BLINK_EXPORT void assignBinary(const WebData&);
6406f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    BLINK_EXPORT void assignString(const WebString&);
6506f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    BLINK_EXPORT void assignDate(double);
6606f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    BLINK_EXPORT void assignNumber(double);
6706f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    BLINK_EXPORT void assignInvalid();
6806f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    BLINK_EXPORT void assignNull();
6906f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    BLINK_EXPORT void reset();
7093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
7106f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    BLINK_EXPORT WebIDBKeyType keyType() const;
7206f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    BLINK_EXPORT bool isValid() const;
7306f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    BLINK_EXPORT WebVector<WebIDBKey> array() const; // Only valid for ArrayType.
7451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    BLINK_EXPORT WebData binary() const; // Only valid for BinaryType.
7506f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    BLINK_EXPORT WebString string() const; // Only valid for StringType.
7606f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    BLINK_EXPORT double date() const; // Only valid for DateType.
7706f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    BLINK_EXPORT double number() const; // Only valid for NumberType.
7893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
7906f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)#if BLINK_IMPLEMENTATION
80e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    WebIDBKey(IDBKey*);
81e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    WebIDBKey& operator=(IDBKey*);
82e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    operator IDBKey*() const;
8393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#endif
8493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
8593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)private:
86e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    WebPrivatePtr<IDBKey> m_private;
8793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)};
8893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
8951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} // namespace blink
9093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
9193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#endif // WebIDBKey_h
92