mozilla

Revision 137636 of mozIStorageValueArray

  • Revision slug: mozIStorageValueArray
  • Revision title: mozIStorageValueArray
  • Revision id: 137636
  • Created:
  • Creator: sdwilsh
  • Is current revision? No
  • Comment 216 words added, 515 words removed; page display name changed to 'mozIStorageValueArray'

Revision Content

The mozIStorageValueArray interface obtains provides methods to obtain data from a given result.

For an introduction on how to use this interface, see the

Storage overview document

.


{{ InterfaceStatus("mozIStorageValueArray", "storage/public/mozIStorageValueArray.idl", "unfrozen", "Mozilla 1.8", "yes") }}.

Inherits from: {{ interface("nsISupports") }}

Method overview

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, {{ mediawiki.external('array,size_is(aDataSize)') }} out octet aData);
boolean getIsNull(in unsigned long aIndex);

Attributes

Attribute Type Description
numEntries unsigned long The number of entries in the array.

Constants

Constant Value Description
VALUE_TYPE_NULL 0 Null data type.
VALUE_TYPE_INTEGER 1 INTEGER data type.
VALUE_TYPE_FLOAT 2 FLOAT data type.
VALUE_TYPE_TEXT 3 TEXT data type.
VALUE_TYPE_BLOB 4 BLOB data type.

Methods

getTypeOfIndex()

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, or VALUE_TYPE_BLOB.

 long getTypeOfIndex(
   in unsigned long aIndex
 );
Parameters
aIndex
The index of the column whose type you wish to determine.
Return value

One of VALUE_TYPE_NULL, VALUE_TYPE_INTEGER, VALUE_TYPE_FLOAT, VALUE_TYPE_TEXT, or VALUE_TYPE_BLOB.

getInt32()

{{ Storage:value_getter_by_index_description() }}

 long getInt32(
   in unsigned long aIndex
 );
Parameters
aIndex
The index of the column whose value is to be returned.
Return value

Returns an Int32 value for the given entry (column) index.

getInt64()

{{ Storage:value_getter_by_index_description() }}

 long long getInt64(
   in unsigned long aIndex
 );
Parameters
aIndex
The index of the column whose data should be retrieved.
Return value

Returns an Int64 value for the given entry (column) index.

getDouble()

{{ Storage:value_getter_by_index_description() }}

 double getDouble(
   in unsigned long aIndex
 );
Parameters
aIndex
The column's index.
Return value

Returns a Double value for the given entry (column) index.

getUTF8String()

{{ Storage:value_getter_by_index_description() }}

{{ Note("C++ callers should be aware that a string value for a <tt>NULL</tt> column has <tt>IsVoid</tt> set to distinguish it from an empty string.") }}

 AUTF8String getUTF8String(
   in unsigned long aIndex
 );
Parameters
aIndex
The column's index.
Return value

Returns an AUTF8String value for the given entry (column) index.

getString()

{{ Storage:value_getter_by_index_description() }}

{{ Note("C++ callers should be aware that a string value for a <tt>NULL</tt> column has <tt>IsVoid</tt> set to distinguish it from an empty string.") }}

 AString getString(
   in unsigned long aIndex
 );
Parameters
aIndex
The column's index.
Return value

Returns an AString value for the given entry (column) index.

getBlob()

{{ Storage:value_getter_by_index_description() }}

 void getBlob(
   in unsigned long aIndex,
   out unsigned long aDataSize,
   [array,size_is(aDataSize)] out octet aData
 );
Parameters
aIndex
The column's index.
aDataSize
The size of the returned data.
aData
The returned data.

getIsNull()

Checks if given column index is NULL or not.

 boolean getIsNull(
   in unsigned long aIndex
 );
Parameters
aIndex
The column's index.
Return value

Returns true or false depending on whether or not the data in the column specified by aIndex is null.

Example: Using get functions to retrieve values

C++

PRBool hasMoreData;
while (NS_SUCCEEDED(statement->ExecuteStep(&hasMoreData)) && hasMoreData) {
  PRInt32 value = statement->AsInt32(0);
  // use the value...
}

JavaScript

while (statement.executeStep()) {
  var value = statement.getInt32(0);
  // use the value...
}

See also

Revision Source

<p>The <code>mozIStorageValueArray</code> interface obtains provides methods to obtain data from a given result.</p>
<p>For an introduction on how to use this interface, see the</p>
<a href="/en/Storage" title="eStorage">Storage overview document</a>
<p>.</p>
<p><br>
{{ InterfaceStatus("mozIStorageValueArray", "storage/public/mozIStorageValueArray.idl", "unfrozen", "Mozilla 1.8", "yes") }}.</p>
<p>Inherits from: {{ interface("nsISupports") }}</p>
<h2 name="Method_overview">Method overview</h2>
<table class="standard-table"> <tbody> <tr> <td><code>long <a href="#getTypeOfIndex.28.29">getTypeOfIndex</a>(in unsigned long aIndex);</code></td> </tr> <tr> <td><code>long <a href="#getInt32.28.29">getInt32</a>(in unsigned long aIndex);</code></td> </tr> <tr> <td><code>long long <a href="#getInt64.28.29">getInt64</a>(in unsigned long aIndex);</code></td> </tr> <tr> <td><code>double <a href="#getDouble.28.29">getDouble</a>(in unsigned long aIndex);</code></td> </tr> <tr> <td><code>AUTF8String <a href="#getUTF8String.28.29">getUTF8String</a>(in unsigned long aIndex);</code></td> </tr> <tr> <td><code>AString <a href="#getString.28.29">getString</a>(in unsigned long aIndex);</code></td> </tr> <tr> <td><code>void <a href="#getBlob.28.29">getBlob</a>(in unsigned long aIndex, out unsigned long aDataSize, {{ mediawiki.external('array,size_is(aDataSize)') }} out octet aData);</code></td> </tr> <tr> <td><code>boolean <a href="#getIsNull.28.29">getIsNull</a>(in unsigned long aIndex);</code></td> </tr> </tbody>
</table>
<h2 name="Attributes">Attributes</h2>
<table class="standard-table"> <tbody> <tr> <td class="header">Attribute</td> <td class="header">Type</td> <td class="header">Description</td> </tr> <tr> <td><code>numEntries</code></td> <td><code>unsigned long</code></td> <td>The number of entries in the array.</td> </tr> </tbody>
</table>
<h2 name="Constants">Constants</h2>
<table class="standard-table"> <tbody> <tr> <td class="header">Constant</td> <td class="header">Value</td> <td class="header">Description</td> </tr> <tr> <td><code>VALUE_TYPE_NULL</code></td> <td>0</td> <td>Null data type.</td> </tr> <tr> <td><code>VALUE_TYPE_INTEGER</code></td> <td>1</td> <td><code>INTEGER</code> data type.</td> </tr> <tr> <td><code>VALUE_TYPE_FLOAT</code></td> <td>2</td> <td><code>FLOAT</code> data type.</td> </tr> <tr> <td><code>VALUE_TYPE_TEXT</code></td> <td>3</td> <td><code>TEXT</code> data type.</td> </tr> <tr> <td><code>VALUE_TYPE_BLOB</code></td> <td>4</td> <td><code>BLOB</code> data type.</td> </tr> </tbody>
</table>
<h2 name="Methods">Methods</h2>
<h3 name="getTypeOfIndex.28.29">getTypeOfIndex()</h3>
<p>Returns the type of the value at the given column index; one of <code>VALUE_TYPE_NULL</code>, <code>VALUE_TYPE_INTEGER</code>, <code>VALUE_TYPE_FLOAT</code>, <code>VALUE_TYPE_TEXT</code>, or <code>VALUE_TYPE_BLOB</code>.</p>
<pre class="eval"> long getTypeOfIndex(
   in unsigned long aIndex
 );
</pre>
<h6 name="Parameters">Parameters</h6>
<dl><dt><code>aIndex</code> </dt><dd>The index of the column whose type you wish to determine. </dd></dl>
<h6 name="Return_value">Return value</h6>
<p>One of <code>VALUE_TYPE_NULL</code>, <code>VALUE_TYPE_INTEGER</code>, <code>VALUE_TYPE_FLOAT</code>, <code>VALUE_TYPE_TEXT</code>, or <code>VALUE_TYPE_BLOB</code>.</p>
<h3 name="getInt32.28.29">getInt32()</h3>
<p>{{ Storage:value_getter_by_index_description() }}</p>
<pre class="eval"> long getInt32(
   in unsigned long aIndex
 );
</pre>
<h6 name="Parameters_2">Parameters</h6>
<dl><dt><code>aIndex</code> </dt><dd>The index of the column whose value is to be returned. </dd></dl>
<h6 name="Return_value_2">Return value</h6>
<p>Returns an <code>Int32</code> value for the given entry (column) index.</p>
<h3 name="getInt64.28.29">getInt64()</h3>
<p>{{ Storage:value_getter_by_index_description() }}</p>
<pre class="eval"> long long getInt64(
   in unsigned long aIndex
 );
</pre>
<h6 name="Parameters_3">Parameters</h6>
<dl><dt><code>aIndex</code> </dt><dd>The index of the column whose data should be retrieved. </dd></dl>
<h6 name="Return_value_3">Return value</h6>
<p>Returns an <code>Int64</code> value for the given entry (column) index.</p>
<h3 name="getDouble.28.29">getDouble()</h3>
<p>{{ Storage:value_getter_by_index_description() }}</p>
<pre class="eval"> double getDouble(
   in unsigned long aIndex
 );
</pre>
<h6 name="Parameters_4">Parameters</h6>
<dl><dt><code>aIndex</code> </dt><dd>The column's index. </dd></dl>
<h6 name="Return_value_4">Return value</h6>
<p>Returns a <code>Double</code> value for the given entry (column) index.</p>
<h3 name="getUTF8String.28.29">getUTF8String()</h3>
<p>{{ Storage:value_getter_by_index_description() }}</p>
<p>{{ Note("C++ callers should be aware that a string value for a <tt>NULL</tt> column has <tt>IsVoid</tt> set to distinguish it from an empty string.") }}</p>
<pre class="eval"> AUTF8String getUTF8String(
   in unsigned long aIndex
 );
</pre>
<h6 name="Parameters_5">Parameters</h6>
<dl><dt><code>aIndex</code> </dt><dd>The column's index. </dd></dl>
<h6 name="Return_value_5">Return value</h6>
<p>Returns an <code><a href="/en/AUTF8String" title="en/AUTF8String">AUTF8String</a></code> value for the given entry (column) index.</p>
<h3 name="getString.28.29">getString()</h3>
<p>{{ Storage:value_getter_by_index_description() }}</p>
<p>{{ Note("C++ callers should be aware that a string value for a <tt>NULL</tt> column has <tt>IsVoid</tt> set to distinguish it from an empty string.") }}</p>
<pre class="eval"> AString getString(
   in unsigned long aIndex
 );
</pre>
<h6 name="Parameters_6">Parameters</h6>
<dl><dt><code>aIndex</code> </dt><dd>The column's index. </dd></dl>
<h6 name="Return_value_6">Return value</h6>
<p>Returns an <code><a href="/en/AString" title="en/AString">AString</a></code> value for the given entry (column) index.</p>
<h3 name="getBlob.28.29">getBlob()</h3>
<p>{{ Storage:value_getter_by_index_description() }}</p>
<pre class="eval"> void getBlob(
   in unsigned long aIndex,
   out unsigned long aDataSize,
   [array,size_is(aDataSize)] out octet aData
 );
</pre>
<h6 name="Parameters_7">Parameters</h6>
<dl><dt><code>aIndex</code> </dt><dd>The column's index. </dd><dt><code>aDataSize</code> </dt><dd>The size of the returned data. </dd><dt><code>aData</code> </dt><dd>The returned data. </dd></dl>
<h3 name="getIsNull.28.29">getIsNull()</h3>
<p>Checks if given column index is <code>NULL</code> or not.</p>
<pre class="eval"> boolean getIsNull(
   in unsigned long aIndex
 );
</pre>
<h6 name="Parameters_8">Parameters</h6>
<dl><dt><code>aIndex</code> </dt><dd>The column's index. </dd></dl>
<h6 name="Return_value_7">Return value</h6>
<p>Returns <code>true</code> or <code>false</code> depending on whether or not the data in the column specified by <code>aIndex</code> is null.</p>
<h3 name="Example:_Using_get_functions_to_retrieve_values">Example: Using get functions to retrieve values</h3>
<h4 name="C.2B.2B">C++</h4>
<pre>PRBool hasMoreData;
while (NS_SUCCEEDED(statement-&gt;ExecuteStep(&amp;hasMoreData)) &amp;&amp; hasMoreData) {
  PRInt32 value = statement-&gt;AsInt32(0);
  // use the value...
}
</pre>
<h4 name="JavaScript">JavaScript</h4>
<pre>while (statement.executeStep()) {
  var value = statement.getInt32(0);
  // use the value...
}
</pre>
<h2 name="See_also">See also</h2>
<ul> <li><a href="/en/Storage" title="en/Storage">Storage</a> mozStorage introduction and how-to article</li> <li><a href="/en/mozIStorageConnection" title="en/mozIStorageConnection">mozIStorageConnection</a> Database connection to a specific file or in-memory data storage</li> <li><a href="/en/mozIStorageStatement" title="en/mozIStorageStatement">mozIStorageStatement</a> Create and execute SQL statements on a SQLite database.</li> <li><a href="/en/mozIStorageFunction" title="en/mozIStorageFunction">mozIStorageFunction</a> Create a new SQLite function.</li> <li><a href="/en/MozIStorageAggregateFunction" title="en/MozIStorageAggregateFunction">mozIStorageAggregateFunction</a> Create a new SQLite aggregate function.</li> <li><a href="/en/mozIStorageProgressHandler" title="en/mozIStorageProgressHandler">mozIStorageProgressHandler</a> Monitor progress during the execution of a statement.</li> <li><a href="/en/mozIStorageStatementWrapper" title="en/mozIStorageStatementWrapper">mozIStorageStatementWrapper</a> Storage statement wrapper</li>
</ul>
Revert to this revision