Moved utilities to util directory.

This commit is contained in:
warren%netscape.com 1999-02-17 23:42:09 +00:00
Родитель c7aaa78312
Коммит 55c88a9491
11 изменённых файлов: 1167 добавлений и 0 удалений

29
rdf/util/Makefile.in Normal file
Просмотреть файл

@ -0,0 +1,29 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public src
include $(topsrcdir)/config/config.mk
include $(topsrcdir)/config/rules.mk

27
rdf/util/makefile.win Normal file
Просмотреть файл

@ -0,0 +1,27 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=..\..
MODULE = rdfutil
DIRS=\
public \
src \
$(NULL)
include <$(DEPTH)\config\rules.mak>

2
rdf/util/public/MANIFEST Normal file
Просмотреть файл

@ -0,0 +1,2 @@
nsRDFCursorUtils.h
nsRDFResource.h

Просмотреть файл

@ -0,0 +1,36 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = rdfutil
EXPORTS = \
nsRDFResource.h \
nsRDFCursorUtils.h \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
include $(topsrcdir)/config/config.mk
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -0,0 +1,30 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
MODULE=rdfutil
DEPTH=..\..\..
EXPORTS=\
nsRDFResource.h \
nsRDFCursorUtils.h \
$(NULL)
include <$(DEPTH)/config/rules.mak>

Просмотреть файл

@ -0,0 +1,399 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsRDFCursorUtils_h__
#define nsRDFCursorUtils_h__
#include "nsIRDFCursor.h"
#include "nsIRDFNode.h"
#include "nsSupportsArrayEnumerator.h"
#include "nsIEnumerator.h"
class nsRDFArrayCursor : public nsSupportsArrayEnumerator,
public nsIRDFCursor
{
public:
NS_DECL_ISUPPORTS
// nsIRDFCursor methods:
NS_IMETHOD Advance(void);
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource);
NS_IMETHOD GetValue(nsIRDFNode** aValue);
// nsRDFArrayCursor methods:
nsRDFArrayCursor(nsIRDFDataSource* aDataSource,
nsISupportsArray* valueArray);
virtual ~nsRDFArrayCursor(void);
protected:
nsIRDFDataSource* mDataSource;
};
////////////////////////////////////////////////////////////////////////////////
class nsRDFArrayAssertionCursor : public nsRDFArrayCursor,
public nsIRDFAssertionCursor
{
public:
NS_DECL_ISUPPORTS
// nsIRDFCursor methods:
NS_IMETHOD Advance(void) {
return nsRDFArrayCursor::Advance();
}
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource) {
return nsRDFArrayCursor::GetDataSource(aDataSource);
}
NS_IMETHOD GetValue(nsIRDFNode** aValue) {
return nsRDFArrayCursor::GetValue(aValue);
}
// nsIRDFAssertionCursor methods:
NS_IMETHOD GetSubject(nsIRDFResource* *aSubject);
NS_IMETHOD GetPredicate(nsIRDFResource* *aPredicate);
NS_IMETHOD GetObject(nsIRDFNode* *aObject);
NS_IMETHOD GetTruthValue(PRBool *aTruthValue);
// nsRDFArrayAssertionCursor methods:
nsRDFArrayAssertionCursor(nsIRDFDataSource* aDataSource,
nsIRDFResource* subject,
nsIRDFResource* predicate,
nsISupportsArray* objectsArray,
PRBool truthValue = PR_TRUE);
virtual ~nsRDFArrayAssertionCursor();
protected:
nsIRDFResource* mSubject;
nsIRDFResource* mPredicate;
PRBool mTruthValue;
};
////////////////////////////////////////////////////////////////////////////////
class nsRDFSingletonAssertionCursor : public nsIRDFAssertionCursor
{
public:
NS_DECL_ISUPPORTS
// nsIRDFCursor methods:
NS_IMETHOD Advance(void);
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource);
NS_IMETHOD GetValue(nsIRDFNode** aValue);
// nsIRDFAssertionCursor methods:
NS_IMETHOD GetSubject(nsIRDFResource* *aSubject);
NS_IMETHOD GetPredicate(nsIRDFResource* *aPredicate);
NS_IMETHOD GetObject(nsIRDFNode* *aObject);
NS_IMETHOD GetTruthValue(PRBool *aTruthValue);
// nsRDFSingletonAssertionCursor methods:
// node == subject if inverse == false
// node == target if inverse == true
// value computed when accessed from datasource
nsRDFSingletonAssertionCursor(nsIRDFDataSource* aDataSource,
nsIRDFNode* node,
nsIRDFResource* predicate,
PRBool inverse = PR_FALSE,
PRBool truthValue = PR_TRUE);
virtual ~nsRDFSingletonAssertionCursor();
protected:
nsIRDFDataSource* mDataSource;
nsIRDFNode* mNode;
nsIRDFResource* mPredicate;
nsIRDFNode* mValue;
PRBool mInverse;
PRBool mTruthValue;
PRBool mConsumed;
};
////////////////////////////////////////////////////////////////////////////////
class nsRDFArrayArcsCursor : public nsRDFArrayCursor
{
public:
NS_DECL_ISUPPORTS
// nsRDFArrayArcsOutCursor methods:
nsRDFArrayArcsCursor(nsIRDFDataSource* aDataSource,
nsIRDFNode* node,
nsIRDFResource* predicate,
nsISupportsArray* arcs);
virtual ~nsRDFArrayArcsCursor();
protected:
nsresult GetPredicate(nsIRDFResource** aPredicate) {
*aPredicate = mPredicate;
NS_ADDREF(mPredicate);
return NS_OK;
}
nsresult GetNode(nsIRDFNode* *result) {
*result = mNode;
NS_ADDREF(mNode);
return NS_OK;
}
nsIRDFNode* mNode;
nsIRDFResource* mPredicate;
};
////////////////////////////////////////////////////////////////////////////////
class nsRDFArrayArcsOutCursor : public nsRDFArrayArcsCursor,
public nsIRDFArcsOutCursor
{
public:
NS_DECL_ISUPPORTS
// nsIRDFCursor methods:
NS_IMETHOD Advance(void) {
return nsRDFArrayArcsCursor::Advance();
}
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource) {
return nsRDFArrayArcsCursor::GetDataSource(aDataSource);
}
NS_IMETHOD GetValue(nsIRDFNode** aValue) {
return nsRDFArrayArcsCursor::GetValue(aValue);
}
// nsIRDFArcsOutCursor methods:
NS_IMETHOD GetSubject(nsIRDFResource** aSubject) {
return GetNode((nsIRDFNode**)aSubject);
}
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) {
return nsRDFArrayArcsCursor::GetPredicate(aPredicate);
}
// nsRDFArrayArcsOutCursor methods:
nsRDFArrayArcsOutCursor(nsIRDFDataSource* aDataSource,
nsIRDFResource* subject,
nsIRDFResource* predicate,
nsISupportsArray* arcs)
: nsRDFArrayArcsCursor(aDataSource, subject,
predicate, arcs) {}
virtual ~nsRDFArrayArcsOutCursor() {}
};
////////////////////////////////////////////////////////////////////////////////
class nsRDFArrayArcsInCursor : public nsRDFArrayArcsCursor,
public nsIRDFArcsInCursor
{
public:
NS_DECL_ISUPPORTS
// nsIRDFCursor methods:
NS_IMETHOD Advance(void) {
return nsRDFArrayArcsCursor::Advance();
}
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource) {
return nsRDFArrayArcsCursor::GetDataSource(aDataSource);
}
NS_IMETHOD GetValue(nsIRDFNode** aValue) {
return nsRDFArrayArcsCursor::GetValue(aValue);
}
// nsIRDFArcsInCursor methods:
NS_IMETHOD GetObject(nsIRDFNode** aObject) {
return GetNode(aObject);
}
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) {
return nsRDFArrayArcsCursor::GetPredicate(aPredicate);
}
// nsRDFArrayArcsInCursor methods:
nsRDFArrayArcsInCursor(nsIRDFDataSource* aDataSource,
nsIRDFNode* object,
nsIRDFResource* predicate,
nsISupportsArray* arcs)
: nsRDFArrayArcsCursor(aDataSource, object,
predicate, arcs) {}
virtual ~nsRDFArrayArcsInCursor() {}
};
////////////////////////////////////////////////////////////////////////////////
class nsRDFEnumeratorCursor : public nsIRDFCursor
{
public:
NS_DECL_ISUPPORTS
// nsIRDFCursor methods:
NS_IMETHOD Advance(void);
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource);
NS_IMETHOD GetValue(nsIRDFNode** aValue);
// nsRDFEnumeratorCursor methods:
nsRDFEnumeratorCursor(nsIRDFDataSource* aDataSource,
nsIEnumerator* valueEnumerator);
virtual ~nsRDFEnumeratorCursor(void);
protected:
nsIRDFDataSource* mDataSource;
nsIEnumerator* mEnum;
};
////////////////////////////////////////////////////////////////////////////////
class nsRDFEnumeratorAssertionCursor : public nsRDFEnumeratorCursor,
public nsIRDFAssertionCursor
{
public:
NS_DECL_ISUPPORTS
// nsIRDFCursor methods:
NS_IMETHOD Advance(void) {
return nsRDFEnumeratorCursor::Advance();
}
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource) {
return nsRDFEnumeratorCursor::GetDataSource(aDataSource);
}
NS_IMETHOD GetValue(nsIRDFNode** aValue) {
return nsRDFEnumeratorCursor::GetValue(aValue);
}
// nsIRDFAssertionCursor methods:
NS_IMETHOD GetSubject(nsIRDFResource* *aSubject);
NS_IMETHOD GetPredicate(nsIRDFResource* *aPredicate);
NS_IMETHOD GetObject(nsIRDFNode* *aObject);
NS_IMETHOD GetTruthValue(PRBool *aTruthValue);
// nsRDFEnumeratorAssertionCursor methods:
nsRDFEnumeratorAssertionCursor(nsIRDFDataSource* aDataSource,
nsIRDFResource* subject,
nsIRDFResource* predicate,
nsIEnumerator* objectsEnumerator,
PRBool truthValue = PR_TRUE);
virtual ~nsRDFEnumeratorAssertionCursor();
protected:
nsIRDFResource* mSubject;
nsIRDFResource* mPredicate;
PRBool mTruthValue;
};
////////////////////////////////////////////////////////////////////////////////
class nsRDFEnumeratorArcsCursor : public nsRDFEnumeratorCursor
{
public:
NS_DECL_ISUPPORTS
// nsRDFEnumeratorArcsOutCursor methods:
nsRDFEnumeratorArcsCursor(nsIRDFDataSource* aDataSource,
nsIRDFNode* node,
nsIRDFResource* predicate,
nsIEnumerator* arcs);
virtual ~nsRDFEnumeratorArcsCursor();
protected:
nsresult GetPredicate(nsIRDFResource** aPredicate) {
*aPredicate = mPredicate;
NS_ADDREF(mPredicate);
return NS_OK;
}
nsresult GetNode(nsIRDFNode* *result) {
*result = mNode;
NS_ADDREF(mNode);
return NS_OK;
}
nsIRDFNode* mNode;
nsIRDFResource* mPredicate;
};
////////////////////////////////////////////////////////////////////////////////
class nsRDFEnumeratorArcsOutCursor : public nsRDFEnumeratorArcsCursor,
public nsIRDFArcsOutCursor
{
public:
NS_DECL_ISUPPORTS
// nsIRDFCursor methods:
NS_IMETHOD Advance(void) {
return nsRDFEnumeratorArcsCursor::Advance();
}
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource) {
return nsRDFEnumeratorArcsCursor::GetDataSource(aDataSource);
}
NS_IMETHOD GetValue(nsIRDFNode** aValue) {
return nsRDFEnumeratorArcsCursor::GetValue(aValue);
}
// nsIRDFArcsOutCursor methods:
NS_IMETHOD GetSubject(nsIRDFResource** aSubject) {
return GetNode((nsIRDFNode**)aSubject);
}
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) {
return nsRDFEnumeratorArcsCursor::GetPredicate(aPredicate);
}
// nsRDFEnumeratorArcsOutCursor methods:
nsRDFEnumeratorArcsOutCursor(nsIRDFDataSource* aDataSource,
nsIRDFResource* subject,
nsIRDFResource* predicate,
nsIEnumerator* arcs)
: nsRDFEnumeratorArcsCursor(aDataSource, subject,
predicate, arcs) {}
virtual ~nsRDFEnumeratorArcsOutCursor() {}
};
////////////////////////////////////////////////////////////////////////////////
class nsRDFEnumeratorArcsInCursor : public nsRDFEnumeratorArcsCursor,
public nsIRDFArcsInCursor
{
public:
NS_DECL_ISUPPORTS
// nsIRDFCursor methods:
NS_IMETHOD Advance(void) {
return nsRDFEnumeratorArcsCursor::Advance();
}
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource) {
return nsRDFEnumeratorArcsCursor::GetDataSource(aDataSource);
}
NS_IMETHOD GetValue(nsIRDFNode** aValue) {
return nsRDFEnumeratorArcsCursor::GetValue(aValue);
}
// nsIRDFArcsInCursor methods:
NS_IMETHOD GetObject(nsIRDFNode** aObject) {
return GetNode(aObject);
}
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) {
return nsRDFEnumeratorArcsCursor::GetPredicate(aPredicate);
}
// nsRDFEnumeratorArcsInCursor methods:
nsRDFEnumeratorArcsInCursor(nsIRDFDataSource* aDataSource,
nsIRDFNode* object,
nsIRDFResource* predicate,
nsIEnumerator* arcs)
: nsRDFEnumeratorArcsCursor(aDataSource, object,
predicate, arcs) {}
virtual ~nsRDFEnumeratorArcsInCursor() {}
};
////////////////////////////////////////////////////////////////////////////////
#endif /* nsRDFCursorUtils_h__ */

Просмотреть файл

@ -0,0 +1,51 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsRDFResource_h__
#define nsRDFResource_h__
#include "nsIRDFNode.h"
#include "nscore.h"
/**
* This simple base class implements nsIRDFResource, and can be used as a
* superclass for more sophisticated resource implementations.
*/
class NS_RDF nsRDFResource : public nsIRDFResource {
public:
NS_DECL_ISUPPORTS
// nsIRDFNode methods:
NS_IMETHOD EqualsNode(nsIRDFNode* node, PRBool* result) const;
// nsIRDFResource methods:
NS_IMETHOD GetValue(const char* *uri) const;
NS_IMETHOD EqualsResource(const nsIRDFResource* resource, PRBool* result) const;
NS_IMETHOD EqualsString(const char* uri, PRBool* result) const;
// nsRDFResource methods:
nsRDFResource(const char* uri);
virtual ~nsRDFResource(void);
protected:
char* mURI;
};
#endif // nsRDFResource_h__

48
rdf/util/src/Makefile.in Normal file
Просмотреть файл

@ -0,0 +1,48 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/config.mk
LIBRARY_NAME = rdfutil_s
CPPSRCS = \
nsRDFCursorUtils.cpp \
nsRDFResource.cpp \
$(NULL)
EXPORTS = \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
MODULE = rdfutil
REQUIRES = xpcom rdf rdfutil raptor
MKSHLIB :=
# we don't want the shared lib
NO_SHARED_LIB=1
include $(topsrcdir)/config/rules.mk

42
rdf/util/src/makefile.win Normal file
Просмотреть файл

@ -0,0 +1,42 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=..\..\..
LCFLAGS=-D_IMPL_NS_RDF -DWIN32_LEAN_AND_MEAN
MODULE=rdfutil
LIBRARY_NAME=rdfutil_s
CPP_OBJS=\
.\$(OBJDIR)\nsRDFCursorUtils.obj \
.\$(OBJDIR)\nsRDFResource.obj \
$(NULL)
LINCS= -I$(PUBLIC)\xpcom \
-I$(PUBLIC)\rdf \
-I$(PUBLIC)\rdfutil \
-I$(PUBLIC)\raptor \
$(NULL)
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
clobber::
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib

Просмотреть файл

@ -0,0 +1,372 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsRDFCursorUtils.h"
#include "nsIRDFDataSource.h"
#include "nscore.h"
nsRDFArrayCursor::nsRDFArrayCursor(nsIRDFDataSource* aDataSource,
nsISupportsArray* valueArray)
: mDataSource(aDataSource), nsSupportsArrayEnumerator(valueArray)
{
NS_IF_ADDREF(mDataSource);
}
nsRDFArrayCursor::~nsRDFArrayCursor(void)
{
NS_IF_RELEASE(mDataSource);
}
NS_IMPL_ADDREF(nsRDFArrayCursor);
NS_IMPL_RELEASE(nsRDFArrayCursor);
NS_IMETHODIMP
nsRDFArrayCursor::QueryInterface(REFNSIID iid, void** result)
{
if (!result)
return NS_ERROR_NULL_POINTER;
if (iid.Equals(nsIRDFCursor::IID()) ||
iid.Equals(::nsISupports::IID())) {
*result = NS_STATIC_CAST(nsIRDFCursor*, this);
AddRef();
return NS_OK;
}
else if (iid.Equals(nsIEnumerator::IID())) {
*result = NS_STATIC_CAST(nsIEnumerator*, this);
AddRef();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMETHODIMP nsRDFArrayCursor::Advance(void)
{
nsresult rv = Next();
if (NS_SUCCEEDED(rv)) return rv;
return NS_ERROR_RDF_CURSOR_EMPTY;
}
NS_IMETHODIMP nsRDFArrayCursor::GetDataSource(nsIRDFDataSource** aDataSource)
{
*aDataSource = mDataSource;
NS_IF_ADDREF(mDataSource);
return NS_OK;
}
NS_IMETHODIMP nsRDFArrayCursor::GetValue(nsIRDFNode** aValue)
{
return CurrentItem((nsISupports**)aValue);
}
////////////////////////////////////////////////////////////////////////////////
nsRDFArrayAssertionCursor::nsRDFArrayAssertionCursor(nsIRDFDataSource* aDataSource,
nsIRDFResource* subject,
nsIRDFResource* predicate,
nsISupportsArray* objectsArray,
PRBool truthValue)
: nsRDFArrayCursor(aDataSource, objectsArray),
mSubject(subject), mPredicate(predicate), mTruthValue(truthValue)
{
NS_ADDREF(mSubject);
NS_ADDREF(mPredicate);
}
nsRDFArrayAssertionCursor::~nsRDFArrayAssertionCursor()
{
NS_RELEASE(mSubject);
NS_RELEASE(mPredicate);
}
NS_IMPL_ADDREF(nsRDFArrayAssertionCursor);
NS_IMPL_RELEASE(nsRDFArrayAssertionCursor);
NS_IMETHODIMP
nsRDFArrayAssertionCursor::QueryInterface(REFNSIID iid, void** result)
{
if (!result)
return NS_ERROR_NULL_POINTER;
if (iid.Equals(nsIRDFAssertionCursor::IID())) {
*result = NS_STATIC_CAST(nsIRDFAssertionCursor*, this);
AddRef();
return NS_OK;
}
return nsRDFArrayCursor::QueryInterface(iid, result);
}
NS_IMETHODIMP
nsRDFArrayAssertionCursor::GetSubject(nsIRDFResource* *aSubject)
{
*aSubject = mSubject;
NS_ADDREF(mSubject);
return NS_OK;
}
NS_IMETHODIMP nsRDFArrayAssertionCursor::GetPredicate(nsIRDFResource* *aPredicate)
{
*aPredicate = mPredicate;
NS_ADDREF(mPredicate);
return NS_OK;
}
NS_IMETHODIMP nsRDFArrayAssertionCursor::GetObject(nsIRDFNode* *aObject)
{
return nsRDFArrayCursor::GetValue(aObject);
}
NS_IMETHODIMP nsRDFArrayAssertionCursor::GetTruthValue(PRBool *aTruthValue)
{
*aTruthValue = mTruthValue;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
nsRDFSingletonAssertionCursor::nsRDFSingletonAssertionCursor(nsIRDFDataSource* aDataSource,
nsIRDFNode* node,
nsIRDFResource* predicate,
PRBool inverse,
PRBool truthValue)
: mDataSource(aDataSource), mNode(node), mPredicate(predicate),
mValue(nsnull), mInverse(inverse), mTruthValue(truthValue), mConsumed(PR_FALSE)
{
NS_ADDREF(mDataSource);
NS_ADDREF(mNode);
NS_ADDREF(mPredicate);
}
nsRDFSingletonAssertionCursor::~nsRDFSingletonAssertionCursor()
{
NS_RELEASE(mDataSource);
NS_RELEASE(mNode);
NS_RELEASE(mPredicate);
NS_IF_RELEASE(mValue);
}
NS_IMPL_ADDREF(nsRDFSingletonAssertionCursor);
NS_IMPL_RELEASE(nsRDFSingletonAssertionCursor);
NS_IMETHODIMP
nsRDFSingletonAssertionCursor::QueryInterface(REFNSIID iid, void** result)
{
if (!result)
return NS_ERROR_NULL_POINTER;
if (iid.Equals(nsIRDFAssertionCursor::IID()) ||
iid.Equals(nsIRDFCursor::IID()) ||
iid.Equals(::nsISupports::IID())) {
*result = NS_STATIC_CAST(nsIRDFAssertionCursor*, this);
AddRef();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMETHODIMP nsRDFSingletonAssertionCursor::Advance(void)
{
mConsumed = PR_TRUE;
return NS_ERROR_RDF_CURSOR_EMPTY;
}
NS_IMETHODIMP nsRDFSingletonAssertionCursor::GetDataSource(nsIRDFDataSource** aDataSource)
{
*aDataSource = mDataSource;
NS_ADDREF(mDataSource);
return NS_OK;
}
NS_IMETHODIMP nsRDFSingletonAssertionCursor::GetValue(nsIRDFNode** aValue)
{
if (mConsumed)
return NS_ERROR_RDF_CURSOR_EMPTY;
if (mValue == nsnull) {
if (mInverse)
return mDataSource->GetSource(mPredicate, mNode, mTruthValue,
(nsIRDFResource**)&mValue);
else
return mDataSource->GetTarget(NS_STATIC_CAST(nsIRDFResource*, mNode),
mPredicate, mTruthValue, &mValue);
}
*aValue = mValue;
return NS_OK;
}
NS_IMETHODIMP nsRDFSingletonAssertionCursor::GetSubject(nsIRDFResource* *aSubject)
{
if (mConsumed)
return NS_ERROR_RDF_CURSOR_EMPTY;
if (mInverse) {
return GetValue((nsIRDFNode**)aSubject);
}
else {
*aSubject = NS_STATIC_CAST(nsIRDFResource*, mNode);
NS_ADDREF(mNode);
return NS_OK;
}
}
NS_IMETHODIMP nsRDFSingletonAssertionCursor::GetPredicate(nsIRDFResource* *aPredicate)
{
if (mConsumed)
return NS_ERROR_RDF_CURSOR_EMPTY;
*aPredicate = mPredicate;
NS_ADDREF(mPredicate);
return NS_OK;
}
NS_IMETHODIMP nsRDFSingletonAssertionCursor::GetObject(nsIRDFNode* *aObject)
{
if (mConsumed)
return NS_ERROR_RDF_CURSOR_EMPTY;
if (mInverse) {
*aObject = mNode;
NS_ADDREF(mNode);
return NS_OK;
}
else {
return GetValue(aObject);
}
}
NS_IMETHODIMP nsRDFSingletonAssertionCursor::GetTruthValue(PRBool *aTruthValue)
{
if (mConsumed)
return NS_ERROR_RDF_CURSOR_EMPTY;
*aTruthValue = mTruthValue;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
nsRDFEnumeratorCursor::nsRDFEnumeratorCursor(nsIRDFDataSource* aDataSource,
nsIEnumerator* valueEnumerator)
: mDataSource(aDataSource), mEnum(valueEnumerator)
{
NS_IF_ADDREF(mEnum);
NS_IF_ADDREF(mDataSource);
}
nsRDFEnumeratorCursor::~nsRDFEnumeratorCursor(void)
{
NS_IF_RELEASE(mEnum);
NS_IF_RELEASE(mDataSource);
}
NS_IMPL_ADDREF(nsRDFEnumeratorCursor);
NS_IMPL_RELEASE(nsRDFEnumeratorCursor);
NS_IMETHODIMP
nsRDFEnumeratorCursor::QueryInterface(REFNSIID iid, void** result)
{
if (!result)
return NS_ERROR_NULL_POINTER;
if (iid.Equals(nsIRDFCursor::IID()) ||
iid.Equals(::nsISupports::IID())) {
*result = NS_STATIC_CAST(nsIRDFCursor*, this);
AddRef();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMETHODIMP nsRDFEnumeratorCursor::Advance(void)
{
nsresult rv = mEnum->Next();
if (NS_SUCCEEDED(rv)) return rv;
return NS_ERROR_RDF_CURSOR_EMPTY;
}
NS_IMETHODIMP nsRDFEnumeratorCursor::GetDataSource(nsIRDFDataSource** aDataSource)
{
*aDataSource = mDataSource;
NS_IF_ADDREF(mDataSource);
return NS_OK;
}
NS_IMETHODIMP nsRDFEnumeratorCursor::GetValue(nsIRDFNode** aValue)
{
return mEnum->CurrentItem((nsISupports**)aValue);
}
////////////////////////////////////////////////////////////////////////////////
nsRDFEnumeratorAssertionCursor::nsRDFEnumeratorAssertionCursor(nsIRDFDataSource* aDataSource,
nsIRDFResource* subject,
nsIRDFResource* predicate,
nsIEnumerator* objectsEnumerator,
PRBool truthValue)
: nsRDFEnumeratorCursor(aDataSource, objectsEnumerator),
mSubject(subject), mPredicate(predicate), mTruthValue(truthValue)
{
NS_ADDREF(mSubject);
NS_ADDREF(mPredicate);
}
nsRDFEnumeratorAssertionCursor::~nsRDFEnumeratorAssertionCursor()
{
NS_RELEASE(mSubject);
NS_RELEASE(mPredicate);
}
NS_IMPL_ADDREF(nsRDFEnumeratorAssertionCursor);
NS_IMPL_RELEASE(nsRDFEnumeratorAssertionCursor);
NS_IMETHODIMP
nsRDFEnumeratorAssertionCursor::QueryInterface(REFNSIID iid, void** result)
{
if (!result)
return NS_ERROR_NULL_POINTER;
if (iid.Equals(nsIRDFAssertionCursor::IID())) {
*result = NS_STATIC_CAST(nsIRDFAssertionCursor*, this);
AddRef();
return NS_OK;
}
return nsRDFEnumeratorCursor::QueryInterface(iid, result);
}
NS_IMETHODIMP
nsRDFEnumeratorAssertionCursor::GetSubject(nsIRDFResource* *aSubject)
{
*aSubject = mSubject;
NS_ADDREF(mSubject);
return NS_OK;
}
NS_IMETHODIMP nsRDFEnumeratorAssertionCursor::GetPredicate(nsIRDFResource* *aPredicate)
{
*aPredicate = mPredicate;
NS_ADDREF(mPredicate);
return NS_OK;
}
NS_IMETHODIMP nsRDFEnumeratorAssertionCursor::GetObject(nsIRDFNode* *aObject)
{
return nsRDFEnumeratorCursor::GetValue(aObject);
}
NS_IMETHODIMP nsRDFEnumeratorAssertionCursor::GetTruthValue(PRBool *aTruthValue)
{
*aTruthValue = mTruthValue;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -0,0 +1,131 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsRDFResource.h"
#include "nsCRT.h"
#include "nsIServiceManager.h"
#include "nsIRDFService.h"
#include "nsRDFCID.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
////////////////////////////////////////////////////////////////////////////////
nsRDFResource::nsRDFResource(const char* uri)
: mURI(nsCRT::strdup(uri))
{
NS_INIT_REFCNT();
}
nsRDFResource::~nsRDFResource(void)
{
nsresult rv;
nsIRDFService* mgr;
rv = nsServiceManager::GetService(kRDFServiceCID,
nsIRDFService::IID(),
(nsISupports**) &mgr);
PR_ASSERT(NS_SUCCEEDED(rv));
if (NS_SUCCEEDED(rv)) {
mgr->UnCacheResource(this);
nsServiceManager::ReleaseService(kRDFServiceCID, mgr);
}
// N.B. that we need to free the URI *after* we un-cache the resource,
// due to the way that the resource manager is implemented.
delete[] mURI;
}
NS_IMPL_ADDREF(nsRDFResource)
NS_IMPL_RELEASE(nsRDFResource)
NS_IMETHODIMP
nsRDFResource::QueryInterface(REFNSIID iid, void** result)
{
if (! result)
return NS_ERROR_NULL_POINTER;
*result = nsnull;
if (iid.Equals(nsIRDFResource::IID()) ||
iid.Equals(nsIRDFNode::IID()) ||
iid.Equals(kISupportsIID)) {
*result = NS_STATIC_CAST(nsIRDFResource*, this);
AddRef();
return NS_OK;
}
return NS_NOINTERFACE;
}
////////////////////////////////////////////////////////////////////////////////
// nsIRDFNode methods:
NS_IMETHODIMP
nsRDFResource::EqualsNode(nsIRDFNode* node, PRBool* result) const
{
nsresult rv;
nsIRDFResource* resource;
if (NS_SUCCEEDED(node->QueryInterface(nsIRDFResource::IID(), (void**)&resource))) {
rv = EqualsResource(resource, result);
NS_RELEASE(resource);
}
else {
*result = PR_FALSE;
rv = NS_OK;
}
return rv;
}
////////////////////////////////////////////////////////////////////////////////
// nsIRDFResource methods:
NS_IMETHODIMP
nsRDFResource::GetValue(const char* *uri) const
{
if (!uri)
return NS_ERROR_NULL_POINTER;
*uri = mURI;
return NS_OK;
}
NS_IMETHODIMP
nsRDFResource::EqualsResource(const nsIRDFResource* resource, PRBool* result) const
{
if (!resource || !result)
return NS_ERROR_NULL_POINTER;
const char *uri;
if (NS_SUCCEEDED(resource->GetValue(&uri))) {
return NS_SUCCEEDED(EqualsString(uri, result)) ? NS_OK : NS_ERROR_FAILURE;
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsRDFResource::EqualsString(const char* uri, PRBool* result) const
{
if (!uri || !result)
return NS_ERROR_NULL_POINTER;
*result = nsCRT::strcmp(uri, mURI) == 0;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////