michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ : michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "mozStorageRow.h" michael@0: #include "mozStorageResultSet.h" michael@0: michael@0: namespace mozilla { michael@0: namespace storage { michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: //// ResultSet michael@0: michael@0: ResultSet::ResultSet() michael@0: : mCurrentIndex(0) michael@0: { michael@0: } michael@0: michael@0: ResultSet::~ResultSet() michael@0: { michael@0: mData.Clear(); michael@0: } michael@0: michael@0: nsresult michael@0: ResultSet::add(mozIStorageRow *aRow) michael@0: { michael@0: return mData.AppendObject(aRow) ? NS_OK : NS_ERROR_OUT_OF_MEMORY; michael@0: } michael@0: michael@0: /** michael@0: * Note: This object is only ever accessed on one thread at a time. It it not michael@0: * threadsafe, but it does need threadsafe AddRef and Release. michael@0: */ michael@0: NS_IMPL_ISUPPORTS( michael@0: ResultSet, michael@0: mozIStorageResultSet michael@0: ) michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: //// mozIStorageResultSet michael@0: michael@0: NS_IMETHODIMP michael@0: ResultSet::GetNextRow(mozIStorageRow **_row) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(_row); michael@0: michael@0: if (mCurrentIndex >= mData.Count()) { michael@0: // Just return null here michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_ADDREF(*_row = mData.ObjectAt(mCurrentIndex++)); michael@0: return NS_OK; michael@0: } michael@0: michael@0: } // namespace storage michael@0: } // namespace mozilla