/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ : * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
nsresult Row::initialize(sqlite3_stmt* aStatement) { // Get the number of results
mNumCols = ::sqlite3_column_count(aStatement);
// Start copying over values for (uint32_t i = 0; i < mNumCols; i++) { // Store the value
nsIVariant* variant = nullptr; int type = ::sqlite3_column_type(aStatement, i); switch (type) { case SQLITE_INTEGER:
variant = new IntegerVariant(::sqlite3_column_int64(aStatement, i)); break; case SQLITE_FLOAT:
variant = new FloatVariant(::sqlite3_column_double(aStatement, i)); break; case SQLITE_TEXT: { const char16_t* value = static_cast<const char16_t*>(
::sqlite3_column_text16(aStatement, i));
nsDependentString str(
value, ::sqlite3_column_bytes16(aStatement, i) / sizeof(char16_t));
variant = new TextVariant(str); break;
} case SQLITE_NULL:
variant = new NullVariant(); break; case SQLITE_BLOB: { constvoid* data = ::sqlite3_column_blob(aStatement, i); int size = ::sqlite3_column_bytes(aStatement, i);
variant = new BlobVariant(std::pair<constvoid*, int>(data, size)); break;
} default: return NS_ERROR_UNEXPECTED;
}
NS_ENSURE_TRUE(variant, NS_ERROR_OUT_OF_MEMORY);
// Insert into our storage array
NS_ENSURE_TRUE(mData.InsertObjectAt(variant, i), NS_ERROR_OUT_OF_MEMORY);
// Associate the name (if any) with the index constchar* name = ::sqlite3_column_name(aStatement, i); if (!name) break;
nsAutoCString colName(name);
mNameHashtable.InsertOrUpdate(colName, i);
}
return NS_OK;
}
/** * Note: This object is only ever accessed on one thread at a time. It it not * threadsafe, but it does need threadsafe AddRef and Release.
*/
NS_IMPL_ISUPPORTS(Row, mozIStorageRow, mozIStorageValueArray)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.