storage/public/mozIStorageValueArray.idl

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "nsISupports.idl"
michael@0 7 %{C++
michael@0 8 #include "mozilla/DebugOnly.h"
michael@0 9 %}
michael@0 10
michael@0 11 [ptr] native octetPtr(uint8_t);
michael@0 12
michael@0 13 /**
michael@0 14 * mozIStorageValueArray wraps an array of SQL values, such as a single database
michael@0 15 * row.
michael@0 16 */
michael@0 17 [scriptable, uuid(07b5b93e-113c-4150-863c-d247b003a55d)]
michael@0 18 interface mozIStorageValueArray : nsISupports {
michael@0 19 /**
michael@0 20 * These type values are returned by getTypeOfIndex
michael@0 21 * to indicate what type of value is present at
michael@0 22 * a given column.
michael@0 23 */
michael@0 24 const long VALUE_TYPE_NULL = 0;
michael@0 25 const long VALUE_TYPE_INTEGER = 1;
michael@0 26 const long VALUE_TYPE_FLOAT = 2;
michael@0 27 const long VALUE_TYPE_TEXT = 3;
michael@0 28 const long VALUE_TYPE_BLOB = 4;
michael@0 29
michael@0 30 /**
michael@0 31 * numEntries
michael@0 32 *
michael@0 33 * number of entries in the array (each corresponding to a column
michael@0 34 * in the database row)
michael@0 35 */
michael@0 36 readonly attribute unsigned long numEntries;
michael@0 37
michael@0 38 /**
michael@0 39 * Returns the type of the value at the given column index;
michael@0 40 * one of VALUE_TYPE_NULL, VALUE_TYPE_INTEGER, VALUE_TYPE_FLOAT,
michael@0 41 * VALUE_TYPE_TEXT, VALUE_TYPE_BLOB.
michael@0 42 */
michael@0 43 long getTypeOfIndex(in unsigned long aIndex);
michael@0 44
michael@0 45 /**
michael@0 46 * Obtain a value for the given entry (column) index.
michael@0 47 * Due to SQLite's type conversion rules, any of these are valid
michael@0 48 * for any column regardless of the column's data type. However,
michael@0 49 * if the specific type matters, getTypeOfIndex should be used
michael@0 50 * first to identify the column type, and then the appropriate
michael@0 51 * get method should be called.
michael@0 52 *
michael@0 53 * If you ask for a string value for a NULL column, you will get an empty
michael@0 54 * string with IsVoid set to distinguish it from an explicitly set empty
michael@0 55 * string.
michael@0 56 */
michael@0 57 long getInt32(in unsigned long aIndex);
michael@0 58 long long getInt64(in unsigned long aIndex);
michael@0 59 double getDouble(in unsigned long aIndex);
michael@0 60 AUTF8String getUTF8String(in unsigned long aIndex);
michael@0 61 AString getString(in unsigned long aIndex);
michael@0 62
michael@0 63 // data will be NULL if dataSize = 0
michael@0 64 void getBlob(in unsigned long aIndex, out unsigned long aDataSize, [array,size_is(aDataSize)] out octet aData);
michael@0 65 boolean getIsNull(in unsigned long aIndex);
michael@0 66
michael@0 67 /**
michael@0 68 * Returns a shared string pointer
michael@0 69 */
michael@0 70 [noscript] void getSharedUTF8String(in unsigned long aIndex, out unsigned long aLength, [shared,retval] out string aResult);
michael@0 71 [noscript] void getSharedString(in unsigned long aIndex, out unsigned long aLength, [shared,retval] out wstring aResult);
michael@0 72 [noscript] void getSharedBlob(in unsigned long aIndex, out unsigned long aLength, [shared,retval] out octetPtr aResult);
michael@0 73
michael@0 74 %{C++
michael@0 75 /**
michael@0 76 * Getters for native code that return their values as
michael@0 77 * the return type, for convenience and sanity.
michael@0 78 *
michael@0 79 * Not virtual; no vtable bloat.
michael@0 80 */
michael@0 81
michael@0 82 inline int32_t AsInt32(uint32_t idx) {
michael@0 83 int32_t v = 0;
michael@0 84 mozilla::DebugOnly<nsresult> rv = GetInt32(idx, &v);
michael@0 85 NS_ABORT_IF_FALSE(NS_SUCCEEDED(rv) || IsNull(idx),
michael@0 86 "Getting value failed, wrong column index?");
michael@0 87 return v;
michael@0 88 }
michael@0 89
michael@0 90 inline int64_t AsInt64(uint32_t idx) {
michael@0 91 int64_t v = 0;
michael@0 92 mozilla::DebugOnly<nsresult> rv = GetInt64(idx, &v);
michael@0 93 NS_ABORT_IF_FALSE(NS_SUCCEEDED(rv) || IsNull(idx),
michael@0 94 "Getting value failed, wrong column index?");
michael@0 95 return v;
michael@0 96 }
michael@0 97
michael@0 98 inline double AsDouble(uint32_t idx) {
michael@0 99 double v = 0.0;
michael@0 100 mozilla::DebugOnly<nsresult> rv = GetDouble(idx, &v);
michael@0 101 NS_ABORT_IF_FALSE(NS_SUCCEEDED(rv) || IsNull(idx),
michael@0 102 "Getting value failed, wrong column index?");
michael@0 103 return v;
michael@0 104 }
michael@0 105
michael@0 106 inline const char* AsSharedUTF8String(uint32_t idx, uint32_t *len) {
michael@0 107 const char *str = nullptr;
michael@0 108 *len = 0;
michael@0 109 mozilla::DebugOnly<nsresult> rv = GetSharedUTF8String(idx, len, &str);
michael@0 110 NS_ABORT_IF_FALSE(NS_SUCCEEDED(rv) || IsNull(idx),
michael@0 111 "Getting value failed, wrong column index?");
michael@0 112 return str;
michael@0 113 }
michael@0 114
michael@0 115 inline const char16_t* AsSharedWString(uint32_t idx, uint32_t *len) {
michael@0 116 const char16_t *str = nullptr;
michael@0 117 *len = 0;
michael@0 118 mozilla::DebugOnly<nsresult> rv = GetSharedString(idx, len, &str);
michael@0 119 NS_ABORT_IF_FALSE(NS_SUCCEEDED(rv) || IsNull(idx),
michael@0 120 "Getting value failed, wrong column index?");
michael@0 121 return str;
michael@0 122 }
michael@0 123
michael@0 124 inline const uint8_t* AsSharedBlob(uint32_t idx, uint32_t *len) {
michael@0 125 const uint8_t *blob = nullptr;
michael@0 126 *len = 0;
michael@0 127 mozilla::DebugOnly<nsresult> rv = GetSharedBlob(idx, len, &blob);
michael@0 128 NS_ABORT_IF_FALSE(NS_SUCCEEDED(rv) || IsNull(idx),
michael@0 129 "Getting value failed, wrong column index?");
michael@0 130 return blob;
michael@0 131 }
michael@0 132
michael@0 133 inline bool IsNull(uint32_t idx) {
michael@0 134 bool b = false;
michael@0 135 mozilla::DebugOnly<nsresult> rv = GetIsNull(idx, &b);
michael@0 136 NS_ABORT_IF_FALSE(NS_SUCCEEDED(rv),
michael@0 137 "Getting value failed, wrong column index?");
michael@0 138 return b;
michael@0 139 }
michael@0 140
michael@0 141 %}
michael@0 142
michael@0 143 };

mercurial