mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-21 17:59:34 +00:00
xpild-ing nsIAtom. Now nsIAtom is xpcom compliant.
This commit is contained in:
parent
7f99104407
commit
32a9a77110
@ -126,7 +126,10 @@ nsXULAttribute::QueryInterface(REFNSIID aIID, void** aResult)
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::GetNodeName(nsString& aNodeName)
|
||||
{
|
||||
aNodeName.SetString(mName->GetUnicode());
|
||||
PRUnichar *unicodeString;
|
||||
mName->GetUnicode(&unicodeString);
|
||||
|
||||
aNodeName.SetString(unicodeString);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -250,7 +253,9 @@ nsXULAttribute::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::GetName(nsString& aName)
|
||||
{
|
||||
aName.SetString(mName->GetUnicode());
|
||||
PRUnichar *unicodeString;
|
||||
mName->GetUnicode(&unicodeString);
|
||||
aName.SetString(unicodeString);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -335,12 +340,16 @@ nsXULAttribute::GetQualifiedName(nsString& aQualifiedName)
|
||||
rv = mContent->GetNameSpacePrefixFromId(mNameSpaceID, prefix);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && (prefix != nsnull)) {
|
||||
aQualifiedName.Append(prefix->GetUnicode());
|
||||
PRUnichar *unicodeString;
|
||||
prefix->GetUnicode(&unicodeString);
|
||||
aQualifiedName.Append(unicodeString);
|
||||
aQualifiedName.Append(':');
|
||||
NS_RELEASE(prefix);
|
||||
}
|
||||
}
|
||||
aQualifiedName.Append(mName->GetUnicode());
|
||||
PRUnichar *unicodeString;
|
||||
mName->GetUnicode(&unicodeString);
|
||||
aQualifiedName.Append(unicodeString);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1751,8 +1751,10 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
||||
nsXPIDLCString resourceCStr;
|
||||
rv = aChild->GetValue(getter_Copies(resourceCStr));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString tagStr(tag->GetUnicode());
|
||||
|
||||
PRUnichar *unicodeString;
|
||||
tag->GetUnicode(&unicodeString);
|
||||
nsAutoString tagStr(unicodeString);
|
||||
char* tagCStr = tagStr.ToNewCString();
|
||||
|
||||
PR_LOG(gLog, PR_LOG_DEBUG,
|
||||
@ -1875,7 +1877,10 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
||||
|
||||
nsCOMPtr<nsIHTMLContent> element;
|
||||
//nsAutoString tagName(tag->GetUnicode());
|
||||
rv = factory->CreateInstanceByTag(tag->GetUnicode(), getter_AddRefs(element));
|
||||
PRUnichar *unicodeString;
|
||||
tag->GetUnicode(&unicodeString);
|
||||
|
||||
rv = factory->CreateInstanceByTag(unicodeString, getter_AddRefs(element));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
realKid = do_QueryInterface(element);
|
||||
@ -2778,7 +2783,9 @@ RDFGenericBuilderImpl::GetResource(PRInt32 aNameSpaceID,
|
||||
gNameSpaceManager->GetNameSpaceURI(aNameSpaceID, uri);
|
||||
|
||||
// XXX check to see if we need to insert a '/' or a '#'
|
||||
nsAutoString tag(aNameAtom->GetUnicode());
|
||||
PRUnichar *unicodeString;
|
||||
aNameAtom->GetUnicode(&unicodeString);
|
||||
nsAutoString tag(unicodeString);
|
||||
if (0 < uri.Length() && uri.Last() != '#' && uri.Last() != '/' && tag.First() != '#')
|
||||
uri.Append('#');
|
||||
|
||||
|
@ -2624,7 +2624,9 @@ nsEditor::NodeIsType(nsIDOMNode *aNode, nsIAtom *aTag)
|
||||
{
|
||||
nsAutoString tag;
|
||||
element->GetTagName(tag);
|
||||
if (tag.EqualsIgnoreCase(aTag->GetUnicode()))
|
||||
PRUnichar *unicodeString;
|
||||
aTag->GetUnicode(&unicodeString);
|
||||
if (tag.EqualsIgnoreCase(unicodeString))
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
@ -5271,7 +5271,9 @@ nsHTMLEditor::RemoveTextPropertiesForNode(nsIDOMNode *aNode,
|
||||
if (gNoisy) { printf("* parent has tag %s\n", tag.ToNewCString()); } // XXX leak!
|
||||
if (NS_SUCCEEDED(result))
|
||||
{
|
||||
if (PR_FALSE==tag.EqualsIgnoreCase(aPropName->GetUnicode()))
|
||||
PRUnichar *unicodeString;
|
||||
aPropName->GetUnicode(&unicodeString);
|
||||
if (PR_FALSE==tag.EqualsIgnoreCase(unicodeString))
|
||||
{
|
||||
PRInt32 offsetInParent;
|
||||
result = GetChildOffset(newMiddleNode, parent, offsetInParent);
|
||||
|
@ -2339,7 +2339,9 @@ NS_IMETHODIMP nsTextEditor::RemoveTextPropertiesForNode(nsIDOMNode *aNode,
|
||||
if (gNoisy) { printf("* parent has tag %s\n", tag.ToNewCString()); } // XXX leak!
|
||||
if (NS_SUCCEEDED(result))
|
||||
{
|
||||
if (PR_FALSE==tag.EqualsIgnoreCase(aPropName->GetUnicode()))
|
||||
PRUnichar *unicodeString;
|
||||
aPropName->GetUnicode(&unicodeString);
|
||||
if (PR_FALSE==tag.EqualsIgnoreCase(unicodeString))
|
||||
{
|
||||
PRInt32 offsetInParent;
|
||||
result = GetChildOffset(newMiddleNode, parent, offsetInParent);
|
||||
|
@ -2624,7 +2624,9 @@ nsEditor::NodeIsType(nsIDOMNode *aNode, nsIAtom *aTag)
|
||||
{
|
||||
nsAutoString tag;
|
||||
element->GetTagName(tag);
|
||||
if (tag.EqualsIgnoreCase(aTag->GetUnicode()))
|
||||
PRUnichar *unicodeString;
|
||||
aTag->GetUnicode(&unicodeString);
|
||||
if (tag.EqualsIgnoreCase(unicodeString))
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
@ -5271,7 +5271,9 @@ nsHTMLEditor::RemoveTextPropertiesForNode(nsIDOMNode *aNode,
|
||||
if (gNoisy) { printf("* parent has tag %s\n", tag.ToNewCString()); } // XXX leak!
|
||||
if (NS_SUCCEEDED(result))
|
||||
{
|
||||
if (PR_FALSE==tag.EqualsIgnoreCase(aPropName->GetUnicode()))
|
||||
PRUnichar *unicodeString;
|
||||
aPropName->GetUnicode(&unicodeString);
|
||||
if (PR_FALSE==tag.EqualsIgnoreCase(unicodeString))
|
||||
{
|
||||
PRInt32 offsetInParent;
|
||||
result = GetChildOffset(newMiddleNode, parent, offsetInParent);
|
||||
|
@ -1131,7 +1131,9 @@ RDFContentSinkImpl::AddProperties(const nsIParserNode& aNode,
|
||||
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
|
||||
}
|
||||
GetNameSpaceURI(nameSpaceID, k);
|
||||
k.Append(attr->GetUnicode());
|
||||
PRUnichar *unicodeString;
|
||||
attr->GetUnicode(&unicodeString);
|
||||
k.Append(unicodeString);
|
||||
|
||||
// Add the attribute to RDF
|
||||
|
||||
@ -1238,7 +1240,9 @@ RDFContentSinkImpl::OpenObject(const nsIParserNode& aNode)
|
||||
// tag name. We can do this 'cause we don't need it anymore...
|
||||
nsAutoString typeStr;
|
||||
GetNameSpaceURI(nameSpaceID, typeStr); // XXX append ':' too?
|
||||
typeStr.Append(tag->GetUnicode());
|
||||
PRUnichar *unicodeString;
|
||||
tag->GetUnicode(&unicodeString);
|
||||
typeStr.Append(unicodeString);
|
||||
|
||||
nsCOMPtr<nsIRDFResource> type;
|
||||
rv = gRDFService->GetUnicodeResource(typeStr.GetUnicode(), getter_AddRefs(type));
|
||||
@ -1275,7 +1279,10 @@ RDFContentSinkImpl::OpenProperty(const nsIParserNode& aNode)
|
||||
|
||||
// destructively alter "ns" to contain the fully qualified tag
|
||||
// name. We can do this 'cause we don't need it anymore...
|
||||
ns.Append(tag->GetUnicode());
|
||||
PRUnichar *unicodeString;
|
||||
tag->GetUnicode(&unicodeString);
|
||||
ns.Append(unicodeString);
|
||||
|
||||
nsCOMPtr<nsIRDFResource> property;
|
||||
rv = gRDFService->GetUnicodeResource(ns.GetUnicode(), getter_AddRefs(property));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -352,7 +352,9 @@ nsRDFContentUtils::GetElementLogString(nsIContent* aElement, nsString& aResult)
|
||||
nsAutoString prefixStr;
|
||||
prefix->ToString(prefixStr);
|
||||
if (prefixStr.Length()) {
|
||||
aResult.Append(prefix->GetUnicode());
|
||||
PRUnichar *unicodeString;
|
||||
prefix->GetUnicode(&unicodeString);
|
||||
aResult.Append(unicodeString);
|
||||
aResult.Append(':');
|
||||
}
|
||||
}
|
||||
@ -362,7 +364,9 @@ nsRDFContentUtils::GetElementLogString(nsIContent* aElement, nsString& aResult)
|
||||
rv = aElement->GetTag(*getter_AddRefs(tag));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
aResult.Append(tag->GetUnicode());
|
||||
PRUnichar *unicodeString;
|
||||
tag->GetUnicode(&unicodeString);
|
||||
aResult.Append(unicodeString);
|
||||
|
||||
PRInt32 count;
|
||||
rv = aElement->GetAttributeCount(count);
|
||||
@ -424,13 +428,17 @@ nsRDFContentUtils::GetAttributeLogString(nsIContent* aElement, PRInt32 aNameSpac
|
||||
nsAutoString prefixStr;
|
||||
prefix->ToString(prefixStr);
|
||||
if (prefixStr.Length()) {
|
||||
aResult.Append(prefix->GetUnicode());
|
||||
PRUnichar *unicodeString;
|
||||
prefix->GetUnicode(&unicodeString);
|
||||
aResult.Append(unicodeString);
|
||||
aResult.Append(':');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
aResult.Append(aTag->GetUnicode());
|
||||
PRUnichar *unicodeString;
|
||||
aTag->GetUnicode(&unicodeString);
|
||||
aResult.Append(unicodeString);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1751,8 +1751,10 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
||||
nsXPIDLCString resourceCStr;
|
||||
rv = aChild->GetValue(getter_Copies(resourceCStr));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString tagStr(tag->GetUnicode());
|
||||
|
||||
PRUnichar *unicodeString;
|
||||
tag->GetUnicode(&unicodeString);
|
||||
nsAutoString tagStr(unicodeString);
|
||||
char* tagCStr = tagStr.ToNewCString();
|
||||
|
||||
PR_LOG(gLog, PR_LOG_DEBUG,
|
||||
@ -1875,7 +1877,10 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
||||
|
||||
nsCOMPtr<nsIHTMLContent> element;
|
||||
//nsAutoString tagName(tag->GetUnicode());
|
||||
rv = factory->CreateInstanceByTag(tag->GetUnicode(), getter_AddRefs(element));
|
||||
PRUnichar *unicodeString;
|
||||
tag->GetUnicode(&unicodeString);
|
||||
|
||||
rv = factory->CreateInstanceByTag(unicodeString, getter_AddRefs(element));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
realKid = do_QueryInterface(element);
|
||||
@ -2778,7 +2783,9 @@ RDFGenericBuilderImpl::GetResource(PRInt32 aNameSpaceID,
|
||||
gNameSpaceManager->GetNameSpaceURI(aNameSpaceID, uri);
|
||||
|
||||
// XXX check to see if we need to insert a '/' or a '#'
|
||||
nsAutoString tag(aNameAtom->GetUnicode());
|
||||
PRUnichar *unicodeString;
|
||||
aNameAtom->GetUnicode(&unicodeString);
|
||||
nsAutoString tag(unicodeString);
|
||||
if (0 < uri.Length() && uri.Last() != '#' && uri.Last() != '/' && tag.First() != '#')
|
||||
uri.Append('#');
|
||||
|
||||
|
@ -2218,7 +2218,9 @@ RDFXULBuilderImpl::CreateHTMLElement(nsINameSpace* aContainingNameSpace,
|
||||
// bit of a hack: a bridge until we get to a more DOM-based
|
||||
// solution.
|
||||
nsCOMPtr<nsIHTMLContent> element;
|
||||
rv = mHTMLElementFactory->CreateInstanceByTag(aTagName->GetUnicode(),
|
||||
PRUnichar *unicodeString;
|
||||
aTagName->GetUnicode(&unicodeString);
|
||||
rv = mHTMLElementFactory->CreateInstanceByTag(unicodeString,
|
||||
getter_AddRefs(element));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
@ -3068,7 +3070,9 @@ RDFXULBuilderImpl::GetResource(PRInt32 aNameSpaceID,
|
||||
gNameSpaceManager->GetNameSpaceURI(aNameSpaceID, uri);
|
||||
|
||||
// XXX check to see if we need to insert a '/' or a '#'
|
||||
nsAutoString tag(aNameAtom->GetUnicode());
|
||||
PRUnichar *unicodeString;
|
||||
aNameAtom->GetUnicode(&unicodeString);
|
||||
nsAutoString tag(unicodeString);
|
||||
if (0 < uri.Length() && uri.Last() != '#' && uri.Last() != '/' && tag.First() != '#')
|
||||
uri.Append('#');
|
||||
|
||||
@ -3104,7 +3108,9 @@ RDFXULBuilderImpl::MakeProperty(PRInt32 aNameSpaceID, nsIAtom* aTagName, nsIRDFR
|
||||
if (uri.Last() != PRUnichar('#') && uri.Last() != PRUnichar('/'))
|
||||
uri.Append('#');
|
||||
|
||||
uri.Append(aTagName->GetUnicode());
|
||||
PRUnichar *unicodeString;
|
||||
aTagName->GetUnicode(&unicodeString);
|
||||
uri.Append(unicodeString);
|
||||
|
||||
rv = gRDFService->GetUnicodeResource(uri.GetUnicode(), aResult);
|
||||
return rv;
|
||||
|
@ -126,7 +126,10 @@ nsXULAttribute::QueryInterface(REFNSIID aIID, void** aResult)
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::GetNodeName(nsString& aNodeName)
|
||||
{
|
||||
aNodeName.SetString(mName->GetUnicode());
|
||||
PRUnichar *unicodeString;
|
||||
mName->GetUnicode(&unicodeString);
|
||||
|
||||
aNodeName.SetString(unicodeString);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -250,7 +253,9 @@ nsXULAttribute::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
NS_IMETHODIMP
|
||||
nsXULAttribute::GetName(nsString& aName)
|
||||
{
|
||||
aName.SetString(mName->GetUnicode());
|
||||
PRUnichar *unicodeString;
|
||||
mName->GetUnicode(&unicodeString);
|
||||
aName.SetString(unicodeString);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -335,12 +340,16 @@ nsXULAttribute::GetQualifiedName(nsString& aQualifiedName)
|
||||
rv = mContent->GetNameSpacePrefixFromId(mNameSpaceID, prefix);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && (prefix != nsnull)) {
|
||||
aQualifiedName.Append(prefix->GetUnicode());
|
||||
PRUnichar *unicodeString;
|
||||
prefix->GetUnicode(&unicodeString);
|
||||
aQualifiedName.Append(unicodeString);
|
||||
aQualifiedName.Append(':');
|
||||
NS_RELEASE(prefix);
|
||||
}
|
||||
}
|
||||
aQualifiedName.Append(mName->GetUnicode());
|
||||
PRUnichar *unicodeString;
|
||||
mName->GetUnicode(&unicodeString);
|
||||
aQualifiedName.Append(unicodeString);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1751,8 +1751,10 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
||||
nsXPIDLCString resourceCStr;
|
||||
rv = aChild->GetValue(getter_Copies(resourceCStr));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString tagStr(tag->GetUnicode());
|
||||
|
||||
PRUnichar *unicodeString;
|
||||
tag->GetUnicode(&unicodeString);
|
||||
nsAutoString tagStr(unicodeString);
|
||||
char* tagCStr = tagStr.ToNewCString();
|
||||
|
||||
PR_LOG(gLog, PR_LOG_DEBUG,
|
||||
@ -1875,7 +1877,10 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
||||
|
||||
nsCOMPtr<nsIHTMLContent> element;
|
||||
//nsAutoString tagName(tag->GetUnicode());
|
||||
rv = factory->CreateInstanceByTag(tag->GetUnicode(), getter_AddRefs(element));
|
||||
PRUnichar *unicodeString;
|
||||
tag->GetUnicode(&unicodeString);
|
||||
|
||||
rv = factory->CreateInstanceByTag(unicodeString, getter_AddRefs(element));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
realKid = do_QueryInterface(element);
|
||||
@ -2778,7 +2783,9 @@ RDFGenericBuilderImpl::GetResource(PRInt32 aNameSpaceID,
|
||||
gNameSpaceManager->GetNameSpaceURI(aNameSpaceID, uri);
|
||||
|
||||
// XXX check to see if we need to insert a '/' or a '#'
|
||||
nsAutoString tag(aNameAtom->GetUnicode());
|
||||
PRUnichar *unicodeString;
|
||||
aNameAtom->GetUnicode(&unicodeString);
|
||||
nsAutoString tag(unicodeString);
|
||||
if (0 < uri.Length() && uri.Last() != '#' && uri.Last() != '/' && tag.First() != '#')
|
||||
uri.Append('#');
|
||||
|
||||
|
@ -355,9 +355,15 @@ XULContentSinkImpl::~XULContentSinkImpl()
|
||||
|
||||
nsAutoString prefix;
|
||||
if (prefixAtom)
|
||||
prefix = prefixAtom->GetUnicode();
|
||||
{
|
||||
PRUnichar *unicodeString;
|
||||
prefixAtom->GetUnicode(&unicodeString);
|
||||
prefix = unicodeString;
|
||||
}
|
||||
else
|
||||
{
|
||||
prefix = "<default>";
|
||||
}
|
||||
|
||||
char* prefixStr = prefix.ToNewCString();
|
||||
char* uriStr = uri.ToNewCString();
|
||||
@ -405,7 +411,9 @@ XULContentSinkImpl::~XULContentSinkImpl()
|
||||
nsCOMPtr<nsIAtom> tagAtom;
|
||||
rv = rdfDoc->SplitProperty(type, &nameSpaceID, getter_AddRefs(tagAtom));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
tag = tagAtom->GetUnicode();
|
||||
PRUnichar *unicodeString;
|
||||
tagAtom->GetUnicode(&unicodeString);
|
||||
tag = unicodeString;
|
||||
mNameSpaceManager->GetNameSpaceURI(nameSpaceID, nameSpaceURI);
|
||||
}
|
||||
}
|
||||
|
@ -1639,7 +1639,7 @@ PRBool nsString::EqualsIgnoreCase(const char* aString,PRInt32 aLength) const {
|
||||
return Equals(aString,PR_TRUE,aLength);
|
||||
}
|
||||
|
||||
PRBool nsString::EqualsIgnoreCase(const nsIAtom *aAtom) const {
|
||||
PRBool nsString::EqualsIgnoreCase(nsIAtom *aAtom) const {
|
||||
return Equals(aAtom,PR_TRUE);
|
||||
}
|
||||
|
||||
@ -1715,15 +1715,18 @@ PRBool nsString::Equals(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCou
|
||||
* @param aLength -- length of given string.
|
||||
* @return TRUE if equal
|
||||
*/
|
||||
PRBool nsString::Equals(const nsIAtom* aAtom,PRBool aIgnoreCase) const{
|
||||
PRBool nsString::Equals(nsIAtom* aAtom,PRBool aIgnoreCase) const{
|
||||
NS_ASSERTION(0!=aAtom,kNullPointerError);
|
||||
PRBool result=PR_FALSE;
|
||||
if(aAtom){
|
||||
PRInt32 cmp=0;
|
||||
PRUnichar* unicode;
|
||||
if (aAtom->GetUnicode(&unicode) != NS_OK || unicode == nsnull)
|
||||
return PR_FALSE;
|
||||
if (aIgnoreCase)
|
||||
cmp=nsCRT::strcasecmp(mUStr,aAtom->GetUnicode());
|
||||
cmp=nsCRT::strcasecmp(mUStr,unicode);
|
||||
else
|
||||
cmp=nsCRT::strcmp(mUStr,aAtom->GetUnicode());
|
||||
cmp=nsCRT::strcmp(mUStr,unicode);
|
||||
result=PRBool(0==cmp);
|
||||
}
|
||||
|
||||
|
@ -724,12 +724,12 @@ PRBool Equals(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCoun
|
||||
PRBool Equals(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
PRBool Equals(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
PRBool Equals(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
PRBool Equals(const nsIAtom* anAtom,PRBool aIgnoreCase) const;
|
||||
PRBool Equals(nsIAtom* anAtom,PRBool aIgnoreCase) const;
|
||||
PRBool Equals(const PRUnichar* s1, const PRUnichar* s2,PRBool aIgnoreCase=PR_FALSE) const;
|
||||
|
||||
PRBool EqualsIgnoreCase(const nsString& aString) const;
|
||||
PRBool EqualsIgnoreCase(const char* aString,PRInt32 aCount=-1) const;
|
||||
PRBool EqualsIgnoreCase(const nsIAtom *aAtom) const;
|
||||
PRBool EqualsIgnoreCase(nsIAtom *aAtom) const;
|
||||
PRBool EqualsIgnoreCase(const PRUnichar* s1, const PRUnichar* s2) const;
|
||||
|
||||
/**
|
||||
|
@ -1,3 +1,4 @@
|
||||
nsIAtom.idl
|
||||
nsICollection.idl
|
||||
nsIEnumerator.idl
|
||||
nsIObserver.idl
|
||||
|
@ -31,7 +31,8 @@ MODULE = xpcom
|
||||
XPIDL_MODULE = xpcom_ds
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsICollection.idl \
|
||||
nsIAtom.idl \
|
||||
nsICollection.idl \
|
||||
nsIEnumerator.idl \
|
||||
nsIObserver.idl \
|
||||
nsIObserverService.idl \
|
||||
|
@ -59,6 +59,7 @@ EXPORTS = \
|
||||
XPIDL_MODULE = xpcom_ds
|
||||
|
||||
XPIDLSRCS = \
|
||||
.\nsIAtom.idl \
|
||||
.\nsICollection.idl \
|
||||
.\nsIEnumerator.idl \
|
||||
.\nsIObserver.idl \
|
||||
|
@ -62,19 +62,24 @@ void* AtomImpl::operator new(size_t size, const PRUnichar* us, PRInt32 uslen)
|
||||
return ii;
|
||||
}
|
||||
|
||||
void AtomImpl::ToString(nsString& aBuf) const
|
||||
NS_IMETHODIMP
|
||||
AtomImpl::ToString(nsString& aBuf)
|
||||
{
|
||||
aBuf.SetLength(0);
|
||||
aBuf.Append(mString, nsCRT::strlen(mString));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const PRUnichar* AtomImpl::GetUnicode() const
|
||||
NS_IMETHODIMP
|
||||
AtomImpl::GetUnicode( PRUnichar** _retval )
|
||||
{
|
||||
return mString;
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = mString;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AtomImpl::SizeOf(nsISizeOfHandler* aHandler) const
|
||||
AtomImpl::SizeOf(nsISizeOfHandler* aHandler)
|
||||
{
|
||||
aHandler->Add(sizeof(*this) + nsCRT::strlen(mString) * sizeof(PRUnichar));
|
||||
return NS_OK;
|
||||
|
@ -27,6 +27,7 @@ public:
|
||||
virtual ~AtomImpl();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIATOM
|
||||
|
||||
void* operator new(size_t size, const PRUnichar* us, PRInt32 uslen);
|
||||
|
||||
@ -34,12 +35,6 @@ public:
|
||||
::operator delete(ptr);
|
||||
}
|
||||
|
||||
virtual void ToString(nsString& aBuf) const;
|
||||
|
||||
virtual const PRUnichar* GetUnicode() const;
|
||||
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const;
|
||||
|
||||
// Actually more; 0 terminated. This slot is reserved for the
|
||||
// terminating zero.
|
||||
PRUnichar mString[1];
|
||||
|
@ -1,79 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 nsIAtom_h___
|
||||
#define nsIAtom_h___
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
class nsString;
|
||||
class nsISizeOfHandler;
|
||||
|
||||
#define NS_IATOM_IID \
|
||||
{ 0x3d1b15b0, 0x93b4, 0x11d1, \
|
||||
{0x89, 0x5b, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} }
|
||||
|
||||
/**
|
||||
* A globally unique identfier. nsIAtom's can be compared for
|
||||
* equality by using operator '=='. These objects are reference
|
||||
* counted like other nsISupports objects. When you are done with
|
||||
* the atom, NS_RELEASE it.
|
||||
*/
|
||||
class nsIAtom : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IATOM_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Translate the unicode string into the stringbuf.
|
||||
*/
|
||||
virtual void ToString(nsString& aString) const = 0;
|
||||
|
||||
/**
|
||||
* Return a pointer to a zero terminated unicode string.
|
||||
*/
|
||||
virtual const PRUnichar* GetUnicode() const = 0;
|
||||
|
||||
/**
|
||||
* Add the size, in bytes, of the atom to the handler.
|
||||
*/
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Find an atom that matches the given iso-latin1 C string. The
|
||||
* C string is translated into it's unicode equivalent.
|
||||
*/
|
||||
extern NS_COM nsIAtom* NS_NewAtom(const char* isolatin1);
|
||||
|
||||
/**
|
||||
* Find an atom that matches the given unicode string. The string is assumed
|
||||
* to be zero terminated.
|
||||
*/
|
||||
extern NS_COM nsIAtom* NS_NewAtom(const PRUnichar* unicode);
|
||||
|
||||
/**
|
||||
* Find an atom that matches the given string.
|
||||
*/
|
||||
extern NS_COM nsIAtom* NS_NewAtom(const nsString& aString);
|
||||
|
||||
/**
|
||||
* Return a count of the total number of atoms currently
|
||||
* alive in the system.
|
||||
*/
|
||||
extern NS_COM nsrefcnt NS_GetNumberOfAtoms(void);
|
||||
|
||||
#endif /* nsIAtom_h___ */
|
@ -1639,7 +1639,7 @@ PRBool nsString::EqualsIgnoreCase(const char* aString,PRInt32 aLength) const {
|
||||
return Equals(aString,PR_TRUE,aLength);
|
||||
}
|
||||
|
||||
PRBool nsString::EqualsIgnoreCase(const nsIAtom *aAtom) const {
|
||||
PRBool nsString::EqualsIgnoreCase(nsIAtom *aAtom) const {
|
||||
return Equals(aAtom,PR_TRUE);
|
||||
}
|
||||
|
||||
@ -1715,15 +1715,18 @@ PRBool nsString::Equals(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCou
|
||||
* @param aLength -- length of given string.
|
||||
* @return TRUE if equal
|
||||
*/
|
||||
PRBool nsString::Equals(const nsIAtom* aAtom,PRBool aIgnoreCase) const{
|
||||
PRBool nsString::Equals(nsIAtom* aAtom,PRBool aIgnoreCase) const{
|
||||
NS_ASSERTION(0!=aAtom,kNullPointerError);
|
||||
PRBool result=PR_FALSE;
|
||||
if(aAtom){
|
||||
PRInt32 cmp=0;
|
||||
PRUnichar* unicode;
|
||||
if (aAtom->GetUnicode(&unicode) != NS_OK || unicode == nsnull)
|
||||
return PR_FALSE;
|
||||
if (aIgnoreCase)
|
||||
cmp=nsCRT::strcasecmp(mUStr,aAtom->GetUnicode());
|
||||
cmp=nsCRT::strcasecmp(mUStr,unicode);
|
||||
else
|
||||
cmp=nsCRT::strcmp(mUStr,aAtom->GetUnicode());
|
||||
cmp=nsCRT::strcmp(mUStr,unicode);
|
||||
result=PRBool(0==cmp);
|
||||
}
|
||||
|
||||
|
@ -724,12 +724,12 @@ PRBool Equals(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCoun
|
||||
PRBool Equals(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
PRBool Equals(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
PRBool Equals(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
PRBool Equals(const nsIAtom* anAtom,PRBool aIgnoreCase) const;
|
||||
PRBool Equals(nsIAtom* anAtom,PRBool aIgnoreCase) const;
|
||||
PRBool Equals(const PRUnichar* s1, const PRUnichar* s2,PRBool aIgnoreCase=PR_FALSE) const;
|
||||
|
||||
PRBool EqualsIgnoreCase(const nsString& aString) const;
|
||||
PRBool EqualsIgnoreCase(const char* aString,PRInt32 aCount=-1) const;
|
||||
PRBool EqualsIgnoreCase(const nsIAtom *aAtom) const;
|
||||
PRBool EqualsIgnoreCase(nsIAtom *aAtom) const;
|
||||
PRBool EqualsIgnoreCase(const PRUnichar* s1, const PRUnichar* s2) const;
|
||||
|
||||
/**
|
||||
|
@ -1639,7 +1639,7 @@ PRBool nsString::EqualsIgnoreCase(const char* aString,PRInt32 aLength) const {
|
||||
return Equals(aString,PR_TRUE,aLength);
|
||||
}
|
||||
|
||||
PRBool nsString::EqualsIgnoreCase(const nsIAtom *aAtom) const {
|
||||
PRBool nsString::EqualsIgnoreCase(nsIAtom *aAtom) const {
|
||||
return Equals(aAtom,PR_TRUE);
|
||||
}
|
||||
|
||||
@ -1715,15 +1715,18 @@ PRBool nsString::Equals(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCou
|
||||
* @param aLength -- length of given string.
|
||||
* @return TRUE if equal
|
||||
*/
|
||||
PRBool nsString::Equals(const nsIAtom* aAtom,PRBool aIgnoreCase) const{
|
||||
PRBool nsString::Equals(nsIAtom* aAtom,PRBool aIgnoreCase) const{
|
||||
NS_ASSERTION(0!=aAtom,kNullPointerError);
|
||||
PRBool result=PR_FALSE;
|
||||
if(aAtom){
|
||||
PRInt32 cmp=0;
|
||||
PRUnichar* unicode;
|
||||
if (aAtom->GetUnicode(&unicode) != NS_OK || unicode == nsnull)
|
||||
return PR_FALSE;
|
||||
if (aIgnoreCase)
|
||||
cmp=nsCRT::strcasecmp(mUStr,aAtom->GetUnicode());
|
||||
cmp=nsCRT::strcasecmp(mUStr,unicode);
|
||||
else
|
||||
cmp=nsCRT::strcmp(mUStr,aAtom->GetUnicode());
|
||||
cmp=nsCRT::strcmp(mUStr,unicode);
|
||||
result=PRBool(0==cmp);
|
||||
}
|
||||
|
||||
|
@ -724,12 +724,12 @@ PRBool Equals(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCoun
|
||||
PRBool Equals(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
PRBool Equals(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
PRBool Equals(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
PRBool Equals(const nsIAtom* anAtom,PRBool aIgnoreCase) const;
|
||||
PRBool Equals(nsIAtom* anAtom,PRBool aIgnoreCase) const;
|
||||
PRBool Equals(const PRUnichar* s1, const PRUnichar* s2,PRBool aIgnoreCase=PR_FALSE) const;
|
||||
|
||||
PRBool EqualsIgnoreCase(const nsString& aString) const;
|
||||
PRBool EqualsIgnoreCase(const char* aString,PRInt32 aCount=-1) const;
|
||||
PRBool EqualsIgnoreCase(const nsIAtom *aAtom) const;
|
||||
PRBool EqualsIgnoreCase(nsIAtom *aAtom) const;
|
||||
PRBool EqualsIgnoreCase(const PRUnichar* s1, const PRUnichar* s2) const;
|
||||
|
||||
/**
|
||||
|
@ -60,7 +60,9 @@ int main(int argc, char** argv)
|
||||
|
||||
// Now make sure we can find all the idents we just made
|
||||
for (i = 0; i < count; i++) {
|
||||
nsIAtom* id = NS_NewAtom(ids[i]->GetUnicode());
|
||||
PRUnichar *unicodeString;
|
||||
ids[i]->GetUnicode(&unicodeString);
|
||||
nsIAtom* id = NS_NewAtom(unicodeString);
|
||||
if (id != ids[i]) {
|
||||
id->ToString(s1);
|
||||
ids[i]->ToString(s2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user