2008-07-11 19:47:28 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2009-04-13 16:29:41 +00:00
|
|
|
* vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
|
2012-05-21 11:12:37 +00:00
|
|
|
* 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/. */
|
2008-07-11 19:47:28 +00:00
|
|
|
|
|
|
|
#include "mozStorageRow.h"
|
|
|
|
#include "mozStorageResultSet.h"
|
|
|
|
|
2009-05-09 00:29:56 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace storage {
|
2008-07-11 19:47:28 +00:00
|
|
|
|
2009-05-09 00:29:56 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//// ResultSet
|
2008-07-11 19:47:28 +00:00
|
|
|
|
2009-05-09 00:29:56 +00:00
|
|
|
ResultSet::ResultSet()
|
|
|
|
: mCurrentIndex(0)
|
2008-07-11 19:47:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-05-09 00:29:56 +00:00
|
|
|
ResultSet::~ResultSet()
|
2008-07-11 19:47:28 +00:00
|
|
|
{
|
|
|
|
mData.Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2009-05-09 00:29:56 +00:00
|
|
|
ResultSet::add(mozIStorageRow *aRow)
|
2008-07-11 19:47:28 +00:00
|
|
|
{
|
|
|
|
return mData.AppendObject(aRow) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
2009-05-09 00:29:56 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS(
|
2009-05-09 00:29:56 +00:00
|
|
|
ResultSet,
|
|
|
|
mozIStorageResultSet
|
|
|
|
)
|
|
|
|
|
2008-07-11 19:47:28 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//// mozIStorageResultSet
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2009-05-09 00:29:56 +00:00
|
|
|
ResultSet::GetNextRow(mozIStorageRow **_row)
|
2008-07-11 19:47:28 +00:00
|
|
|
{
|
2009-10-31 10:38:31 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(_row);
|
|
|
|
|
2008-07-11 19:47:28 +00:00
|
|
|
if (mCurrentIndex >= mData.Count()) {
|
|
|
|
// Just return null here
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ADDREF(*_row = mData.ObjectAt(mCurrentIndex++));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2009-05-09 00:29:56 +00:00
|
|
|
|
|
|
|
} // namespace storage
|
|
|
|
} // namespace mozilla
|