Modified cursors to return NS_ERROR_RDF_CURSOR_EMPTY when the cursor is empty, rather than NS_ERROR_UNEXPECTED. Miscellaneous bug fixes related to new cursors.

This commit is contained in:
waterson%netscape.com 1998-12-22 01:12:45 +00:00
parent 75dee01cc1
commit 6130e3efda
6 changed files with 44 additions and 23 deletions

View File

@ -177,7 +177,7 @@ ContainerCursorImpl::Advance(void)
// initialize rv to the case where mCounter has advanced past the
// last element
rv = NS_ERROR_UNEXPECTED;
rv = NS_ERROR_RDF_CURSOR_EMPTY;
while (mCounter < last) {
nsIRDFResource* ordinalProperty = nsnull;

View File

@ -58,7 +58,7 @@ public:
// nsIRDFCursor
NS_IMETHOD Advance(void) {
return NS_ERROR_UNEXPECTED;
return NS_ERROR_RDF_CURSOR_EMPTY;
}
// nsIRDFAssertionCursor
@ -124,7 +124,7 @@ public:
// nsIRDFCursor
NS_IMETHOD Advance(void) {
return NS_ERROR_UNEXPECTED;
return NS_ERROR_RDF_CURSOR_EMPTY;
}
// nsIRDFArcsOutCursor
@ -186,7 +186,7 @@ public:
// nsIRDFCursor
NS_IMETHOD Advance(void) {
return NS_ERROR_UNEXPECTED;
return NS_ERROR_RDF_CURSOR_EMPTY;
}
// nsIRDFArcsInCursor

View File

@ -307,7 +307,7 @@ PropertyCursorImpl::PropertyCursorImpl(PropertyListElement* first,
nsIRDFResource* predicate,
PRBool tv)
: mFirst(first),
mNext(first),
mNext(nsnull),
mDataSource(ds),
mSubject(subject),
mPredicate(predicate),
@ -334,20 +334,26 @@ PropertyCursorImpl::Advance(void)
{
if (! mNext) {
mNext = mFirst;
do {
if (mNext->GetTruthValue() == mTruthValue)
return NS_OK;
mNext = mNext->GetNext();
} while (mNext != mFirst);
}
else {
mNext = mNext->GetNext();
while (mNext != mFirst) {
if (mNext->GetTruthValue() == mTruthValue)
return NS_OK;
mNext = mNext->GetNext();
}
}
while (1) {
if (mNext == mFirst)
return NS_ERROR_UNEXPECTED;
if (mNext->GetTruthValue() == mTruthValue)
return NS_OK;
mNext = mNext->GetNext();
}
return NS_ERROR_RDF_CURSOR_EMPTY;
}
@ -464,11 +470,11 @@ NS_IMETHODIMP
ArcsOutCursorImpl::Advance(void)
{
if (! mProperties || ! mProperties->Count())
return NS_ERROR_UNEXPECTED;
return NS_ERROR_RDF_CURSOR_EMPTY;
PRInt32 index = mProperties->Count() - 1;
if (index < 0)
return NS_ERROR_UNEXPECTED;
return NS_ERROR_RDF_CURSOR_EMPTY;
NS_IF_RELEASE(mCurrent);

View File

@ -1140,11 +1140,12 @@ nsRDFDocument::CreateChildren(nsIRDFContent* element)
NS_RELEASE(assertions);
NS_RELEASE(property);
if (NS_FAILED(rv))
break;
}
if (rv = NS_ERROR_RDF_CURSOR_EMPTY)
// This is a normal return code from nsIRDFCursor::Advance()
rv = NS_OK;
done:
NS_IF_RELEASE(resource);
NS_IF_RELEASE(properties);

View File

@ -402,6 +402,10 @@ RDFTreeDocumentImpl::AddColumnsFromContainer(nsIContent* parent,
break;
}
if (rv == NS_ERROR_RDF_CURSOR_EMPTY)
// This is a "normal" return code from nsIRDFCursor::Advance().
rv = NS_OK;
done:
NS_IF_RELEASE(cursor);
NS_IF_RELEASE(NC_Title);
@ -473,6 +477,10 @@ RDFTreeDocumentImpl::AddColumnsFromMultiAttributes(nsIContent* parent,
break;
}
if (rv == NS_ERROR_RDF_CURSOR_EMPTY)
// This is a reasonable return code from nsIRDFCursor::Advance()
rv = NS_OK;
// XXX Now search for an "order" property and apply it to the
// above to sort them...

View File

@ -149,11 +149,16 @@ MultiCursor::AdvanceImpl(void)
}
do {
// If we can't advance the current cursor, then it's
// depleted. Break out of this loop and advance to the
// next cursor.
if (NS_FAILED(rv = mCurrentCursor->Advance()))
if (NS_FAILED(rv = mCurrentCursor->Advance())) {
// If we can't advance the current cursor, then either
// a catastrophic error occurred, or it's depleted. If
// it's just depleted break out of this loop and
// advance to the next cursor.
if (rv != NS_ERROR_RDF_CURSOR_EMPTY)
return rv;
break;
}
// Even if the current cursor has more elements, we still
// need to check that the current element isn't masked by
@ -424,6 +429,7 @@ nsresult
SimpleDBArcsOutCursorImpl::IsCurrentNegatedBy(nsIRDFDataSource* ds0,
PRBool* result)
{
*result = PR_FALSE; // XXX always?
return NS_OK;
}