Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions
mozStorageStatement Class Reference

#include <mozStorageStatement.h>

Inheritance diagram for mozStorageStatement:
Inheritance graph
[legend]
Collaboration diagram for mozStorageStatement:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 mozStorageStatement ()
 mozStorageStatement
void initialize (in mozIStorageConnection aDBConnection, in AUTF8String aSQLStatement)
 Initialize this query with the given SQL statement.
mozIStorageStatement clone ()
 Create a clone of this statement, by initializing a new statement with the same connection and same SQL statement as this one.
AUTF8String getParameterName (in unsigned long aParamIndex)
 Name of nth parameter, if given.
void getParameterIndexes (in AUTF8String aParameterName, out unsigned long aCount,[array, size_is(aCount), retval] out unsigned long aIndexes)
 All indexes of a named parameter, if it's specified more than once.
AUTF8String getColumnName (in unsigned long aColumnIndex)
 Name of nth column.
void reset ()
 Reset parameters/statement execution.
void bindUTF8StringParameter (in unsigned long aParamIndex, in AUTF8String aValue)
 Bind the given value to the parameter at aParamIndex.
void bindStringParameter (in unsigned long aParamIndex, in AString aValue)
void bindDoubleParameter (in unsigned long aParamIndex, in double aValue)
void bindInt32Parameter (in unsigned long aParamIndex, in long aValue)
void bindInt64Parameter (in unsigned long aParamIndex, in long long aValue)
void bindNullParameter (in unsigned long aParamIndex)
void bindBlobParameter (in unsigned long aParamIndex,[array, const, size_is(aValueSize)] in octet aValue, in unsigned long aValueSize)
void execute ()
 Execute the query, ignoring any results.
boolean executeStep ()
 Execute a query, using any currently-bound parameters.
sqlite3stmtptr getNativeStatementPointer ()
long getTypeOfIndex (in unsigned long aIndex)
 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.
long getInt32 (in unsigned long aIndex)
 Obtain a value for the given entry (column) index.
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)
void getSharedUTF8String (in unsigned long aIndex, out unsigned long aLength,[shared, retval] out string aResult)
 Returns a shared string pointer.
void getSharedString (in unsigned long aIndex, out unsigned long aLength,[shared, retval] out wstring aResult)
void getSharedBlob (in unsigned long aIndex, out unsigned long aLength,[shared, retval] out octetPtr aResult)
PRInt32 AsInt32 (PRUint32 idx)
 Getters for native code that return their values as the return type, for convenience and sanity.
PRInt64 AsInt64 (PRUint32 idx)
double AsDouble (PRUint32 idx)
const char * AsSharedUTF8String (PRUint32 idx, PRUint32 *len)
const PRUnicharAsSharedWString (PRUint32 idx, PRUint32 *len)
const PRUint8AsSharedBlob (PRUint32 idx, PRUint32 *len)
PRBool IsNull (PRUint32 idx)

Public Attributes

readonly attribute unsigned long parameterCount
readonly attribute unsigned long columnCount
 Number of columns returned.
const long MOZ_STORAGE_STATEMENT_INVALID = 0
 The current state.
const long MOZ_STORAGE_STATEMENT_READY = 1
const long MOZ_STORAGE_STATEMENT_EXECUTING = 2
readonly attribute long state
const long VALUE_TYPE_NULL = 0
 These type values are returned by getTypeOfIndex to indicate what type of value is present at a given column.
const long VALUE_TYPE_INTEGER = 1
const long VALUE_TYPE_FLOAT = 2
const long VALUE_TYPE_TEXT = 3
const long VALUE_TYPE_BLOB = 4
readonly attribute unsigned long numEntries
 numEntries

Protected Member Functions

nsresult Recreate ()

Protected Attributes

nsCString mStatementString
nsCOMPtr< mozIStorageConnectionmDBConnection
sqlite3_stmtmDBStatement
PRUint32 mParamCount
PRUint32 mResultColumnCount
nsStringArray mColumnNames
PRBool mExecuting

Private Member Functions

 ~mozStorageStatement ()

Detailed Description

Definition at line 52 of file mozStorageStatement.h.


Constructor & Destructor Documentation

Definition at line 157 of file mozStorageStatement.cpp.

Here is the call graph for this function:


Member Function Documentation

double mozIStorageValueArray::AsDouble ( PRUint32  idx) [inline, inherited]

Definition at line 124 of file mozIStorageValueArray.idl.

                                       {
    double v;
    GetDouble(idx, &v);
    return v;
  }
PRInt32 mozIStorageValueArray::AsInt32 ( PRUint32  idx) [inline, inherited]

Getters for native code that return their values as the return type, for convenience and sanity.

Not virtual; no vtable bloat.

Definition at line 112 of file mozIStorageValueArray.idl.

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

Here is the caller graph for this function:

PRInt64 mozIStorageValueArray::AsInt64 ( PRUint32  idx) [inline, inherited]

Definition at line 118 of file mozIStorageValueArray.idl.

                                       {
    PRInt64 v;
    GetInt64(idx, &v);
    return v;
  }
const PRUint8* mozIStorageValueArray::AsSharedBlob ( PRUint32  idx,
PRUint32 len 
) [inline, inherited]

Definition at line 142 of file mozIStorageValueArray.idl.

                                                                  {
    const PRUint8 *blob = nsnull;
    GetSharedBlob(idx, len, &blob);
    return blob;
  }
const char* mozIStorageValueArray::AsSharedUTF8String ( PRUint32  idx,
PRUint32 len 
) [inline, inherited]

Definition at line 130 of file mozIStorageValueArray.idl.

                                                                     {
    const char *str = nsnull;
    GetSharedUTF8String(idx, len, &str);
    return str;
  }
const PRUnichar* mozIStorageValueArray::AsSharedWString ( PRUint32  idx,
PRUint32 len 
) [inline, inherited]

Definition at line 136 of file mozIStorageValueArray.idl.

                                                                       {
    const PRUnichar *str = nsnull;
    GetSharedString(idx, len, &str);
    return str;
  }
void mozIStorageStatement::bindBlobParameter ( in unsigned long  aParamIndex,
[array, const, size_is(aValueSize)] in octet  aValue,
in unsigned long  aValueSize 
) [inherited]
void mozIStorageStatement::bindDoubleParameter ( in unsigned long  aParamIndex,
in double  aValue 
) [inherited]
void mozIStorageStatement::bindInt32Parameter ( in unsigned long  aParamIndex,
in long  aValue 
) [inherited]
void mozIStorageStatement::bindInt64Parameter ( in unsigned long  aParamIndex,
in long long  aValue 
) [inherited]
void mozIStorageStatement::bindNullParameter ( in unsigned long  aParamIndex) [inherited]
void mozIStorageStatement::bindStringParameter ( in unsigned long  aParamIndex,
in AString  aValue 
) [inherited]
void mozIStorageStatement::bindUTF8StringParameter ( in unsigned long  aParamIndex,
in AUTF8String  aValue 
) [inherited]

Bind the given value to the parameter at aParamIndex.

Create a clone of this statement, by initializing a new statement with the same connection and same SQL statement as this one.

It does not preserve statement state; that is, if a statement is being executed when it is cloned, the new statement will not be executing.

Execute the query, ignoring any results.

This is accomplished by calling step() once, and then calling reset().

Error and last insert info, etc. are available from the mozStorageConnection.

Execute a query, using any currently-bound parameters.

Reset must be called on the statement after the last call of executeStep.

Returns:
a boolean indicating whether there are more rows or not; row data may be accessed using mozIStorageValueArray methods on the statement.
void mozIStorageValueArray::getBlob ( in unsigned long  aIndex,
out unsigned long  aDataSize,
[array, size_is(aDataSize)] out octet  aData 
) [inherited]
AUTF8String mozIStorageStatement::getColumnName ( in unsigned long  aColumnIndex) [inherited]

Name of nth column.

double mozIStorageValueArray::getDouble ( in unsigned long  aIndex) [inherited]
long mozIStorageValueArray::getInt32 ( in unsigned long  aIndex) [inherited]

Obtain a value for the given entry (column) index.

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.

long long mozIStorageValueArray::getInt64 ( in unsigned long  aIndex) [inherited]
boolean mozIStorageValueArray::getIsNull ( in unsigned long  aIndex) [inherited]
void mozIStorageStatement::getParameterIndexes ( in AUTF8String  aParameterName,
out unsigned long  aCount,
[array, size_is(aCount), retval] out unsigned long  aIndexes 
) [inherited]

All indexes of a named parameter, if it's specified more than once.

AUTF8String mozIStorageStatement::getParameterName ( in unsigned long  aParamIndex) [inherited]

Name of nth parameter, if given.

void mozIStorageValueArray::getSharedBlob ( in unsigned long  aIndex,
out unsigned long  aLength,
[shared, retval] out octetPtr  aResult 
) [inherited]
void mozIStorageValueArray::getSharedString ( in unsigned long  aIndex,
out unsigned long  aLength,
[shared, retval] out wstring  aResult 
) [inherited]
void mozIStorageValueArray::getSharedUTF8String ( in unsigned long  aIndex,
out unsigned long  aLength,
[shared, retval] out string  aResult 
) [inherited]

Returns a shared string pointer.

AString mozIStorageValueArray::getString ( in unsigned long  aIndex) [inherited]
long mozIStorageValueArray::getTypeOfIndex ( in unsigned long  aIndex) [inherited]

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.

AUTF8String mozIStorageValueArray::getUTF8String ( in unsigned long  aIndex) [inherited]
void mozIStorageStatement::initialize ( in mozIStorageConnection  aDBConnection,
in AUTF8String  aSQLStatement 
) [inherited]

Initialize this query with the given SQL statement.

PRBool mozIStorageValueArray::IsNull ( PRUint32  idx) [inline, inherited]

Definition at line 148 of file mozIStorageValueArray.idl.

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

Definition at line 494 of file mozStorageStatement.cpp.

{
    nsresult rv;
    int srv;
    sqlite3_stmt *savedStmt = mDBStatement;
    mDBStatement = nsnull;
    rv = Initialize(mDBConnection, mStatementString);
    NS_ENSURE_SUCCESS(rv, rv);

    // copy over the param bindings
    srv = sqlite3_transfer_bindings(savedStmt, mDBStatement);

    // we're always going to finalize this, so no need to
    // error check
    sqlite3_finalize(savedStmt);

    if (srv != SQLITE_OK) {
        PR_LOG(gStorageLog, PR_LOG_ERROR, ("sqlite3_transfer_bindings returned: %d", srv));
        return NS_ERROR_FAILURE;
    }

    return NS_OK;
}

Here is the call graph for this function:

Reset parameters/statement execution.


Member Data Documentation

readonly attribute unsigned long mozIStorageStatement::columnCount [inherited]

Number of columns returned.

Definition at line 87 of file mozIStorageStatement.idl.

nsStringArray mozStorageStatement::mColumnNames [protected]

Definition at line 71 of file mozStorageStatement.h.

Definition at line 67 of file mozStorageStatement.h.

Definition at line 68 of file mozStorageStatement.h.

Definition at line 72 of file mozStorageStatement.h.

Definition at line 140 of file mozIStorageStatement.idl.

The current state.

Row getters are only valid while the statement is in the "executing" state.

Definition at line 138 of file mozIStorageStatement.idl.

Definition at line 139 of file mozIStorageStatement.idl.

Definition at line 69 of file mozStorageStatement.h.

Definition at line 70 of file mozStorageStatement.h.

Definition at line 66 of file mozStorageStatement.h.

readonly attribute unsigned long mozIStorageValueArray::numEntries [inherited]

numEntries

number of entries in the array (each corresponding to a column in the database row)

Definition at line 66 of file mozIStorageValueArray.idl.

readonly attribute unsigned long mozIStorageStatement::parameterCount [inherited]

Definition at line 69 of file mozIStorageStatement.idl.

Definition at line 142 of file mozIStorageStatement.idl.

Definition at line 58 of file mozIStorageValueArray.idl.

Definition at line 56 of file mozIStorageValueArray.idl.

Definition at line 55 of file mozIStorageValueArray.idl.

These type values are returned by getTypeOfIndex to indicate what type of value is present at a given column.

Definition at line 54 of file mozIStorageValueArray.idl.

Definition at line 57 of file mozIStorageValueArray.idl.


The documentation for this class was generated from the following files: