mozIStorageValueArray

  • Revision slug: mozIStorageValueArray
  • Revision title: mozIStorageValueArray
  • Revision id: 137597
  • Created:
  • Creator: Arehman4
  • Is current revision? No
  • Comment /* Summary */

Revision Content

Summary

mozIStorageValueArray wraps an array of SQL values, such as a single database row.

You can get the type of a value from mozIStorageValueArray.getTypeOfIndex, which returns the type of the specified column.

{{template.InterfaceStatus("mozIStorageValueArray", "storage/public/mozIStorageValueArray.idl", "unfrozen", "Mozilla 2.0 alpha 2", "yes")}}

Inherits from: nsISupports

JavaScript example of opening a connection to "asdf.sqlite" in the user's profile directory:


Be careful: SQLite is not a typed database. Any type can be put into any cell, regardless of the type declared for the column. If you request a different type, SQLite will do its best to convert them, and will do some default value if it is impossible. Therefore, it is impossible to get type errors, but you may get weird data out.

Interface Code

[scriptable, uuid(07b5b93e-113c-4150-863c-d247b003a55d)]
interface mozIStorageValueArray : nsISupports {
{
  /* Type Values */
  const long VALUE_TYPE_NULL = 0;
  const long VALUE_TYPE_INTEGER = 1;
  const long VALUE_TYPE_FLOAT = 2;
  const long VALUE_TYPE_TEXT = 3;
  const long VALUE_TYPE_BLOB = 4;

  /* Attributes */
  readonly attribute unsigned long numEntries;
  
  /* Methods */
  long getTypeOfIndex(in unsigned long aIndex);
  long getInt32(in unsigned long aIndex);
  long long getInt64(in unsigned long aIndex);
  double getDouble(in unsigned long aIndex);
  AUTF8String getUTF8String(in unsigned long aIndex);
  AString getString(in unsigned long aIndex);
  void getBlob(in unsigned long aIndex, out unsigned long aDataSize, [array,size_is(aDataSize)] out octet aData);
  boolean getIsNull(in unsigned long aIndex);
  [noscript] void getSharedUTF8String(in unsigned long aIndex, out unsigned long aLength, [shared,retval] out string aResult);
  [noscript] void getSharedString(in unsigned long aIndex, out unsigned long aLength, [shared,retval] out wstring aResult);
  [noscript] void getSharedBlob(in unsigned long aIndex, out unsigned long aLength, [shared,retval] out octetPtr aResult);
};

Attributes

numEntries

 readonly attribute unsigned long numEntries; 

Methods

getTypeOfIndex

  long getTypeOfIndex(in unsigned long aIndex);

getTypeOfIndex is a function method that returns the type of the value at the given column index; one of (VALUE_TYPE_NULL, VALUE_TYPE_INTEGER, VALUE_TYPE_FLOAT, VALUE_TYPE_TEXT, VALUE_TYPE_BLOB).

getInt32

  long getInt32(in unsigned long aIndex);

getInt32 is a function method that returns an Int32 value for the given entry (column) index as provided by the aIndex parameter.

Due to SQLite's type conversion rules, any of these are valid for any column regardless of the column's data type. However, if the specific type matters, getTypeOfIndex should be used first to identify the column type, and then the appropriate get method should be called.

If you ask for a string value for a "NULL" column, you will get an empty string with IsVoid set to distinguish it from an explicitly set empty string.

getInt64

  long long getInt64(in unsigned long aIndex);

getInt62 is a function method that returns an Int62 value for the given entry (column) index as provided by the aIndex parameter.

Due to SQLite's type conversion rules, any of these are valid for any column regardless of the column's data type. However, if the specific type matters, getTypeOfIndex should be used first to identify the column type, and then the appropriate get method should be called.

If you ask for a string value for a "NULL" column, you will get an empty string with IsVoid set to distinguish it from an explicitly set empty string.

getDouble

  double getDouble(in unsigned long aIndex);

getDouble is a function method that returns a Double value for the given entry (column) index as provided by the aIndex parameter.

Due to SQLite's type conversion rules, any of these are valid for any column regardless of the column's data type. However, if the specific type matters, getTypeOfIndex should be used first to identify the column type, and then the appropriate get method should be called.

If you ask for a string value for a "NULL" column, you will get an empty string with IsVoid set to distinguish it from an explicitly set empty string.

getUTF8String

  AUTF8String getUTF8String(in unsigned long aIndex);

getUTF8String is a function method that returns a UTF8String value for the given entry (column) index as provided by the aIndex parameter.

Due to SQLite's type conversion rules, any of these are valid for any column regardless of the column's data type. However, if the specific type matters, getTypeOfIndex should be used first to identify the column type, and then the appropriate get method should be called.

If you ask for a string value for a "NULL" column, you will get an empty string with IsVoid set to distinguish it from an explicitly set empty string.

getString

  AString getString(in unsigned long aIndex);

getString is a function method that returns a String value for the given entry (column) index as provided by the aIndex parameter.

Due to SQLite's type conversion rules, any of these are valid for any column regardless of the column's data type. However, if the specific type matters, getTypeOfIndex should be used first to identify the column type, and then the appropriate get method should be called.

If you ask for a string value for a "NULL" column, you will get an empty string with IsVoid set to distinguish it from an explicitly set empty string.

getBlob

  void getBlob(in unsigned long aIndex, out unsigned long aDataSize, [array,size_is(aDataSize)] out octet aData);

getBlob is a function method that sets data at the provided aIndex parameter value to be "NULL" if dataSize = 0.

getIsNull

boolean getIsNull(in unsigned long aIndex);

getIsNull is a function method that returns a boolean value indicating whether the provided aIndex parameter value is "NULL" or not.

getSharedUTF8String

[noscript] void getSharedUTF8String(in unsigned long aIndex, out unsigned long aLength, [shared,retval] out string aResult);

getSharedUTF8String is a function method that returns a shared UTF8String pointer.

getSharedString

[noscript] void getSharedString(in unsigned long aIndex, out unsigned long aLength, [shared,retval] out wstring aResult);

getSharedString is a function method that returns a shared String pointer.

getSharedBlob

[noscript] void getSharedBlob(in unsigned long aIndex, out unsigned long aLength, [shared,retval] out octetPtr aResult);

getSharedBlob is a function method that returns a shared Blob pointer.

AsInt32

inline PRInt32 AsInt32(PRUint32 idx) {
  PRInt32 v;
  GetInt32(idx, &v);
  return v;
}

AsInt32 is a native code (C++) function method GETTER that returns an Int32 value as the return type, for convenience and sanity.

Not virtual; no vtable bloat.

AsInt64

inline PRInt64 AsInt64(PRUint32 idx) {
  PRInt64 v;
  GetInt64(idx, &v);
  return v;
}

AsInt64 is a native code (C++) function method GETTER that returns an Int64 value as the return type, for convenience and sanity.

Not virtual; no vtable bloat.

AsDouble

inline double AsDouble(PRUint32 idx) {
  double v;
  GetDouble(idx, &v);
  return v;
}

AsDouble is a native code (C++) function method GETTER that returns a Double value as the return type, for convenience and sanity.

Not virtual; no vtable bloat.

AsSharedUTF8String

inline const char* AsSharedUTF8String(PRUint32 idx, PRUint32 *len) {
  const char *str = nsnull;
  GetSharedUTF8String(idx, len, &str);
  return str;
}

AsSharedUTF8String is a native code (C++) function method GETTER that returns an UTF8String value as the return type, for convenience and sanity.

Not virtual; no vtable bloat.

AsSharedWString

inline const PRUnichar* AsSharedWString(PRUint32 idx, PRUint32 *len) {
  const PRUnichar *str = nsnull;
  GetSharedString(idx, len, &str);
  return str;
}

AsSharedWString is a native code (C++) function method GETTER that returns a String value as the return type, for convenience and sanity.

Not virtual; no vtable bloat.

AsSharedBlob

 
inline const PRUint8* AsSharedBlob(PRUint32 idx, PRUint32 *len) {
  const PRUint8 *blob = nsnull;
  GetSharedBlob(idx, len, &blob);
  return blob;
}

AsSharedBlob is a native code (C++) function method GETTER that returns a Blob value as the return type, for convenience and sanity.

Not virtual; no vtable bloat.

IsNull

 
inline PRBool IsNull(PRUint32 idx) {
  PRBool b = PR_FALSE;
  GetIsNull(idx, &b);
  return b;
}

IsNull is a native code (C++) function method GETTER that returns a "NULL" value as the return type, for convenience and sanity.

Not virtual; no vtable bloat.

Revision Source

<p>
</p>
<h3 name="Summary"> Summary </h3>
<p><code>mozIStorageValueArray</code> wraps an array of SQL values, such as a single database row.
</p><p>You can get the type of a value from <code>mozIStorageValueArray.getTypeOfIndex</code>, which returns the type of the specified column. 
</p><p>{{template.InterfaceStatus("mozIStorageValueArray", "storage/public/mozIStorageValueArray.idl", "unfrozen", "Mozilla 2.0 alpha 2", "yes")}}
</p><p>Inherits from: <a href="en/NsISupports">nsISupports</a>
</p><p>JavaScript example of opening a connection to "asdf.sqlite" in the user's profile directory:
</p>
<pre></pre>
<dl><dd><div class="note">Be careful: SQLite is not a typed database. Any type can be put into any cell, regardless of the type declared for the column. If you request a different type, SQLite will do its best to convert them, and will do some default value if it is impossible. Therefore, it is impossible to get type errors, but you may get weird data out.</div>
</dd></dl>
<h3 name="Interface_Code"> Interface Code </h3>
<pre>[scriptable, uuid(07b5b93e-113c-4150-863c-d247b003a55d)]
interface mozIStorageValueArray : nsISupports {
{
  /* Type Values */
  const long VALUE_TYPE_NULL = 0;
  const long VALUE_TYPE_INTEGER = 1;
  const long VALUE_TYPE_FLOAT = 2;
  const long VALUE_TYPE_TEXT = 3;
  const long VALUE_TYPE_BLOB = 4;

  /* Attributes */
  readonly attribute unsigned long numEntries;
  
  /* Methods */
  long getTypeOfIndex(in unsigned long aIndex);
  long getInt32(in unsigned long aIndex);
  long long getInt64(in unsigned long aIndex);
  double getDouble(in unsigned long aIndex);
  AUTF8String getUTF8String(in unsigned long aIndex);
  AString getString(in unsigned long aIndex);
  void getBlob(in unsigned long aIndex, out unsigned long aDataSize, [array,size_is(aDataSize)] out octet aData);
  boolean getIsNull(in unsigned long aIndex);
  [noscript] void getSharedUTF8String(in unsigned long aIndex, out unsigned long aLength, [shared,retval] out string aResult);
  [noscript] void getSharedString(in unsigned long aIndex, out unsigned long aLength, [shared,retval] out wstring aResult);
  [noscript] void getSharedBlob(in unsigned long aIndex, out unsigned long aLength, [shared,retval] out octetPtr aResult);
};
</pre>
<h2 name="Attributes"> Attributes </h2>
<h3 name="numEntries"> numEntries </h3>
<pre> readonly attribute unsigned long numEntries; </pre>
<h2 name="Methods"> Methods </h2>
<h3 name="getTypeOfIndex"> getTypeOfIndex </h3>
<pre>  long getTypeOfIndex(in unsigned long aIndex);
</pre>
<p><code>getTypeOfIndex</code> is a function method that returns the type of the value at the given column index; one of (VALUE_TYPE_NULL, VALUE_TYPE_INTEGER, VALUE_TYPE_FLOAT, VALUE_TYPE_TEXT, VALUE_TYPE_BLOB).
</p>
<h3 name="getInt32"> getInt32 </h3>
<pre>  long getInt32(in unsigned long aIndex);
</pre>
<p><code>getInt32</code> is a function method that returns an <code>Int32</code> value for the given entry (column) index as provided by the <code>aIndex</code> parameter.
</p><p>Due to SQLite's type conversion rules, any of these are valid for any column regardless of the column's data type. However, if the specific type matters, <code>getTypeOfIndex</code> should be used first to identify the column type, and then the appropriate get method should be called.
</p><p>If you ask for a string value for a <code>"NULL"</code> column, you will get an empty string with <code>IsVoid</code> set to distinguish it from an explicitly set empty string.
</p>
<h3 name="getInt64"> getInt64 </h3>
<pre>  long long getInt64(in unsigned long aIndex);
</pre>
<p><code>getInt62</code> is a function method that returns an <code>Int62</code> value for the given entry (column) index as provided by the <code>aIndex</code> parameter.
</p><p>Due to SQLite's type conversion rules, any of these are valid for any column regardless of the column's data type. However, if the specific type matters, <code>getTypeOfIndex</code> should be used first to identify the column type, and then the appropriate get method should be called.
</p><p>If you ask for a string value for a <code>"NULL"</code> column, you will get an empty string with <code>IsVoid</code> set to distinguish it from an explicitly set empty string.
</p>
<h3 name="getDouble"> getDouble </h3>
<pre>  double getDouble(in unsigned long aIndex);
</pre>
<p><code>getDouble</code> is a function method that returns a <code>Double</code> value for the given entry (column) index as provided by the <code>aIndex</code> parameter.
</p><p>Due to SQLite's type conversion rules, any of these are valid for any column regardless of the column's data type. However, if the specific type matters, <code>getTypeOfIndex</code> should be used first to identify the column type, and then the appropriate get method should be called.
</p><p>If you ask for a string value for a <code>"NULL"</code> column, you will get an empty string with <code>IsVoid</code> set to distinguish it from an explicitly set empty string.
</p>
<h3 name="getUTF8String"> getUTF8String </h3>
<pre>  AUTF8String getUTF8String(in unsigned long aIndex);
</pre>
<p><code>getUTF8String</code> is a function method that returns a <code>UTF8String</code> value for the given entry (column) index as provided by the <code>aIndex</code> parameter.
</p><p>Due to SQLite's type conversion rules, any of these are valid for any column regardless of the column's data type. However, if the specific type matters, <code>getTypeOfIndex</code> should be used first to identify the column type, and then the appropriate get method should be called.
</p><p>If you ask for a string value for a <code>"NULL"</code> column, you will get an empty string with <code>IsVoid</code> set to distinguish it from an explicitly set empty string.
</p>
<h3 name="getString"> getString </h3>
<pre>  AString getString(in unsigned long aIndex);
</pre>
<p><code>getString</code> is a function method that returns a <code>String</code> value for the given entry (column) index as provided by the <code>aIndex</code> parameter.
</p><p>Due to SQLite's type conversion rules, any of these are valid for any column regardless of the column's data type. However, if the specific type matters, <code>getTypeOfIndex</code> should be used first to identify the column type, and then the appropriate get method should be called.
</p><p>If you ask for a string value for a <code>"NULL"</code> column, you will get an empty string with <code>IsVoid</code> set to distinguish it from an explicitly set empty string.
</p>
<h3 name="getBlob"> getBlob </h3>
<pre>  void getBlob(in unsigned long aIndex, out unsigned long aDataSize, [array,size_is(aDataSize)] out octet aData);
</pre>
<p><code>getBlob</code> is a function method that sets data at the provided <code>aIndex</code> parameter value to be <code>"NULL"</code> if <code>dataSize = 0</code>.
</p>
<h3 name="getIsNull"> getIsNull </h3>
<pre>boolean getIsNull(in unsigned long aIndex);
</pre>
<p><code>getIsNull</code> is a function method that returns a boolean value indicating whether the provided <code>aIndex</code> parameter value is <code>"NULL"</code> or not.
</p>
<h3 name="getSharedUTF8String"> getSharedUTF8String </h3>
<pre>[noscript] void getSharedUTF8String(in unsigned long aIndex, out unsigned long aLength, [shared,retval] out string aResult);
</pre>
<p><code>getSharedUTF8String</code> is a function method that returns a shared <code>UTF8String</code> pointer.
</p>
<h3 name="getSharedString"> getSharedString </h3>
<pre>[noscript] void getSharedString(in unsigned long aIndex, out unsigned long aLength, [shared,retval] out wstring aResult);
</pre>
<p><code>getSharedString</code> is a function method that returns a shared <code>String</code> pointer.
</p>
<h3 name="getSharedBlob"> getSharedBlob </h3>
<pre>[noscript] void getSharedBlob(in unsigned long aIndex, out unsigned long aLength, [shared,retval] out octetPtr aResult);
</pre>
<p><code>getSharedBlob</code> is a function method that returns a shared <code>Blob</code> pointer.
</p>
<h3 name="AsInt32"> AsInt32 </h3>
<pre>inline PRInt32 AsInt32(PRUint32 idx) {
  PRInt32 v;
  GetInt32(idx, &amp;v);
  return v;
}
</pre>
<p><code>AsInt32</code> is a native code (C++) function method GETTER that returns an <code>Int32</code> value as the return type, for convenience and sanity.
</p><p>Not virtual; no vtable bloat.
</p>
<h3 name="AsInt64"> AsInt64 </h3>
<pre>inline PRInt64 AsInt64(PRUint32 idx) {
  PRInt64 v;
  GetInt64(idx, &amp;v);
  return v;
}
</pre>
<p><code>AsInt64</code> is a native code (C++) function method GETTER that returns an <code>Int64</code> value as the return type, for convenience and sanity.
</p><p>Not virtual; no vtable bloat.
</p>
<h3 name="AsDouble"> AsDouble </h3>
<pre>inline double AsDouble(PRUint32 idx) {
  double v;
  GetDouble(idx, &amp;v);
  return v;
}
</pre>
<p><code>AsDouble</code> is a native code (C++) function method GETTER that returns a <code>Double</code> value as the return type, for convenience and sanity.
</p><p>Not virtual; no vtable bloat.
</p>
<h3 name="AsSharedUTF8String"> AsSharedUTF8String </h3>
<pre>inline const char* AsSharedUTF8String(PRUint32 idx, PRUint32 *len) {
  const char *str = nsnull;
  GetSharedUTF8String(idx, len, &amp;str);
  return str;
}
</pre>
<p><code>AsSharedUTF8String</code> is a native code (C++) function method GETTER that returns an <code>UTF8String</code> value as the return type, for convenience and sanity.
</p><p>Not virtual; no vtable bloat.
</p>
<h3 name="AsSharedWString"> AsSharedWString </h3>
<pre>inline const PRUnichar* AsSharedWString(PRUint32 idx, PRUint32 *len) {
  const PRUnichar *str = nsnull;
  GetSharedString(idx, len, &amp;str);
  return str;
}
</pre> 
<p><code>AsSharedWString</code> is a native code (C++) function method GETTER that returns a <code>String</code> value as the return type, for convenience and sanity.
</p><p>Not virtual; no vtable bloat.
</p>
<h3 name="AsSharedBlob"> AsSharedBlob </h3>
<pre> 
inline const PRUint8* AsSharedBlob(PRUint32 idx, PRUint32 *len) {
  const PRUint8 *blob = nsnull;
  GetSharedBlob(idx, len, &amp;blob);
  return blob;
}
</pre> 
<p><code>AsSharedBlob</code> is a native code (C++) function method GETTER that returns a <code>Blob</code> value as the return type, for convenience and sanity.
</p><p>Not virtual; no vtable bloat.
</p>
<h3 name="IsNull"> IsNull </h3>
<pre> 
inline PRBool IsNull(PRUint32 idx) {
  PRBool b = PR_FALSE;
  GetIsNull(idx, &amp;b);
  return b;
}
</pre> 
<p><code>IsNull</code> is a native code (C++) function method GETTER that returns a <code>"NULL"</code> value as the return type, for convenience and sanity.
</p><p>Not virtual; no vtable bloat.
</p>
Revert to this revision