mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-25 03:05:34 +00:00
Fix for bug 74786 (String cleanup). Remove Transformiix string wrappers. r=sicking, sr=jst. r=Pike on the Transformiix standalone parts.
This commit is contained in:
parent
1f8e2ba3b9
commit
194a04ac46
@ -1,277 +0,0 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is TransforMiiX XSLT processor.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Keith Visco
|
||||
* Portions created by Keith Visco are
|
||||
* Copyright (C) 1999, 2000 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ArrayList.h"
|
||||
|
||||
/*
|
||||
Implementation of ArrayList
|
||||
*/
|
||||
|
||||
|
||||
//-------------/
|
||||
//- Constants -/
|
||||
//-------------/
|
||||
const int ArrayList::DEFAULT_SIZE = 17;
|
||||
|
||||
|
||||
//----------------/
|
||||
//- Constructors -/
|
||||
//----------------/
|
||||
|
||||
/**
|
||||
* Creates a new ArrayList with the default Size
|
||||
**/
|
||||
ArrayList::ArrayList() {
|
||||
initialize(DEFAULT_SIZE);
|
||||
} //-- ArrayList
|
||||
|
||||
/**
|
||||
* Creates a new ArrayList with the given Size
|
||||
* @param size the size the list should be initialized to
|
||||
**/
|
||||
ArrayList::ArrayList(int size) {
|
||||
initialize(size);
|
||||
} //-- ArrayList
|
||||
|
||||
|
||||
/**
|
||||
* Helper method for Constructors
|
||||
**/
|
||||
void ArrayList::initialize(int size) {
|
||||
elements = new TxObject*[size];
|
||||
for ( int i = 0; i < size; i++ ) elements[i] = 0;
|
||||
elementCount = 0;
|
||||
bufferSize = size;
|
||||
initialSize = size;
|
||||
} //-- initialize
|
||||
|
||||
/**
|
||||
* Destructor for ArrayList, does not delete elements by default
|
||||
**/
|
||||
ArrayList::~ArrayList() {
|
||||
delete [] elements;
|
||||
} //-- ~ArrayList
|
||||
|
||||
/**
|
||||
* Adds the specified TxObject to this ArrayList
|
||||
* @param object the TxObject to add to the ArrayList
|
||||
**/
|
||||
void ArrayList::add(TxObject* object) {
|
||||
if (!object) return;
|
||||
if (elementCount == bufferSize) increaseSize();
|
||||
elements[elementCount++] = object;
|
||||
} //-- add
|
||||
|
||||
/**
|
||||
* Adds the given TxObject to this ArrayList at the specified index.
|
||||
* @param object the TxObject to add
|
||||
* @return true if the object has been properly added at the correct index.
|
||||
**/
|
||||
MBool ArrayList::add(int index, TxObject* object) {
|
||||
|
||||
if ((index < 0) || (index > elementCount)) return MB_FALSE;
|
||||
|
||||
// make sure we have room to add the object
|
||||
if (elementCount == bufferSize) increaseSize();
|
||||
|
||||
if (index == elementCount) {
|
||||
elements[elementCount++] = object;
|
||||
}
|
||||
else {
|
||||
shiftUp(index);
|
||||
elements[index] = object;
|
||||
++elementCount;
|
||||
}
|
||||
return MB_TRUE;
|
||||
} //-- add
|
||||
|
||||
/**
|
||||
* Removes all elements from the list
|
||||
**/
|
||||
void ArrayList::clear() {
|
||||
for (int i = 0; i < elementCount; i++) {
|
||||
elements[i] = 0;
|
||||
}
|
||||
elementCount = 0;
|
||||
} //-- clear
|
||||
|
||||
/**
|
||||
* Removes all elements from the list
|
||||
* @param deleteObjects allows specifying whether or not to delete the TxObjects
|
||||
* that are currently in the list.
|
||||
*
|
||||
* Note: If object deletion is enabled this method will check for duplicate references
|
||||
* in the list to prevent possible seg faults and will therefore run slower than an algorithm
|
||||
* that doesn't check for duplicates.
|
||||
**/
|
||||
void ArrayList::clear(MBool deleteObjects) {
|
||||
|
||||
|
||||
if (deleteObjects) {
|
||||
for (int i = 0; i < elementCount; i++) {
|
||||
if (elements[i]) {
|
||||
TxObject* tmp = elements[i];
|
||||
elements[i] = 0;
|
||||
//-- check for duplicates to avoid attempting to free memory that
|
||||
//-- has already been freed
|
||||
int idx = i+1;
|
||||
for ( ; idx < elementCount; idx++) {
|
||||
if (elements[idx] == tmp) elements[idx] = 0;
|
||||
}
|
||||
delete tmp;
|
||||
}
|
||||
}
|
||||
elementCount = 0;
|
||||
}
|
||||
else clear();
|
||||
|
||||
} //-- clear(MBool);
|
||||
|
||||
/**
|
||||
* Returns true if the specified TxObject is contained in the list.
|
||||
* @param object the TxObject to search for
|
||||
* @return true if specified object is contained in the list
|
||||
**/
|
||||
MBool ArrayList::contains(TxObject* object) {
|
||||
return (MBool)(indexOf(object) >= 0);
|
||||
} //-- contains
|
||||
|
||||
/**
|
||||
* Copies the elements of this ArrayList, into the destination ArrayList
|
||||
**/
|
||||
void ArrayList::copyInto(ArrayList& dest) const {
|
||||
for ( int i = 0; i < elementCount; i++ ) dest.add(elements[i]);
|
||||
} //-- copyInto
|
||||
|
||||
/**
|
||||
* Returns the TxObject at the specified position in this ArrayList.
|
||||
* @param index the position of the object to return, if the index
|
||||
* is out-of-bounds, 0 will be returned.
|
||||
**/
|
||||
TxObject* ArrayList::get(int index) {
|
||||
if ((index < 0) || index >= elementCount) return 0;
|
||||
return elements[index];
|
||||
} //-- get
|
||||
|
||||
|
||||
/**
|
||||
* Returns the index of the specified object,
|
||||
* or -1 if the object is not contained in the ArrayList
|
||||
* @param object the TxObject to get the index of
|
||||
**/
|
||||
int ArrayList::indexOf(TxObject* object) {
|
||||
for (int i = 0; i < elementCount; i++)
|
||||
if (object == elements[i]) return i;
|
||||
return -1;
|
||||
} //-- indexOf
|
||||
|
||||
/**
|
||||
* Removes the TxObject at the specified index
|
||||
* @param index the position of the TxObject to remove
|
||||
* @return the TxObject that was removed from the list
|
||||
**/
|
||||
TxObject* ArrayList::remove(int index) {
|
||||
|
||||
if ((index < 0) || (index >= elementCount)) return 0;
|
||||
|
||||
TxObject* object = elements[index];
|
||||
shiftDown(index+1);
|
||||
--elementCount;
|
||||
return object;
|
||||
} //-- remove
|
||||
|
||||
/**
|
||||
* Removes the the specified TxObject from the list
|
||||
* @param object the TxObject to remove from the list
|
||||
* @return true if the object was removed from the list
|
||||
**/
|
||||
MBool ArrayList::remove(TxObject* object) {
|
||||
|
||||
int index = indexOf(object);
|
||||
|
||||
if (index > -1) {
|
||||
remove(index);
|
||||
}
|
||||
else return MB_FALSE;
|
||||
|
||||
return MB_TRUE;
|
||||
} //-- remove
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of elements in the ArrayList
|
||||
* @return the number of elements in the ArrayList
|
||||
**/
|
||||
int ArrayList::size() const{
|
||||
return elementCount;
|
||||
} //-- size
|
||||
|
||||
//-------------------/
|
||||
//- Private Methods -/
|
||||
//-------------------/
|
||||
|
||||
/**
|
||||
* increase the capacity by a factor of its initial size
|
||||
**/
|
||||
void ArrayList::increaseSize() {
|
||||
|
||||
if (initialSize == 0) bufferSize += DEFAULT_SIZE;
|
||||
else bufferSize += initialSize;
|
||||
|
||||
TxObject** tmp = elements;
|
||||
elements = new TxObject*[bufferSize];
|
||||
int i=0;
|
||||
for (;i < elementCount; i++) elements[i] = tmp[i];
|
||||
for (;i<bufferSize;i++)elements[i] = 0;
|
||||
delete [] tmp;
|
||||
|
||||
} //-- increaseSize
|
||||
|
||||
/**
|
||||
* Shifts all elements at the specified index to down by 1
|
||||
**/
|
||||
void ArrayList::shiftDown(int index) {
|
||||
if ((index <= 0) || (index > elementCount)) return;
|
||||
|
||||
for (int i = index; i < elementCount; i++) {
|
||||
elements[i-1] = elements[i];
|
||||
}
|
||||
|
||||
elements[elementCount-1] = 0;
|
||||
} //-- shiftDown
|
||||
|
||||
/**
|
||||
* Shifts all elements at the specified index up by 1
|
||||
**/
|
||||
void ArrayList::shiftUp(int index) {
|
||||
if (index == elementCount) return;
|
||||
if (elementCount == bufferSize) increaseSize();
|
||||
|
||||
//-- from Java
|
||||
//-- System.arraycopy(elements, index, elements, index + 1, elementCount - index);
|
||||
for (int i = elementCount; i > index; i--) {
|
||||
elements[i] = elements[i-1];
|
||||
}
|
||||
} //-- shiftUp
|
||||
|
||||
|
@ -1,179 +0,0 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is TransforMiiX XSLT processor.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Keith Visco
|
||||
* Portions created by Keith Visco are
|
||||
* Copyright (C) 1999, 2000 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* ArrayList is a simple array which will grow automatically, similar to
|
||||
* the Vector class in that other more popular object oriented programming language.
|
||||
**/
|
||||
|
||||
#ifndef TRANSFRMX_ARRAYLIST_H
|
||||
#define TRANSFRMX_ARRAYLIST_H
|
||||
|
||||
#include "TxObject.h"
|
||||
#include "baseutils.h"
|
||||
|
||||
class ArrayList {
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//----------------/
|
||||
//- Constructors -/
|
||||
//----------------/
|
||||
|
||||
/**
|
||||
* Creates a new ArrayList with the default Size
|
||||
**/
|
||||
ArrayList();
|
||||
|
||||
/**
|
||||
* Creates a new ArrayList with the specified Size
|
||||
**/
|
||||
ArrayList(int size);
|
||||
|
||||
/**
|
||||
* Destructor for ArrayList, will not delete TxObject References
|
||||
* by default
|
||||
**/
|
||||
virtual ~ArrayList();
|
||||
|
||||
/**
|
||||
* Adds the specified TxObject to this ArrayList
|
||||
* @param object the TxObject to add to the ArrayList
|
||||
**/
|
||||
void add(TxObject* object);
|
||||
|
||||
/**
|
||||
* Adds the given TxObject to this ArrayList at the specified index.
|
||||
* @param object the TxObject to add
|
||||
* @return true if the object has been properly added at the correct index.
|
||||
**/
|
||||
MBool add(int index, TxObject* object);
|
||||
|
||||
/**
|
||||
* Removes all elements from the list
|
||||
**/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Removes all elements from the list
|
||||
* @param deleteObjects allows specifying whether or not to delete the TxObjects
|
||||
* that are currently in the list
|
||||
**/
|
||||
void clear(MBool deleteObjects);
|
||||
|
||||
/**
|
||||
* Returns true if the specified TxObject is contained in the list.
|
||||
* @param object the TxObject to search for
|
||||
* @return true if specified object is contained in the list
|
||||
**/
|
||||
MBool contains(TxObject* object);
|
||||
|
||||
/**
|
||||
* Copies the elements of this ArrayList, into the destination ArrayList
|
||||
**/
|
||||
void copyInto(ArrayList& dest) const;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the TxObject at the specified position in this ArrayList.
|
||||
* @param index the position of the object to return, if the index
|
||||
* is out-of-bounds, 0 will be returned.
|
||||
**/
|
||||
TxObject* get(int index);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the index of the specified object,
|
||||
* or -1 if the object is not contained in the ArrayList
|
||||
* @param object the TxObject to get the index of
|
||||
**/
|
||||
int indexOf(TxObject* object);
|
||||
|
||||
/**
|
||||
* Removes the TxObject at the specified index
|
||||
* @param index the position of the TxObject to remove
|
||||
* @return the TxObject that was removed from the list
|
||||
**/
|
||||
TxObject* remove(int index);
|
||||
|
||||
/**
|
||||
* Removes the the specified TxObject from the list
|
||||
* @param object the TxObject to remove from the list
|
||||
* @return true if the object was removed from the list
|
||||
**/
|
||||
MBool remove(TxObject* object);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of elements in the list
|
||||
* @return the number of elements in the list
|
||||
**/
|
||||
int size() const;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
//-------------------/
|
||||
//- Private Members -/
|
||||
//-------------------/
|
||||
|
||||
static const int DEFAULT_SIZE;
|
||||
|
||||
TxObject** elements;
|
||||
|
||||
int initialSize;
|
||||
int bufferSize;
|
||||
|
||||
/**
|
||||
* The next available location in the elements array
|
||||
**/
|
||||
int elementCount;
|
||||
|
||||
//-------------------/
|
||||
//- Private Methods -/
|
||||
//-------------------/
|
||||
|
||||
/**
|
||||
* Helper method for constructors
|
||||
**/
|
||||
void initialize(int size);
|
||||
|
||||
/**
|
||||
* increase the NodeSet capacity by a factor of its initial size
|
||||
**/
|
||||
void increaseSize();
|
||||
|
||||
/**
|
||||
* Shifts all elements at the specified index to down by 1
|
||||
**/
|
||||
void shiftDown(int index);
|
||||
|
||||
/**
|
||||
* Shifts all elements at the specified index up by 1
|
||||
**/
|
||||
void shiftUp(int index);
|
||||
|
||||
}; //-- ArrayList
|
||||
|
||||
#endif
|
@ -1,80 +0,0 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is TransforMiiX XSLT processor.
|
||||
*
|
||||
* The Initial Developer of the Original Code is The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "CommandLineUtils.h"
|
||||
|
||||
void CommandLineUtils::getOptions
|
||||
(NamedMap& options, int argc, char** argv, StringList& flags)
|
||||
{
|
||||
String arg;
|
||||
String flag;
|
||||
for (int i = 0; i < argc; i++) {
|
||||
arg.Truncate();
|
||||
arg.getNSString().AppendWithConversion(argv[i]);
|
||||
|
||||
if (!arg.IsEmpty() && (arg.CharAt(0) == '-')) {
|
||||
|
||||
// clean up previous flag
|
||||
if (!flag.IsEmpty()) {
|
||||
options.put(flag, new String(arg));
|
||||
flag.Truncate();
|
||||
}
|
||||
// get next flag
|
||||
arg.subString(1,flag);
|
||||
|
||||
//-- check full flag, otherwise try to find
|
||||
//-- flag within string
|
||||
if (!flags.contains(flag)) {
|
||||
PRUint32 idx = 1;
|
||||
String tmpFlag;
|
||||
while(idx <= flag.Length()) {
|
||||
flag.subString(0,idx, tmpFlag);
|
||||
if (flags.contains(tmpFlag)) {
|
||||
if (idx < flag.Length()) {
|
||||
String* value = new String();
|
||||
flag.subString(idx, *value);
|
||||
options.put(tmpFlag,value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (idx == flag.Length()) {
|
||||
cout << "invalid option: -" << flag << endl;
|
||||
}
|
||||
++idx;
|
||||
}// end while
|
||||
}
|
||||
}// if flag char '-'
|
||||
else {
|
||||
// Store both flag key and number key
|
||||
if (!flag.IsEmpty())
|
||||
options.put(flag, new String(arg));
|
||||
flag.Truncate();
|
||||
}
|
||||
|
||||
}// end for
|
||||
if (!flag.IsEmpty())
|
||||
options.put(flag, new String(NS_LITERAL_STRING("no value")));
|
||||
} //-- getOptions
|
||||
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is TransforMiiX XSLT processor.
|
||||
*
|
||||
* The Initial Developer of the Original Code is The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TRANSFRMX_COMMANDLINEUTILS_H
|
||||
#define TRANSFRMX_COMMANDLINEUTILS_H
|
||||
|
||||
#include "StringList.h"
|
||||
#include "NamedMap.h"
|
||||
|
||||
class CommandLineUtils {
|
||||
|
||||
public:
|
||||
static void getOptions
|
||||
(NamedMap& options, int argc, char** argv, StringList& flags);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -1,318 +0,0 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is TransforMiiX XSLT processor.
|
||||
*
|
||||
* The Initial Developer of the Original Code is The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
* Bob Miller, kbob@oblix.com
|
||||
* -- plugged core leak.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* StringList
|
||||
**/
|
||||
|
||||
#include "StringList.h"
|
||||
|
||||
/**
|
||||
* Creates an empty list
|
||||
**/
|
||||
StringList::StringList() {
|
||||
firstItem = 0;
|
||||
lastItem = 0;
|
||||
itemCount = 0;
|
||||
} //-- StringList;
|
||||
|
||||
/**
|
||||
* StringList Destructor, Cleans up pointers and will delete the String
|
||||
* references, make sure you make copies of any needed Strings
|
||||
*/
|
||||
StringList::~StringList() {
|
||||
StringListItem* item = firstItem;
|
||||
while (item) {
|
||||
StringListItem* tItem = item;
|
||||
item = item->nextItem;
|
||||
delete tItem->strptr;
|
||||
delete tItem;
|
||||
}
|
||||
} //-- ~StringList
|
||||
|
||||
void StringList::add(String* strptr) {
|
||||
StringListItem* sItem = new StringListItem;
|
||||
if (sItem) {
|
||||
sItem->strptr = strptr;
|
||||
sItem->nextItem = 0;
|
||||
sItem->prevItem = lastItem;
|
||||
}
|
||||
if (lastItem) lastItem->nextItem = sItem;
|
||||
lastItem = sItem;
|
||||
if (!firstItem) firstItem = sItem;
|
||||
|
||||
// increase the item count
|
||||
++itemCount;
|
||||
} //-- add
|
||||
|
||||
MBool StringList::contains(String& search) {
|
||||
StringListItem* sItem = firstItem;
|
||||
while ( sItem ) {
|
||||
if ( search.Equals(*sItem->strptr)) return MB_TRUE;
|
||||
sItem = sItem->nextItem;
|
||||
}
|
||||
return MB_FALSE;
|
||||
} //-- contains
|
||||
|
||||
/**
|
||||
* Returns the number of Strings in this List
|
||||
**/
|
||||
PRInt32 StringList::getLength() {
|
||||
return itemCount;
|
||||
} //-- getLength
|
||||
|
||||
|
||||
/**
|
||||
* Inserts the given String pointer as the item just after refItem.
|
||||
* If refItem is a null pointer the String will inserted at the
|
||||
* beginning of the List (ie, insert after nothing).
|
||||
* This method assumes refItem is a member of this list, and since this
|
||||
* is a private method, I feel that's a valid assumption
|
||||
**/
|
||||
void StringList::insertAfter(String* strptr, StringListItem* refItem) {
|
||||
|
||||
//-- if refItem == null insert at end
|
||||
if (!refItem) {
|
||||
if (firstItem) insertBefore(strptr, firstItem);
|
||||
else add(strptr);
|
||||
return;
|
||||
}
|
||||
|
||||
//-- if inserting at end of list
|
||||
if (refItem == lastItem) {
|
||||
add(strptr);
|
||||
return;
|
||||
}
|
||||
|
||||
//-- insert into middle of list
|
||||
StringListItem* sItem = new StringListItem;
|
||||
if (sItem) {
|
||||
sItem->strptr = strptr;
|
||||
sItem->prevItem = refItem;
|
||||
sItem->nextItem = refItem->nextItem;
|
||||
refItem->nextItem = sItem;
|
||||
|
||||
// increase the item count
|
||||
++itemCount;
|
||||
}
|
||||
} //-- insertAfter
|
||||
|
||||
/**
|
||||
* Inserts the given String pointer as the item just before refItem.
|
||||
* If refItem is a null pointer the String will inserted at the
|
||||
* end of the List (ie, insert before nothing).
|
||||
* This method assumes refItem is a member of this list, and since this
|
||||
* is a private method, I feel that's a valid assumption
|
||||
**/
|
||||
void StringList::insertBefore(String* strptr, StringListItem* refItem) {
|
||||
|
||||
//-- if refItem == null insert at end
|
||||
if (!refItem) {
|
||||
add(strptr);
|
||||
return;
|
||||
}
|
||||
|
||||
StringListItem* sItem = new StringListItem;
|
||||
if (sItem) {
|
||||
sItem->strptr = strptr;
|
||||
sItem->nextItem = refItem;
|
||||
sItem->prevItem = refItem->prevItem;
|
||||
refItem->prevItem = sItem;
|
||||
}
|
||||
|
||||
if (refItem == firstItem) firstItem = sItem;
|
||||
if (itemCount == 0) lastItem = sItem;
|
||||
|
||||
// increase the item count
|
||||
++itemCount;
|
||||
} //-- insertBefore
|
||||
|
||||
/**
|
||||
* Returns a StringListIterator for this StringList, this iterator
|
||||
* will need to be deleted by the caller.
|
||||
**/
|
||||
StringListIterator* StringList::iterator() {
|
||||
return new StringListIterator(this);
|
||||
} //-- iterator
|
||||
|
||||
String* StringList::remove(String* strptr) {
|
||||
StringListItem* sItem = firstItem;
|
||||
while (sItem) {
|
||||
if (sItem->strptr == strptr) {
|
||||
remove(sItem);
|
||||
delete sItem;
|
||||
return strptr;
|
||||
}
|
||||
sItem = sItem->nextItem;
|
||||
}
|
||||
// not in list
|
||||
return 0;
|
||||
} //-- remove
|
||||
|
||||
StringList::StringListItem* StringList::remove(StringList::StringListItem* sItem) {
|
||||
if (sItem->prevItem) {
|
||||
sItem->prevItem->nextItem = sItem->nextItem;
|
||||
}
|
||||
if (sItem == firstItem) firstItem = sItem->nextItem;
|
||||
if (sItem == lastItem) lastItem = sItem->prevItem;
|
||||
//-- decrease Item count
|
||||
--itemCount;
|
||||
return sItem;
|
||||
} //-- remove
|
||||
|
||||
/**
|
||||
* Removes all Strings equal to the given String from the list
|
||||
* All removed strings will be destroyed
|
||||
**/
|
||||
void StringList::remove(String& search) {
|
||||
StringListItem* sItem = firstItem;
|
||||
while (sItem) {
|
||||
if (sItem->strptr->Equals(search)) {
|
||||
delete sItem->strptr;
|
||||
StringListItem* temp = remove(sItem);
|
||||
sItem = sItem->nextItem;
|
||||
delete temp;
|
||||
}
|
||||
else sItem = sItem->nextItem;
|
||||
}
|
||||
} //-- remove
|
||||
|
||||
//----------------------------------------/
|
||||
//- Implementation of StringListIterator -/
|
||||
//----------------------------------------/
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new StringListIterator for the given StringList
|
||||
**/
|
||||
StringListIterator::StringListIterator(StringList* list) {
|
||||
stringList = list;
|
||||
currentItem = 0;
|
||||
allowRemove = MB_FALSE;
|
||||
} //-- StringListIterator
|
||||
|
||||
StringListIterator::~StringListIterator() {
|
||||
//-- overrides default destructor to do nothing
|
||||
} //-- ~StringListIterator
|
||||
|
||||
/**
|
||||
* Adds the String pointer to the StringList of this StringListIterator.
|
||||
* The String pointer is inserted as the next item in the StringList
|
||||
* based on the current position within the StringList
|
||||
**/
|
||||
void StringListIterator::add(String* strptr) {
|
||||
|
||||
stringList->insertAfter(strptr,currentItem);
|
||||
allowRemove = MB_FALSE;
|
||||
|
||||
} //-- add
|
||||
|
||||
/**
|
||||
* Returns true if a sucessful call to the next() method can be made
|
||||
**/
|
||||
MBool StringListIterator::hasNext() {
|
||||
if (currentItem) {
|
||||
return (currentItem->nextItem != 0);
|
||||
}
|
||||
return (stringList->firstItem != 0);
|
||||
} //-- hasNext
|
||||
|
||||
/**
|
||||
* Returns true if a successful call to the previous() method can be made
|
||||
**/
|
||||
MBool StringListIterator::hasPrevious() {
|
||||
if (currentItem) {
|
||||
return (currentItem->prevItem != 0);
|
||||
}
|
||||
return MB_FALSE;
|
||||
} //-- hasPrevious
|
||||
|
||||
/**
|
||||
* Returns the next String in the list
|
||||
**/
|
||||
String* StringListIterator::next() {
|
||||
|
||||
if (currentItem) {
|
||||
if (currentItem->nextItem) {
|
||||
currentItem = currentItem->nextItem;
|
||||
allowRemove = MB_TRUE;
|
||||
return currentItem->strptr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
currentItem = stringList->firstItem;
|
||||
allowRemove = MB_TRUE;
|
||||
if (currentItem)
|
||||
return currentItem->strptr;
|
||||
}
|
||||
return 0;
|
||||
} //-- next
|
||||
|
||||
/**
|
||||
* Returns the previous String in the list
|
||||
**/
|
||||
String* StringListIterator::previous() {
|
||||
|
||||
if (currentItem) {
|
||||
if (currentItem->prevItem) {
|
||||
currentItem = currentItem->prevItem;
|
||||
allowRemove = MB_TRUE;
|
||||
return currentItem->strptr;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
//-- prev
|
||||
|
||||
/**
|
||||
* Removes the String last return by the next() or previous();
|
||||
* The removed String* is returned
|
||||
**/
|
||||
String* StringListIterator::remove() {
|
||||
|
||||
if (allowRemove == MB_FALSE) return 0;
|
||||
|
||||
allowRemove = MB_FALSE;
|
||||
|
||||
StringList::StringListItem* sItem = 0;
|
||||
if (currentItem) {
|
||||
// Make previous Item the current Item or null
|
||||
sItem = currentItem;
|
||||
if (stringList->firstItem == sItem) currentItem = 0;
|
||||
stringList->remove(sItem);
|
||||
return sItem->strptr;
|
||||
}
|
||||
return 0;
|
||||
} //-- remove
|
||||
|
||||
/**
|
||||
* Resets the current location within the StringList to the beginning
|
||||
**/
|
||||
void StringListIterator::reset() {
|
||||
currentItem = 0;
|
||||
} //-- reset
|
@ -1,143 +0,0 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is TransforMiiX XSLT processor.
|
||||
*
|
||||
* The Initial Developer of the Original Code is The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
* Bob Miller, kbob@oblix.com
|
||||
* -- plugged core leak.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* A class for keeping an ordered list of Strings
|
||||
**/
|
||||
|
||||
#ifndef TRANSFRMX_STRINGLIST_H
|
||||
#define TRANSFRMX_STRINGLIST_H
|
||||
|
||||
#include "baseutils.h"
|
||||
#include "TxString.h"
|
||||
|
||||
class StringListIterator;
|
||||
|
||||
class StringList {
|
||||
friend class StringListIterator;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Creates an empty StringList
|
||||
**/
|
||||
StringList();
|
||||
|
||||
/**
|
||||
* StringList destructor
|
||||
**/
|
||||
virtual ~StringList();
|
||||
|
||||
MBool contains(String& search);
|
||||
|
||||
/**
|
||||
* Returns the number of Strings in this List
|
||||
**/
|
||||
PRInt32 getLength();
|
||||
|
||||
/**
|
||||
* Returns a StringListIterator for this StringList
|
||||
**/
|
||||
StringListIterator* iterator();
|
||||
|
||||
/**
|
||||
* Adds the given String to the list
|
||||
**/
|
||||
void add(String* strptr);
|
||||
|
||||
/**
|
||||
* Removes the given String pointer from the list
|
||||
**/
|
||||
String* remove(String* strptr);
|
||||
|
||||
/**
|
||||
* Removes all Strings equal to the given String from the list
|
||||
* All removed strings will be destroyed
|
||||
**/
|
||||
void remove(String& search);
|
||||
|
||||
protected:
|
||||
struct StringListItem {
|
||||
StringListItem* nextItem;
|
||||
StringListItem* prevItem;
|
||||
String* strptr;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
StringListItem* firstItem;
|
||||
StringListItem* lastItem;
|
||||
PRInt32 itemCount;
|
||||
|
||||
void insertAfter(String* strptr, StringListItem* sItem);
|
||||
void insertBefore(String* strptr, StringListItem* sItem);
|
||||
|
||||
/**
|
||||
* Removes the given StringListItem pointer from the list
|
||||
**/
|
||||
StringListItem* remove(StringListItem* sItem);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class StringListIterator {
|
||||
|
||||
public:
|
||||
|
||||
|
||||
StringListIterator(StringList* list);
|
||||
virtual ~StringListIterator();
|
||||
|
||||
void add(String* strptr);
|
||||
|
||||
MBool hasNext();
|
||||
|
||||
MBool hasPrevious();
|
||||
|
||||
String* next();
|
||||
|
||||
String* previous();
|
||||
|
||||
String* remove();
|
||||
|
||||
void reset();
|
||||
|
||||
private:
|
||||
|
||||
StringList::StringListItem* currentItem;
|
||||
|
||||
StringList* stringList;
|
||||
MBool allowRemove;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,109 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* The program provided "as is" without any warranty express or
|
||||
* implied, including the warranty of non-infringement and the implied
|
||||
* warranties of merchantibility and fitness for a particular purpose.
|
||||
* The Copyright owner will not be liable for any damages suffered by
|
||||
* you as a result of using the Program. In no event will the Copyright
|
||||
* owner be liable for any special, indirect or consequential damages or
|
||||
* lost profits even if the Copyright owner has been advised of the
|
||||
* possibility of their occurrence.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Tom Kneeland
|
||||
* -- original author.
|
||||
*
|
||||
* Keith Visco <kvisco@ziplink.net>
|
||||
* Larry Fitzpatrick
|
||||
*
|
||||
*/
|
||||
|
||||
#include "TxString.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
String::String(const PRUnichar* aSource, PRUint32 aLength)
|
||||
{
|
||||
if (aLength) {
|
||||
mString = Substring(aSource, aSource + aLength);
|
||||
}
|
||||
else {
|
||||
mString = nsDependentString(aSource);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
txCaseInsensitiveStringComparator::operator()(const char_type* lhs,
|
||||
const char_type* rhs,
|
||||
PRUint32 aLength ) const
|
||||
{
|
||||
PRUnichar thisChar, otherChar;
|
||||
PRUint32 compLoop = 0;
|
||||
while (compLoop < aLength) {
|
||||
thisChar = lhs[compLoop];
|
||||
if ((thisChar >= 'A') && (thisChar <= 'Z')) {
|
||||
thisChar += 32;
|
||||
}
|
||||
otherChar = rhs[compLoop];
|
||||
if ((otherChar >= 'A') && (otherChar <= 'Z')) {
|
||||
otherChar += 32;
|
||||
}
|
||||
if (thisChar != otherChar) {
|
||||
return thisChar - otherChar;
|
||||
}
|
||||
++compLoop;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
txCaseInsensitiveStringComparator::operator()(char_type lhs,
|
||||
char_type rhs) const
|
||||
{
|
||||
if (lhs >= 'A' && lhs <= 'Z') {
|
||||
lhs += 32;
|
||||
}
|
||||
if (rhs >= 'A' && rhs <= 'Z') {
|
||||
rhs += 32;
|
||||
}
|
||||
return lhs - rhs;
|
||||
}
|
||||
|
||||
void String::toLowerCase()
|
||||
{
|
||||
nsAFlatString::char_iterator c, e;
|
||||
mString.BeginWriting(c);
|
||||
mString.EndWriting(e);
|
||||
while (c != e) {
|
||||
if (*c >= 'A' && *c <= 'Z')
|
||||
*c += 32;
|
||||
++c;
|
||||
}
|
||||
}
|
||||
|
||||
void String::toUpperCase()
|
||||
{
|
||||
nsAFlatString::char_iterator c, e;
|
||||
mString.BeginWriting(c);
|
||||
mString.EndWriting(e);
|
||||
while (c != e) {
|
||||
if (*c >= 'a' && *c <= 'z')
|
||||
*c -= 32;
|
||||
++c;
|
||||
}
|
||||
}
|
||||
|
||||
ostream& operator<<(ostream& aOutput, const String& aSource)
|
||||
{
|
||||
aOutput << NS_LossyConvertUCS2toASCII(aSource.mString).get();
|
||||
return aOutput;
|
||||
}
|
@ -1,204 +0,0 @@
|
||||
/*
|
||||
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* The program provided "as is" without any warranty express or
|
||||
* implied, including the warranty of non-infringement and the implied
|
||||
* warranties of merchantibility and fitness for a particular purpose.
|
||||
* The Copyright owner will not be liable for any damages suffered by
|
||||
* you as a result of using the Program. In no event will the Copyright
|
||||
* owner be liable for any special, indirect or consequential damages or
|
||||
* lost profits even if the Copyright owner has been advised of the
|
||||
* possibility of their occurrence.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Tom Kneeland
|
||||
* -- original author.
|
||||
*
|
||||
* Keith Visco <kvisco@ziplink.net>
|
||||
* Larry Fitzpatrick
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef txString_h__
|
||||
#define txString_h__
|
||||
|
||||
#include "baseutils.h"
|
||||
|
||||
#include "TxObject.h"
|
||||
#include <iostream.h>
|
||||
#include "nsString.h"
|
||||
|
||||
#ifdef TX_EXE
|
||||
class txCaseInsensitiveStringComparator
|
||||
: public nsStringComparator
|
||||
{
|
||||
public:
|
||||
virtual int operator()(const char_type*, const char_type*, PRUint32 aLength) const;
|
||||
virtual int operator()(char_type, char_type) const;
|
||||
};
|
||||
#endif
|
||||
|
||||
class String
|
||||
: public TxObject
|
||||
{
|
||||
public:
|
||||
/*
|
||||
* Default constructor.
|
||||
*/
|
||||
String();
|
||||
|
||||
/*
|
||||
* Copying constructor.
|
||||
*/
|
||||
String(const String& aSource);
|
||||
|
||||
#ifdef TX_EXE
|
||||
/*
|
||||
* Constructor, allocates a buffer and copies the supplied string buffer.
|
||||
* If aLength is zero it computes the length from the supplied string.
|
||||
*/
|
||||
explicit String(const PRUnichar* aSource, PRUint32 aLength = 0);
|
||||
#endif
|
||||
explicit String(const nsAString& aSource);
|
||||
~String();
|
||||
|
||||
/*
|
||||
* Append aSource to this string.
|
||||
*/
|
||||
void Append(PRUnichar aSource);
|
||||
void Append(const String& aSource);
|
||||
void Append(const PRUnichar* aSource, PRUint32 aLength);
|
||||
void Append(const nsAString& aSource);
|
||||
|
||||
/*
|
||||
* Insert aSource at aOffset in this string.
|
||||
*/
|
||||
void insert(PRUint32 aOffset, PRUnichar aSource);
|
||||
void insert(PRUint32 aOffset, const String& aSource);
|
||||
|
||||
/*
|
||||
* Replace characters starting at aOffset with aSource.
|
||||
*/
|
||||
void replace(PRUint32 aOffset, PRUnichar aSource);
|
||||
void replace(PRUint32 aOffset, const String& aSource);
|
||||
|
||||
/*
|
||||
* Delete aCount characters starting at aOffset.
|
||||
*/
|
||||
void Cut(PRUint32 aOffset, PRUint32 aCount);
|
||||
|
||||
/*
|
||||
* Returns the character at aIndex. Caller needs to check the
|
||||
* index for out-of-bounds errors.
|
||||
*/
|
||||
PRUnichar CharAt(PRUint32 aIndex) const;
|
||||
|
||||
/*
|
||||
* Returns index of first occurrence of aData.
|
||||
*/
|
||||
PRInt32 indexOf(PRUnichar aData,
|
||||
PRInt32 aOffset = 0) const;
|
||||
PRInt32 indexOf(const String& aData, PRInt32 aOffset = 0) const;
|
||||
|
||||
/*
|
||||
* Returns index of last occurrence of aData.
|
||||
*/
|
||||
PRInt32 RFindChar(PRUnichar aData,
|
||||
PRInt32 aOffset = -1) const;
|
||||
|
||||
/*
|
||||
* Check equality between strings.
|
||||
*/
|
||||
MBool Equals(const String& aData) const;
|
||||
|
||||
/*
|
||||
* Check equality (ignoring case) between strings.
|
||||
*/
|
||||
MBool isEqualIgnoreCase(const String& aData) const;
|
||||
|
||||
/*
|
||||
* Check whether the string is empty.
|
||||
*/
|
||||
MBool IsEmpty() const;
|
||||
|
||||
/*
|
||||
* Return the length of the string.
|
||||
*/
|
||||
PRUint32 Length() const;
|
||||
|
||||
/*
|
||||
* Returns a substring starting at start
|
||||
* Note: the dest String is cleared before use
|
||||
*/
|
||||
String& subString(PRUint32 aStart, String& aDest) const;
|
||||
|
||||
/*
|
||||
* Returns the subString starting at start and ending at end
|
||||
* Note: the dest String is cleared before use
|
||||
*/
|
||||
String& subString(PRUint32 aStart, PRUint32 aEnd,
|
||||
String& aDest) const;
|
||||
|
||||
/*
|
||||
* Convert string to lowercase.
|
||||
*/
|
||||
void toLowerCase();
|
||||
|
||||
/*
|
||||
* Convert string to uppercase.
|
||||
*/
|
||||
void toUpperCase();
|
||||
|
||||
/*
|
||||
* Shorten the string to aLength.
|
||||
*/
|
||||
void Truncate(PRUint32 aLength = 0);
|
||||
|
||||
/*
|
||||
* Return a reference to this string's nsString.
|
||||
*/
|
||||
operator nsAString&();
|
||||
|
||||
/*
|
||||
* Return a const reference to this string's nsString.
|
||||
*/
|
||||
operator const nsAString&() const;
|
||||
|
||||
private:
|
||||
nsString mString;
|
||||
|
||||
friend ostream& operator << (ostream& aOutput, const String& aSource);
|
||||
|
||||
// XXX NOT IMPLEMENTED
|
||||
explicit String(PRUint32 aSize);
|
||||
explicit String(char* aSource);
|
||||
explicit String(char aSource);
|
||||
void Append(char* aSource);
|
||||
void Append(char aSource);
|
||||
MBool Equals(char* aSource);
|
||||
MBool Equals(char aSource);
|
||||
// XXX NOT IMPLEMENTED
|
||||
|
||||
// XXX DEPRECATED
|
||||
public:
|
||||
nsString& getNSString();
|
||||
const nsString& getConstNSString() const;
|
||||
// XXX DEPRECATED
|
||||
};
|
||||
|
||||
/*
|
||||
* Translate PRUnichars to Chars and output to the provided stream.
|
||||
*/
|
||||
ostream& operator << (ostream& aOutput, const String& aSource);
|
||||
|
||||
// txMozillaString.h contains all inline implementations for the
|
||||
// Mozilla module.
|
||||
#include "txMozillaString.h"
|
||||
|
||||
#endif // txString_h__
|
@ -1,228 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Peter Van der Beken <peterv@netscape.com>
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef txMozillaString_h__
|
||||
#define txMozillaString_h__
|
||||
|
||||
#include "nsReadableUtils.h"
|
||||
#ifndef TX_EXE
|
||||
#include "nsUnicharUtils.h"
|
||||
typedef nsCaseInsensitiveStringComparator txCaseInsensitiveStringComparator;
|
||||
#endif
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(String)
|
||||
|
||||
inline String::String()
|
||||
{
|
||||
MOZ_COUNT_CTOR(String);
|
||||
}
|
||||
|
||||
inline String::String(const String& aSource) : mString(aSource.mString)
|
||||
{
|
||||
MOZ_COUNT_CTOR(String);
|
||||
}
|
||||
|
||||
inline String::String(const nsAString& aSource) : mString(aSource)
|
||||
{
|
||||
MOZ_COUNT_CTOR(String);
|
||||
}
|
||||
|
||||
inline String::~String()
|
||||
{
|
||||
MOZ_COUNT_DTOR(String);
|
||||
}
|
||||
|
||||
inline void String::Append(PRUnichar aSource)
|
||||
{
|
||||
mString.Append(aSource);
|
||||
}
|
||||
|
||||
inline void String::Append(const String& aSource)
|
||||
{
|
||||
mString.Append(aSource.mString);
|
||||
}
|
||||
|
||||
inline void String::Append(const PRUnichar* aSource, PRUint32 aLength)
|
||||
{
|
||||
mString.Append(aSource, aLength);
|
||||
}
|
||||
|
||||
inline void String::Append(const nsAString& aSource)
|
||||
{
|
||||
mString.Append(aSource);
|
||||
}
|
||||
|
||||
inline void String::insert(PRUint32 aOffset,
|
||||
PRUnichar aSource)
|
||||
{
|
||||
mString.Insert(aSource, aOffset);
|
||||
}
|
||||
|
||||
inline void String::insert(PRUint32 aOffset, const String& aSource)
|
||||
{
|
||||
mString.Insert(aSource.mString, aOffset);
|
||||
}
|
||||
|
||||
inline void String::replace(PRUint32 aOffset,
|
||||
PRUnichar aSource)
|
||||
{
|
||||
mString.SetCharAt(aSource, aOffset);
|
||||
}
|
||||
|
||||
inline void String::replace(PRUint32 aOffset, const String& aSource)
|
||||
{
|
||||
mString.Replace(aOffset, mString.Length() - aOffset, aSource.mString);
|
||||
}
|
||||
|
||||
inline void String::Cut(PRUint32 aOffset, PRUint32 aCount)
|
||||
{
|
||||
mString.Cut(aOffset, aCount);
|
||||
}
|
||||
|
||||
inline PRUnichar String::CharAt(PRUint32 aIndex) const
|
||||
{
|
||||
return mString.CharAt(aIndex);
|
||||
}
|
||||
|
||||
inline PRInt32 String::indexOf(PRUnichar aData,
|
||||
PRInt32 aOffset) const
|
||||
{
|
||||
return mString.FindChar(aData, (PRUint32)aOffset);
|
||||
}
|
||||
|
||||
inline PRInt32 String::indexOf(const String& aData,
|
||||
PRInt32 aOffset) const
|
||||
{
|
||||
return mString.Find(aData.mString, aOffset);
|
||||
}
|
||||
|
||||
inline PRInt32 String::RFindChar(PRUnichar aData, PRInt32 aOffset) const
|
||||
{
|
||||
return mString.RFindChar(aData, aOffset);
|
||||
}
|
||||
|
||||
inline MBool String::Equals(const String& aData) const
|
||||
{
|
||||
return mString.Equals(aData.mString);
|
||||
}
|
||||
|
||||
inline MBool String::isEqualIgnoreCase(const String& aData) const
|
||||
{
|
||||
if (this == &aData)
|
||||
return MB_TRUE;
|
||||
return mString.Equals(aData.mString, txCaseInsensitiveStringComparator());
|
||||
}
|
||||
|
||||
inline MBool String::IsEmpty() const
|
||||
{
|
||||
return mString.IsEmpty();
|
||||
}
|
||||
|
||||
inline PRUint32 String::Length() const
|
||||
{
|
||||
return mString.Length();
|
||||
}
|
||||
|
||||
inline void String::Truncate(PRUint32 aLength)
|
||||
{
|
||||
mString.Truncate(aLength);
|
||||
}
|
||||
|
||||
inline String& String::subString(PRUint32 aStart, String& aDest) const
|
||||
{
|
||||
PRUint32 length = mString.Length();
|
||||
if (aStart < length) {
|
||||
aDest.mString.Assign(Substring(mString, aStart, length - aStart));
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(aStart == length,
|
||||
"Bonehead! Calling subString with negative length.");
|
||||
aDest.Truncate();
|
||||
}
|
||||
return aDest;
|
||||
}
|
||||
|
||||
inline String& String::subString(PRUint32 aStart, PRUint32 aEnd,
|
||||
String& aDest) const
|
||||
{
|
||||
if (aStart < aEnd) {
|
||||
aDest.mString.Assign(Substring(mString, aStart, aEnd - aStart));
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(aStart == aEnd,
|
||||
"Bonehead! Calling subString with negative length.");
|
||||
aDest.Truncate();
|
||||
}
|
||||
return aDest;
|
||||
}
|
||||
|
||||
#ifndef TX_EXE
|
||||
inline void String::toLowerCase()
|
||||
{
|
||||
ToLowerCase(mString);
|
||||
}
|
||||
|
||||
inline void String::toUpperCase()
|
||||
{
|
||||
ToUpperCase(mString);
|
||||
}
|
||||
#endif
|
||||
|
||||
inline String::operator nsAString&()
|
||||
{
|
||||
return mString;
|
||||
}
|
||||
|
||||
inline String::operator const nsAString&() const
|
||||
{
|
||||
return mString;
|
||||
}
|
||||
|
||||
// XXX DEPRECATED
|
||||
inline nsString& String::getNSString()
|
||||
{
|
||||
return mString;
|
||||
}
|
||||
|
||||
inline const nsString& String::getConstNSString() const
|
||||
{
|
||||
return mString;
|
||||
}
|
||||
|
||||
#endif // txMozillaString_h__
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is TransforMiiX XSLT processor.
|
||||
*
|
||||
* The Initial Developer of the Original Code is The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999, 2000 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
* Marina Mechtcheriakova, mmarina@mindspring.com
|
||||
* -- Removed the trailing "s" from FOLLOWING_SIBLING_AXIS, and
|
||||
* PRECEDING_SIBLING_AXIS to be compatible with the
|
||||
* W3C XPath 1.0 Recommendation
|
||||
* -- Added lang attr declaration
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* XSL names used throughout the XSLProcessor.
|
||||
* Probably should be wrapped in a Namespace
|
||||
**/
|
||||
#include "Names.h"
|
||||
|
||||
//-- Global Strings
|
||||
const String STYLESHEET_PI(NS_LITERAL_STRING("xml-stylesheet"));
|
||||
const String STYLESHEET_PI_OLD(NS_LITERAL_STRING("xml:stylesheet"));
|
||||
const String XSL_MIME_TYPE(NS_LITERAL_STRING("text/xsl"));
|
||||
|
||||
//-- Attribute Values
|
||||
const String ASCENDING_VALUE(NS_LITERAL_STRING("ascending"));
|
||||
const String DESCENDING_VALUE(NS_LITERAL_STRING("descending"));
|
||||
const String LOWER_FIRST_VALUE(NS_LITERAL_STRING("lower-first"));
|
||||
const String NUMBER_VALUE(NS_LITERAL_STRING("number"));
|
||||
const String TEXT_VALUE(NS_LITERAL_STRING("text"));
|
||||
const String UPPER_FIRST_VALUE(NS_LITERAL_STRING("upper-first"));
|
||||
const String YES_VALUE(NS_LITERAL_STRING("yes"));
|
||||
|
||||
//-- Stylesheet attributes
|
||||
const String ANCESTOR_AXIS(NS_LITERAL_STRING("ancestor"));
|
||||
const String ANCESTOR_OR_SELF_AXIS(NS_LITERAL_STRING("ancestor-or-self"));
|
||||
const String ATTRIBUTE_AXIS(NS_LITERAL_STRING("attribute"));
|
||||
const String CHILD_AXIS(NS_LITERAL_STRING("child"));
|
||||
const String DESCENDANT_AXIS(NS_LITERAL_STRING("descendant"));
|
||||
const String DESCENDANT_OR_SELF_AXIS(NS_LITERAL_STRING("descendant-or-self"));
|
||||
const String FOLLOWING_AXIS(NS_LITERAL_STRING("following"));
|
||||
const String FOLLOWING_SIBLING_AXIS(NS_LITERAL_STRING("following-sibling"));
|
||||
const String NAMESPACE_AXIS(NS_LITERAL_STRING("namespace"));
|
||||
const String PARENT_AXIS(NS_LITERAL_STRING("parent"));
|
||||
const String PRECEDING_AXIS(NS_LITERAL_STRING("preceding"));
|
||||
const String PRECEDING_SIBLING_AXIS(NS_LITERAL_STRING("preceding-sibling"));
|
||||
const String SELF_AXIS(NS_LITERAL_STRING("self"));
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is TransforMiiX XSLT processor.
|
||||
*
|
||||
* The Initial Developer of the Original Code is The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
* Marina Mechtcheriakova, mmarina@mindspring.com
|
||||
* -- Removed the trailing "s" from FOLLOWING_SIBLING_AXIS, and
|
||||
* PRECEDING_SIBLING_AXIS to be compatible with the
|
||||
* W3C XPath 1.0 Recommendation
|
||||
* -- Added lang attr declaration
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TRANSFRMX_NAMES_H
|
||||
#define TRANSFRMX_NAMES_H
|
||||
|
||||
#include "TxString.h"
|
||||
|
||||
//-- Global Strings
|
||||
extern const String STYLESHEET_PI;
|
||||
extern const String STYLESHEET_PI_OLD;
|
||||
extern const String XSL_MIME_TYPE;
|
||||
|
||||
//-- Attribute Values
|
||||
extern const String ASCENDING_VALUE;
|
||||
extern const String DESCENDING_VALUE;
|
||||
extern const String LOWER_FIRST_VALUE;
|
||||
extern const String NUMBER_VALUE;
|
||||
extern const String TEXT_VALUE;
|
||||
extern const String UPPER_FIRST_VALUE;
|
||||
extern const String YES_VALUE;
|
||||
|
||||
//-- Stylesheet attributes
|
||||
extern const String ANCESTOR_AXIS;
|
||||
extern const String ANCESTOR_OR_SELF_AXIS;
|
||||
extern const String ATTRIBUTE_AXIS;
|
||||
extern const String CHILD_AXIS;
|
||||
extern const String DESCENDANT_AXIS;
|
||||
extern const String DESCENDANT_OR_SELF_AXIS;
|
||||
extern const String FOLLOWING_AXIS;
|
||||
extern const String FOLLOWING_SIBLING_AXIS;
|
||||
extern const String NAMESPACE_AXIS;
|
||||
extern const String PARENT_AXIS;
|
||||
extern const String PRECEDING_AXIS;
|
||||
extern const String PRECEDING_SIBLING_AXIS;
|
||||
extern const String SELF_AXIS;
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user