mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-14 02:31:59 +00:00
Bug 122001. Implement txExpandedNameMap. Add QName parsing and some operators to txExpandedName.
r=peterv sr=jst a=asa
This commit is contained in:
parent
a313452081
commit
783e3ea68e
@ -63,6 +63,7 @@ LOBJS =../source/base/ArrayList.$(OBJ_SUFFIX) \
|
||||
../source/base/StringList.$(OBJ_SUFFIX) \
|
||||
../source/base/Tokenizer.$(OBJ_SUFFIX) \
|
||||
../source/base/txAtoms.$(OBJ_SUFFIX) \
|
||||
../source/base/txExpandedNameMap.$(OBJ_SUFFIX) \
|
||||
../source/base/MozillaString.$(OBJ_SUFFIX) \
|
||||
../source/net/URIUtils.$(OBJ_SUFFIX) \
|
||||
../source/xml/dom/mozImpl/MozillaObjectWrapper.$(OBJ_SUFFIX) \
|
||||
|
@ -46,6 +46,7 @@ CPP_OBJS= \
|
||||
..\source\base\$(OBJDIR)\StringList.obj \
|
||||
..\source\base\$(OBJDIR)\Tokenizer.obj \
|
||||
..\source\base\$(OBJDIR)\txAtoms.obj \
|
||||
..\source\base\$(OBJDIR)\txExpandedNameMap.obj \
|
||||
..\source\base\$(OBJDIR)\MozillaString.obj \
|
||||
..\source\net\$(OBJDIR)\URIUtils.obj \
|
||||
..\source\xml\dom\mozImpl\$(OBJDIR)\MozillaObjectWrapper.obj \
|
||||
|
@ -31,6 +31,9 @@ MODULE = transformiix
|
||||
REQUIRES = string \
|
||||
xpcom \
|
||||
unicharutil \
|
||||
dom \
|
||||
content \
|
||||
widget \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
@ -44,7 +47,8 @@ CPPSRCS = ArrayList.cpp \
|
||||
Stack.cpp \
|
||||
StringList.cpp \
|
||||
Tokenizer.cpp \
|
||||
txAtoms.cpp
|
||||
txAtoms.cpp \
|
||||
txExpandedNameMap.cpp
|
||||
|
||||
ifdef TX_EXE
|
||||
CPPSRCS += CommandLineUtils.cpp \
|
||||
@ -55,6 +59,7 @@ endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
INCLUDES += -I$(srcdir)/../xpath -I$(srcdir)/../xslt
|
||||
INCLUDES += -I$(srcdir)/../xpath -I$(srcdir)/../xslt -I$(srcdir)/../xml \
|
||||
-I$(srcdir)/../xml/dom
|
||||
|
||||
libs:: $(OBJS)
|
||||
|
@ -20,9 +20,13 @@
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
MODULE = transformiix
|
||||
REQUIRES = string \
|
||||
xpcom \
|
||||
unicharutil \
|
||||
dom \
|
||||
content \
|
||||
widget \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
@ -42,7 +46,8 @@ CPP_OBJS= \
|
||||
.\$(OBJDIR)\Map.obj \
|
||||
.\$(OBJDIR)\StringList.obj \
|
||||
.\$(OBJDIR)\Tokenizer.obj \
|
||||
.\$(OBJDIR)\txAtoms.obj
|
||||
.\$(OBJDIR)\txAtoms.obj \
|
||||
.\$(OBJDIR)\txExpandedNameMap.obj
|
||||
|
||||
!ifndef TX_EXE
|
||||
CPP_OBJS = $(CPP_OBJS) \
|
||||
@ -58,7 +63,7 @@ CPP_OBJS = $(CPP_OBJS) \
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
LINCS=-I$(PUBLIC)\xpcom -I..\xpath -I..\xslt
|
||||
LINCS=-I$(PUBLIC)\xpcom -I..\xpath -I..\xslt -I..\xml -I..\xml\dom
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
|
@ -138,6 +138,8 @@ private:
|
||||
|
||||
#define TX_ADDREF_ATOM(atom) {}
|
||||
|
||||
#define TX_IF_ADDREF_ATOM(atom) {}
|
||||
|
||||
#define TX_RELEASE_ATOM(atom) {}
|
||||
|
||||
#define TX_IF_RELEASE_ATOM(atom) {}
|
||||
@ -157,6 +159,8 @@ typedef nsIAtom txAtom;
|
||||
|
||||
#define TX_ADDREF_ATOM(atom) NS_ADDREF(atom)
|
||||
|
||||
#define TX_IF_ADDREF_ATOM(atom) NS_IF_ADDREF(atom)
|
||||
|
||||
#define TX_RELEASE_ATOM(atom) NS_RELEASE(atom)
|
||||
|
||||
#define TX_IF_RELEASE_ATOM(atom) NS_IF_RELEASE(atom)
|
||||
|
@ -40,6 +40,7 @@ OBJS =../base/ArrayList.$(OBJ_SUFFIX) \
|
||||
../base/StringList.$(OBJ_SUFFIX) \
|
||||
../base/Tokenizer.$(OBJ_SUFFIX) \
|
||||
../base/txAtoms.$(OBJ_SUFFIX) \
|
||||
../base/txExpandedNameMap.$(OBJ_SUFFIX) \
|
||||
../base/TxString.$(OBJ_SUFFIX) \
|
||||
../net/URIUtils.$(OBJ_SUFFIX) \
|
||||
../xml/dom/standalone/Attr.$(OBJ_SUFFIX) \
|
||||
|
@ -38,6 +38,7 @@ CPP_OBJS= \
|
||||
../base/$(OBJDIR)/StringList.obj \
|
||||
../base/$(OBJDIR)/Tokenizer.obj \
|
||||
../base/$(OBJDIR)/txAtoms.obj \
|
||||
../base/$(OBJDIR)/txExpandedNameMap.obj \
|
||||
../base/$(OBJDIR)/TxString.obj \
|
||||
../net/$(OBJDIR)/URIUtils.obj \
|
||||
../xml/dom/standalone/$(OBJDIR)/Attr.obj \
|
||||
|
@ -31,17 +31,37 @@
|
||||
|
||||
#include "XMLUtils.h"
|
||||
|
||||
txExpandedName::txExpandedName(PRInt32 aNsID,
|
||||
txAtom* aLocalName) : mNamespaceID(aNsID),
|
||||
mLocalName(aLocalName)
|
||||
nsresult txExpandedName::init(const String& aQName,
|
||||
Node* aResolver,
|
||||
MBool aUseDefault)
|
||||
{
|
||||
if (mLocalName)
|
||||
TX_ADDREF_ATOM(mLocalName);
|
||||
}
|
||||
NS_ASSERTION(aResolver, "missing resolve node");
|
||||
if (!XMLUtils::isValidQName(aQName))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
txExpandedName::~txExpandedName()
|
||||
{
|
||||
TX_IF_RELEASE_ATOM(mLocalName);
|
||||
int idx = aQName.indexOf(':');
|
||||
if (idx >= 0) {
|
||||
String localName, prefixStr;
|
||||
aQName.subString(0, idx, prefixStr);
|
||||
txAtom* prefix = TX_GET_ATOM(prefixStr);
|
||||
PRInt32 namespaceID = aResolver->lookupNamespaceID(prefix);
|
||||
if (namespaceID == kNameSpaceID_Unknown)
|
||||
return NS_ERROR_FAILURE;
|
||||
mNamespaceID = namespaceID;
|
||||
|
||||
aQName.subString(idx+1, localName);
|
||||
TX_IF_RELEASE_ATOM(mLocalName);
|
||||
mLocalName = TX_GET_ATOM(localName);
|
||||
}
|
||||
else {
|
||||
TX_IF_RELEASE_ATOM(mLocalName);
|
||||
mLocalName = TX_GET_ATOM(aQName);
|
||||
if (aUseDefault)
|
||||
mNamespaceID = aResolver->lookupNamespaceID(0);
|
||||
else
|
||||
mNamespaceID = kNameSpaceID_None;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------/
|
||||
@ -111,7 +131,7 @@ MBool XMLUtils::isQNameChar(PRInt32 ch) {
|
||||
/**
|
||||
* Returns true if the given String is a valid XML QName
|
||||
**/
|
||||
MBool XMLUtils::isValidQName(String& name) {
|
||||
MBool XMLUtils::isValidQName(const String& name) {
|
||||
|
||||
if (name.isEmpty())
|
||||
return MB_FALSE;
|
||||
|
@ -32,26 +32,58 @@
|
||||
|
||||
#include "baseutils.h"
|
||||
#include "txAtom.h"
|
||||
#include "dom.h"
|
||||
#include "txError.h"
|
||||
|
||||
class String;
|
||||
|
||||
class txExpandedName {
|
||||
public:
|
||||
txExpandedName(PRInt32 aNsID, txAtom* aLocalName);
|
||||
~txExpandedName();
|
||||
|
||||
MBool
|
||||
operator == (const txExpandedName& rhs)
|
||||
txExpandedName() : mNamespaceID(kNameSpaceID_None),
|
||||
mLocalName(0)
|
||||
{
|
||||
return ((mNamespaceID == rhs.mNamespaceID) &&
|
||||
(mLocalName == rhs.mLocalName));
|
||||
}
|
||||
|
||||
MBool
|
||||
operator != (const txExpandedName& rhs)
|
||||
txExpandedName(PRInt32 aNsID,
|
||||
txAtom* aLocalName) : mNamespaceID(aNsID),
|
||||
mLocalName(aLocalName)
|
||||
{
|
||||
return ((mNamespaceID != rhs.mNamespaceID) ||
|
||||
(mLocalName != rhs.mLocalName));
|
||||
TX_IF_ADDREF_ATOM(mLocalName);
|
||||
}
|
||||
|
||||
txExpandedName(const txExpandedName& aOther) :
|
||||
mNamespaceID(aOther.mNamespaceID),
|
||||
mLocalName(aOther.mLocalName)
|
||||
{
|
||||
TX_IF_ADDREF_ATOM(mLocalName);
|
||||
}
|
||||
|
||||
~txExpandedName()
|
||||
{
|
||||
TX_IF_RELEASE_ATOM(mLocalName);
|
||||
}
|
||||
|
||||
nsresult init(const String& aQName, Node* aResolver, MBool aUseDefault);
|
||||
|
||||
txExpandedName& operator = (const txExpandedName& rhs)
|
||||
{
|
||||
mNamespaceID = rhs.mNamespaceID;
|
||||
TX_IF_RELEASE_ATOM(mLocalName);
|
||||
mLocalName = rhs.mLocalName;
|
||||
TX_IF_ADDREF_ATOM(mLocalName);
|
||||
return *this;
|
||||
}
|
||||
|
||||
MBool operator == (const txExpandedName& rhs) const
|
||||
{
|
||||
return ((mLocalName == rhs.mLocalName) &&
|
||||
(mNamespaceID == rhs.mNamespaceID));
|
||||
}
|
||||
|
||||
MBool operator != (const txExpandedName& rhs) const
|
||||
{
|
||||
return ((mLocalName != rhs.mLocalName) ||
|
||||
(mNamespaceID != rhs.mNamespaceID));
|
||||
}
|
||||
|
||||
PRInt32 mNamespaceID;
|
||||
@ -69,7 +101,7 @@ public:
|
||||
/**
|
||||
* Returns true if the given String is a valid XML QName
|
||||
**/
|
||||
static MBool isValidQName(String& name);
|
||||
static MBool isValidQName(const String& name);
|
||||
|
||||
/**
|
||||
* Returns true if the given string has only whitespace characters
|
||||
|
Loading…
Reference in New Issue
Block a user