Expunge EqualsResource() and EqualsLiteral().

This commit is contained in:
waterson%netscape.com 1999-06-25 20:51:13 +00:00
Родитель c13d69e55e
Коммит 30f5f63b74
13 изменённых файлов: 167 добавлений и 192 удалений

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

@ -80,17 +80,6 @@ DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, NewCard);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Utilities // Utilities
static PRBool
peq(nsIRDFResource* r1, nsIRDFResource* r2)
{
PRBool result;
if (NS_SUCCEEDED(r1->EqualsResource(r2, &result)) && result) {
return PR_TRUE;
} else {
return PR_FALSE;
}
}
#if 0 #if 0
static PRBool static PRBool
peqSort(nsIRDFResource* r1, nsIRDFResource* r2, PRBool *isSort) peqSort(nsIRDFResource* r1, nsIRDFResource* r2, PRBool *isSort)
@ -129,7 +118,7 @@ peqSort(nsIRDFResource* r1, nsIRDFResource* r2, PRBool *isSort)
//In case the resources are equal but the values are different. I'm not sure if this //In case the resources are equal but the values are different. I'm not sure if this
//could happen but it is feasible given interface. //could happen but it is feasible given interface.
*isSort = PR_FALSE; *isSort = PR_FALSE;
return(peq(r1, r2)); return(r1 == r2);
} }
} }
#endif #endif
@ -305,10 +294,10 @@ NS_IMETHODIMP nsABCardDataSource::GetTargets(nsIRDFResource* source,
nsCOMPtr<nsIAbCard> card(do_QueryInterface(source, &rv)); nsCOMPtr<nsIAbCard> card(do_QueryInterface(source, &rv));
if (NS_SUCCEEDED(rv) && card) if (NS_SUCCEEDED(rv) && card)
{ {
if(peq(kNC_PersonName, property) || peq(kNC_ListName, property) || if((kNC_PersonName == property) || (kNC_ListName == property) ||
peq(kNC_Email, property) || peq(kNC_City, property) || (kNC_Email == property) || (kNC_City == property) ||
peq(kNC_Organization, property) || peq(kNC_WorkPhone, property) || (kNC_Organization == property) || (kNC_WorkPhone == property) ||
peq(kNC_Nickname, property)) (kNC_Nickname == property))
{ {
nsSingletonEnumerator* cursor = nsSingletonEnumerator* cursor =
new nsSingletonEnumerator(property); new nsSingletonEnumerator(property);
@ -530,8 +519,8 @@ nsABCardDataSource::IsCommandEnabled(nsISupportsArray/*<nsIRDFResource>*/* aSour
card = do_QueryInterface(source, &rv); card = do_QueryInterface(source, &rv);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
// we don't care about the arguments -- card commands are always enabled // we don't care about the arguments -- card commands are always enabled
if (!(peq(aCommand, kNC_Delete) || if (!((aCommand == kNC_Delete) ||
peq(aCommand, kNC_NewCard))) { (aCommand == kNC_NewCard))) {
*aResult = PR_FALSE; *aResult = PR_FALSE;
return NS_OK; return NS_OK;
} }
@ -556,10 +545,10 @@ nsABCardDataSource::DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSources,
nsCOMPtr<nsISupports> supports = getter_AddRefs(aSources->ElementAt(i)); nsCOMPtr<nsISupports> supports = getter_AddRefs(aSources->ElementAt(i));
nsCOMPtr<nsIAbCard> card = do_QueryInterface(supports, &rv); nsCOMPtr<nsIAbCard> card = do_QueryInterface(supports, &rv);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
if (peq(aCommand, kNC_Delete)) { if ((aCommand == kNC_Delete)) {
rv = DoDeleteFromCard(card, aArguments); rv = DoDeleteFromCard(card, aArguments);
} }
else if(peq(aCommand, kNC_NewCard)) { else if((aCommand == kNC_NewCard)) {
rv = DoNewCard(card, aArguments); rv = DoNewCard(card, aArguments);
} }
@ -655,19 +644,19 @@ nsresult nsABCardDataSource::createCardNode(nsIAbCard* card,
char *name; char *name;
nsresult rv = NS_RDF_NO_VALUE; nsresult rv = NS_RDF_NO_VALUE;
if (peq(kNC_PersonName, property)) if ((kNC_PersonName == property))
rv = card->GetPersonName(&name); rv = card->GetPersonName(&name);
else if (peq(kNC_ListName, property)) else if ((kNC_ListName == property))
rv = card->GetListName(&name); rv = card->GetListName(&name);
else if (peq(kNC_Email, property)) else if ((kNC_Email == property))
rv = card->GetEmail(&name); rv = card->GetEmail(&name);
else if (peq(kNC_City, property)) else if ((kNC_City == property))
rv = card->GetCity(&name); rv = card->GetCity(&name);
else if (peq(kNC_Organization, property)) else if ((kNC_Organization == property))
rv = card->GetOrganization(&name); rv = card->GetOrganization(&name);
else if (peq(kNC_WorkPhone, property)) else if ((kNC_WorkPhone == property))
rv = card->GetWorkPhone(&name); rv = card->GetWorkPhone(&name);
else if (peq(kNC_Nickname, property)) else if ((kNC_Nickname == property))
rv = card->GetNickName(&name); rv = card->GetNickName(&name);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
nsString nameString(name); nsString nameString(name);

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

@ -74,16 +74,6 @@ DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, NewDirectory);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Utilities // Utilities
static PRBool
peq(nsIRDFResource* r1, nsIRDFResource* r2)
{
PRBool result;
if (NS_SUCCEEDED(r1->EqualsResource(r2, &result)) && result)
return PR_TRUE;
else
return PR_FALSE;
}
#if 0 #if 0
static PRBool static PRBool
peqSort(nsIRDFResource* r1, nsIRDFResource* r2, PRBool *isSort) peqSort(nsIRDFResource* r1, nsIRDFResource* r2, PRBool *isSort)
@ -122,7 +112,7 @@ peqSort(nsIRDFResource* r1, nsIRDFResource* r2, PRBool *isSort)
//In case the resources are equal but the values are different. I'm not sure if this //In case the resources are equal but the values are different. I'm not sure if this
//could happen but it is feasible given interface. //could happen but it is feasible given interface.
*isSort = PR_FALSE; *isSort = PR_FALSE;
return(peq(r1, r2)); return((r1 == r2));
} }
} }
#endif #endif
@ -303,7 +293,7 @@ NS_IMETHODIMP nsABDirectoryDataSource::GetTargets(nsIRDFResource* source,
nsCOMPtr<nsIAbDirectory> directory(do_QueryInterface(source, &rv)); nsCOMPtr<nsIAbDirectory> directory(do_QueryInterface(source, &rv));
if (NS_SUCCEEDED(rv) && directory) if (NS_SUCCEEDED(rv) && directory)
{ {
if (peq(kNC_Child, property)) if ((kNC_Child == property))
{ {
nsCOMPtr<nsIEnumerator> subDirectories; nsCOMPtr<nsIEnumerator> subDirectories;
@ -317,7 +307,7 @@ NS_IMETHODIMP nsABDirectoryDataSource::GetTargets(nsIRDFResource* source,
*targets = cursor; *targets = cursor;
rv = NS_OK; rv = NS_OK;
} }
else if(peq(kNC_DirName, property)) else if((kNC_DirName == property))
{ {
nsSingletonEnumerator* cursor = nsSingletonEnumerator* cursor =
new nsSingletonEnumerator(property); new nsSingletonEnumerator(property);
@ -327,7 +317,7 @@ NS_IMETHODIMP nsABDirectoryDataSource::GetTargets(nsIRDFResource* source,
*targets = cursor; *targets = cursor;
rv = NS_OK; rv = NS_OK;
} }
else if(peq(kNC_CardChild, property)) else if((kNC_CardChild == property))
{ {
nsCOMPtr<nsIEnumerator> cardChild; nsCOMPtr<nsIEnumerator> cardChild;
@ -341,7 +331,7 @@ NS_IMETHODIMP nsABDirectoryDataSource::GetTargets(nsIRDFResource* source,
*targets = cursor; *targets = cursor;
rv = NS_OK; rv = NS_OK;
} }
else if(peq(kNC_DirChild, property)) else if((kNC_DirChild == property))
{ {
rv = NS_OK; rv = NS_OK;
} }
@ -556,8 +546,8 @@ nsABDirectoryDataSource::IsCommandEnabled(nsISupportsArray/*<nsIRDFResource>*/*
directory = do_QueryInterface(source, &rv); directory = do_QueryInterface(source, &rv);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
// we don't care about the arguments -- directory commands are always enabled // we don't care about the arguments -- directory commands are always enabled
if (!(peq(aCommand, kNC_Delete) || if (!((aCommand == kNC_Delete) ||
peq(aCommand, kNC_NewDirectory))) { (aCommand == kNC_NewDirectory))) {
*aResult = PR_FALSE; *aResult = PR_FALSE;
return NS_OK; return NS_OK;
} }
@ -582,10 +572,10 @@ nsABDirectoryDataSource::DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSource
nsCOMPtr<nsISupports> supports = getter_AddRefs(aSources->ElementAt(i)); nsCOMPtr<nsISupports> supports = getter_AddRefs(aSources->ElementAt(i));
nsCOMPtr<nsIAbDirectory> directory = do_QueryInterface(supports, &rv); nsCOMPtr<nsIAbDirectory> directory = do_QueryInterface(supports, &rv);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
if (peq(aCommand, kNC_Delete)) { if ((aCommand == kNC_Delete)) {
rv = DoDeleteFromDirectory(directory, aArguments); rv = DoDeleteFromDirectory(directory, aArguments);
} }
else if(peq(aCommand, kNC_NewDirectory)) { else if((aCommand == kNC_NewDirectory)) {
rv = DoNewDirectory(directory, aArguments); rv = DoNewDirectory(directory, aArguments);
} }
@ -679,11 +669,11 @@ nsresult nsABDirectoryDataSource::createDirectoryNode(nsIAbDirectory* directory,
{ {
nsresult rv = NS_RDF_NO_VALUE; nsresult rv = NS_RDF_NO_VALUE;
if (peq(kNC_DirName, property)) if ((kNC_DirName == property))
rv = createDirectoryNameNode(directory, target); rv = createDirectoryNameNode(directory, target);
else if (peq(kNC_Child, property)) else if ((kNC_Child == property))
rv = createDirectoryChildNode(directory,target); rv = createDirectoryChildNode(directory,target);
else if (peq(kNC_CardChild, property)) else if ((kNC_CardChild == property))
rv = createCardChildNode(directory,target); rv = createCardChildNode(directory,target);
return rv; return rv;

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

@ -208,12 +208,11 @@ NS_IMETHODIMP nsMessageViewDataSource::GetTargets(nsIRDFResource* source,
nsCOMPtr<nsIMsgFolder> folder; nsCOMPtr<nsIMsgFolder> folder;
nsCOMPtr<nsIMessage> message; nsCOMPtr<nsIMessage> message;
PRBool equal;
folder = do_QueryInterface(source, &rv); folder = do_QueryInterface(source, &rv);
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
{ {
if (NS_SUCCEEDED(property->EqualsResource(kNC_MessageChild, &equal)) && equal) if (property == kNC_MessageChild)
{ {
if(mShowThreads) if(mShowThreads)
@ -256,7 +255,7 @@ NS_IMETHODIMP nsMessageViewDataSource::GetTargets(nsIRDFResource* source,
} }
else if (mShowThreads && NS_SUCCEEDED(source->QueryInterface(nsIMessage::GetIID(), getter_AddRefs(message)))) else if (mShowThreads && NS_SUCCEEDED(source->QueryInterface(nsIMessage::GetIID(), getter_AddRefs(message))))
{ {
if(NS_SUCCEEDED(property->EqualsResource(kNC_MessageChild, &equal)) && equal) if(property == kNC_MessageChild)
{ {
nsCOMPtr<nsIMsgFolder> msgfolder; nsCOMPtr<nsIMsgFolder> msgfolder;
rv = message->GetMsgFolder(getter_AddRefs(msgfolder)); rv = message->GetMsgFolder(getter_AddRefs(msgfolder));

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

@ -262,7 +262,7 @@ NS_IMETHODIMP nsMsgFolderDataSource::GetTargets(nsIRDFResource* source,
nsCOMPtr<nsIMsgFolder> folder(do_QueryInterface(source, &rv)); nsCOMPtr<nsIMsgFolder> folder(do_QueryInterface(source, &rv));
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
{ {
if (peq(kNC_Child, property)) if ((kNC_Child == property))
{ {
nsCOMPtr<nsIEnumerator> subFolders; nsCOMPtr<nsIEnumerator> subFolders;
@ -278,7 +278,7 @@ NS_IMETHODIMP nsMsgFolderDataSource::GetTargets(nsIRDFResource* source,
rv = NS_OK; rv = NS_OK;
} }
} }
else if (peq(kNC_MessageChild, property)) else if ((kNC_MessageChild == property))
{ {
nsCOMPtr<nsIEnumerator> messages; nsCOMPtr<nsIEnumerator> messages;
@ -294,7 +294,7 @@ NS_IMETHODIMP nsMsgFolderDataSource::GetTargets(nsIRDFResource* source,
rv = NS_OK; rv = NS_OK;
} }
} }
else if(peq(kNC_Name, property) || peq(kNC_SpecialFolder, property)) else if((kNC_Name == property) || (kNC_SpecialFolder == property))
{ {
nsSingletonEnumerator* cursor = nsSingletonEnumerator* cursor =
new nsSingletonEnumerator(property); new nsSingletonEnumerator(property);
@ -469,11 +469,11 @@ nsMsgFolderDataSource::IsCommandEnabled(nsISupportsArray/*<nsIRDFResource>*/* aS
folder = do_QueryInterface(source, &rv); folder = do_QueryInterface(source, &rv);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
// we don't care about the arguments -- folder commands are always enabled // we don't care about the arguments -- folder commands are always enabled
if (!(peq(aCommand, kNC_Delete) || if (!((aCommand == kNC_Delete) ||
peq(aCommand, kNC_NewFolder) || (aCommand == kNC_NewFolder) ||
peq(aCommand, kNC_Copy) || (aCommand == kNC_Copy) ||
peq(aCommand, kNC_Move) || (aCommand == kNC_Move) ||
peq(aCommand, kNC_GetNewMessages))) { (aCommand == kNC_GetNewMessages))) {
*aResult = PR_FALSE; *aResult = PR_FALSE;
return NS_OK; return NS_OK;
} }
@ -514,23 +514,23 @@ nsMsgFolderDataSource::DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSources,
supports = getter_AddRefs(aSources->ElementAt(i)); supports = getter_AddRefs(aSources->ElementAt(i));
nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(supports, &rv); nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(supports, &rv);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
if (peq(aCommand, kNC_Delete)) if ((aCommand == kNC_Delete))
{ {
rv = DoDeleteFromFolder(folder, aArguments, transactionManager); rv = DoDeleteFromFolder(folder, aArguments, transactionManager);
} }
else if(peq(aCommand, kNC_NewFolder)) else if((aCommand == kNC_NewFolder))
{ {
rv = DoNewFolder(folder, aArguments); rv = DoNewFolder(folder, aArguments);
} }
else if(peq(aCommand, kNC_GetNewMessages)) else if((aCommand == kNC_GetNewMessages))
{ {
rv = folder->GetNewMessages(); rv = folder->GetNewMessages();
} }
else if(peq(aCommand, kNC_Copy)) else if((aCommand == kNC_Copy))
{ {
rv = DoCopyToFolder(folder, aArguments, transactionManager, PR_FALSE); rv = DoCopyToFolder(folder, aArguments, transactionManager, PR_FALSE);
} }
else if(peq(aCommand, kNC_Move)) else if((aCommand == kNC_Move))
{ {
rv = DoCopyToFolder(folder, aArguments, transactionManager, PR_TRUE); rv = DoCopyToFolder(folder, aArguments, transactionManager, PR_TRUE);
} }
@ -678,21 +678,21 @@ nsresult nsMsgFolderDataSource::createFolderNode(nsIMsgFolder* folder,
{ {
nsresult rv = NS_RDF_NO_VALUE; nsresult rv = NS_RDF_NO_VALUE;
if (peq(kNC_Name, property)) if ((kNC_Name == property))
rv = createFolderNameNode(folder, target); rv = createFolderNameNode(folder, target);
else if (peq(kNC_SpecialFolder, property)) else if ((kNC_SpecialFolder == property))
rv = createFolderSpecialNode(folder,target); rv = createFolderSpecialNode(folder,target);
else if (peq(kNC_TotalMessages, property)) else if ((kNC_TotalMessages == property))
rv = createTotalMessagesNode(folder, target); rv = createTotalMessagesNode(folder, target);
else if (peq(kNC_TotalUnreadMessages, property)) else if ((kNC_TotalUnreadMessages == property))
rv = createUnreadMessagesNode(folder, target); rv = createUnreadMessagesNode(folder, target);
else if (peq(kNC_Charset, property)) else if ((kNC_Charset == property))
rv = createCharsetNode(folder, target); rv = createCharsetNode(folder, target);
else if (peq(kNC_BiffState, property)) else if ((kNC_BiffState == property))
rv = createBiffStateNode(folder, target); rv = createBiffStateNode(folder, target);
else if (peq(kNC_Child, property)) else if ((kNC_Child == property))
rv = createFolderChildNode(folder, target); rv = createFolderChildNode(folder, target);
else if (peq(kNC_MessageChild, property)) else if ((kNC_MessageChild == property))
rv = createFolderMessageNode(folder, target); rv = createFolderMessageNode(folder, target);
return rv; return rv;
@ -979,7 +979,7 @@ nsresult nsMsgFolderDataSource::DoFolderAssert(nsIMsgFolder *folder, nsIRDFResou
{ {
nsresult rv = NS_ERROR_FAILURE; nsresult rv = NS_ERROR_FAILURE;
if(peq(kNC_Charset, property)) if((kNC_Charset == property))
{ {
nsCOMPtr<nsIRDFLiteral> literal(do_QueryInterface(target)); nsCOMPtr<nsIRDFLiteral> literal(do_QueryInterface(target));
if(literal) if(literal)
@ -1015,7 +1015,7 @@ nsresult nsMsgFolderDataSource::DoFolderHasAssertion(nsIMsgFolder *folder, nsIRD
return NS_OK; return NS_OK;
} }
if(peq(kNC_Child, property)) if((kNC_Child == property))
{ {
nsCOMPtr<nsIFolder> childFolder(do_QueryInterface(target, &rv)); nsCOMPtr<nsIFolder> childFolder(do_QueryInterface(target, &rv));
if(NS_SUCCEEDED(rv)) if(NS_SUCCEEDED(rv))
@ -1027,14 +1027,14 @@ nsresult nsMsgFolderDataSource::DoFolderHasAssertion(nsIMsgFolder *folder, nsIRD
&& (childsParent.get() == folderasFolder.get())); && (childsParent.get() == folderasFolder.get()));
} }
} }
else if(peq(kNC_MessageChild, property)) else if((kNC_MessageChild == property))
{ {
nsCOMPtr<nsIMessage> message(do_QueryInterface(target, &rv)); nsCOMPtr<nsIMessage> message(do_QueryInterface(target, &rv));
if(NS_SUCCEEDED(rv)) if(NS_SUCCEEDED(rv))
rv = folder->HasMessage(message, hasAssertion); rv = folder->HasMessage(message, hasAssertion);
} }
else if (peq(kNC_Name, property) || peq(kNC_SpecialFolder, property) || peq(kNC_TotalMessages, property) else if ((kNC_Name == property) || (kNC_SpecialFolder == property) || (kNC_TotalMessages == property)
|| peq(kNC_TotalUnreadMessages, property) || peq(kNC_Charset, property) || peq(kNC_BiffState, property)) || (kNC_TotalUnreadMessages == property) || (kNC_Charset == property) || (kNC_BiffState == property))
{ {
nsCOMPtr<nsIRDFResource> folderResource(do_QueryInterface(folder, &rv)); nsCOMPtr<nsIRDFResource> folderResource(do_QueryInterface(folder, &rv));

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

@ -248,8 +248,8 @@ NS_IMETHODIMP nsMsgMessageDataSource::GetTargets(nsIRDFResource* source,
*targets = nsnull; *targets = nsnull;
nsCOMPtr<nsIMessage> message(do_QueryInterface(source, &rv)); nsCOMPtr<nsIMessage> message(do_QueryInterface(source, &rv));
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
if(peq(kNC_Subject, property) || peq(kNC_Date, property) || if((kNC_Subject == property) || (kNC_Date == property) ||
peq(kNC_Status, property)) (kNC_Status == property))
{ {
nsSingletonEnumerator* cursor = nsSingletonEnumerator* cursor =
new nsSingletonEnumerator(source); new nsSingletonEnumerator(source);
@ -429,9 +429,9 @@ nsMsgMessageDataSource::DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSources
nsCOMPtr<nsIMessage> message = do_QueryInterface(source, &rv); nsCOMPtr<nsIMessage> message = do_QueryInterface(source, &rv);
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
{ {
if(peq(aCommand, kNC_MarkRead)) if((aCommand == kNC_MarkRead))
rv = DoMarkMessageRead(message, PR_TRUE); rv = DoMarkMessageRead(message, PR_TRUE);
else if(peq(aCommand, kNC_MarkUnread)) else if((aCommand == kNC_MarkUnread))
rv = DoMarkMessageRead(message, PR_FALSE); rv = DoMarkMessageRead(message, PR_FALSE);
} }
} }
@ -491,9 +491,9 @@ nsMsgMessageDataSource::createMessageNode(nsIMessage *message,
return createMessageNameNode(message, sort, target); return createMessageNameNode(message, sort, target);
else if (peqCollationSort(kNC_Sender, property, &sort)) else if (peqCollationSort(kNC_Sender, property, &sort))
return createMessageSenderNode(message, sort, target); return createMessageSenderNode(message, sort, target);
else if (peq(kNC_Date, property)) else if ((kNC_Date == property))
return createMessageDateNode(message, target); return createMessageDateNode(message, target);
else if (peq(kNC_Status, property)) else if ((kNC_Status == property))
return createMessageStatusNode(message, target); return createMessageStatusNode(message, target);
else else
return NS_RDF_NO_VALUE; return NS_RDF_NO_VALUE;

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

@ -26,17 +26,6 @@
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
PRBool
peq(nsIRDFResource* r1, nsIRDFResource* r2)
{
PRBool result;
if (NS_SUCCEEDED(r1->EqualsResource(r2, &result)) && result) {
return PR_TRUE;
} else {
return PR_FALSE;
}
}
static PRBool static PRBool
peqWithParameter(nsIRDFResource *r1, nsIRDFResource *r2, PRBool *isParameter, const char *parameter) peqWithParameter(nsIRDFResource *r1, nsIRDFResource *r2, PRBool *isParameter, const char *parameter)
{ {
@ -141,7 +130,7 @@ nsresult GetTargetHasAssertion(nsIRDFDataSource *dataSource, nsIRDFResource* fol
nsCOMPtr<nsIRDFLiteral> value2(do_QueryInterface(currentTarget)); nsCOMPtr<nsIRDFLiteral> value2(do_QueryInterface(currentTarget));
if(value1 && value2) if(value1 && value2)
//If the two values are equal then it has this assertion //If the two values are equal then it has this assertion
rv = value1->EqualsLiteral(value2, hasAssertion); *hasAssertion = (value1 == value2);
} }
else else
rv = NS_NOINTERFACE; rv = NS_NOINTERFACE;

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

@ -61,10 +61,6 @@ typedef struct _nsMsgRDFNotification {
#define NC_RDF_TOGGLEREAD "http://home.netscape.com/NC-rdf#ToggleRead" #define NC_RDF_TOGGLEREAD "http://home.netscape.com/NC-rdf#ToggleRead"
//Returns PR_TRUE if r1 is equal to r2
PRBool
peq(nsIRDFResource* r1, nsIRDFResource* r2);
//Returns PR_TRUE if r1 is equal to r2 and r2 is the sort property. //Returns PR_TRUE if r1 is equal to r2 and r2 is the sort property.
PRBool PRBool
peqSort(nsIRDFResource* r1, nsIRDFResource* r2, PRBool *isSort); peqSort(nsIRDFResource* r1, nsIRDFResource* r2, PRBool *isSort);

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

@ -22,37 +22,42 @@
#include "nscore.h" // for PRUnichar #include "nscore.h" // for PRUnichar
%} %}
// A literal node in the graph, whose value is a string. /**
* A literal node in the graph, whose value is a string.
*/
[scriptable, uuid(E0C493D2-9542-11d2-8EB8-00805F29F370)] [scriptable, uuid(E0C493D2-9542-11d2-8EB8-00805F29F370)]
interface nsIRDFLiteral : nsIRDFNode { interface nsIRDFLiteral : nsIRDFNode {
// The Unicode string value of the literal. /**
* The Unicode string value of the literal.
*/
readonly attribute wstring Value; readonly attribute wstring Value;
// Determine if two literals are identical. /**
boolean EqualsLiteral(in nsIRDFLiteral aLiteral); * An unscriptable version used to avoid a string copy. Meant
* for use as a performance optimization.
*/
[noscript] void GetValueConst([shared] out wstring aConstValue);
}; };
// A literal node in the graph, whose value is a date /**
* A literal node in the graph, whose value is a date
*/
[scriptable, uuid(E13A24E1-C77A-11d2-80BE-006097B76B8E)] [scriptable, uuid(E13A24E1-C77A-11d2-80BE-006097B76B8E)]
interface nsIRDFDate : nsIRDFNode { interface nsIRDFDate : nsIRDFNode {
// The date value of the literal /**
* The date value of the literal
*/
readonly attribute long long Value; readonly attribute long long Value;
// Determine if the date is equal to another
//
// XXX Is this really necessary?
boolean EqualsDate(in nsIRDFDate aDate);
}; };
// A literal node in the graph, whose value is an integer /**
* A literal node in the graph, whose value is an integer
*/
[scriptable, uuid(E13A24E3-C77A-11d2-80BE-006097B76B8E)] [scriptable, uuid(E13A24E3-C77A-11d2-80BE-006097B76B8E)]
interface nsIRDFInt : nsIRDFNode { interface nsIRDFInt : nsIRDFNode {
// The integer value of the literal /**
* The integer value of the literal
*/
readonly attribute long Value; readonly attribute long Value;
// Determine if the integer is equal to another
//
// XXX Is this really necessary?
boolean EqualsInt(in nsIRDFInt aInt);
}; };

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

@ -19,22 +19,33 @@
#include "nsIRDFNode.idl" #include "nsIRDFNode.idl"
// An nsIRDFResource is an object that has unique identity in the /**
// RDF data model. The object's identity is determined by its URI. * An nsIRDFResource is an object that has unique identity in the
* RDF data model. The object's identity is determined by its URI.
*/
[scriptable, uuid(E0C493D1-9542-11d2-8EB8-00805F29F370)] [scriptable, uuid(E0C493D1-9542-11d2-8EB8-00805F29F370)]
interface nsIRDFResource : nsIRDFNode { interface nsIRDFResource : nsIRDFNode {
// The single-byte string value of the resource /**
* The single-byte string value of the resource
*/
readonly attribute string Value; readonly attribute string Value;
// This method is called by the nsIRDFService after constructing /**
// a resource object to initialize it's URI. You would not normally * An unscriptable version used to avoid a string copy. Meant
// call this method directly * for use as a performance optimization.
*/
[noscript] void GetValueConst([shared] out string aConstValue);
/**
* This method is called by the nsIRDFService after constructing
* a resource object to initialize it's URI. You would not normally
* call this method directly
*/
void Init(in string uri); void Init(in string uri);
// Determine if two resources are identical. /**
boolean EqualsResource(in nsIRDFResource aResource); * Determine if the resource has the given URI.
*/
// Determine if the resource has the given URI.
boolean EqualsString(in string aURI); boolean EqualsString(in string aURI);
}; };

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

@ -120,11 +120,11 @@ public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
// nsIRDFNode // nsIRDFNode
NS_IMETHOD EqualsNode(nsIRDFNode* node, PRBool* result); NS_IMETHOD EqualsNode(nsIRDFNode* aNode, PRBool* aResult);
// nsIRDFLiteral // nsIRDFLiteral
NS_IMETHOD GetValue(PRUnichar* *value); NS_IMETHOD GetValue(PRUnichar* *aValue);
NS_IMETHOD EqualsLiteral(nsIRDFLiteral* literal, PRBool* result); NS_IMETHOD GetValueConst(const PRUnichar** aValue);
private: private:
nsAutoString mValue; nsAutoString mValue;
@ -164,19 +164,23 @@ LiteralImpl::QueryInterface(REFNSIID iid, void** result)
} }
NS_IMETHODIMP NS_IMETHODIMP
LiteralImpl::EqualsNode(nsIRDFNode* node, PRBool* result) LiteralImpl::EqualsNode(nsIRDFNode* aNode, PRBool* aResult)
{ {
nsresult rv; nsresult rv;
nsIRDFLiteral* literal; nsIRDFLiteral* literal;
if (NS_SUCCEEDED(node->QueryInterface(kIRDFLiteralIID, (void**) &literal))) { rv = aNode->QueryInterface(kIRDFLiteralIID, (void**) &literal);
rv = EqualsLiteral(literal, result); if (NS_SUCCEEDED(rv)) {
*aResult = (NS_STATIC_CAST(nsIRDFLiteral*, this) == literal);
NS_RELEASE(literal); NS_RELEASE(literal);
return NS_OK;
}
else if (rv == NS_NOINTERFACE) {
*aResult = PR_FALSE;
return NS_OK;
} }
else { else {
*result = PR_FALSE; return rv;
rv = NS_OK;
} }
return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -192,24 +196,12 @@ LiteralImpl::GetValue(PRUnichar* *value)
NS_IMETHODIMP NS_IMETHODIMP
LiteralImpl::EqualsLiteral(nsIRDFLiteral* literal, PRBool* result) LiteralImpl::GetValueConst(const PRUnichar** aValue)
{ {
NS_ASSERTION(literal && result, "null ptr"); *aValue = mValue.GetUnicode();
if (!literal || !result)
return NS_ERROR_NULL_POINTER;
nsresult rv;
nsXPIDLString p;
if (NS_FAILED(rv = literal->GetValue(getter_Copies(p))))
return rv;
nsAutoString s((const PRUnichar*) p);
*result = s.Equals(mValue);
return NS_OK; return NS_OK;
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// DateImpl // DateImpl
// //
@ -227,9 +219,9 @@ public:
// nsIRDFDate // nsIRDFDate
NS_IMETHOD GetValue(PRTime *value); NS_IMETHOD GetValue(PRTime *value);
NS_IMETHOD EqualsDate(nsIRDFDate* date, PRBool* result);
private: private:
nsresult EqualsDate(nsIRDFDate* date, PRBool* result);
PRTime mValue; PRTime mValue;
}; };
@ -292,7 +284,7 @@ DateImpl::GetValue(PRTime *value)
} }
NS_IMETHODIMP nsresult
DateImpl::EqualsDate(nsIRDFDate* date, PRBool* result) DateImpl::EqualsDate(nsIRDFDate* date, PRBool* result)
{ {
NS_ASSERTION(date && result, "null ptr"); NS_ASSERTION(date && result, "null ptr");
@ -325,9 +317,9 @@ public:
// nsIRDFInt // nsIRDFInt
NS_IMETHOD GetValue(PRInt32 *value); NS_IMETHOD GetValue(PRInt32 *value);
NS_IMETHOD EqualsInt(nsIRDFInt* value, PRBool* result);
private: private:
nsresult EqualsInt(nsIRDFInt* value, PRBool* result);
PRInt32 mValue; PRInt32 mValue;
}; };
@ -390,7 +382,7 @@ IntImpl::GetValue(PRInt32 *value)
} }
NS_IMETHODIMP nsresult
IntImpl::EqualsInt(nsIRDFInt* intValue, PRBool* result) IntImpl::EqualsInt(nsIRDFInt* intValue, PRBool* result)
{ {
NS_ASSERTION(intValue && result, "null ptr"); NS_ASSERTION(intValue && result, "null ptr");

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

@ -35,13 +35,13 @@ public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
// nsIRDFNode methods: // nsIRDFNode methods:
NS_IMETHOD EqualsNode(nsIRDFNode* node, PRBool* result); NS_IMETHOD EqualsNode(nsIRDFNode* aNode, PRBool* aResult);
// nsIRDFResource methods: // nsIRDFResource methods:
NS_IMETHOD Init(const char* uri); NS_IMETHOD Init(const char* aURI);
NS_IMETHOD GetValue(char* *uri); NS_IMETHOD GetValue(char* *aURI);
NS_IMETHOD EqualsResource(nsIRDFResource* resource, PRBool* result); NS_IMETHOD GetValueConst(const char** aURI);
NS_IMETHOD EqualsString(const char* uri, PRBool* result); NS_IMETHOD EqualsString(const char* aURI, PRBool* aResult);
// nsRDFResource methods: // nsRDFResource methods:
nsRDFResource(void); nsRDFResource(void);

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

@ -60,16 +60,17 @@ NS_IMPL_ADDREF(nsRDFResource)
NS_IMPL_RELEASE(nsRDFResource) NS_IMPL_RELEASE(nsRDFResource)
NS_IMETHODIMP NS_IMETHODIMP
nsRDFResource::QueryInterface(REFNSIID iid, void** result) nsRDFResource::QueryInterface(REFNSIID aIID, void** aResult)
{ {
if (! result) NS_PRECONDITION(aResult != nsnull, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
*result = nsnull; *aResult = nsnull;
if (iid.Equals(nsIRDFResource::GetIID()) || if (aIID.Equals(nsIRDFResource::GetIID()) ||
iid.Equals(nsIRDFNode::GetIID()) || aIID.Equals(nsIRDFNode::GetIID()) ||
iid.Equals(kISupportsIID)) { aIID.Equals(kISupportsIID)) {
*result = NS_STATIC_CAST(nsIRDFResource*, this); *aResult = NS_STATIC_CAST(nsIRDFResource*, this);
NS_ADDREF_THIS(); NS_ADDREF_THIS();
return NS_OK; return NS_OK;
} }
@ -81,19 +82,27 @@ nsRDFResource::QueryInterface(REFNSIID iid, void** result)
// nsIRDFNode methods: // nsIRDFNode methods:
NS_IMETHODIMP NS_IMETHODIMP
nsRDFResource::EqualsNode(nsIRDFNode* node, PRBool* result) nsRDFResource::EqualsNode(nsIRDFNode* aNode, PRBool* aResult)
{ {
NS_PRECONDITION(aNode != nsnull, "null ptr");
if (! aNode)
return NS_ERROR_NULL_POINTER;
nsresult rv; nsresult rv;
nsIRDFResource* resource; nsIRDFResource* resource;
if (NS_SUCCEEDED(node->QueryInterface(nsIRDFResource::GetIID(), (void**)&resource))) { rv = aNode->QueryInterface(nsIRDFResource::GetIID(), (void**)&resource);
rv = EqualsResource(resource, result); if (NS_SUCCEEDED(rv)) {
*aResult = (NS_STATIC_CAST(nsIRDFResource*, this) == resource);
NS_RELEASE(resource); NS_RELEASE(resource);
return NS_OK;
}
else if (rv == NS_NOINTERFACE) {
*aResult = PR_FALSE;
return NS_OK;
} }
else { else {
*result = PR_FALSE; return rv;
rv = NS_OK;
} }
return rv;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -132,41 +141,36 @@ nsRDFResource::Init(const char* aURI)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsRDFResource::GetValue(char* *uri) nsRDFResource::GetValue(char* *aURI)
{ {
if (!uri) if (!aURI)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
if ((*uri = nsXPIDLCString::Copy(mURI)) == nsnull) if ((*aURI = nsXPIDLCString::Copy(mURI)) == nsnull)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
else else
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsRDFResource::EqualsResource(nsIRDFResource* resource, PRBool* result) nsRDFResource::GetValueConst(const char** aURI)
{ {
NS_PRECONDITION(resource != nsnull, "null ptr"); *aURI = mURI;
NS_PRECONDITION(result != nsnull, "null ptr");
if (!resource || !result)
return NS_ERROR_NULL_POINTER;
// nsIRDFResource interfaces are unique
*result = ((nsIRDFResource*) this) == resource;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsRDFResource::EqualsString(const char* uri, PRBool* result) nsRDFResource::EqualsString(const char* aURI, PRBool* aResult)
{ {
NS_PRECONDITION(uri != nsnull, "null ptr"); NS_PRECONDITION(aURI != nsnull, "null ptr");
NS_PRECONDITION(result != nsnull, "null ptr"); if (! aURI)
if (!uri || !result)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
*result = nsCRT::strcmp(uri, mURI) == 0; NS_PRECONDITION(aResult != nsnull, "null ptr");
if (!aResult)
return NS_ERROR_NULL_POINTER;
*aResult = (nsCRT::strcmp(aURI, mURI) == 0);
return NS_OK; return NS_OK;
} }

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

@ -1455,7 +1455,7 @@ nsBookmarksService::WriteBookmarksContainer(nsIRDFDataSource *ds, nsOutputFileSt
if (!child) break; if (!child) break;
PRBool isIERoot = PR_FALSE, isContainer = PR_FALSE; PRBool isIERoot = PR_FALSE, isContainer = PR_FALSE;
if (NS_SUCCEEDED(child->EqualsResource(kNC_IEFavoritesRoot, &isIERoot))) if (child == kNC_IEFavoritesRoot)
{ {
if (isIERoot == PR_FALSE) if (isIERoot == PR_FALSE)
{ {