Compare commits
1 Commits
tags/AMO2_
...
CVS
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5d6b83e4c |
617
mozilla/htmlparser/src/nsAVLTree.cpp
Normal file
@@ -0,0 +1,617 @@
|
||||
/* -*- 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) 1999 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsAVLTree.h"
|
||||
|
||||
|
||||
enum eLean {eLeft,eNeutral,eRight};
|
||||
|
||||
struct NS_COM nsAVLNode {
|
||||
public:
|
||||
|
||||
nsAVLNode(void* aValue) {
|
||||
mLeft=0;
|
||||
mRight=0;
|
||||
mSkew=eNeutral;
|
||||
mValue=aValue;
|
||||
}
|
||||
|
||||
nsAVLNode* mLeft;
|
||||
nsAVLNode* mRight;
|
||||
eLean mSkew;
|
||||
void* mValue;
|
||||
};
|
||||
|
||||
|
||||
/************************************************************
|
||||
Now begin the tree class. Don't forget that the comparison
|
||||
between nodes must occur via the comparitor function,
|
||||
otherwise all you're testing is pointer addresses.
|
||||
************************************************************/
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
nsAVLTree::nsAVLTree(nsAVLNodeComparitor& aComparitor,
|
||||
nsAVLNodeFunctor* aDeallocator) :
|
||||
mComparitor(aComparitor), mDeallocator(aDeallocator) {
|
||||
mRoot=0;
|
||||
mCount=0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
avlDeleteTree(nsAVLNode* aNode){
|
||||
if (aNode) {
|
||||
avlDeleteTree(aNode->mLeft);
|
||||
avlDeleteTree(aNode->mRight);
|
||||
delete aNode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/27/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsAVLTree::~nsAVLTree(){
|
||||
if (mDeallocator) {
|
||||
ForEachDepthFirst(*mDeallocator);
|
||||
}
|
||||
avlDeleteTree(mRoot);
|
||||
}
|
||||
|
||||
|
||||
class CDoesntExist: public nsAVLNodeFunctor {
|
||||
public:
|
||||
CDoesntExist(const nsAVLTree& anotherTree) : mOtherTree(anotherTree) {
|
||||
}
|
||||
virtual void* operator()(void* anItem) {
|
||||
void* result=mOtherTree.FindItem(anItem);
|
||||
if(result)
|
||||
return nsnull;
|
||||
return anItem;
|
||||
}
|
||||
protected:
|
||||
const nsAVLTree& mOtherTree;
|
||||
};
|
||||
|
||||
/**
|
||||
* This method compares two trees (members by identity).
|
||||
* @update gess12/27/98
|
||||
* @param tree to compare against
|
||||
* @return true if they are identical (contain same stuff).
|
||||
*/
|
||||
PRBool nsAVLTree::operator==(const nsAVLTree& aCopy) const{
|
||||
CDoesntExist functor(aCopy);
|
||||
void* theItem=FirstThat(functor);
|
||||
PRBool result=PRBool(!theItem);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/27/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
static void
|
||||
avlRotateRight(nsAVLNode*& aRootNode){
|
||||
nsAVLNode* ptr2;
|
||||
nsAVLNode* ptr3;
|
||||
|
||||
ptr2=aRootNode->mRight;
|
||||
if(ptr2->mSkew==eRight) {
|
||||
aRootNode->mRight=ptr2->mLeft;
|
||||
ptr2->mLeft=aRootNode;
|
||||
aRootNode->mSkew=eNeutral;
|
||||
aRootNode=ptr2;
|
||||
}
|
||||
else {
|
||||
ptr3=ptr2->mLeft;
|
||||
ptr2->mLeft=ptr3->mRight;
|
||||
ptr3->mRight=ptr2;
|
||||
aRootNode->mRight=ptr3->mLeft;
|
||||
ptr3->mLeft=aRootNode;
|
||||
if(ptr3->mSkew==eLeft)
|
||||
ptr2->mSkew=eRight;
|
||||
else ptr2->mSkew=eNeutral;
|
||||
if(ptr3->mSkew==eRight)
|
||||
aRootNode->mSkew=eLeft;
|
||||
else aRootNode->mSkew=eNeutral;
|
||||
aRootNode=ptr3;
|
||||
}
|
||||
aRootNode->mSkew=eNeutral;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/27/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
static void
|
||||
avlRotateLeft(nsAVLNode*& aRootNode){
|
||||
nsAVLNode* ptr2;
|
||||
nsAVLNode* ptr3;
|
||||
|
||||
ptr2=aRootNode->mLeft;
|
||||
if(ptr2->mSkew==eLeft) {
|
||||
aRootNode->mLeft=ptr2->mRight;
|
||||
ptr2->mRight=aRootNode;
|
||||
aRootNode->mSkew=eNeutral;
|
||||
aRootNode=ptr2;
|
||||
}
|
||||
else {
|
||||
ptr3=ptr2->mRight;
|
||||
ptr2->mRight=ptr3->mLeft;
|
||||
ptr3->mLeft=ptr2;
|
||||
aRootNode->mLeft=ptr3->mRight;
|
||||
ptr3->mRight=aRootNode;
|
||||
if(ptr3->mSkew==eRight)
|
||||
ptr2->mSkew=eLeft;
|
||||
else ptr2->mSkew=eNeutral;
|
||||
if(ptr3->mSkew==eLeft)
|
||||
aRootNode->mSkew=eRight;
|
||||
else aRootNode->mSkew=eNeutral;
|
||||
aRootNode=ptr3;
|
||||
}
|
||||
aRootNode->mSkew=eNeutral;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
static eAVLStatus
|
||||
avlInsert(nsAVLNode*& aRootNode, nsAVLNode* aNewNode,
|
||||
nsAVLNodeComparitor& aComparitor) {
|
||||
eAVLStatus result=eAVL_unknown;
|
||||
|
||||
if(!aRootNode) {
|
||||
aRootNode = aNewNode;
|
||||
return eAVL_ok;
|
||||
}
|
||||
|
||||
if(aNewNode==aRootNode->mValue) {
|
||||
return eAVL_duplicate;
|
||||
}
|
||||
|
||||
PRInt32 theCompareResult=aComparitor(aRootNode->mValue,aNewNode->mValue);
|
||||
if(0 < theCompareResult) { //if(anItem<aRootNode->mValue)
|
||||
result=avlInsert(aRootNode->mLeft,aNewNode,aComparitor);
|
||||
if(eAVL_ok==result) {
|
||||
switch(aRootNode->mSkew){
|
||||
case eLeft:
|
||||
avlRotateLeft(aRootNode);
|
||||
result=eAVL_fail;
|
||||
break;
|
||||
case eRight:
|
||||
aRootNode->mSkew=eNeutral;
|
||||
result=eAVL_fail;
|
||||
break;
|
||||
case eNeutral:
|
||||
aRootNode->mSkew=eLeft;
|
||||
break;
|
||||
} //switch
|
||||
}//if
|
||||
} //if
|
||||
else {
|
||||
result=avlInsert(aRootNode->mRight,aNewNode,aComparitor);
|
||||
if(eAVL_ok==result) {
|
||||
switch(aRootNode->mSkew){
|
||||
case eLeft:
|
||||
aRootNode->mSkew=eNeutral;
|
||||
result=eAVL_fail;
|
||||
break;
|
||||
case eRight:
|
||||
avlRotateRight(aRootNode);
|
||||
result=eAVL_fail;
|
||||
break;
|
||||
case eNeutral:
|
||||
aRootNode->mSkew=eRight;
|
||||
break;
|
||||
} //switch
|
||||
}
|
||||
} //if
|
||||
return result;
|
||||
}
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
static void
|
||||
avlBalanceLeft(nsAVLNode*& aRootNode, PRBool& delOk){
|
||||
nsAVLNode* ptr2;
|
||||
nsAVLNode* ptr3;
|
||||
eLean balnc2;
|
||||
eLean balnc3;
|
||||
|
||||
switch(aRootNode->mSkew){
|
||||
case eLeft:
|
||||
ptr2=aRootNode->mLeft;
|
||||
balnc2=ptr2->mSkew;
|
||||
if(balnc2!=eRight) {
|
||||
aRootNode->mLeft=ptr2->mRight;
|
||||
ptr2->mRight=aRootNode;
|
||||
if(balnc2==eNeutral){
|
||||
aRootNode->mSkew=eLeft;
|
||||
ptr2->mSkew=eRight;
|
||||
delOk=PR_FALSE;
|
||||
}
|
||||
else{
|
||||
aRootNode->mSkew=eNeutral;
|
||||
ptr2->mSkew=eNeutral;
|
||||
}
|
||||
aRootNode=ptr2;
|
||||
}
|
||||
else{
|
||||
ptr3=ptr2->mRight;
|
||||
balnc3=ptr3->mSkew;
|
||||
ptr2->mRight=ptr3->mLeft;
|
||||
ptr3->mLeft=ptr2;
|
||||
aRootNode->mLeft=ptr3->mRight;
|
||||
ptr3->mRight=aRootNode;
|
||||
if(balnc3==eRight) {
|
||||
ptr2->mSkew=eLeft;
|
||||
}
|
||||
else {
|
||||
ptr2->mSkew=eNeutral;
|
||||
}
|
||||
if(balnc3==eLeft) {
|
||||
aRootNode->mSkew=eRight;
|
||||
}
|
||||
else {
|
||||
aRootNode->mSkew=eNeutral;
|
||||
}
|
||||
aRootNode=ptr3;
|
||||
ptr3->mSkew=eNeutral;
|
||||
}
|
||||
break;
|
||||
|
||||
case eRight:
|
||||
aRootNode->mSkew=eNeutral;
|
||||
break;
|
||||
|
||||
case eNeutral:
|
||||
aRootNode->mSkew=eLeft;
|
||||
delOk=PR_FALSE;
|
||||
break;
|
||||
}//switch
|
||||
return;
|
||||
}
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
static void
|
||||
avlBalanceRight(nsAVLNode*& aRootNode, PRBool& delOk){
|
||||
nsAVLNode* ptr2;
|
||||
nsAVLNode* ptr3;
|
||||
eLean balnc2;
|
||||
eLean balnc3;
|
||||
|
||||
switch(aRootNode->mSkew){
|
||||
case eLeft:
|
||||
aRootNode->mSkew=eNeutral;
|
||||
break;
|
||||
|
||||
case eRight:
|
||||
ptr2=aRootNode->mRight;
|
||||
balnc2=ptr2->mSkew;
|
||||
if(balnc2!=eLeft) {
|
||||
aRootNode->mRight=ptr2->mLeft;
|
||||
ptr2->mLeft=aRootNode;
|
||||
if(balnc2==eNeutral){
|
||||
aRootNode->mSkew=eRight;
|
||||
ptr2->mSkew=eLeft;
|
||||
delOk=PR_FALSE;
|
||||
}
|
||||
else{
|
||||
aRootNode->mSkew=eNeutral;
|
||||
ptr2->mSkew=eNeutral;
|
||||
}
|
||||
aRootNode=ptr2;
|
||||
}
|
||||
else{
|
||||
ptr3=ptr2->mLeft;
|
||||
balnc3=ptr3->mSkew;
|
||||
ptr2->mLeft=ptr3->mRight;
|
||||
ptr3->mRight=ptr2;
|
||||
aRootNode->mRight=ptr3->mLeft;
|
||||
ptr3->mLeft=aRootNode;
|
||||
if(balnc3==eLeft) {
|
||||
ptr2->mSkew=eRight;
|
||||
}
|
||||
else {
|
||||
ptr2->mSkew=eNeutral;
|
||||
}
|
||||
if(balnc3==eRight) {
|
||||
aRootNode->mSkew=eLeft;
|
||||
}
|
||||
else {
|
||||
aRootNode->mSkew=eNeutral;
|
||||
}
|
||||
aRootNode=ptr3;
|
||||
ptr3->mSkew=eNeutral;
|
||||
}
|
||||
break;
|
||||
|
||||
case eNeutral:
|
||||
aRootNode->mSkew=eRight;
|
||||
delOk=PR_FALSE;
|
||||
break;
|
||||
}//switch
|
||||
return;
|
||||
}
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
static eAVLStatus
|
||||
avlRemoveChildren(nsAVLNode*& aRootNode,nsAVLNode*& anotherNode, PRBool& delOk){
|
||||
eAVLStatus result=eAVL_ok;
|
||||
|
||||
if(!anotherNode->mRight){
|
||||
aRootNode->mValue=anotherNode->mValue; //swap
|
||||
anotherNode=anotherNode->mLeft;
|
||||
delOk=PR_TRUE;
|
||||
}
|
||||
else{
|
||||
avlRemoveChildren(aRootNode,anotherNode->mRight,delOk);
|
||||
if(delOk)
|
||||
avlBalanceLeft(anotherNode,delOk);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
static eAVLStatus
|
||||
avlRemove(nsAVLNode*& aRootNode, void* anItem, PRBool& delOk,
|
||||
nsAVLNodeComparitor& aComparitor){
|
||||
eAVLStatus result=eAVL_ok;
|
||||
|
||||
if(!aRootNode)
|
||||
delOk=PR_FALSE;
|
||||
else {
|
||||
PRInt32 cmp=aComparitor(anItem,aRootNode->mValue);
|
||||
if(cmp<0){
|
||||
avlRemove(aRootNode->mLeft,anItem,delOk,aComparitor);
|
||||
if(delOk)
|
||||
avlBalanceRight(aRootNode,delOk);
|
||||
}
|
||||
else if(cmp>0){
|
||||
avlRemove(aRootNode->mRight,anItem,delOk,aComparitor);
|
||||
if(delOk)
|
||||
avlBalanceLeft(aRootNode,delOk);
|
||||
}
|
||||
else{ //they match...
|
||||
nsAVLNode* temp=aRootNode;
|
||||
if(!aRootNode->mRight) {
|
||||
aRootNode=aRootNode->mLeft;
|
||||
delOk=PR_TRUE;
|
||||
delete temp;
|
||||
}
|
||||
else if(!aRootNode->mLeft) {
|
||||
aRootNode=aRootNode->mRight;
|
||||
delOk=PR_TRUE;
|
||||
delete temp;
|
||||
}
|
||||
else {
|
||||
avlRemoveChildren(aRootNode,aRootNode->mLeft,delOk);
|
||||
if(delOk)
|
||||
avlBalanceRight(aRootNode,delOk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
eAVLStatus
|
||||
nsAVLTree::AddItem(void* anItem){
|
||||
eAVLStatus result=eAVL_ok;
|
||||
|
||||
nsAVLNode* theNewNode=new nsAVLNode(anItem);
|
||||
result=avlInsert(mRoot,theNewNode,mComparitor);
|
||||
if(eAVL_duplicate!=result)
|
||||
mCount++;
|
||||
else {
|
||||
delete theNewNode;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
void* nsAVLTree::FindItem(void* aValue) const{
|
||||
nsAVLNode* result=mRoot;
|
||||
PRInt32 count=0;
|
||||
while(result) {
|
||||
count++;
|
||||
PRInt32 cmp=mComparitor(aValue,result->mValue);
|
||||
if(0==cmp) {
|
||||
//we matched...
|
||||
break;
|
||||
}
|
||||
else if(0>cmp){
|
||||
//theNode was greater...
|
||||
result=result->mLeft;
|
||||
}
|
||||
else {
|
||||
//aValue is greater...
|
||||
result=result->mRight;
|
||||
}
|
||||
}
|
||||
if(result) {
|
||||
return result->mValue;
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/30/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
eAVLStatus
|
||||
nsAVLTree::RemoveItem(void* aValue){
|
||||
PRBool delOk=PR_TRUE;
|
||||
eAVLStatus result=avlRemove(mRoot,aValue,delOk,mComparitor);
|
||||
if(eAVL_ok==result)
|
||||
mCount--;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
static void
|
||||
avlForEachDepthFirst(nsAVLNode* aNode, nsAVLNodeFunctor& aFunctor){
|
||||
if(aNode) {
|
||||
avlForEachDepthFirst(aNode->mLeft,aFunctor);
|
||||
avlForEachDepthFirst(aNode->mRight,aFunctor);
|
||||
aFunctor(aNode->mValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void
|
||||
nsAVLTree::ForEachDepthFirst(nsAVLNodeFunctor& aFunctor) const{
|
||||
::avlForEachDepthFirst(mRoot,aFunctor);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
static void
|
||||
avlForEach(nsAVLNode* aNode, nsAVLNodeFunctor& aFunctor) {
|
||||
if(aNode) {
|
||||
avlForEach(aNode->mLeft,aFunctor);
|
||||
aFunctor(aNode->mValue);
|
||||
avlForEach(aNode->mRight,aFunctor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void
|
||||
nsAVLTree::ForEach(nsAVLNodeFunctor& aFunctor) const{
|
||||
::avlForEach(mRoot,aFunctor);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
static void*
|
||||
avlFirstThat(nsAVLNode* aNode, nsAVLNodeFunctor& aFunctor) {
|
||||
void* result=nsnull;
|
||||
if(aNode) {
|
||||
result = avlFirstThat(aNode->mLeft,aFunctor);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
result = aFunctor(aNode->mValue);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
result = avlFirstThat(aNode->mRight,aFunctor);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void*
|
||||
nsAVLTree::FirstThat(nsAVLNodeFunctor& aFunctor) const{
|
||||
return ::avlFirstThat(mRoot,aFunctor);
|
||||
}
|
||||
|
||||
74
mozilla/htmlparser/src/nsAVLTree.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/* -*- 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) 1999 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsAVLTree_h___
|
||||
#define nsAVLTree_h___
|
||||
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
|
||||
enum eAVLStatus {eAVL_unknown,eAVL_ok,eAVL_fail,eAVL_duplicate};
|
||||
|
||||
|
||||
struct nsAVLNode;
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/26/98
|
||||
* @param anObject1 is the first object to be compared
|
||||
* @param anObject2 is the second object to be compared
|
||||
* @return -1,0,1 if object1 is less, equal, greater than object2
|
||||
*/
|
||||
class NS_COM nsAVLNodeComparitor {
|
||||
public:
|
||||
virtual PRInt32 operator()(void* anItem1,void* anItem2)=0;
|
||||
};
|
||||
|
||||
class NS_COM nsAVLNodeFunctor {
|
||||
public:
|
||||
virtual void* operator()(void* anItem)=0;
|
||||
};
|
||||
|
||||
class NS_COM nsAVLTree {
|
||||
public:
|
||||
nsAVLTree(nsAVLNodeComparitor& aComparitor, nsAVLNodeFunctor* aDeallocator);
|
||||
~nsAVLTree(void);
|
||||
|
||||
PRBool operator==(const nsAVLTree& aOther) const;
|
||||
PRInt32 GetCount(void) const {return mCount;}
|
||||
|
||||
//main functions...
|
||||
eAVLStatus AddItem(void* anItem);
|
||||
eAVLStatus RemoveItem(void* anItem);
|
||||
void* FindItem(void* anItem) const;
|
||||
void ForEach(nsAVLNodeFunctor& aFunctor) const;
|
||||
void ForEachDepthFirst(nsAVLNodeFunctor& aFunctor) const;
|
||||
void* FirstThat(nsAVLNodeFunctor& aFunctor) const;
|
||||
|
||||
protected:
|
||||
|
||||
nsAVLNode* mRoot;
|
||||
PRInt32 mCount;
|
||||
nsAVLNodeComparitor& mComparitor;
|
||||
nsAVLNodeFunctor* mDeallocator;
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsAVLTree_h___ */
|
||||
|
||||
617
mozilla/parser/htmlparser/src/nsAVLTree.cpp
Normal file
@@ -0,0 +1,617 @@
|
||||
/* -*- 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) 1999 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsAVLTree.h"
|
||||
|
||||
|
||||
enum eLean {eLeft,eNeutral,eRight};
|
||||
|
||||
struct NS_COM nsAVLNode {
|
||||
public:
|
||||
|
||||
nsAVLNode(void* aValue) {
|
||||
mLeft=0;
|
||||
mRight=0;
|
||||
mSkew=eNeutral;
|
||||
mValue=aValue;
|
||||
}
|
||||
|
||||
nsAVLNode* mLeft;
|
||||
nsAVLNode* mRight;
|
||||
eLean mSkew;
|
||||
void* mValue;
|
||||
};
|
||||
|
||||
|
||||
/************************************************************
|
||||
Now begin the tree class. Don't forget that the comparison
|
||||
between nodes must occur via the comparitor function,
|
||||
otherwise all you're testing is pointer addresses.
|
||||
************************************************************/
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
nsAVLTree::nsAVLTree(nsAVLNodeComparitor& aComparitor,
|
||||
nsAVLNodeFunctor* aDeallocator) :
|
||||
mComparitor(aComparitor), mDeallocator(aDeallocator) {
|
||||
mRoot=0;
|
||||
mCount=0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
avlDeleteTree(nsAVLNode* aNode){
|
||||
if (aNode) {
|
||||
avlDeleteTree(aNode->mLeft);
|
||||
avlDeleteTree(aNode->mRight);
|
||||
delete aNode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/27/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsAVLTree::~nsAVLTree(){
|
||||
if (mDeallocator) {
|
||||
ForEachDepthFirst(*mDeallocator);
|
||||
}
|
||||
avlDeleteTree(mRoot);
|
||||
}
|
||||
|
||||
|
||||
class CDoesntExist: public nsAVLNodeFunctor {
|
||||
public:
|
||||
CDoesntExist(const nsAVLTree& anotherTree) : mOtherTree(anotherTree) {
|
||||
}
|
||||
virtual void* operator()(void* anItem) {
|
||||
void* result=mOtherTree.FindItem(anItem);
|
||||
if(result)
|
||||
return nsnull;
|
||||
return anItem;
|
||||
}
|
||||
protected:
|
||||
const nsAVLTree& mOtherTree;
|
||||
};
|
||||
|
||||
/**
|
||||
* This method compares two trees (members by identity).
|
||||
* @update gess12/27/98
|
||||
* @param tree to compare against
|
||||
* @return true if they are identical (contain same stuff).
|
||||
*/
|
||||
PRBool nsAVLTree::operator==(const nsAVLTree& aCopy) const{
|
||||
CDoesntExist functor(aCopy);
|
||||
void* theItem=FirstThat(functor);
|
||||
PRBool result=PRBool(!theItem);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/27/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
static void
|
||||
avlRotateRight(nsAVLNode*& aRootNode){
|
||||
nsAVLNode* ptr2;
|
||||
nsAVLNode* ptr3;
|
||||
|
||||
ptr2=aRootNode->mRight;
|
||||
if(ptr2->mSkew==eRight) {
|
||||
aRootNode->mRight=ptr2->mLeft;
|
||||
ptr2->mLeft=aRootNode;
|
||||
aRootNode->mSkew=eNeutral;
|
||||
aRootNode=ptr2;
|
||||
}
|
||||
else {
|
||||
ptr3=ptr2->mLeft;
|
||||
ptr2->mLeft=ptr3->mRight;
|
||||
ptr3->mRight=ptr2;
|
||||
aRootNode->mRight=ptr3->mLeft;
|
||||
ptr3->mLeft=aRootNode;
|
||||
if(ptr3->mSkew==eLeft)
|
||||
ptr2->mSkew=eRight;
|
||||
else ptr2->mSkew=eNeutral;
|
||||
if(ptr3->mSkew==eRight)
|
||||
aRootNode->mSkew=eLeft;
|
||||
else aRootNode->mSkew=eNeutral;
|
||||
aRootNode=ptr3;
|
||||
}
|
||||
aRootNode->mSkew=eNeutral;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/27/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
static void
|
||||
avlRotateLeft(nsAVLNode*& aRootNode){
|
||||
nsAVLNode* ptr2;
|
||||
nsAVLNode* ptr3;
|
||||
|
||||
ptr2=aRootNode->mLeft;
|
||||
if(ptr2->mSkew==eLeft) {
|
||||
aRootNode->mLeft=ptr2->mRight;
|
||||
ptr2->mRight=aRootNode;
|
||||
aRootNode->mSkew=eNeutral;
|
||||
aRootNode=ptr2;
|
||||
}
|
||||
else {
|
||||
ptr3=ptr2->mRight;
|
||||
ptr2->mRight=ptr3->mLeft;
|
||||
ptr3->mLeft=ptr2;
|
||||
aRootNode->mLeft=ptr3->mRight;
|
||||
ptr3->mRight=aRootNode;
|
||||
if(ptr3->mSkew==eRight)
|
||||
ptr2->mSkew=eLeft;
|
||||
else ptr2->mSkew=eNeutral;
|
||||
if(ptr3->mSkew==eLeft)
|
||||
aRootNode->mSkew=eRight;
|
||||
else aRootNode->mSkew=eNeutral;
|
||||
aRootNode=ptr3;
|
||||
}
|
||||
aRootNode->mSkew=eNeutral;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
static eAVLStatus
|
||||
avlInsert(nsAVLNode*& aRootNode, nsAVLNode* aNewNode,
|
||||
nsAVLNodeComparitor& aComparitor) {
|
||||
eAVLStatus result=eAVL_unknown;
|
||||
|
||||
if(!aRootNode) {
|
||||
aRootNode = aNewNode;
|
||||
return eAVL_ok;
|
||||
}
|
||||
|
||||
if(aNewNode==aRootNode->mValue) {
|
||||
return eAVL_duplicate;
|
||||
}
|
||||
|
||||
PRInt32 theCompareResult=aComparitor(aRootNode->mValue,aNewNode->mValue);
|
||||
if(0 < theCompareResult) { //if(anItem<aRootNode->mValue)
|
||||
result=avlInsert(aRootNode->mLeft,aNewNode,aComparitor);
|
||||
if(eAVL_ok==result) {
|
||||
switch(aRootNode->mSkew){
|
||||
case eLeft:
|
||||
avlRotateLeft(aRootNode);
|
||||
result=eAVL_fail;
|
||||
break;
|
||||
case eRight:
|
||||
aRootNode->mSkew=eNeutral;
|
||||
result=eAVL_fail;
|
||||
break;
|
||||
case eNeutral:
|
||||
aRootNode->mSkew=eLeft;
|
||||
break;
|
||||
} //switch
|
||||
}//if
|
||||
} //if
|
||||
else {
|
||||
result=avlInsert(aRootNode->mRight,aNewNode,aComparitor);
|
||||
if(eAVL_ok==result) {
|
||||
switch(aRootNode->mSkew){
|
||||
case eLeft:
|
||||
aRootNode->mSkew=eNeutral;
|
||||
result=eAVL_fail;
|
||||
break;
|
||||
case eRight:
|
||||
avlRotateRight(aRootNode);
|
||||
result=eAVL_fail;
|
||||
break;
|
||||
case eNeutral:
|
||||
aRootNode->mSkew=eRight;
|
||||
break;
|
||||
} //switch
|
||||
}
|
||||
} //if
|
||||
return result;
|
||||
}
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
static void
|
||||
avlBalanceLeft(nsAVLNode*& aRootNode, PRBool& delOk){
|
||||
nsAVLNode* ptr2;
|
||||
nsAVLNode* ptr3;
|
||||
eLean balnc2;
|
||||
eLean balnc3;
|
||||
|
||||
switch(aRootNode->mSkew){
|
||||
case eLeft:
|
||||
ptr2=aRootNode->mLeft;
|
||||
balnc2=ptr2->mSkew;
|
||||
if(balnc2!=eRight) {
|
||||
aRootNode->mLeft=ptr2->mRight;
|
||||
ptr2->mRight=aRootNode;
|
||||
if(balnc2==eNeutral){
|
||||
aRootNode->mSkew=eLeft;
|
||||
ptr2->mSkew=eRight;
|
||||
delOk=PR_FALSE;
|
||||
}
|
||||
else{
|
||||
aRootNode->mSkew=eNeutral;
|
||||
ptr2->mSkew=eNeutral;
|
||||
}
|
||||
aRootNode=ptr2;
|
||||
}
|
||||
else{
|
||||
ptr3=ptr2->mRight;
|
||||
balnc3=ptr3->mSkew;
|
||||
ptr2->mRight=ptr3->mLeft;
|
||||
ptr3->mLeft=ptr2;
|
||||
aRootNode->mLeft=ptr3->mRight;
|
||||
ptr3->mRight=aRootNode;
|
||||
if(balnc3==eRight) {
|
||||
ptr2->mSkew=eLeft;
|
||||
}
|
||||
else {
|
||||
ptr2->mSkew=eNeutral;
|
||||
}
|
||||
if(balnc3==eLeft) {
|
||||
aRootNode->mSkew=eRight;
|
||||
}
|
||||
else {
|
||||
aRootNode->mSkew=eNeutral;
|
||||
}
|
||||
aRootNode=ptr3;
|
||||
ptr3->mSkew=eNeutral;
|
||||
}
|
||||
break;
|
||||
|
||||
case eRight:
|
||||
aRootNode->mSkew=eNeutral;
|
||||
break;
|
||||
|
||||
case eNeutral:
|
||||
aRootNode->mSkew=eLeft;
|
||||
delOk=PR_FALSE;
|
||||
break;
|
||||
}//switch
|
||||
return;
|
||||
}
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
static void
|
||||
avlBalanceRight(nsAVLNode*& aRootNode, PRBool& delOk){
|
||||
nsAVLNode* ptr2;
|
||||
nsAVLNode* ptr3;
|
||||
eLean balnc2;
|
||||
eLean balnc3;
|
||||
|
||||
switch(aRootNode->mSkew){
|
||||
case eLeft:
|
||||
aRootNode->mSkew=eNeutral;
|
||||
break;
|
||||
|
||||
case eRight:
|
||||
ptr2=aRootNode->mRight;
|
||||
balnc2=ptr2->mSkew;
|
||||
if(balnc2!=eLeft) {
|
||||
aRootNode->mRight=ptr2->mLeft;
|
||||
ptr2->mLeft=aRootNode;
|
||||
if(balnc2==eNeutral){
|
||||
aRootNode->mSkew=eRight;
|
||||
ptr2->mSkew=eLeft;
|
||||
delOk=PR_FALSE;
|
||||
}
|
||||
else{
|
||||
aRootNode->mSkew=eNeutral;
|
||||
ptr2->mSkew=eNeutral;
|
||||
}
|
||||
aRootNode=ptr2;
|
||||
}
|
||||
else{
|
||||
ptr3=ptr2->mLeft;
|
||||
balnc3=ptr3->mSkew;
|
||||
ptr2->mLeft=ptr3->mRight;
|
||||
ptr3->mRight=ptr2;
|
||||
aRootNode->mRight=ptr3->mLeft;
|
||||
ptr3->mLeft=aRootNode;
|
||||
if(balnc3==eLeft) {
|
||||
ptr2->mSkew=eRight;
|
||||
}
|
||||
else {
|
||||
ptr2->mSkew=eNeutral;
|
||||
}
|
||||
if(balnc3==eRight) {
|
||||
aRootNode->mSkew=eLeft;
|
||||
}
|
||||
else {
|
||||
aRootNode->mSkew=eNeutral;
|
||||
}
|
||||
aRootNode=ptr3;
|
||||
ptr3->mSkew=eNeutral;
|
||||
}
|
||||
break;
|
||||
|
||||
case eNeutral:
|
||||
aRootNode->mSkew=eRight;
|
||||
delOk=PR_FALSE;
|
||||
break;
|
||||
}//switch
|
||||
return;
|
||||
}
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
static eAVLStatus
|
||||
avlRemoveChildren(nsAVLNode*& aRootNode,nsAVLNode*& anotherNode, PRBool& delOk){
|
||||
eAVLStatus result=eAVL_ok;
|
||||
|
||||
if(!anotherNode->mRight){
|
||||
aRootNode->mValue=anotherNode->mValue; //swap
|
||||
anotherNode=anotherNode->mLeft;
|
||||
delOk=PR_TRUE;
|
||||
}
|
||||
else{
|
||||
avlRemoveChildren(aRootNode,anotherNode->mRight,delOk);
|
||||
if(delOk)
|
||||
avlBalanceLeft(anotherNode,delOk);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
static eAVLStatus
|
||||
avlRemove(nsAVLNode*& aRootNode, void* anItem, PRBool& delOk,
|
||||
nsAVLNodeComparitor& aComparitor){
|
||||
eAVLStatus result=eAVL_ok;
|
||||
|
||||
if(!aRootNode)
|
||||
delOk=PR_FALSE;
|
||||
else {
|
||||
PRInt32 cmp=aComparitor(anItem,aRootNode->mValue);
|
||||
if(cmp<0){
|
||||
avlRemove(aRootNode->mLeft,anItem,delOk,aComparitor);
|
||||
if(delOk)
|
||||
avlBalanceRight(aRootNode,delOk);
|
||||
}
|
||||
else if(cmp>0){
|
||||
avlRemove(aRootNode->mRight,anItem,delOk,aComparitor);
|
||||
if(delOk)
|
||||
avlBalanceLeft(aRootNode,delOk);
|
||||
}
|
||||
else{ //they match...
|
||||
nsAVLNode* temp=aRootNode;
|
||||
if(!aRootNode->mRight) {
|
||||
aRootNode=aRootNode->mLeft;
|
||||
delOk=PR_TRUE;
|
||||
delete temp;
|
||||
}
|
||||
else if(!aRootNode->mLeft) {
|
||||
aRootNode=aRootNode->mRight;
|
||||
delOk=PR_TRUE;
|
||||
delete temp;
|
||||
}
|
||||
else {
|
||||
avlRemoveChildren(aRootNode,aRootNode->mLeft,delOk);
|
||||
if(delOk)
|
||||
avlBalanceRight(aRootNode,delOk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
eAVLStatus
|
||||
nsAVLTree::AddItem(void* anItem){
|
||||
eAVLStatus result=eAVL_ok;
|
||||
|
||||
nsAVLNode* theNewNode=new nsAVLNode(anItem);
|
||||
result=avlInsert(mRoot,theNewNode,mComparitor);
|
||||
if(eAVL_duplicate!=result)
|
||||
mCount++;
|
||||
else {
|
||||
delete theNewNode;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** ------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 4/22/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //----------------------------------------------
|
||||
void* nsAVLTree::FindItem(void* aValue) const{
|
||||
nsAVLNode* result=mRoot;
|
||||
PRInt32 count=0;
|
||||
while(result) {
|
||||
count++;
|
||||
PRInt32 cmp=mComparitor(aValue,result->mValue);
|
||||
if(0==cmp) {
|
||||
//we matched...
|
||||
break;
|
||||
}
|
||||
else if(0>cmp){
|
||||
//theNode was greater...
|
||||
result=result->mLeft;
|
||||
}
|
||||
else {
|
||||
//aValue is greater...
|
||||
result=result->mRight;
|
||||
}
|
||||
}
|
||||
if(result) {
|
||||
return result->mValue;
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/30/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
eAVLStatus
|
||||
nsAVLTree::RemoveItem(void* aValue){
|
||||
PRBool delOk=PR_TRUE;
|
||||
eAVLStatus result=avlRemove(mRoot,aValue,delOk,mComparitor);
|
||||
if(eAVL_ok==result)
|
||||
mCount--;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
static void
|
||||
avlForEachDepthFirst(nsAVLNode* aNode, nsAVLNodeFunctor& aFunctor){
|
||||
if(aNode) {
|
||||
avlForEachDepthFirst(aNode->mLeft,aFunctor);
|
||||
avlForEachDepthFirst(aNode->mRight,aFunctor);
|
||||
aFunctor(aNode->mValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void
|
||||
nsAVLTree::ForEachDepthFirst(nsAVLNodeFunctor& aFunctor) const{
|
||||
::avlForEachDepthFirst(mRoot,aFunctor);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
static void
|
||||
avlForEach(nsAVLNode* aNode, nsAVLNodeFunctor& aFunctor) {
|
||||
if(aNode) {
|
||||
avlForEach(aNode->mLeft,aFunctor);
|
||||
aFunctor(aNode->mValue);
|
||||
avlForEach(aNode->mRight,aFunctor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void
|
||||
nsAVLTree::ForEach(nsAVLNodeFunctor& aFunctor) const{
|
||||
::avlForEach(mRoot,aFunctor);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
static void*
|
||||
avlFirstThat(nsAVLNode* aNode, nsAVLNodeFunctor& aFunctor) {
|
||||
void* result=nsnull;
|
||||
if(aNode) {
|
||||
result = avlFirstThat(aNode->mLeft,aFunctor);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
result = aFunctor(aNode->mValue);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
result = avlFirstThat(aNode->mRight,aFunctor);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess9/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void*
|
||||
nsAVLTree::FirstThat(nsAVLNodeFunctor& aFunctor) const{
|
||||
return ::avlFirstThat(mRoot,aFunctor);
|
||||
}
|
||||
|
||||
74
mozilla/parser/htmlparser/src/nsAVLTree.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/* -*- 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) 1999 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsAVLTree_h___
|
||||
#define nsAVLTree_h___
|
||||
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
|
||||
enum eAVLStatus {eAVL_unknown,eAVL_ok,eAVL_fail,eAVL_duplicate};
|
||||
|
||||
|
||||
struct nsAVLNode;
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/26/98
|
||||
* @param anObject1 is the first object to be compared
|
||||
* @param anObject2 is the second object to be compared
|
||||
* @return -1,0,1 if object1 is less, equal, greater than object2
|
||||
*/
|
||||
class NS_COM nsAVLNodeComparitor {
|
||||
public:
|
||||
virtual PRInt32 operator()(void* anItem1,void* anItem2)=0;
|
||||
};
|
||||
|
||||
class NS_COM nsAVLNodeFunctor {
|
||||
public:
|
||||
virtual void* operator()(void* anItem)=0;
|
||||
};
|
||||
|
||||
class NS_COM nsAVLTree {
|
||||
public:
|
||||
nsAVLTree(nsAVLNodeComparitor& aComparitor, nsAVLNodeFunctor* aDeallocator);
|
||||
~nsAVLTree(void);
|
||||
|
||||
PRBool operator==(const nsAVLTree& aOther) const;
|
||||
PRInt32 GetCount(void) const {return mCount;}
|
||||
|
||||
//main functions...
|
||||
eAVLStatus AddItem(void* anItem);
|
||||
eAVLStatus RemoveItem(void* anItem);
|
||||
void* FindItem(void* anItem) const;
|
||||
void ForEach(nsAVLNodeFunctor& aFunctor) const;
|
||||
void ForEachDepthFirst(nsAVLNodeFunctor& aFunctor) const;
|
||||
void* FirstThat(nsAVLNodeFunctor& aFunctor) const;
|
||||
|
||||
protected:
|
||||
|
||||
nsAVLNode* mRoot;
|
||||
PRInt32 mCount;
|
||||
nsAVLNodeComparitor& mComparitor;
|
||||
nsAVLNodeFunctor* mDeallocator;
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsAVLTree_h___ */
|
||||
|
||||
717
mozilla/string/obsolete/nsStr.cpp
Normal file
@@ -0,0 +1,717 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
/******************************************************************************************
|
||||
MODULE NOTES:
|
||||
|
||||
This file contains the nsStr data structure.
|
||||
This general purpose buffer management class is used as the basis for our strings.
|
||||
It's benefits include:
|
||||
1. An efficient set of library style functions for manipulating nsStrs
|
||||
2. Support for 1 and 2 byte character strings (which can easily be increased to n)
|
||||
3. Unicode awareness and interoperability.
|
||||
|
||||
*******************************************************************************************/
|
||||
|
||||
#include "nsStr.h"
|
||||
#include "bufferRoutines.h"
|
||||
#include "stdio.h" //only used for printf
|
||||
#include "nsCRT.h"
|
||||
#include "nsDeque.h"
|
||||
|
||||
|
||||
//static const char* kCallFindChar = "For better performance, call FindChar() for targets whose length==1.";
|
||||
//static const char* kCallRFindChar = "For better performance, call RFindChar() for targets whose length==1.";
|
||||
|
||||
static const PRUnichar gCommonEmptyBuffer[1] = {0};
|
||||
|
||||
/**
|
||||
* This method initializes all the members of the nsStr structure
|
||||
*
|
||||
* @update gess10/30/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void nsStr::Initialize(nsStr& aDest,eCharSize aCharSize) {
|
||||
aDest.mStr=(char*)gCommonEmptyBuffer;
|
||||
aDest.mLength=0;
|
||||
aDest.mCapacity=0;
|
||||
aDest.mCharSize=aCharSize;
|
||||
aDest.mOwnsBuffer=0;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes all the members of the nsStr structure
|
||||
* @update gess10/30/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void nsStr::Initialize(nsStr& aDest,char* aCString,PRUint32 aCapacity,PRUint32 aLength,eCharSize aCharSize,PRBool aOwnsBuffer){
|
||||
aDest.mStr=(aCString) ? aCString : (char*)gCommonEmptyBuffer;
|
||||
aDest.mLength=aLength;
|
||||
aDest.mCapacity=aCapacity;
|
||||
aDest.mCharSize=aCharSize;
|
||||
aDest.mOwnsBuffer=aOwnsBuffer;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This member destroys the memory buffer owned by an nsStr object (if it actually owns it)
|
||||
* @update gess10/30/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void nsStr::Destroy(nsStr& aDest) {
|
||||
if((aDest.mStr) && (aDest.mStr!=(char*)gCommonEmptyBuffer)) {
|
||||
Free(aDest);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method gets called when the internal buffer needs
|
||||
* to grow to a given size. The original contents are not preserved.
|
||||
* @update gess 3/30/98
|
||||
* @param aNewLength -- new capacity of string in charSize units
|
||||
* @return void
|
||||
*/
|
||||
PRBool nsStr::EnsureCapacity(nsStr& aString,PRUint32 aNewLength) {
|
||||
PRBool result=PR_TRUE;
|
||||
if(aNewLength>aString.mCapacity) {
|
||||
result=Realloc(aString,aNewLength);
|
||||
if(aString.mStr)
|
||||
AddNullTerminator(aString);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called when the internal buffer needs
|
||||
* to grow to a given size. The original contents ARE preserved.
|
||||
* @update gess 3/30/98
|
||||
* @param aNewLength -- new capacity of string in charSize units
|
||||
* @return void
|
||||
*/
|
||||
PRBool nsStr::GrowCapacity(nsStr& aDest,PRUint32 aNewLength) {
|
||||
PRBool result=PR_TRUE;
|
||||
if(aNewLength>aDest.mCapacity) {
|
||||
nsStr theTempStr;
|
||||
nsStr::Initialize(theTempStr,aDest.mCharSize);
|
||||
|
||||
result=EnsureCapacity(theTempStr,aNewLength);
|
||||
if(result) {
|
||||
if(aDest.mLength) {
|
||||
Append(theTempStr,aDest,0,aDest.mLength);
|
||||
}
|
||||
Free(aDest);
|
||||
aDest.mStr = theTempStr.mStr;
|
||||
theTempStr.mStr=0; //make sure to null this out so that you don't lose the buffer you just stole...
|
||||
aDest.mLength=theTempStr.mLength;
|
||||
aDest.mCapacity=theTempStr.mCapacity;
|
||||
aDest.mOwnsBuffer=theTempStr.mOwnsBuffer;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the contents of aDest with aSource, up to aCount of chars.
|
||||
* @update gess10/30/98
|
||||
* @param aDest is the nsStr that gets changed.
|
||||
* @param aSource is where chars are copied from
|
||||
* @param aCount is the number of chars copied from aSource
|
||||
*/
|
||||
void nsStr::Assign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){
|
||||
if(&aDest!=&aSource){
|
||||
Truncate(aDest,0);
|
||||
Append(aDest,aSource,anOffset,aCount);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method appends the given nsStr to this one. Note that we have to
|
||||
* pay attention to the underlying char-size of both structs.
|
||||
* @update gess10/30/98
|
||||
* @param aDest is the nsStr to be manipulated
|
||||
* @param aSource is where char are copied from
|
||||
* @aCount is the number of bytes to be copied
|
||||
*/
|
||||
void nsStr::Append(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){
|
||||
if(anOffset<aSource.mLength){
|
||||
PRUint32 theRealLen=(aCount<0) ? aSource.mLength : MinInt(aCount,aSource.mLength);
|
||||
PRUint32 theLength=(anOffset+theRealLen<aSource.mLength) ? theRealLen : (aSource.mLength-anOffset);
|
||||
if(0<theLength){
|
||||
|
||||
PRBool isBigEnough=PR_TRUE;
|
||||
if(aDest.mLength+theLength > aDest.mCapacity) {
|
||||
isBigEnough=GrowCapacity(aDest,aDest.mLength+theLength);
|
||||
}
|
||||
|
||||
if(isBigEnough) {
|
||||
//now append new chars, starting at offset
|
||||
(*gCopyChars[aSource.mCharSize][aDest.mCharSize])(aDest.mStr,aDest.mLength,aSource.mStr,anOffset,theLength);
|
||||
|
||||
aDest.mLength+=theLength;
|
||||
AddNullTerminator(aDest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method inserts up to "aCount" chars from a source nsStr into a dest nsStr.
|
||||
* @update gess10/30/98
|
||||
* @param aDest is the nsStr that gets changed
|
||||
* @param aDestOffset is where in aDest the insertion is to occur
|
||||
* @param aSource is where chars are copied from
|
||||
* @param aSrcOffset is where in aSource chars are copied from
|
||||
* @param aCount is the number of chars from aSource to be inserted into aDest
|
||||
*/
|
||||
void nsStr::Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount){
|
||||
//there are a few cases for insert:
|
||||
// 1. You're inserting chars into an empty string (assign)
|
||||
// 2. You're inserting onto the end of a string (append)
|
||||
// 3. You're inserting onto the 1..n-1 pos of a string (the hard case).
|
||||
if(0<aSource.mLength){
|
||||
if(aDest.mLength){
|
||||
if(aDestOffset<aDest.mLength){
|
||||
PRInt32 theRealLen=(aCount<0) ? aSource.mLength : MinInt(aCount,aSource.mLength);
|
||||
PRInt32 theLength=(aSrcOffset+theRealLen<aSource.mLength) ? theRealLen : (aSource.mLength-aSrcOffset);
|
||||
|
||||
if(aSrcOffset<aSource.mLength) {
|
||||
//here's the only new case we have to handle.
|
||||
//chars are really being inserted into our buffer...
|
||||
|
||||
if(aDest.mLength+theLength > aDest.mCapacity) {
|
||||
nsStr theTempStr;
|
||||
nsStr::Initialize(theTempStr,aDest.mCharSize);
|
||||
|
||||
PRBool isBigEnough=EnsureCapacity(theTempStr,aDest.mLength+theLength); //grow the temp buffer to the right size
|
||||
|
||||
if(isBigEnough) {
|
||||
if(aDestOffset) {
|
||||
Append(theTempStr,aDest,0,aDestOffset); //first copy leftmost data...
|
||||
}
|
||||
|
||||
Append(theTempStr,aSource,0,aSource.mLength); //next copy inserted (new) data
|
||||
|
||||
PRUint32 theRemains=aDest.mLength-aDestOffset;
|
||||
if(theRemains) {
|
||||
Append(theTempStr,aDest,aDestOffset,theRemains); //next copy rightmost data
|
||||
}
|
||||
|
||||
Free(aDest);
|
||||
aDest.mStr = theTempStr.mStr;
|
||||
theTempStr.mStr=0; //make sure to null this out so that you don't lose the buffer you just stole...
|
||||
aDest.mCapacity=theTempStr.mCapacity;
|
||||
aDest.mOwnsBuffer=theTempStr.mOwnsBuffer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
//shift the chars right by theDelta...
|
||||
(*gShiftChars[aDest.mCharSize][KSHIFTRIGHT])(aDest.mStr,aDest.mLength,aDestOffset,theLength);
|
||||
|
||||
//now insert new chars, starting at offset
|
||||
(*gCopyChars[aSource.mCharSize][aDest.mCharSize])(aDest.mStr,aDestOffset,aSource.mStr,aSrcOffset,theLength);
|
||||
}
|
||||
|
||||
//finally, make sure to update the string length...
|
||||
aDest.mLength+=theLength;
|
||||
AddNullTerminator(aDest);
|
||||
|
||||
}//if
|
||||
//else nothing to do!
|
||||
}
|
||||
else Append(aDest,aSource,0,aCount);
|
||||
}
|
||||
else Append(aDest,aSource,0,aCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method deletes up to aCount chars from aDest
|
||||
* @update gess10/30/98
|
||||
* @param aDest is the nsStr to be manipulated
|
||||
* @param aDestOffset is where in aDest deletion is to occur
|
||||
* @param aCount is the number of chars to be deleted in aDest
|
||||
*/
|
||||
void nsStr::Delete(nsStr& aDest,PRUint32 aDestOffset,PRUint32 aCount){
|
||||
if(aDestOffset<aDest.mLength){
|
||||
|
||||
PRUint32 theDelta=aDest.mLength-aDestOffset;
|
||||
PRUint32 theLength=(theDelta<aCount) ? theDelta : aCount;
|
||||
|
||||
if(aDestOffset+theLength<aDest.mLength) {
|
||||
|
||||
//if you're here, it means we're cutting chars out of the middle of the string...
|
||||
//so shift the chars left by theLength...
|
||||
(*gShiftChars[aDest.mCharSize][KSHIFTLEFT])(aDest.mStr,aDest.mLength,aDestOffset,theLength);
|
||||
aDest.mLength-=theLength;
|
||||
AddNullTerminator(aDest);
|
||||
}
|
||||
else Truncate(aDest,aDestOffset);
|
||||
}//if
|
||||
}
|
||||
|
||||
/**
|
||||
* This method truncates the given nsStr at given offset
|
||||
* @update gess10/30/98
|
||||
* @param aDest is the nsStr to be truncated
|
||||
* @param aDestOffset is where in aDest truncation is to occur
|
||||
*/
|
||||
void nsStr::Truncate(nsStr& aDest,PRUint32 aDestOffset){
|
||||
if(aDestOffset<aDest.mLength){
|
||||
aDest.mLength=aDestOffset;
|
||||
AddNullTerminator(aDest);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method forces the given string to upper or lowercase
|
||||
* @update gess1/7/99
|
||||
* @param aDest is the string you're going to change
|
||||
* @param aToUpper: if TRUE, then we go uppercase, otherwise we go lowercase
|
||||
* @return
|
||||
*/
|
||||
void nsStr::ChangeCase(nsStr& aDest,PRBool aToUpper) {
|
||||
// somehow UnicharUtil return failed, fallback to the old ascii only code
|
||||
gCaseConverters[aDest.mCharSize](aDest.mStr,aDest.mLength,aToUpper);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess1/7/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void nsStr::Trim(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing){
|
||||
|
||||
if((aDest.mLength>0) && aSet){
|
||||
PRInt32 theIndex=-1;
|
||||
PRInt32 theMax=aDest.mLength;
|
||||
PRInt32 theSetLen=nsCRT::strlen(aSet);
|
||||
|
||||
if(aEliminateLeading) {
|
||||
while(++theIndex<=theMax) {
|
||||
PRUnichar theChar=GetCharAt(aDest,theIndex);
|
||||
PRInt32 thePos=gFindChars[eOneByte](aSet,theSetLen,0,theChar,PR_FALSE);
|
||||
if(kNotFound==thePos)
|
||||
break;
|
||||
}
|
||||
if(0<theIndex) {
|
||||
if(theIndex<theMax) {
|
||||
Delete(aDest,0,theIndex);
|
||||
}
|
||||
else Truncate(aDest,0);
|
||||
}
|
||||
}
|
||||
|
||||
if(aEliminateTrailing) {
|
||||
theIndex=aDest.mLength;
|
||||
PRInt32 theNewLen=theIndex;
|
||||
while(--theIndex>0) {
|
||||
PRUnichar theChar=GetCharAt(aDest,theIndex); //read at end now...
|
||||
PRInt32 thePos=gFindChars[eOneByte](aSet,theSetLen,0,theChar,PR_FALSE);
|
||||
if(kNotFound<thePos)
|
||||
theNewLen=theIndex;
|
||||
else break;
|
||||
}
|
||||
if(theNewLen<theMax) {
|
||||
Truncate(aDest,theNewLen);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess1/7/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void nsStr::CompressSet(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing){
|
||||
Trim(aDest,aSet,aEliminateLeading,aEliminateTrailing);
|
||||
PRUint32 aNewLen=gCompressChars[aDest.mCharSize](aDest.mStr,aDest.mLength,aSet);
|
||||
aDest.mLength=aNewLen;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess1/7/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void nsStr::StripChars(nsStr& aDest,const char* aSet){
|
||||
if((0<aDest.mLength) && (aSet)) {
|
||||
PRUint32 aNewLen=gStripChars[aDest.mCharSize](aDest.mStr,aDest.mLength,aSet);
|
||||
aDest.mLength=aNewLen;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************
|
||||
Searching methods...
|
||||
**************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* This searches aDest for a given substring
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aDest string to search
|
||||
* @param aTarget is the substring you're trying to find.
|
||||
* @param aIgnorecase indicates case sensitivity of search
|
||||
* @param anOffset tells us where to start the search
|
||||
* @return index in aDest where member of aSet occurs, or -1 if not found
|
||||
*/
|
||||
PRInt32 nsStr::FindSubstr(const nsStr& aDest,const nsStr& aTarget, PRBool aIgnoreCase,PRInt32 anOffset) {
|
||||
// NS_PRECONDITION(aTarget.mLength!=1,kCallFindChar);
|
||||
|
||||
PRInt32 result=kNotFound;
|
||||
|
||||
if((0<aDest.mLength) && (anOffset<(PRInt32)aDest.mLength)) {
|
||||
PRInt32 theMax=aDest.mLength-aTarget.mLength;
|
||||
PRInt32 index=(0<=anOffset) ? anOffset : 0;
|
||||
|
||||
if((aDest.mLength>=aTarget.mLength) && (aTarget.mLength>0) && (index>=0)){
|
||||
PRInt32 theTargetMax=aTarget.mLength;
|
||||
while(index<=theMax) {
|
||||
PRInt32 theSubIndex=-1;
|
||||
PRBool matches=PR_TRUE;
|
||||
while((++theSubIndex<theTargetMax) && (matches)){
|
||||
PRUnichar theChar=(aIgnoreCase) ? nsCRT::ToLower(GetCharAt(aDest,index+theSubIndex)) : GetCharAt(aDest,index+theSubIndex);
|
||||
PRUnichar theTargetChar=(aIgnoreCase) ? nsCRT::ToLower(GetCharAt(aTarget,theSubIndex)) : GetCharAt(aTarget,theSubIndex);
|
||||
matches=PRBool(theChar==theTargetChar);
|
||||
}
|
||||
if(matches) {
|
||||
result=index;
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
} //while
|
||||
}//if
|
||||
}//if
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This searches aDest for a given character
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aDest string to search
|
||||
* @param char is the character you're trying to find.
|
||||
* @param aIgnorecase indicates case sensitivity of search
|
||||
* @param anOffset tells us where to start the search
|
||||
* @return index in aDest where member of aSet occurs, or -1 if not found
|
||||
*/
|
||||
PRInt32 nsStr::FindChar(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset) {
|
||||
PRInt32 result=kNotFound;
|
||||
if((0<aDest.mLength) && (anOffset<(PRInt32)aDest.mLength)) {
|
||||
PRUint32 index=(0<=anOffset) ? (PRUint32)anOffset : 0;
|
||||
result=gFindChars[aDest.mCharSize](aDest.mStr,aDest.mLength,index,aChar,aIgnoreCase);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This searches aDest for a character found in aSet.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aDest string to search
|
||||
* @param aSet contains a list of chars to be searched for
|
||||
* @param aIgnorecase indicates case sensitivity of search
|
||||
* @param anOffset tells us where to start the search
|
||||
* @return index in aDest where member of aSet occurs, or -1 if not found
|
||||
*/
|
||||
PRInt32 nsStr::FindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset) {
|
||||
//NS_PRECONDITION(aSet.mLength!=1,kCallFindChar);
|
||||
|
||||
PRInt32 index=(0<=anOffset) ? anOffset-1 : -1;
|
||||
PRInt32 thePos;
|
||||
|
||||
//Note that the search is inverted here. We're scanning aDest, one char at a time
|
||||
//but doing the search against the given set. That's why we use 0 as the offset below.
|
||||
if((0<aDest.mLength) && (0<aSet.mLength)){
|
||||
while(++index<(PRInt32)aDest.mLength) {
|
||||
PRUnichar theChar=GetCharAt(aDest,index);
|
||||
thePos=gFindChars[aSet.mCharSize](aSet.mStr,aSet.mLength,0,theChar,aIgnoreCase);
|
||||
if(kNotFound!=thePos)
|
||||
return index;
|
||||
} //while
|
||||
}
|
||||
return kNotFound;
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
Reverse Searching methods...
|
||||
**************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* This searches aDest (in reverse) for a given substring
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aDest string to search
|
||||
* @param aTarget is the substring you're trying to find.
|
||||
* @param aIgnorecase indicates case sensitivity of search
|
||||
* @param anOffset tells us where to start the search (counting from left)
|
||||
* @return index in aDest where member of aSet occurs, or -1 if not found
|
||||
*/
|
||||
PRInt32 nsStr::RFindSubstr(const nsStr& aDest,const nsStr& aTarget, PRBool aIgnoreCase,PRInt32 anOffset) {
|
||||
//NS_PRECONDITION(aTarget.mLength!=1,kCallRFindChar);
|
||||
|
||||
PRInt32 result=kNotFound;
|
||||
|
||||
if((0<aDest.mLength) && (anOffset<(PRInt32)aDest.mLength)) {
|
||||
PRInt32 index=(0<=anOffset) ? anOffset : aDest.mLength-1;
|
||||
|
||||
if((aDest.mLength>=aTarget.mLength) && (aTarget.mLength>0) && (index>=0)){
|
||||
|
||||
nsStr theCopy;
|
||||
nsStr::Initialize(theCopy,eOneByte);
|
||||
nsStr::Assign(theCopy,aTarget,0,aTarget.mLength);
|
||||
if(aIgnoreCase){
|
||||
nsStr::ChangeCase(theCopy,PR_FALSE); //force to lowercase
|
||||
}
|
||||
|
||||
PRInt32 theTargetMax=theCopy.mLength;
|
||||
while(index>=0) {
|
||||
PRInt32 theSubIndex=-1;
|
||||
PRBool matches=PR_FALSE;
|
||||
if(index+theCopy.mLength<=aDest.mLength) {
|
||||
matches=PR_TRUE;
|
||||
while((++theSubIndex<theTargetMax) && (matches)){
|
||||
PRUnichar theDestChar=(aIgnoreCase) ? nsCRT::ToLower(GetCharAt(aDest,index+theSubIndex)) : GetCharAt(aDest,index+theSubIndex);
|
||||
PRUnichar theTargetChar=GetCharAt(theCopy,theSubIndex);
|
||||
matches=PRBool(theDestChar==theTargetChar);
|
||||
} //while
|
||||
} //if
|
||||
if(matches) {
|
||||
result=index;
|
||||
break;
|
||||
}
|
||||
index--;
|
||||
} //while
|
||||
nsStr::Destroy(theCopy);
|
||||
}//if
|
||||
}//if
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This searches aDest (in reverse) for a given character
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aDest string to search
|
||||
* @param char is the character you're trying to find.
|
||||
* @param aIgnorecase indicates case sensitivity of search
|
||||
* @param anOffset tells us where to start the search
|
||||
* @return index in aDest where member of aSet occurs, or -1 if not found
|
||||
*/
|
||||
PRInt32 nsStr::RFindChar(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset) {
|
||||
PRInt32 result=kNotFound;
|
||||
if((0<aDest.mLength) && (anOffset<(PRInt32)aDest.mLength)) {
|
||||
PRUint32 index=(0<=anOffset) ? anOffset : aDest.mLength-1;
|
||||
result=gRFindChars[aDest.mCharSize](aDest.mStr,aDest.mLength,index,aChar,aIgnoreCase);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This searches aDest (in reverese) for a character found in aSet.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aDest string to search
|
||||
* @param aSet contains a list of chars to be searched for
|
||||
* @param aIgnorecase indicates case sensitivity of search
|
||||
* @param anOffset tells us where to start the search
|
||||
* @return index in aDest where member of aSet occurs, or -1 if not found
|
||||
*/
|
||||
PRInt32 nsStr::RFindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset) {
|
||||
//NS_PRECONDITION(aSet.mLength!=1,kCallRFindChar);
|
||||
|
||||
PRInt32 index=(0<=anOffset) ? anOffset : aDest.mLength;
|
||||
PRInt32 thePos;
|
||||
|
||||
//note that the search is inverted here. We're scanning aDest, one char at a time
|
||||
//but doing the search against the given set. That's why we use 0 as the offset below.
|
||||
if(0<aDest.mLength) {
|
||||
while(--index>=0) {
|
||||
PRUnichar theChar=GetCharAt(aDest,index);
|
||||
thePos=gFindChars[aSet.mCharSize](aSet.mStr,aSet.mLength,0,theChar,aIgnoreCase);
|
||||
if(kNotFound!=thePos)
|
||||
return index;
|
||||
} //while
|
||||
}
|
||||
return kNotFound;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compare source and dest strings, up to an (optional max) number of chars
|
||||
* @param aDest is the first str to compare
|
||||
* @param aSource is the second str to compare
|
||||
* @param aCount -- if (-1), then we use length of longer string; if (0<aCount) then it gives the max # of chars to compare
|
||||
* @param aIgnorecase tells us whether to search with case sensitivity
|
||||
* @return aDest<aSource=-1;aDest==aSource==0;aDest>aSource=1
|
||||
*/
|
||||
PRInt32 nsStr::Compare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) {
|
||||
PRInt32 result=0;
|
||||
|
||||
if(aCount) {
|
||||
PRInt32 minlen=(aSource.mLength<aDest.mLength) ? aSource.mLength : aDest.mLength;
|
||||
|
||||
if(0==minlen) {
|
||||
if ((aDest.mLength == 0) && (aSource.mLength == 0))
|
||||
return 0;
|
||||
if (aDest.mLength == 0)
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
PRInt32 maxlen=(aSource.mLength<aDest.mLength) ? aDest.mLength : aSource.mLength;
|
||||
aCount = (aCount<0) ? maxlen : MinInt(aCount,maxlen);
|
||||
result=(*gCompare[aDest.mCharSize][aSource.mCharSize])(aDest.mStr,aSource.mStr,aCount,aIgnoreCase);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
PRBool nsStr::Alloc(nsStr& aDest,PRUint32 aCount) {
|
||||
|
||||
static int mAllocCount=0;
|
||||
mAllocCount++;
|
||||
|
||||
//we're given the acount value in charunits; now scale up to next multiple.
|
||||
PRUint32 theNewCapacity=kDefaultStringSize;
|
||||
while(theNewCapacity<aCount){
|
||||
theNewCapacity<<=1;
|
||||
}
|
||||
|
||||
aDest.mCapacity=theNewCapacity++;
|
||||
PRUint32 theSize=(theNewCapacity<<aDest.mCharSize);
|
||||
aDest.mStr = (char*)nsAllocator::Alloc(theSize);
|
||||
|
||||
PRBool result=PR_FALSE;
|
||||
if(aDest.mStr) {
|
||||
aDest.mOwnsBuffer=1;
|
||||
result=PR_TRUE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
PRBool nsStr::Free(nsStr& aDest){
|
||||
if(aDest.mStr){
|
||||
if(aDest.mOwnsBuffer){
|
||||
nsAllocator::Free(aDest.mStr);
|
||||
}
|
||||
aDest.mStr=0;
|
||||
aDest.mOwnsBuffer=0;
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsStr::Realloc(nsStr& aDest,PRUint32 aCount){
|
||||
|
||||
nsStr temp;
|
||||
memcpy(&temp,&aDest,sizeof(aDest));
|
||||
|
||||
PRBool result=Alloc(temp,aCount);
|
||||
if(result) {
|
||||
Free(aDest);
|
||||
aDest.mStr=temp.mStr;
|
||||
aDest.mCapacity=temp.mCapacity;
|
||||
aDest.mOwnsBuffer=temp.mOwnsBuffer;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
CBufDescriptor::CBufDescriptor(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
|
||||
mBuffer=aString;
|
||||
mCharSize=eOneByte;
|
||||
mStackBased=aStackBased;
|
||||
mIsConst=PR_FALSE;
|
||||
mLength=mCapacity=0;
|
||||
if(aString && aCapacity>1) {
|
||||
mCapacity=aCapacity-1;
|
||||
mLength=(-1==aLength) ? strlen(aString) : aLength;
|
||||
if(mLength>PRInt32(mCapacity))
|
||||
mLength=mCapacity;
|
||||
}
|
||||
}
|
||||
|
||||
CBufDescriptor::CBufDescriptor(const char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
|
||||
mBuffer=(char*)aString;
|
||||
mCharSize=eOneByte;
|
||||
mStackBased=aStackBased;
|
||||
mIsConst=PR_TRUE;
|
||||
mLength=mCapacity=0;
|
||||
if(aString && aCapacity>1) {
|
||||
mCapacity=aCapacity-1;
|
||||
mLength=(-1==aLength) ? strlen(aString) : aLength;
|
||||
if(mLength>PRInt32(mCapacity))
|
||||
mLength=mCapacity;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CBufDescriptor::CBufDescriptor(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
|
||||
mBuffer=(char*)aString;
|
||||
mCharSize=eTwoByte;
|
||||
mStackBased=aStackBased;
|
||||
mLength=mCapacity=0;
|
||||
mIsConst=PR_FALSE;
|
||||
if(aString && aCapacity>1) {
|
||||
mCapacity=aCapacity-1;
|
||||
mLength=(-1==aLength) ? nsCRT::strlen(aString) : aLength;
|
||||
if(mLength>PRInt32(mCapacity))
|
||||
mLength=mCapacity;
|
||||
}
|
||||
}
|
||||
|
||||
CBufDescriptor::CBufDescriptor(const PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) {
|
||||
mBuffer=(char*)aString;
|
||||
mCharSize=eTwoByte;
|
||||
mStackBased=aStackBased;
|
||||
mLength=mCapacity=0;
|
||||
mIsConst=PR_TRUE;
|
||||
if(aString && aCapacity>1) {
|
||||
mCapacity=aCapacity-1;
|
||||
mLength=(-1==aLength) ? nsCRT::strlen(aString) : aLength;
|
||||
if(mLength>PRInt32(mCapacity))
|
||||
mLength=mCapacity;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
450
mozilla/string/obsolete/nsStr.h
Normal file
@@ -0,0 +1,450 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
MODULE NOTES:
|
||||
|
||||
1. There are two philosophies to building string classes:
|
||||
A. Hide the underlying buffer & offer API's allow indirect iteration
|
||||
B. Reveal underlying buffer, risk corruption, but gain performance
|
||||
|
||||
We chose the option B for performance reasons.
|
||||
|
||||
2 Our internal buffer always holds capacity+1 bytes.
|
||||
|
||||
The nsStr struct is a simple structure (no methods) that contains
|
||||
the necessary info to be described as a string. This simple struct
|
||||
is manipulated by the static methods provided in this class.
|
||||
(Which effectively makes this a library that works on structs).
|
||||
|
||||
There are also object-based versions called nsString and nsAutoString
|
||||
which use nsStr but makes it look at feel like an object.
|
||||
|
||||
***********************************************************************/
|
||||
|
||||
/***********************************************************************
|
||||
ASSUMPTIONS:
|
||||
|
||||
1. nsStrings and nsAutoString are always null terminated.
|
||||
2. If you try to set a null char (via SetChar()) a new length is set
|
||||
3. nsCStrings can be upsampled into nsString without data loss
|
||||
4. Char searching is faster than string searching. Use char interfaces
|
||||
if your needs will allow it.
|
||||
5. It's easy to use the stack for nsAutostring buffer storage (fast too!).
|
||||
See the CBufDescriptor class in this file.
|
||||
6. It's ONLY ok to provide non-null-terminated buffers to Append() and Insert()
|
||||
provided you specify a 0<n value for the optional count argument.
|
||||
7. Downsampling from nsString to nsCString is lossy -- avoid it if possible!
|
||||
8. Calls to ToNewCString() and ToNewUnicode() should be matched with calls to Recycle().
|
||||
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
/**********************************************************************************
|
||||
|
||||
AND NOW FOR SOME GENERAL DOCUMENTATION ON STRING USAGE...
|
||||
|
||||
The fundamental datatype in the string library is nsStr. It's a structure that
|
||||
provides the buffer storage and meta-info. It also provides a C-style library
|
||||
of functions for direct manipulation (for those of you who prefer K&R to Bjarne).
|
||||
|
||||
Here's a diagram of the class hierarchy:
|
||||
|
||||
nsStr
|
||||
|___nsString
|
||||
| |
|
||||
| ------nsAutoString
|
||||
|
|
||||
|___nsCString
|
||||
|
|
||||
------nsCAutoString
|
||||
|
||||
Why so many string classes? The 4 variants give you the control you need to
|
||||
determine the best class for your purpose. There are 2 dimensions to this
|
||||
flexibility: 1) stack vs. heap; and 2) 1-byte chars vs. 2-byte chars.
|
||||
|
||||
Note: While nsAutoString and nsCAutoString begin life using stack-based storage,
|
||||
they may not stay that way. Like all nsString classes, autostrings will
|
||||
automatically grow to contain the data you provide. When autostrings
|
||||
grow beyond their intrinsic buffer, they switch to heap based allocations.
|
||||
(We avoid alloca to avoid considerable platform difficulties; see the
|
||||
GNU documentation for more details).
|
||||
|
||||
I should also briefly mention that all the string classes use a "memory agent"
|
||||
object to perform memory operations. This class proxies the standard nsAllocator
|
||||
for actual memory calls, but knows the structure of nsStr making heap operations
|
||||
more localized.
|
||||
|
||||
|
||||
CHOOSING A STRING CLASS:
|
||||
|
||||
In order to choose a string class for you purpose, use this handy table:
|
||||
|
||||
heap-based stack-based
|
||||
-----------------------------------
|
||||
ascii data | nsCString nsCAutoString |
|
||||
|----------------------------------
|
||||
unicode data | nsString nsAutoString |
|
||||
-----------------------------------
|
||||
|
||||
|
||||
Note: The i18n folks will stenuously object if we get too carried away with the
|
||||
use of nsCString's that pass interface boundaries. Try to limit your
|
||||
use of these to external interfaces that demand them, or for your own
|
||||
private purposes in cases where they'll never be seen by humans.
|
||||
|
||||
|
||||
PERFORMANCE CONSIDERATIONS:
|
||||
|
||||
Here are a few tricks to know in order to get better string performance:
|
||||
|
||||
1) Try to limit conversions between ascii and unicode; By sticking with nsString
|
||||
wherever possible your code will be i18n-compliant.
|
||||
|
||||
|
||||
2) Preallocating your string buffer cuts down trips to the allocator. So if you
|
||||
have need for an arbitrarily large buffer, pre-size it like this:
|
||||
|
||||
{
|
||||
nsString mBuffer;
|
||||
mBuffer.SetCapacity(aReasonableSize);
|
||||
}
|
||||
|
||||
3) Allocating nsAutoString or nsCAutoString on the heap is memory inefficient
|
||||
(after all, the whole point is to avoid a heap allocation of the buffer).
|
||||
|
||||
|
||||
4) Consider using an autoString to write into your arbitrarily-sized stack buffers, rather
|
||||
than it's own buffers.
|
||||
|
||||
For example, let's say you're going to call printf() to emit pretty-printed debug output
|
||||
of your object. You know from experience that the pretty-printed version of your object
|
||||
exceeds the capacity of an autostring. Ignoring memory considerations, you could simply
|
||||
use nsCString, appending the stringized version of each of your class's data members.
|
||||
This will probably result in calls to the heap manager.
|
||||
|
||||
But there's a way to do this without necessarily having to call the heap manager.
|
||||
All you do is declare a stack based buffer and instruct nsCString to use that instead
|
||||
of it's own internal buffer by using the CBufDescriptor class:
|
||||
|
||||
{
|
||||
char theBuffer[256];
|
||||
CBufDescritor theBufDecriptor( theBuffer, PR_TRUE, sizeof(theBuffer), 0);
|
||||
nsCAutoString s3( theBufDescriptor );
|
||||
s3="HELLO, my name is inigo montoya, you killed my father, prepare to die!.";
|
||||
}
|
||||
|
||||
The assignment statment to s3 will cause the given string to be written to your
|
||||
stack-based buffer via the normal nsString/nsCString interfaces. Cool, huh?
|
||||
Note however that just like any other nsStringXXX use, if you write more data
|
||||
than will fit in the buffer, a visit to the heap manager will be in order.
|
||||
|
||||
|
||||
**********************************************************************************/
|
||||
|
||||
|
||||
#ifndef _nsStr
|
||||
#define _nsStr
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIAllocator.h"
|
||||
#include <string.h>
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
enum eCharSize {eOneByte=0,eTwoByte=1};
|
||||
#define kDefaultCharSize eTwoByte
|
||||
#define kRadix10 (10)
|
||||
#define kRadix16 (16)
|
||||
#define kAutoDetect (100)
|
||||
#define kRadixUnknown (kAutoDetect+1)
|
||||
const PRInt32 kDefaultStringSize = 64;
|
||||
const PRInt32 kNotFound = -1;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
class NS_COM CBufDescriptor {
|
||||
public:
|
||||
CBufDescriptor(char* aString, PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
|
||||
CBufDescriptor(const char* aString, PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
|
||||
CBufDescriptor(PRUnichar* aString, PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
|
||||
CBufDescriptor(const PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1);
|
||||
|
||||
char* mBuffer;
|
||||
eCharSize mCharSize;
|
||||
PRUint32 mCapacity;
|
||||
PRInt32 mLength;
|
||||
PRBool mStackBased;
|
||||
PRBool mIsConst;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
struct NS_COM nsStr {
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
nsStr() {
|
||||
MOZ_COUNT_CTOR(nsStr);
|
||||
}
|
||||
|
||||
~nsStr() {
|
||||
MOZ_COUNT_DTOR(nsStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes an nsStr for use
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aString is the nsStr to be initialized
|
||||
* @param aCharSize tells us the requested char size (1 or 2 bytes)
|
||||
*/
|
||||
static void Initialize(nsStr& aDest,eCharSize aCharSize);
|
||||
|
||||
/**
|
||||
* This method initializes an nsStr for use
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aString is the nsStr to be initialized
|
||||
* @param aCharSize tells us the requested char size (1 or 2 bytes)
|
||||
*/
|
||||
static void Initialize(nsStr& aDest,char* aCString,PRUint32 aCapacity,PRUint32 aLength,eCharSize aCharSize,PRBool aOwnsBuffer);
|
||||
|
||||
/**
|
||||
* This method destroys the given nsStr, and *MAY*
|
||||
* deallocate it's memory depending on the setting
|
||||
* of the internal mOwnsBUffer flag.
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aString is the nsStr to be manipulated
|
||||
* @param anAgent is the allocator to be used to the nsStr
|
||||
*/
|
||||
static void Destroy(nsStr& aDest);
|
||||
|
||||
/**
|
||||
* These methods are where memory allocation/reallocation occur.
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aString is the nsStr to be manipulated
|
||||
* @param anAgent is the allocator to be used on the nsStr
|
||||
* @return
|
||||
*/
|
||||
static PRBool EnsureCapacity(nsStr& aString,PRUint32 aNewLength);
|
||||
static PRBool GrowCapacity(nsStr& aString,PRUint32 aNewLength);
|
||||
|
||||
/**
|
||||
* These methods are used to append content to the given nsStr
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aDest is the nsStr to be appended to
|
||||
* @param aSource is the buffer to be copied from
|
||||
* @param anOffset tells us where in source to start copying
|
||||
* @param aCount tells us the (max) # of chars to copy
|
||||
* @param anAgent is the allocator to be used for alloc/free operations
|
||||
*/
|
||||
static void Append(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount);
|
||||
|
||||
/**
|
||||
* These methods are used to assign contents of a source string to dest string
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aDest is the nsStr to be appended to
|
||||
* @param aSource is the buffer to be copied from
|
||||
* @param anOffset tells us where in source to start copying
|
||||
* @param aCount tells us the (max) # of chars to copy
|
||||
* @param anAgent is the allocator to be used for alloc/free operations
|
||||
*/
|
||||
static void Assign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount);
|
||||
|
||||
/**
|
||||
* These methods are used to insert content from source string to the dest nsStr
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aDest is the nsStr to be appended to
|
||||
* @param aDestOffset tells us where in dest to start insertion
|
||||
* @param aSource is the buffer to be copied from
|
||||
* @param aSrcOffset tells us where in source to start copying
|
||||
* @param aCount tells us the (max) # of chars to insert
|
||||
* @param anAgent is the allocator to be used for alloc/free operations
|
||||
*/
|
||||
static void Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount);
|
||||
|
||||
/**
|
||||
* This method deletes chars from the given str.
|
||||
* The given allocator may choose to resize the str as well.
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aDest is the nsStr to be deleted from
|
||||
* @param aDestOffset tells us where in dest to start deleting
|
||||
* @param aCount tells us the (max) # of chars to delete
|
||||
* @param anAgent is the allocator to be used for alloc/free operations
|
||||
*/
|
||||
static void Delete(nsStr& aDest,PRUint32 aDestOffset,PRUint32 aCount);
|
||||
|
||||
/**
|
||||
* This method is used to truncate the given string.
|
||||
* The given allocator may choose to resize the str as well (but it's not likely).
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aDest is the nsStr to be appended to
|
||||
* @param aDestOffset tells us where in dest to start insertion
|
||||
* @param aSource is the buffer to be copied from
|
||||
* @param aSrcOffset tells us where in source to start copying
|
||||
* @param anAgent is the allocator to be used for alloc/free operations
|
||||
*/
|
||||
static void Truncate(nsStr& aDest,PRUint32 aDestOffset);
|
||||
|
||||
/**
|
||||
* This method is used to perform a case conversion on the given string
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aDest is the nsStr to be case shifted
|
||||
* @param toUpper tells us to go upper vs. lower
|
||||
*/
|
||||
static void ChangeCase(nsStr& aDest,PRBool aToUpper);
|
||||
|
||||
|
||||
/**
|
||||
* This method trims chars (given in aSet) from the edges of given buffer
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aDest is the buffer to be manipulated
|
||||
* @param aSet tells us which chars to remove from given buffer
|
||||
* @param aEliminateLeading tells us whether to strip chars from the start of the buffer
|
||||
* @param aEliminateTrailing tells us whether to strip chars from the start of the buffer
|
||||
*/
|
||||
static void Trim(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing);
|
||||
|
||||
/**
|
||||
* This method compresses duplicate runs of a given char from the given buffer
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aDest is the buffer to be manipulated
|
||||
* @param aSet tells us which chars to compress from given buffer
|
||||
* @param aChar is the replacement char
|
||||
* @param aEliminateLeading tells us whether to strip chars from the start of the buffer
|
||||
* @param aEliminateTrailing tells us whether to strip chars from the start of the buffer
|
||||
*/
|
||||
static void CompressSet(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool aEliminateTrailing);
|
||||
|
||||
/**
|
||||
* This method removes all occurances of chars in given set from aDest
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aDest is the buffer to be manipulated
|
||||
* @param aSet tells us which chars to compress from given buffer
|
||||
* @param aChar is the replacement char
|
||||
* @param aEliminateLeading tells us whether to strip chars from the start of the buffer
|
||||
* @param aEliminateTrailing tells us whether to strip chars from the start of the buffer
|
||||
*/
|
||||
static void StripChars(nsStr& aDest,const char* aSet);
|
||||
|
||||
/**
|
||||
* This method compares the data bewteen two nsStr's
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aStr1 is the first buffer to be compared
|
||||
* @param aStr2 is the 2nd buffer to be compared
|
||||
* @param aCount is the number of chars to compare
|
||||
* @param aIgnorecase tells us whether to use a case-sensitive comparison
|
||||
* @return -1,0,1 depending on <,==,>
|
||||
*/
|
||||
static PRInt32 Compare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase);
|
||||
|
||||
/**
|
||||
* These methods scan the given string for 1 or more chars in a given direction
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aDest is the nsStr to be searched to
|
||||
* @param aSource (or aChar) is the substr we're looking to find
|
||||
* @param aIgnoreCase tells us whether to search in a case-sensitive manner
|
||||
* @param anOffset tells us where in the dest string to start searching
|
||||
* @return the index of the source (substr) in dest, or -1 (kNotFound) if not found.
|
||||
*/
|
||||
static PRInt32 FindSubstr(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset);
|
||||
static PRInt32 FindChar(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset);
|
||||
static PRInt32 FindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset);
|
||||
|
||||
static PRInt32 RFindSubstr(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset);
|
||||
static PRInt32 RFindChar(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset);
|
||||
static PRInt32 RFindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset);
|
||||
|
||||
|
||||
PRUint32 mLength;
|
||||
PRUint32 mCapacity;
|
||||
eCharSize mCharSize;
|
||||
PRBool mOwnsBuffer;
|
||||
|
||||
union {
|
||||
char* mStr;
|
||||
PRUnichar* mUStr;
|
||||
};
|
||||
|
||||
private:
|
||||
static PRBool Alloc(nsStr& aString,PRUint32 aCount);
|
||||
static PRBool Realloc(nsStr& aString,PRUint32 aCount);
|
||||
static PRBool Free(nsStr& aString);
|
||||
|
||||
};
|
||||
|
||||
/**************************************************************
|
||||
A couple of tiny helper methods used in the string classes.
|
||||
**************************************************************/
|
||||
|
||||
inline PRInt32 MinInt(PRInt32 anInt1,PRInt32 anInt2){
|
||||
return (anInt1<anInt2) ? anInt1 : anInt2;
|
||||
}
|
||||
|
||||
inline PRInt32 MaxInt(PRInt32 anInt1,PRInt32 anInt2){
|
||||
return (anInt1<anInt2) ? anInt2 : anInt1;
|
||||
}
|
||||
|
||||
inline void AddNullTerminator(nsStr& aDest) {
|
||||
if(eTwoByte==aDest.mCharSize)
|
||||
aDest.mUStr[aDest.mLength]=0;
|
||||
else aDest.mStr[aDest.mLength]=0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the given buffer to the heap manager. Calls allocator::Free()
|
||||
* @return string length
|
||||
*/
|
||||
inline void Recycle( char* aBuffer) { nsAllocator::Free(aBuffer); }
|
||||
inline void Recycle( PRUnichar* aBuffer) { nsAllocator::Free(aBuffer); }
|
||||
|
||||
/**
|
||||
* This method is used to access a given char in the given string
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param aDest is the nsStr to be appended to
|
||||
* @param anIndex tells us where in dest to get the char from
|
||||
* @return the given char, or 0 if anIndex is out of range
|
||||
*/
|
||||
inline PRUnichar GetCharAt(const nsStr& aDest,PRUint32 anIndex){
|
||||
if(anIndex<aDest.mLength) {
|
||||
return (eTwoByte==aDest.mCharSize) ? aDest.mUStr[anIndex] : aDest.mStr[anIndex];
|
||||
}//if
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
1865
mozilla/string/obsolete/nsString.cpp
Normal file
747
mozilla/string/obsolete/nsString.h
Normal file
@@ -0,0 +1,747 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
MODULE NOTES:
|
||||
|
||||
See nsStr.h for a more general description of string classes.
|
||||
|
||||
This version of the nsString class offers many improvements over the
|
||||
original version:
|
||||
1. Wide and narrow chars
|
||||
2. Allocators
|
||||
3. Much smarter autostrings
|
||||
4. Subsumable strings
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
#ifndef _nsCString_
|
||||
#define _nsCString_
|
||||
|
||||
#include "nsString2.h"
|
||||
#include "prtypes.h"
|
||||
#include "nscore.h"
|
||||
#include <stdio.h>
|
||||
#include "nsStr.h"
|
||||
#include "nsIAtom.h"
|
||||
|
||||
|
||||
class NS_COM nsSubsumeCStr;
|
||||
|
||||
class NS_COM nsCString : public nsStr {
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
nsCString();
|
||||
|
||||
/**
|
||||
* This constructor accepts an isolatin string
|
||||
* @param aCString is a ptr to a 1-byte cstr
|
||||
*/
|
||||
nsCString(const char* aCString,PRInt32 aLength=-1);
|
||||
|
||||
/**
|
||||
* This constructor accepts a unichar string
|
||||
* @param aCString is a ptr to a 2-byte cstr
|
||||
*/
|
||||
nsCString(const PRUnichar* aString,PRInt32 aLength=-1);
|
||||
|
||||
/**
|
||||
* This is a copy constructor that accepts an nsStr
|
||||
* @param reference to another nsCString
|
||||
*/
|
||||
nsCString(const nsStr&);
|
||||
|
||||
/**
|
||||
* This is our copy constructor
|
||||
* @param reference to another nsCString
|
||||
*/
|
||||
nsCString(const nsCString& aString);
|
||||
|
||||
/**
|
||||
* This constructor takes a subsumestr
|
||||
* @param reference to subsumestr
|
||||
*/
|
||||
nsCString(nsSubsumeCStr& aSubsumeStr);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*
|
||||
*/
|
||||
virtual ~nsCString();
|
||||
|
||||
/**
|
||||
* Retrieve the length of this string
|
||||
* @return string length
|
||||
*/
|
||||
inline PRInt32 Length() const { return (PRInt32)mLength; }
|
||||
|
||||
/**
|
||||
* Retrieve the size of this string
|
||||
* @return string length
|
||||
*/
|
||||
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
|
||||
|
||||
|
||||
/**
|
||||
* Call this method if you want to force a different string capacity
|
||||
* @update gess7/30/98
|
||||
* @param aLength -- contains new length for mStr
|
||||
* @return
|
||||
*/
|
||||
void SetLength(PRUint32 aLength) {
|
||||
Truncate(aLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new length of the string.
|
||||
* @param aLength is new string length.
|
||||
* @return nada
|
||||
*/
|
||||
void SetCapacity(PRUint32 aLength);
|
||||
/**
|
||||
* This method truncates this string to given length.
|
||||
*
|
||||
* @param anIndex -- new length of string
|
||||
* @return nada
|
||||
*/
|
||||
void Truncate(PRInt32 anIndex=0);
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether or not the characters in this
|
||||
* string are in sorted order.
|
||||
*
|
||||
* @return TRUE if ordered.
|
||||
*/
|
||||
PRBool IsOrdered(void) const;
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether or not this string has a length of 0
|
||||
*
|
||||
* @return TRUE if empty.
|
||||
*/
|
||||
PRBool IsEmpty(void) const {
|
||||
return PRBool(0==mLength);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
Accessor methods...
|
||||
*********************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve const ptr to internal buffer; DO NOT TRY TO FREE IT!
|
||||
*/
|
||||
const char* GetBuffer(void) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get nth character.
|
||||
*/
|
||||
PRUnichar operator[](PRUint32 anIndex) const;
|
||||
PRUnichar CharAt(PRUint32 anIndex) const;
|
||||
PRUnichar First(void) const;
|
||||
PRUnichar Last(void) const;
|
||||
|
||||
PRBool SetCharAt(PRUnichar aChar,PRUint32 anIndex);
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
String creation methods...
|
||||
*********************************************************************/
|
||||
|
||||
/**
|
||||
* Create a new string by appending given string to this
|
||||
* @param aString -- 2nd string to be appended
|
||||
* @return new string
|
||||
*/
|
||||
nsSubsumeCStr operator+(const nsCString& aString);
|
||||
|
||||
/**
|
||||
* create a new string by adding this to the given char*.
|
||||
* @param aCString is a ptr to cstring to be added to this
|
||||
* @return newly created string
|
||||
*/
|
||||
nsSubsumeCStr operator+(const char* aCString);
|
||||
|
||||
|
||||
/**
|
||||
* create a new string by adding this to the given char.
|
||||
* @param aChar is a char to be added to this
|
||||
* @return newly created string
|
||||
*/
|
||||
nsSubsumeCStr operator+(PRUnichar aChar);
|
||||
nsSubsumeCStr operator+(char aChar);
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
Lexomorphic transforms...
|
||||
*********************************************************************/
|
||||
|
||||
/**
|
||||
* Converts chars in this to lowercase
|
||||
* @update gess 7/27/98
|
||||
*/
|
||||
void ToLowerCase();
|
||||
|
||||
|
||||
/**
|
||||
* Converts chars in this to lowercase, and
|
||||
* stores them in aOut
|
||||
* @update gess 7/27/98
|
||||
* @param aOut is a string to contain result
|
||||
*/
|
||||
void ToLowerCase(nsCString& aString) const;
|
||||
|
||||
/**
|
||||
* Converts chars in this to uppercase
|
||||
* @update gess 7/27/98
|
||||
*/
|
||||
void ToUpperCase();
|
||||
|
||||
/**
|
||||
* Converts chars in this to lowercase, and
|
||||
* stores them in a given output string
|
||||
* @update gess 7/27/98
|
||||
* @param aOut is a string to contain result
|
||||
*/
|
||||
void ToUpperCase(nsCString& aString) const;
|
||||
|
||||
|
||||
/**
|
||||
* This method is used to remove all occurances of the
|
||||
* characters found in aSet from this string.
|
||||
*
|
||||
* @param aSet -- characters to be cut from this
|
||||
* @return *this
|
||||
*/
|
||||
nsCString& StripChars(const char* aSet);
|
||||
nsCString& StripChar(char aChar);
|
||||
|
||||
/**
|
||||
* This method strips whitespace throughout the string
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
nsCString& StripWhitespace();
|
||||
|
||||
/**
|
||||
* swaps occurence of 1 string for another
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
nsCString& ReplaceChar(PRUnichar aOldChar,PRUnichar aNewChar);
|
||||
nsCString& ReplaceChar(const char* aSet,PRUnichar aNewChar);
|
||||
|
||||
PRInt32 CountChar(PRUnichar aChar);
|
||||
|
||||
/**
|
||||
* This method trims characters found in aTrimSet from
|
||||
* either end of the underlying string.
|
||||
*
|
||||
* @param aTrimSet -- contains chars to be trimmed from
|
||||
* both ends
|
||||
* @return this
|
||||
*/
|
||||
nsCString& Trim(const char* aSet,PRBool aEliminateLeading=PR_TRUE,PRBool aEliminateTrailing=PR_TRUE);
|
||||
|
||||
/**
|
||||
* This method strips whitespace from string.
|
||||
* You can control whether whitespace is yanked from
|
||||
* start and end of string as well.
|
||||
*
|
||||
* @param aEliminateLeading controls stripping of leading ws
|
||||
* @param aEliminateTrailing controls stripping of trailing ws
|
||||
* @return this
|
||||
*/
|
||||
nsCString& CompressSet(const char* aSet, PRUnichar aChar,PRBool aEliminateLeading=PR_TRUE,PRBool aEliminateTrailing=PR_TRUE);
|
||||
|
||||
/**
|
||||
* This method strips whitespace from string.
|
||||
* You can control whether whitespace is yanked from
|
||||
* start and end of string as well.
|
||||
*
|
||||
* @param aEliminateLeading controls stripping of leading ws
|
||||
* @param aEliminateTrailing controls stripping of trailing ws
|
||||
* @return this
|
||||
*/
|
||||
nsCString& CompressWhitespace( PRBool aEliminateLeading=PR_TRUE,PRBool aEliminateTrailing=PR_TRUE);
|
||||
|
||||
/**********************************************************************
|
||||
string conversion methods...
|
||||
*********************************************************************/
|
||||
|
||||
operator char*() {return mStr;}
|
||||
operator const char*() const {return (const char*)mStr;}
|
||||
|
||||
/**
|
||||
* This method constructs a new nsCString that is a clone
|
||||
* of this string.
|
||||
*
|
||||
*/
|
||||
nsCString* ToNewString() const;
|
||||
|
||||
/**
|
||||
* Creates an ISOLatin1 clone of this string
|
||||
* Note that calls to this method should be matched with calls to Recycle().
|
||||
* @return ptr to new isolatin1 string
|
||||
*/
|
||||
char* ToNewCString() const;
|
||||
|
||||
/**
|
||||
* Creates a unicode clone of this string
|
||||
* Note that calls to this method should be matched with calls to Recycle().
|
||||
* @return ptr to new unicode string
|
||||
*/
|
||||
PRUnichar* ToNewUnicode() const;
|
||||
|
||||
/**
|
||||
* Copies data from internal buffer onto given char* buffer
|
||||
* NOTE: This only copies as many chars as will fit in given buffer (clips)
|
||||
* @param aBuf is the buffer where data is stored
|
||||
* @param aBuflength is the max # of chars to move to buffer
|
||||
* @return ptr to given buffer
|
||||
*/
|
||||
char* ToCString(char* aBuf,PRUint32 aBufLength,PRUint32 anOffset=0) const;
|
||||
|
||||
/**
|
||||
* Perform string to float conversion.
|
||||
* @param aErrorCode will contain error if one occurs
|
||||
* @return float rep of string value
|
||||
*/
|
||||
float ToFloat(PRInt32* aErrorCode) const;
|
||||
|
||||
/**
|
||||
* Try to derive the radix from the value contained in this string
|
||||
* @return kRadix10, kRadix16 or kAutoDetect (meaning unknown)
|
||||
*/
|
||||
PRUint32 DetermineRadix(void);
|
||||
|
||||
/**
|
||||
* Perform string to int conversion.
|
||||
* @param aErrorCode will contain error if one occurs
|
||||
* @return int rep of string value
|
||||
*/
|
||||
PRInt32 ToInteger(PRInt32* aErrorCode,PRUint32 aRadix=kRadix10) const;
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
String manipulation methods...
|
||||
*********************************************************************/
|
||||
|
||||
/**
|
||||
* Functionally equivalent to assign or operator=
|
||||
*
|
||||
*/
|
||||
nsCString& SetString(const char* aString,PRInt32 aLength=-1) {return Assign(aString,aLength);}
|
||||
nsCString& SetString(const nsStr& aString,PRInt32 aLength=-1) {return Assign(aString,aLength);}
|
||||
|
||||
/**
|
||||
* assign given string to this string
|
||||
* @param aStr: buffer to be assigned to this
|
||||
* @param alength is the length of the given str (or -1)
|
||||
if you want me to determine its length
|
||||
* @return this
|
||||
*/
|
||||
nsCString& Assign(const nsStr& aString,PRInt32 aCount=-1);
|
||||
nsCString& Assign(const char* aString,PRInt32 aCount=-1);
|
||||
nsCString& Assign(const PRUnichar* aString,PRInt32 aCount=-1);
|
||||
nsCString& Assign(PRUnichar aChar);
|
||||
nsCString& Assign(char aChar);
|
||||
|
||||
/**
|
||||
* here come a bunch of assignment operators...
|
||||
* @param aString: string to be added to this
|
||||
* @return this
|
||||
*/
|
||||
nsCString& operator=(const nsCString& aString) {return Assign(aString);}
|
||||
nsCString& operator=(const nsStr& aString) {return Assign(aString);}
|
||||
nsCString& operator=(PRUnichar aChar) {return Assign(aChar);}
|
||||
nsCString& operator=(char aChar) {return Assign(aChar);}
|
||||
nsCString& operator=(const char* aCString) {return Assign(aCString);}
|
||||
nsCString& operator=(const PRUnichar* aString) {return Assign(aString);}
|
||||
#ifdef AIX
|
||||
nsCString& operator=(const nsSubsumeCStr& aSubsumeString); // AIX requires a const here
|
||||
#else
|
||||
nsCString& operator=(nsSubsumeCStr& aSubsumeString);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Here's a bunch of methods that append varying types...
|
||||
* @param various...
|
||||
* @return this
|
||||
*/
|
||||
nsCString& operator+=(const nsCString& aString){return Append(aString,aString.mLength);}
|
||||
nsCString& operator+=(const char* aCString) {return Append(aCString);}
|
||||
nsCString& operator+=(PRUnichar aChar){return Append(aChar);}
|
||||
nsCString& operator+=(char aChar){return Append(aChar);}
|
||||
|
||||
/*
|
||||
* Appends n characters from given string to this,
|
||||
* This version computes the length of your given string
|
||||
*
|
||||
* @param aString is the source to be appended to this
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsCString& Append(const nsCString& aString) {return Append(aString,aString.mLength);}
|
||||
|
||||
|
||||
/*
|
||||
* Appends n characters from given string to this,
|
||||
*
|
||||
* @param aString is the source to be appended to this
|
||||
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsCString& Append(const nsCString& aString,PRInt32 aCount);
|
||||
nsCString& Append(const nsStr& aString,PRInt32 aCount=-1);
|
||||
nsCString& Append(const char* aString,PRInt32 aCount=-1);
|
||||
nsCString& Append(PRUnichar aChar);
|
||||
nsCString& Append(char aChar);
|
||||
nsCString& Append(PRInt32 aInteger,PRInt32 aRadix=10); //radix=8,10 or 16
|
||||
nsCString& Append(float aFloat);
|
||||
|
||||
/*
|
||||
* Copies n characters from this string to given string,
|
||||
* starting at the leftmost offset.
|
||||
*
|
||||
*
|
||||
* @param aCopy -- Receiving string
|
||||
* @param aCount -- number of chars to copy
|
||||
* @return number of chars copied
|
||||
*/
|
||||
PRUint32 Left(nsCString& aCopy,PRInt32 aCount) const;
|
||||
|
||||
/*
|
||||
* Copies n characters from this string to given string,
|
||||
* starting at the given offset.
|
||||
*
|
||||
*
|
||||
* @param aCopy -- Receiving string
|
||||
* @param aCount -- number of chars to copy
|
||||
* @param anOffset -- position where copying begins
|
||||
* @return number of chars copied
|
||||
*/
|
||||
PRUint32 Mid(nsCString& aCopy,PRUint32 anOffset,PRInt32 aCount) const;
|
||||
|
||||
/*
|
||||
* Copies n characters from this string to given string,
|
||||
* starting at rightmost char.
|
||||
*
|
||||
*
|
||||
* @param aCopy -- Receiving string
|
||||
* @param aCount -- number of chars to copy
|
||||
* @return number of chars copied
|
||||
*/
|
||||
PRUint32 Right(nsCString& aCopy,PRInt32 aCount) const;
|
||||
|
||||
/*
|
||||
* This method inserts n chars from given string into this
|
||||
* string at str[anOffset].
|
||||
*
|
||||
* @param aCopy -- String to be inserted into this
|
||||
* @param anOffset -- insertion position within this str
|
||||
* @param aCount -- number of chars to be copied from aCopy
|
||||
* @return number of chars inserted into this.
|
||||
*/
|
||||
nsCString& Insert(const nsCString& aCopy,PRUint32 anOffset,PRInt32 aCount=-1);
|
||||
|
||||
/**
|
||||
* Insert a given string into this string at
|
||||
* a specified offset.
|
||||
*
|
||||
* @param aString* to be inserted into this string
|
||||
* @param anOffset is insert pos in str
|
||||
* @return the number of chars inserted into this string
|
||||
*/
|
||||
nsCString& Insert(const char* aChar,PRUint32 anOffset,PRInt32 aCount=-1);
|
||||
|
||||
/**
|
||||
* Insert a single char into this string at
|
||||
* a specified offset.
|
||||
*
|
||||
* @param character to be inserted into this string
|
||||
* @param anOffset is insert pos in str
|
||||
* @return the number of chars inserted into this string
|
||||
*/
|
||||
nsCString& Insert(PRUnichar aChar,PRUint32 anOffset);
|
||||
nsCString& Insert(char aChar,PRUint32 anOffset);
|
||||
|
||||
/*
|
||||
* This method is used to cut characters in this string
|
||||
* starting at anOffset, continuing for aCount chars.
|
||||
*
|
||||
* @param anOffset -- start pos for cut operation
|
||||
* @param aCount -- number of chars to be cut
|
||||
* @return *this
|
||||
*/
|
||||
nsCString& Cut(PRUint32 anOffset,PRInt32 aCount);
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
Searching methods...
|
||||
*********************************************************************/
|
||||
|
||||
/**
|
||||
* Search for given character within this string.
|
||||
* This method does so by using a binary search,
|
||||
* so your string HAD BETTER BE ORDERED!
|
||||
*
|
||||
* @param aChar is the unicode char to be found
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 BinarySearch(PRUnichar aChar) const;
|
||||
|
||||
/**
|
||||
* Search for given substring within this string
|
||||
*
|
||||
* @param aString is substring to be sought in this
|
||||
* @param aIgnoreCase selects case sensitivity
|
||||
* @param anOffset tells us where in this strig to start searching
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 Find(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 Find(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 Find(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
|
||||
/**
|
||||
* Search for given char within this string
|
||||
*
|
||||
* @param aString is substring to be sought in this
|
||||
* @param anOffset tells us where in this strig to start searching
|
||||
* @param aIgnoreCase selects case sensitivity
|
||||
* @return find pos in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 FindChar(PRUnichar aChar,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
|
||||
/**
|
||||
* This method searches this string for the first character
|
||||
* found in the given charset
|
||||
* @param aString contains set of chars to be found
|
||||
* @param anOffset tells us where to start searching in this
|
||||
* @return -1 if not found, else the offset in this
|
||||
*/
|
||||
PRInt32 FindCharInSet(const char* aString,PRInt32 anOffset=-1) const;
|
||||
PRInt32 FindCharInSet(const PRUnichar* aString,PRInt32 anOffset=-1) const;
|
||||
PRInt32 FindCharInSet(const nsStr& aString,PRInt32 anOffset=-1) const;
|
||||
|
||||
|
||||
/**
|
||||
* This methods scans the string backwards, looking for the given string
|
||||
* @param aString is substring to be sought in this
|
||||
* @param aIgnoreCase tells us whether or not to do caseless compare
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 RFind(const char* aCString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFind(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFind(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
|
||||
|
||||
/**
|
||||
* Search for given char within this string
|
||||
*
|
||||
* @param aString is substring to be sought in this
|
||||
* @param anOffset tells us where in this strig to start searching
|
||||
* @param aIgnoreCase selects case sensitivity
|
||||
* @return find pos in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 RFindChar(PRUnichar aChar,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
|
||||
/**
|
||||
* This method searches this string for the last character
|
||||
* found in the given string
|
||||
* @param aString contains set of chars to be found
|
||||
* @param anOffset tells us where to start searching in this
|
||||
* @return -1 if not found, else the offset in this
|
||||
*/
|
||||
PRInt32 RFindCharInSet(const char* aString,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFindCharInSet(const PRUnichar* aString,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFindCharInSet(const nsStr& aString,PRInt32 anOffset=-1) const;
|
||||
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
Comparison methods...
|
||||
*********************************************************************/
|
||||
|
||||
/**
|
||||
* Compares a given string type to this string.
|
||||
* @update gess 7/27/98
|
||||
* @param S is the string to be compared
|
||||
* @param aIgnoreCase tells us how to treat case
|
||||
* @param aCount tells us how many chars to compare
|
||||
* @return -1,0,1
|
||||
*/
|
||||
virtual PRInt32 Compare(const nsStr &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
virtual PRInt32 Compare(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
virtual PRInt32 Compare(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
|
||||
/**
|
||||
* These methods compare a given string type to this one
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
PRBool operator==(const nsStr &aString) const;
|
||||
PRBool operator==(const char* aString) const;
|
||||
PRBool operator==(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* These methods perform a !compare of a given string type to this
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE
|
||||
*/
|
||||
PRBool operator!=(const nsStr &aString) const;
|
||||
PRBool operator!=(const char* aString) const;
|
||||
PRBool operator!=(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* These methods test if a given string is < than this
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
PRBool operator<(const nsStr &aString) const;
|
||||
PRBool operator<(const char* aString) const;
|
||||
PRBool operator<(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* These methods test if a given string is > than this
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
PRBool operator>(const nsStr &S) const;
|
||||
PRBool operator>(const char* aString) const;
|
||||
PRBool operator>(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* These methods test if a given string is <= than this
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
PRBool operator<=(const nsStr &S) const;
|
||||
PRBool operator<=(const char* aString) const;
|
||||
PRBool operator<=(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* These methods test if a given string is >= than this
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
PRBool operator>=(const nsStr &S) const;
|
||||
PRBool operator>=(const char* aString) const;
|
||||
PRBool operator>=(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* Compare this to given string; note that we compare full strings here.
|
||||
* The optional length argument just lets us know how long the given string is.
|
||||
* If you provide a length, it is compared to length of this string as an
|
||||
* optimization.
|
||||
*
|
||||
* @param aString -- the string to compare to this
|
||||
* @param aCount -- number of chars in given string you want to compare
|
||||
* @return TRUE if equal
|
||||
*/
|
||||
PRBool Equals(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
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 EqualsIgnoreCase(const nsStr& aString) const;
|
||||
PRBool EqualsIgnoreCase(const char* aString,PRInt32 aCount=-1) const;
|
||||
PRBool EqualsIgnoreCase(const PRUnichar* aString,PRInt32 aCount=-1) const;
|
||||
|
||||
|
||||
static void Recycle(nsCString* aString);
|
||||
static nsCString* CreateString(void);
|
||||
|
||||
};
|
||||
|
||||
extern NS_COM int fputs(const nsCString& aString, FILE* out);
|
||||
//ostream& operator<<(ostream& aStream,const nsCString& aString);
|
||||
//virtual void DebugDump(ostream& aStream) const;
|
||||
|
||||
|
||||
/**************************************************************
|
||||
Here comes the AutoString class which uses internal memory
|
||||
(typically found on the stack) for its default buffer.
|
||||
If the buffer needs to grow, it gets reallocated on the heap.
|
||||
**************************************************************/
|
||||
|
||||
class NS_COM nsCAutoString : public nsCString {
|
||||
public:
|
||||
|
||||
nsCAutoString();
|
||||
nsCAutoString(const char* aString,PRInt32 aLength=-1);
|
||||
nsCAutoString(const CBufDescriptor& aBuffer);
|
||||
nsCAutoString(const PRUnichar* aString,PRInt32 aLength=-1);
|
||||
nsCAutoString(const nsStr& aString);
|
||||
nsCAutoString(const nsCAutoString& aString);
|
||||
|
||||
#ifdef AIX
|
||||
nsCAutoString(const nsSubsumeCStr& aSubsumeStr); // AIX requires a const
|
||||
#else
|
||||
nsCAutoString(nsSubsumeCStr& aSubsumeStr);
|
||||
#endif // AIX
|
||||
nsCAutoString(PRUnichar aChar);
|
||||
virtual ~nsCAutoString();
|
||||
|
||||
nsCAutoString& operator=(const nsCString& aString) {nsCString::Assign(aString); return *this;}
|
||||
nsCAutoString& operator=(const char* aCString) {nsCString::Assign(aCString); return *this;}
|
||||
nsCAutoString& operator=(PRUnichar aChar) {nsCString::Assign(aChar); return *this;}
|
||||
nsCAutoString& operator=(char aChar) {nsCString::Assign(aChar); return *this;}
|
||||
|
||||
/**
|
||||
* Retrieve the size of this string
|
||||
* @return string length
|
||||
*/
|
||||
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
|
||||
|
||||
char mBuffer[kDefaultStringSize];
|
||||
};
|
||||
|
||||
|
||||
/***************************************************************
|
||||
The subsumestr class is very unusual.
|
||||
It differs from a normal string in that it doesn't use normal
|
||||
copy semantics when another string is assign to this.
|
||||
Instead, it "steals" the contents of the source string.
|
||||
|
||||
This is very handy for returning nsString classes as part of
|
||||
an operator+(...) for example, in that it cuts down the number
|
||||
of copy operations that must occur.
|
||||
|
||||
You should probably not use this class unless you really know
|
||||
what you're doing.
|
||||
***************************************************************/
|
||||
class NS_COM nsSubsumeCStr : public nsCString {
|
||||
public:
|
||||
nsSubsumeCStr(nsStr& aString);
|
||||
nsSubsumeCStr(PRUnichar* aString,PRBool assumeOwnership,PRInt32 aLength=-1);
|
||||
nsSubsumeCStr(char* aString,PRBool assumeOwnership,PRInt32 aLength=-1);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
2233
mozilla/string/obsolete/nsString2.cpp
Normal file
840
mozilla/string/obsolete/nsString2.h
Normal file
@@ -0,0 +1,840 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
MODULE NOTES:
|
||||
|
||||
See nsStr.h for a more general description of string classes.
|
||||
|
||||
This version of the nsString class offers many improvements over the
|
||||
original version:
|
||||
1. Wide and narrow chars
|
||||
2. Allocators
|
||||
3. Much smarter autostrings
|
||||
4. Subsumable strings
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
#ifndef _nsString_
|
||||
#define _nsString_
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "nscore.h"
|
||||
#include <stdio.h>
|
||||
#include "nsString.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsStr.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
class nsISizeOfHandler;
|
||||
|
||||
|
||||
#define nsString2 nsString
|
||||
#define nsAutoString2 nsAutoString
|
||||
|
||||
|
||||
class NS_COM nsSubsumeStr;
|
||||
class NS_COM nsString : public nsStr {
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
nsString();
|
||||
|
||||
|
||||
/**
|
||||
* This constructor accepts an isolatin string
|
||||
* @param aCString is a ptr to a 1-byte cstr
|
||||
*/
|
||||
nsString(const char* aCString);
|
||||
|
||||
/**
|
||||
* This constructor accepts a unichar string
|
||||
* @param aCString is a ptr to a 2-byte cstr
|
||||
*/
|
||||
nsString(const PRUnichar* aString);
|
||||
|
||||
/**
|
||||
* This is a copy constructor that accepts an nsStr
|
||||
* @param reference to another nsString
|
||||
*/
|
||||
nsString(const nsStr&);
|
||||
|
||||
/**
|
||||
* This is our copy constructor
|
||||
* @param reference to another nsString
|
||||
*/
|
||||
nsString(const nsString& aString);
|
||||
|
||||
/**
|
||||
* This constructor takes a subsumestr
|
||||
* @param reference to subsumestr
|
||||
*/
|
||||
nsString(nsSubsumeStr& aSubsumeStr);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*
|
||||
*/
|
||||
virtual ~nsString();
|
||||
|
||||
/**
|
||||
* Retrieve the length of this string
|
||||
* @return string length
|
||||
*/
|
||||
inline PRInt32 Length() const { return (PRInt32)mLength; }
|
||||
|
||||
/**
|
||||
* Retrieve the size of this string
|
||||
* @return string length
|
||||
*/
|
||||
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
|
||||
|
||||
|
||||
/**
|
||||
* Call this method if you want to force a different string length
|
||||
* @update gess7/30/98
|
||||
* @param aLength -- contains new length for mStr
|
||||
* @return
|
||||
*/
|
||||
void SetLength(PRUint32 aLength) {
|
||||
Truncate(aLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new length of the string.
|
||||
* @param aLength is new string length.
|
||||
* @return nada
|
||||
*/
|
||||
void SetCapacity(PRUint32 aLength);
|
||||
|
||||
/**
|
||||
* This method truncates this string to given length.
|
||||
*
|
||||
* @param anIndex -- new length of string
|
||||
* @return nada
|
||||
*/
|
||||
void Truncate(PRInt32 anIndex=0);
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether or not the characters in this
|
||||
* string are in sorted order.
|
||||
*
|
||||
* @return TRUE if ordered.
|
||||
*/
|
||||
PRBool IsOrdered(void) const;
|
||||
|
||||
/**
|
||||
* Determine whether or not the characters in this
|
||||
* string are in store as 1 or 2 byte (unicode) strings.
|
||||
*
|
||||
* @return TRUE if ordered.
|
||||
*/
|
||||
PRBool IsUnicode(void) const {
|
||||
PRBool result=PRBool(mCharSize==eTwoByte);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether or not this string has a length of 0
|
||||
*
|
||||
* @return TRUE if empty.
|
||||
*/
|
||||
PRBool IsEmpty(void) const {
|
||||
return PRBool(0==mLength);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
Getters/Setters...
|
||||
*********************************************************************/
|
||||
|
||||
/**
|
||||
* Retrieve const ptr to internal buffer; DO NOT TRY TO FREE IT!
|
||||
*/
|
||||
const char* GetBuffer(void) const;
|
||||
const PRUnichar* GetUnicode(void) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get nth character.
|
||||
*/
|
||||
PRUnichar operator[](PRUint32 anIndex) const;
|
||||
PRUnichar CharAt(PRUint32 anIndex) const;
|
||||
PRUnichar First(void) const;
|
||||
PRUnichar Last(void) const;
|
||||
|
||||
/**
|
||||
* Set nth character.
|
||||
*/
|
||||
PRBool SetCharAt(PRUnichar aChar,PRUint32 anIndex);
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
String concatenation methods...
|
||||
*********************************************************************/
|
||||
|
||||
/**
|
||||
* Create a new string by appending given string to this
|
||||
* @param aString -- 2nd string to be appended
|
||||
* @return new subsumable string
|
||||
*/
|
||||
nsSubsumeStr operator+(const nsStr& aString);
|
||||
nsSubsumeStr operator+(const nsString& aString);
|
||||
|
||||
/**
|
||||
* create a new string by adding this to the given cstring
|
||||
* @param aCString is a ptr to cstring to be added to this
|
||||
* @return newly created string
|
||||
*/
|
||||
nsSubsumeStr operator+(const char* aCString);
|
||||
|
||||
/**
|
||||
* create a new string by adding this to the given prunichar*.
|
||||
* @param aString is a ptr to UC-string to be added to this
|
||||
* @return newly created string
|
||||
*/
|
||||
nsSubsumeStr operator+(const PRUnichar* aString);
|
||||
|
||||
/**
|
||||
* create a new string by adding this to the given char.
|
||||
* @param aChar is a char to be added to this
|
||||
* @return newly created string
|
||||
*/
|
||||
nsSubsumeStr operator+(char aChar);
|
||||
|
||||
/**
|
||||
* create a new string by adding this to the given char.
|
||||
* @param aChar is a unichar to be added to this
|
||||
* @return newly created string
|
||||
*/
|
||||
nsSubsumeStr operator+(PRUnichar aChar);
|
||||
|
||||
/**********************************************************************
|
||||
Lexomorphic transforms...
|
||||
*********************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* Converts chars in this to lowercase
|
||||
* @update gess 7/27/98
|
||||
*/
|
||||
void ToLowerCase();
|
||||
|
||||
|
||||
/**
|
||||
* Converts chars in this to lowercase, and
|
||||
* stores them in aOut
|
||||
* @update gess 7/27/98
|
||||
* @param aOut is a string to contain result
|
||||
*/
|
||||
void ToLowerCase(nsString& aString) const;
|
||||
|
||||
/**
|
||||
* Converts chars in this to uppercase
|
||||
* @update gess 7/27/98
|
||||
*/
|
||||
void ToUpperCase();
|
||||
|
||||
/**
|
||||
* Converts chars in this to lowercase, and
|
||||
* stores them in a given output string
|
||||
* @update gess 7/27/98
|
||||
* @param aOut is a string to contain result
|
||||
*/
|
||||
void ToUpperCase(nsString& aString) const;
|
||||
|
||||
|
||||
/**
|
||||
* This method is used to remove all occurances of the
|
||||
* characters found in aSet from this string.
|
||||
*
|
||||
* @param aSet -- characters to be cut from this
|
||||
* @return *this
|
||||
*/
|
||||
nsString& StripChars(const char* aSet);
|
||||
nsString& StripChar(char aChar);
|
||||
|
||||
/**
|
||||
* This method strips whitespace throughout the string
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
nsString& StripWhitespace();
|
||||
|
||||
/**
|
||||
* swaps occurence of 1 string for another
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
nsString& ReplaceChar(PRUnichar anOldChar,PRUnichar aNewChar);
|
||||
nsString& ReplaceChar(const char* aSet,PRUnichar aNewChar);
|
||||
|
||||
PRInt32 CountChar(PRUnichar aChar);
|
||||
|
||||
/**
|
||||
* This method trims characters found in aTrimSet from
|
||||
* either end of the underlying string.
|
||||
*
|
||||
* @param aTrimSet -- contains chars to be trimmed from
|
||||
* both ends
|
||||
* @return this
|
||||
*/
|
||||
nsString& Trim(const char* aSet,PRBool aEliminateLeading=PR_TRUE,PRBool aEliminateTrailing=PR_TRUE);
|
||||
|
||||
/**
|
||||
* This method strips whitespace from string.
|
||||
* You can control whether whitespace is yanked from
|
||||
* start and end of string as well.
|
||||
*
|
||||
* @param aEliminateLeading controls stripping of leading ws
|
||||
* @param aEliminateTrailing controls stripping of trailing ws
|
||||
* @return this
|
||||
*/
|
||||
nsString& CompressSet(const char* aSet, PRUnichar aChar,PRBool aEliminateLeading=PR_TRUE,PRBool aEliminateTrailing=PR_TRUE);
|
||||
|
||||
/**
|
||||
* This method strips whitespace from string.
|
||||
* You can control whether whitespace is yanked from
|
||||
* start and end of string as well.
|
||||
*
|
||||
* @param aEliminateLeading controls stripping of leading ws
|
||||
* @param aEliminateTrailing controls stripping of trailing ws
|
||||
* @return this
|
||||
*/
|
||||
nsString& CompressWhitespace( PRBool aEliminateLeading=PR_TRUE,PRBool aEliminateTrailing=PR_TRUE);
|
||||
|
||||
/**********************************************************************
|
||||
string conversion methods...
|
||||
*********************************************************************/
|
||||
|
||||
/**
|
||||
* This method constructs a new nsString is a clone of this string.
|
||||
*
|
||||
*/
|
||||
nsString* ToNewString() const;
|
||||
|
||||
/**
|
||||
* Creates an ISOLatin1 clone of this string
|
||||
* Note that calls to this method should be matched with calls to Recycle().
|
||||
* @return ptr to new isolatin1 string
|
||||
*/
|
||||
char* ToNewCString() const;
|
||||
|
||||
/**
|
||||
* Creates an UTF8 clone of this string
|
||||
* Note that calls to this method should be matched with calls to Recycle().
|
||||
* @return ptr to new isolatin1 string
|
||||
*/
|
||||
char* ToNewUTF8String() const;
|
||||
|
||||
/**
|
||||
* Creates a unicode clone of this string
|
||||
* Note that calls to this method should be matched with calls to Recycle().
|
||||
* @return ptr to new unicode string
|
||||
*/
|
||||
PRUnichar* ToNewUnicode() const;
|
||||
|
||||
/**
|
||||
* Copies data from internal buffer onto given char* buffer
|
||||
* NOTE: This only copies as many chars as will fit in given buffer (clips)
|
||||
* @param aBuf is the buffer where data is stored
|
||||
* @param aBuflength is the max # of chars to move to buffer
|
||||
* @return ptr to given buffer
|
||||
*/
|
||||
char* ToCString(char* aBuf,PRUint32 aBufLength,PRUint32 anOffset=0) const;
|
||||
|
||||
/**
|
||||
* Perform string to float conversion.
|
||||
* @param aErrorCode will contain error if one occurs
|
||||
* @return float rep of string value
|
||||
*/
|
||||
float ToFloat(PRInt32* aErrorCode) const;
|
||||
|
||||
/**
|
||||
* Try to derive the radix from the value contained in this string
|
||||
* @return kRadix10, kRadix16 or kAutoDetect (meaning unknown)
|
||||
*/
|
||||
PRUint32 DetermineRadix(void);
|
||||
|
||||
/**
|
||||
* Perform string to int conversion.
|
||||
* @param aErrorCode will contain error if one occurs
|
||||
* @return int rep of string value
|
||||
*/
|
||||
PRInt32 ToInteger(PRInt32* aErrorCode,PRUint32 aRadix=kRadix10) const;
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
String manipulation methods...
|
||||
*********************************************************************/
|
||||
|
||||
/**
|
||||
* Functionally equivalent to assign or operator=
|
||||
*
|
||||
*/
|
||||
nsString& SetString(const char* aString,PRInt32 aLength=-1) {return Assign(aString,aLength);}
|
||||
nsString& SetString(const PRUnichar* aString,PRInt32 aLength=-1) {return Assign(aString,aLength);}
|
||||
nsString& SetString(const nsString& aString,PRInt32 aLength=-1) {return Assign(aString,aLength);}
|
||||
|
||||
/**
|
||||
* assign given string to this string
|
||||
* @param aStr: buffer to be assigned to this
|
||||
* @param alength is the length of the given str (or -1)
|
||||
if you want me to determine its length
|
||||
* @return this
|
||||
*/
|
||||
nsString& Assign(const nsStr& aString,PRInt32 aCount=-1);
|
||||
nsString& Assign(const char* aString,PRInt32 aCount=-1);
|
||||
nsString& Assign(const PRUnichar* aString,PRInt32 aCount=-1);
|
||||
nsString& Assign(char aChar);
|
||||
nsString& Assign(PRUnichar aChar);
|
||||
|
||||
/**
|
||||
* here come a bunch of assignment operators...
|
||||
* @param aString: string to be added to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& operator=(const nsString& aString) {return Assign(aString);}
|
||||
nsString& operator=(const nsStr& aString) {return Assign(aString);}
|
||||
nsString& operator=(char aChar) {return Assign(aChar);}
|
||||
nsString& operator=(PRUnichar aChar) {return Assign(aChar);}
|
||||
nsString& operator=(const char* aCString) {return Assign(aCString);}
|
||||
nsString& operator=(const PRUnichar* aString) {return Assign(aString);}
|
||||
#ifdef AIX
|
||||
nsString& operator=(const nsSubsumeStr& aSubsumeString); // AIX requires a const here
|
||||
#else
|
||||
nsString& operator=(nsSubsumeStr& aSubsumeString);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Here's a bunch of methods that append varying types...
|
||||
* @param various...
|
||||
* @return this
|
||||
*/
|
||||
nsString& operator+=(const nsStr& aString){return Append(aString,aString.mLength);}
|
||||
nsString& operator+=(const nsString& aString){return Append(aString,aString.mLength);}
|
||||
nsString& operator+=(const char* aCString) {return Append(aCString);}
|
||||
//nsString& operator+=(char aChar){return Append(aChar);}
|
||||
nsString& operator+=(const PRUnichar* aUCString) {return Append(aUCString);}
|
||||
nsString& operator+=(PRUnichar aChar){return Append(aChar);}
|
||||
|
||||
/*
|
||||
* Appends n characters from given string to this,
|
||||
* This version computes the length of your given string
|
||||
*
|
||||
* @param aString is the source to be appended to this
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsString& Append(const nsStr& aString) {return Append(aString,aString.mLength);}
|
||||
nsString& Append(const nsString& aString) {return Append(aString,aString.mLength);}
|
||||
|
||||
|
||||
/*
|
||||
* Appends n characters from given string to this,
|
||||
*
|
||||
* @param aString is the source to be appended to this
|
||||
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsString& Append(const nsStr& aString,PRInt32 aCount);
|
||||
nsString& Append(const nsString& aString,PRInt32 aCount);
|
||||
nsString& Append(const char* aString,PRInt32 aCount=-1);
|
||||
nsString& Append(const PRUnichar* aString,PRInt32 aCount=-1);
|
||||
nsString& Append(char aChar);
|
||||
nsString& Append(PRUnichar aChar);
|
||||
nsString& Append(PRInt32 aInteger,PRInt32 aRadix=10); //radix=8,10 or 16
|
||||
nsString& Append(float aFloat);
|
||||
|
||||
/*
|
||||
* Copies n characters from this string to given string,
|
||||
* starting at the leftmost offset.
|
||||
*
|
||||
*
|
||||
* @param aCopy -- Receiving string
|
||||
* @param aCount -- number of chars to copy
|
||||
* @return number of chars copied
|
||||
*/
|
||||
PRUint32 Left(nsString& aCopy,PRInt32 aCount) const;
|
||||
|
||||
/*
|
||||
* Copies n characters from this string to given string,
|
||||
* starting at the given offset.
|
||||
*
|
||||
*
|
||||
* @param aCopy -- Receiving string
|
||||
* @param aCount -- number of chars to copy
|
||||
* @param anOffset -- position where copying begins
|
||||
* @return number of chars copied
|
||||
*/
|
||||
PRUint32 Mid(nsString& aCopy,PRUint32 anOffset,PRInt32 aCount) const;
|
||||
|
||||
/*
|
||||
* Copies n characters from this string to given string,
|
||||
* starting at rightmost char.
|
||||
*
|
||||
*
|
||||
* @param aCopy -- Receiving string
|
||||
* @param aCount -- number of chars to copy
|
||||
* @return number of chars copied
|
||||
*/
|
||||
PRUint32 Right(nsString& aCopy,PRInt32 aCount) const;
|
||||
|
||||
/*
|
||||
* This method inserts n chars from given string into this
|
||||
* string at str[anOffset].
|
||||
*
|
||||
* @param aCopy -- String to be inserted into this
|
||||
* @param anOffset -- insertion position within this str
|
||||
* @param aCount -- number of chars to be copied from aCopy
|
||||
* @return number of chars inserted into this.
|
||||
*/
|
||||
nsString& Insert(const nsString& aCopy,PRUint32 anOffset,PRInt32 aCount=-1);
|
||||
|
||||
/**
|
||||
* Insert a given string into this string at
|
||||
* a specified offset.
|
||||
*
|
||||
* @param aString* to be inserted into this string
|
||||
* @param anOffset is insert pos in str
|
||||
* @return the number of chars inserted into this string
|
||||
*/
|
||||
nsString& Insert(const char* aChar,PRUint32 anOffset,PRInt32 aCount=-1);
|
||||
nsString& Insert(const PRUnichar* aChar,PRUint32 anOffset,PRInt32 aCount=-1);
|
||||
|
||||
/**
|
||||
* Insert a single char into this string at
|
||||
* a specified offset.
|
||||
*
|
||||
* @param character to be inserted into this string
|
||||
* @param anOffset is insert pos in str
|
||||
* @return the number of chars inserted into this string
|
||||
*/
|
||||
//nsString& Insert(char aChar,PRUint32 anOffset);
|
||||
nsString& Insert(PRUnichar aChar,PRUint32 anOffset);
|
||||
|
||||
/*
|
||||
* This method is used to cut characters in this string
|
||||
* starting at anOffset, continuing for aCount chars.
|
||||
*
|
||||
* @param anOffset -- start pos for cut operation
|
||||
* @param aCount -- number of chars to be cut
|
||||
* @return *this
|
||||
*/
|
||||
nsString& Cut(PRUint32 anOffset,PRInt32 aCount);
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
Searching methods...
|
||||
*********************************************************************/
|
||||
|
||||
/**
|
||||
* Search for given character within this string.
|
||||
* This method does so by using a binary search,
|
||||
* so your string HAD BETTER BE ORDERED!
|
||||
*
|
||||
* @param aChar is the unicode char to be found
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 BinarySearch(PRUnichar aChar) const;
|
||||
|
||||
/**
|
||||
* Search for given substring within this string
|
||||
*
|
||||
* @param aString is substring to be sought in this
|
||||
* @param aIgnoreCase selects case sensitivity
|
||||
* @param anOffset tells us where in this strig to start searching
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 Find(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 Find(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 Find(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 Find(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
|
||||
|
||||
/**
|
||||
* Search for given char within this string
|
||||
*
|
||||
* @param aString is substring to be sought in this
|
||||
* @param anOffset tells us where in this strig to start searching
|
||||
* @param aIgnoreCase selects case sensitivity
|
||||
* @return find pos in string, or -1 (kNotFound)
|
||||
*/
|
||||
//PRInt32 Find(PRUnichar aChar,PRInt32 offset=-1,PRBool aIgnoreCase=PR_FALSE) const;
|
||||
PRInt32 FindChar(PRUnichar aChar,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
|
||||
/**
|
||||
* This method searches this string for the first character
|
||||
* found in the given charset
|
||||
* @param aString contains set of chars to be found
|
||||
* @param anOffset tells us where to start searching in this
|
||||
* @return -1 if not found, else the offset in this
|
||||
*/
|
||||
PRInt32 FindCharInSet(const char* aString,PRInt32 anOffset=-1) const;
|
||||
PRInt32 FindCharInSet(const PRUnichar* aString,PRInt32 anOffset=-1) const;
|
||||
PRInt32 FindCharInSet(const nsStr& aString,PRInt32 anOffset=-1) const;
|
||||
|
||||
|
||||
/**
|
||||
* This methods scans the string backwards, looking for the given string
|
||||
* @param aString is substring to be sought in this
|
||||
* @param aIgnoreCase tells us whether or not to do caseless compare
|
||||
* @param anOffset tells us where in this strig to start searching (counting from left)
|
||||
*/
|
||||
PRInt32 RFind(const char* aCString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFind(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFind(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFind(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
|
||||
|
||||
/**
|
||||
* Search for given char within this string
|
||||
*
|
||||
* @param aString is substring to be sought in this
|
||||
* @param anOffset tells us where in this strig to start searching (counting from left)
|
||||
* @param aIgnoreCase selects case sensitivity
|
||||
* @return find pos in string, or -1 (kNotFound)
|
||||
*/
|
||||
//PRInt32 RFind(PRUnichar aChar,PRInt32 offset=-1,PRBool aIgnoreCase=PR_FALSE) const;
|
||||
PRInt32 RFindChar(PRUnichar aChar,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
|
||||
/**
|
||||
* This method searches this string for the last character
|
||||
* found in the given string
|
||||
* @param aString contains set of chars to be found
|
||||
* @param anOffset tells us where in this strig to start searching (counting from left)
|
||||
* @return -1 if not found, else the offset in this
|
||||
*/
|
||||
PRInt32 RFindCharInSet(const char* aString,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFindCharInSet(const PRUnichar* aString,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFindCharInSet(const nsStr& aString,PRInt32 anOffset=-1) const;
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
Comparison methods...
|
||||
*********************************************************************/
|
||||
|
||||
/**
|
||||
* Compares a given string type to this string.
|
||||
* @update gess 7/27/98
|
||||
* @param S is the string to be compared
|
||||
* @param aIgnoreCase tells us how to treat case
|
||||
* @param aCount tells us how many chars to compare
|
||||
* @return -1,0,1
|
||||
*/
|
||||
virtual PRInt32 Compare(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
virtual PRInt32 Compare(const nsStr &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
virtual PRInt32 Compare(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
virtual PRInt32 Compare(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
|
||||
/**
|
||||
* These methods compare a given string type to this one
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
PRBool operator==(const nsString &aString) const;
|
||||
PRBool operator==(const nsStr &aString) const;
|
||||
PRBool operator==(const char *aString) const;
|
||||
PRBool operator==(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* These methods perform a !compare of a given string type to this
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE
|
||||
*/
|
||||
PRBool operator!=(const nsString &aString) const;
|
||||
PRBool operator!=(const nsStr &aString) const;
|
||||
PRBool operator!=(const char* aString) const;
|
||||
PRBool operator!=(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* These methods test if a given string is < than this
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
PRBool operator<(const nsString &aString) const;
|
||||
PRBool operator<(const nsStr &aString) const;
|
||||
PRBool operator<(const char* aString) const;
|
||||
PRBool operator<(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* These methods test if a given string is > than this
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
PRBool operator>(const nsString &aString) const;
|
||||
PRBool operator>(const nsStr &S) const;
|
||||
PRBool operator>(const char* aString) const;
|
||||
PRBool operator>(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* These methods test if a given string is <= than this
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
PRBool operator<=(const nsString &aString) const;
|
||||
PRBool operator<=(const nsStr &S) const;
|
||||
PRBool operator<=(const char* aString) const;
|
||||
PRBool operator<=(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* These methods test if a given string is >= than this
|
||||
* @param aString is the string to be compared to this
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
PRBool operator>=(const nsString &aString) const;
|
||||
PRBool operator>=(const nsStr &S) const;
|
||||
PRBool operator>=(const char* aString) const;
|
||||
PRBool operator>=(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
* Compare this to given string; note that we compare full strings here.
|
||||
* The optional length argument just lets us know how long the given string is.
|
||||
* If you provide a length, it is compared to length of this string as an
|
||||
* optimization.
|
||||
*
|
||||
* @param aString -- the string to compare to this
|
||||
* @param aCount -- number of chars to be compared.
|
||||
* @return TRUE if equal
|
||||
*/
|
||||
PRBool Equals(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
|
||||
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(/*FIX: const */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(/*FIX: const */nsIAtom *aAtom) const;
|
||||
PRBool EqualsIgnoreCase(const PRUnichar* s1, const PRUnichar* s2) const;
|
||||
|
||||
/**
|
||||
* Determine if given buffer is plain ascii
|
||||
*
|
||||
* @param aBuffer -- if null, then we test *this, otherwise we test given buffer
|
||||
* @return TRUE if is all ascii chars or if strlen==0
|
||||
*/
|
||||
PRBool IsASCII(const PRUnichar* aBuffer=0);
|
||||
|
||||
|
||||
/**
|
||||
* Determine if given char is a valid space character
|
||||
*
|
||||
* @param aChar is character to be tested
|
||||
* @return TRUE if is valid space char
|
||||
*/
|
||||
static PRBool IsSpace(PRUnichar ch);
|
||||
|
||||
/**
|
||||
* Determine if given char in valid alpha range
|
||||
*
|
||||
* @param aChar is character to be tested
|
||||
* @return TRUE if in alpha range
|
||||
*/
|
||||
static PRBool IsAlpha(PRUnichar ch);
|
||||
|
||||
/**
|
||||
* Determine if given char is valid digit
|
||||
*
|
||||
* @param aChar is character to be tested
|
||||
* @return TRUE if char is a valid digit
|
||||
*/
|
||||
static PRBool IsDigit(PRUnichar ch);
|
||||
|
||||
static void Recycle(nsString* aString);
|
||||
static nsString* CreateString(void);
|
||||
|
||||
};
|
||||
|
||||
extern NS_COM int fputs(const nsString& aString, FILE* out);
|
||||
//ostream& operator<<(ostream& aStream,const nsString& aString);
|
||||
//virtual void DebugDump(ostream& aStream) const;
|
||||
|
||||
|
||||
/**************************************************************
|
||||
Here comes the AutoString class which uses internal memory
|
||||
(typically found on the stack) for its default buffer.
|
||||
If the buffer needs to grow, it gets reallocated on the heap.
|
||||
**************************************************************/
|
||||
|
||||
class NS_COM nsAutoString : public nsString {
|
||||
public:
|
||||
|
||||
nsAutoString();
|
||||
nsAutoString(const char* aCString,PRInt32 aLength=-1);
|
||||
nsAutoString(const PRUnichar* aString,PRInt32 aLength=-1);
|
||||
|
||||
nsAutoString(const CBufDescriptor& aBuffer);
|
||||
nsAutoString(const nsStr& aString);
|
||||
nsAutoString(const nsAutoString& aString);
|
||||
#ifdef AIX
|
||||
nsAutoString(const nsSubsumeStr& aSubsumeStr); // AIX requires a const
|
||||
#else
|
||||
nsAutoString(nsSubsumeStr& aSubsumeStr);
|
||||
#endif // AIX
|
||||
nsAutoString(PRUnichar aChar);
|
||||
virtual ~nsAutoString();
|
||||
|
||||
nsAutoString& operator=(const nsStr& aString) {nsString::Assign(aString); return *this;}
|
||||
nsAutoString& operator=(const nsAutoString& aString) {nsString::Assign(aString); return *this;}
|
||||
nsAutoString& operator=(const char* aCString) {nsString::Assign(aCString); return *this;}
|
||||
nsAutoString& operator=(char aChar) {nsString::Assign(aChar); return *this;}
|
||||
nsAutoString& operator=(const PRUnichar* aBuffer) {nsString::Assign(aBuffer); return *this;}
|
||||
nsAutoString& operator=(PRUnichar aChar) {nsString::Assign(aChar); return *this;}
|
||||
|
||||
/**
|
||||
* Retrieve the size of this string
|
||||
* @return string length
|
||||
*/
|
||||
virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
|
||||
|
||||
char mBuffer[kDefaultStringSize<<eTwoByte];
|
||||
};
|
||||
|
||||
|
||||
|
||||
/***************************************************************
|
||||
The subsumestr class is very unusual.
|
||||
It differs from a normal string in that it doesn't use normal
|
||||
copy semantics when another string is assign to this.
|
||||
Instead, it "steals" the contents of the source string.
|
||||
|
||||
This is very handy for returning nsString classes as part of
|
||||
an operator+(...) for example, in that it cuts down the number
|
||||
of copy operations that must occur.
|
||||
|
||||
You should probably not use this class unless you really know
|
||||
what you're doing.
|
||||
***************************************************************/
|
||||
class NS_COM nsSubsumeStr : public nsString {
|
||||
public:
|
||||
nsSubsumeStr(nsStr& aString);
|
||||
nsSubsumeStr(PRUnichar* aString,PRBool assumeOwnership,PRInt32 aLength=-1);
|
||||
nsSubsumeStr(char* aString,PRBool assumeOwnership,PRInt32 aLength=-1);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
179
mozilla/string/obsolete/nsXPIDLString.cpp
Normal file
@@ -0,0 +1,179 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsDebug.h"
|
||||
#include "nsIAllocator.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "plstr.h"
|
||||
|
||||
// If the allocator changes, fix it here.
|
||||
#define XPIDL_STRING_ALLOC(__len) ((PRUnichar*) nsAllocator::Alloc((__len) * sizeof(PRUnichar)))
|
||||
#define XPIDL_CSTRING_ALLOC(__len) ((char*) nsAllocator::Alloc((__len) * sizeof(char)))
|
||||
#define XPIDL_FREE(__ptr) (nsAllocator::Free(__ptr))
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsXPIDLString
|
||||
|
||||
nsXPIDLString::nsXPIDLString()
|
||||
: mBuf(0),
|
||||
mBufOwner(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
nsXPIDLString::~nsXPIDLString()
|
||||
{
|
||||
if (mBufOwner && mBuf)
|
||||
XPIDL_FREE(mBuf);
|
||||
}
|
||||
|
||||
|
||||
nsXPIDLString::operator const PRUnichar*()
|
||||
{
|
||||
return mBuf;
|
||||
}
|
||||
|
||||
|
||||
PRUnichar*
|
||||
nsXPIDLString::Copy(const PRUnichar* aString)
|
||||
{
|
||||
NS_ASSERTION(aString, "null ptr");
|
||||
if (! aString)
|
||||
return 0;
|
||||
|
||||
PRInt32 len = 0;
|
||||
|
||||
{
|
||||
const PRUnichar* p = aString;
|
||||
while (*p++)
|
||||
len++;
|
||||
}
|
||||
|
||||
PRUnichar* result = XPIDL_STRING_ALLOC(len + 1);
|
||||
if (result) {
|
||||
PRUnichar* q = result;
|
||||
while (*aString) {
|
||||
*q = *aString;
|
||||
q++;
|
||||
aString++;
|
||||
}
|
||||
*q = '\0';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
PRUnichar**
|
||||
nsXPIDLString::StartAssignmentByValue()
|
||||
{
|
||||
if (mBufOwner && mBuf)
|
||||
XPIDL_FREE(mBuf);
|
||||
|
||||
mBuf = 0;
|
||||
mBufOwner = PR_TRUE;
|
||||
return &mBuf;
|
||||
}
|
||||
|
||||
|
||||
const PRUnichar**
|
||||
nsXPIDLString::StartAssignmentByReference()
|
||||
{
|
||||
if (mBufOwner && mBuf)
|
||||
XPIDL_FREE(mBuf);
|
||||
|
||||
mBuf = 0;
|
||||
mBufOwner = PR_FALSE;
|
||||
return (const PRUnichar**) &mBuf;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsXPIDLCString
|
||||
|
||||
nsXPIDLCString::nsXPIDLCString()
|
||||
: mBuf(0),
|
||||
mBufOwner(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
nsXPIDLCString::~nsXPIDLCString()
|
||||
{
|
||||
if (mBufOwner && mBuf)
|
||||
XPIDL_FREE(mBuf);
|
||||
}
|
||||
|
||||
|
||||
nsXPIDLCString& nsXPIDLCString::operator =(const char* aCString)
|
||||
{
|
||||
if (mBufOwner && mBuf)
|
||||
XPIDL_FREE(mBuf);
|
||||
|
||||
mBuf = Copy(aCString);
|
||||
mBufOwner = PR_TRUE;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
nsXPIDLCString::operator const char*()
|
||||
{
|
||||
return mBuf;
|
||||
}
|
||||
|
||||
|
||||
char*
|
||||
nsXPIDLCString::Copy(const char* aCString)
|
||||
{
|
||||
NS_ASSERTION(aCString, "null ptr");
|
||||
if (! aCString)
|
||||
return 0;
|
||||
|
||||
PRInt32 len = PL_strlen(aCString);
|
||||
char* result = XPIDL_CSTRING_ALLOC(len + 1);
|
||||
if (result)
|
||||
PL_strcpy(result, aCString);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
char**
|
||||
nsXPIDLCString::StartAssignmentByValue()
|
||||
{
|
||||
if (mBufOwner && mBuf)
|
||||
XPIDL_FREE(mBuf);
|
||||
|
||||
mBuf = 0;
|
||||
mBufOwner = PR_TRUE;
|
||||
return &mBuf;
|
||||
}
|
||||
|
||||
|
||||
const char**
|
||||
nsXPIDLCString::StartAssignmentByReference()
|
||||
{
|
||||
if (mBufOwner && mBuf)
|
||||
XPIDL_FREE(mBuf);
|
||||
|
||||
mBuf = 0;
|
||||
mBufOwner = PR_FALSE;
|
||||
return (const char**) &mBuf;
|
||||
}
|
||||
|
||||
|
||||
302
mozilla/string/obsolete/nsXPIDLString.h
Normal file
@@ -0,0 +1,302 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
A set of string wrapper classes that ease transition to use of XPIDL
|
||||
interfaces. nsXPIDLString and nsXPIDLCString are to XPIDL `wstring'
|
||||
and `string' out params as nsCOMPtr is to generic XPCOM interface
|
||||
pointers. They help you deal with object ownership.
|
||||
|
||||
Consider the following interface:
|
||||
|
||||
interface nsIFoo {
|
||||
attribute string Bar;
|
||||
};
|
||||
|
||||
This will generate the following C++ header file:
|
||||
|
||||
class nsIFoo {
|
||||
NS_IMETHOD SetBar(const PRUnichar* aValue);
|
||||
NS_IMETHOD GetBar(PRUnichar* *aValue);
|
||||
};
|
||||
|
||||
The GetBar() method will allocate a copy of the nsIFoo object's
|
||||
"bar" attribute, and leave you to deal with freeing it:
|
||||
|
||||
nsIFoo* aFoo; // assume we get this somehow
|
||||
PRUnichar* bar;
|
||||
aFoo->GetFoo(&bar);
|
||||
// Use bar here...
|
||||
printf("bar is %s!\n", bar);
|
||||
nsAllocator::Free(bar);
|
||||
|
||||
This makes your life harder, because you need to convolute your code
|
||||
to ensure that you don't leak `bar'.
|
||||
|
||||
Enter nsXPIDLString, which manages the ownership of the allocated
|
||||
string, and automatically destroys it when the nsXPIDLString goes
|
||||
out of scope:
|
||||
|
||||
nsIFoo* aFoo;
|
||||
nsXPIDLString bar;
|
||||
aFoo->GetFoo( getter_Copies(bar) );
|
||||
// Use bar here...
|
||||
printf("bar is %s!\n", (const char*) bar);
|
||||
// no need to remember to nsAllocator::Free().
|
||||
|
||||
Like nsCOMPtr, nsXPIDLString uses some syntactic sugar to make it
|
||||
painfully clear exactly what the code expects. You need to wrap an
|
||||
nsXPIDLString object with either `getter_Copies()' or
|
||||
`getter_Shares()' before passing it to a getter: these tell the
|
||||
nsXPIDLString how ownership is being handled.
|
||||
|
||||
In the case of `getter_Copies()', the callee is allocating a copy
|
||||
(which is usually the case). In the case of `getter_Shares()', the
|
||||
callee is returning a const reference to `the real deal' (this can
|
||||
be done using the [shared] attribute in XPIDL).
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsXPIDLString_h__
|
||||
#define nsXPIDLString_h__
|
||||
|
||||
#include "nsCom.h"
|
||||
#include "prtypes.h"
|
||||
|
||||
#ifndef __PRUNICHAR__
|
||||
#define __PRUNICHAR__
|
||||
typedef PRUint16 PRUnichar;
|
||||
#endif /* __PRUNICHAR__ */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsXPIDLString
|
||||
//
|
||||
// A wrapper for Unicode strings. With the |getter_Copies()| and
|
||||
// |getter_Shares()| helper functions, this can be used instead of
|
||||
// the "naked" |PRUnichar*| interface for |wstring| parameters in
|
||||
// XPIDL interfaces.
|
||||
//
|
||||
|
||||
class NS_COM nsXPIDLString {
|
||||
private:
|
||||
PRUnichar* mBuf;
|
||||
PRBool mBufOwner;
|
||||
|
||||
PRUnichar** StartAssignmentByValue();
|
||||
const PRUnichar** StartAssignmentByReference();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Construct a new, uninitialized wrapper for a Unicode string.
|
||||
*/
|
||||
nsXPIDLString();
|
||||
|
||||
virtual ~nsXPIDLString();
|
||||
|
||||
/**
|
||||
* Return a reference to the immutable Unicode string.
|
||||
*/
|
||||
operator const PRUnichar*();
|
||||
|
||||
/**
|
||||
* Make a copy of the Unicode string. Use this function in the
|
||||
* callee to ensure that the correct memory allocator is used.
|
||||
*/
|
||||
static PRUnichar* Copy(const PRUnichar* aString);
|
||||
|
||||
// A helper class for assignment-by-value. This class is an
|
||||
// implementation detail and should not be considered part of the
|
||||
// public interface.
|
||||
class NS_COM GetterCopies {
|
||||
private:
|
||||
nsXPIDLString& mXPIDLString;
|
||||
|
||||
public:
|
||||
GetterCopies(nsXPIDLString& aXPIDLString)
|
||||
: mXPIDLString(aXPIDLString) {}
|
||||
|
||||
operator PRUnichar**() {
|
||||
return mXPIDLString.StartAssignmentByValue();
|
||||
}
|
||||
|
||||
friend GetterCopies getter_Copies(nsXPIDLString& aXPIDLString);
|
||||
};
|
||||
|
||||
friend class GetterCopies;
|
||||
|
||||
// A helper class for assignment-by-reference. This class is an
|
||||
// implementation detail and should not be considered part of the
|
||||
// public interface.
|
||||
class NS_COM GetterShares {
|
||||
private:
|
||||
nsXPIDLString& mXPIDLString;
|
||||
|
||||
public:
|
||||
GetterShares(nsXPIDLString& aXPIDLString)
|
||||
: mXPIDLString(aXPIDLString) {}
|
||||
|
||||
operator const PRUnichar**() {
|
||||
return mXPIDLString.StartAssignmentByReference();
|
||||
}
|
||||
|
||||
friend GetterShares getter_Shares(nsXPIDLString& aXPIDLString);
|
||||
};
|
||||
|
||||
friend class GetterShares;
|
||||
|
||||
private:
|
||||
// not to be implemented
|
||||
nsXPIDLString(nsXPIDLString& /* aXPIDLString */) {}
|
||||
nsXPIDLString& operator =(nsXPIDLString& /* aXPIDLString */) { return *this; }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Use this function to "wrap" the nsXPIDLString object that is to
|
||||
* receive an |out| value.
|
||||
*/
|
||||
inline nsXPIDLString::GetterCopies
|
||||
getter_Copies(nsXPIDLString& aXPIDLString)
|
||||
{
|
||||
return nsXPIDLString::GetterCopies(aXPIDLString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this function to "wrap" the nsXPIDLString object that is to
|
||||
* receive a |[shared] out| value.
|
||||
*/
|
||||
inline nsXPIDLString::GetterShares
|
||||
getter_Shares(nsXPIDLString& aXPIDLString)
|
||||
{
|
||||
return nsXPIDLString::GetterShares(aXPIDLString);
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsXPIDLCString
|
||||
//
|
||||
// A wrapper for Unicode strings. With the |getter_Copies()| and
|
||||
// |getter_Shares()| helper functions, this can be used instead of
|
||||
// the "naked" |char*| interface for |string| parameters in XPIDL
|
||||
// interfaces.
|
||||
//
|
||||
|
||||
class NS_COM nsXPIDLCString {
|
||||
private:
|
||||
char* mBuf;
|
||||
PRBool mBufOwner;
|
||||
|
||||
char** StartAssignmentByValue();
|
||||
const char** StartAssignmentByReference();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Construct a new, uninitialized wrapper for a single-byte string.
|
||||
*/
|
||||
nsXPIDLCString();
|
||||
|
||||
virtual ~nsXPIDLCString();
|
||||
|
||||
/**
|
||||
* Assign a single-byte string to this wrapper. Copies and owns the result.
|
||||
*/
|
||||
nsXPIDLCString& operator =(const char* aString);
|
||||
|
||||
/**
|
||||
* Return a reference to the immutable single-byte string.
|
||||
*/
|
||||
operator const char*();
|
||||
|
||||
/**
|
||||
* Make a copy of the single-byte string. Use this function in the
|
||||
* callee to ensure that the correct memory allocator is used.
|
||||
*/
|
||||
static char* Copy(const char* aString);
|
||||
|
||||
// A helper class for assignment-by-value. This class is an
|
||||
// implementation detail and should not be considered part of the
|
||||
// public interface.
|
||||
class NS_COM GetterCopies {
|
||||
private:
|
||||
nsXPIDLCString& mXPIDLString;
|
||||
|
||||
public:
|
||||
GetterCopies(nsXPIDLCString& aXPIDLString)
|
||||
: mXPIDLString(aXPIDLString) {}
|
||||
|
||||
operator char**() {
|
||||
return mXPIDLString.StartAssignmentByValue();
|
||||
}
|
||||
|
||||
friend GetterCopies getter_Copies(nsXPIDLCString& aXPIDLString);
|
||||
};
|
||||
|
||||
friend class GetterCopies;
|
||||
|
||||
// A helper class for assignment-by-reference. This class is an
|
||||
// implementation detail and should not be considered part of the
|
||||
// public interface.
|
||||
class NS_COM GetterShares {
|
||||
private:
|
||||
nsXPIDLCString& mXPIDLString;
|
||||
|
||||
public:
|
||||
GetterShares(nsXPIDLCString& aXPIDLString)
|
||||
: mXPIDLString(aXPIDLString) {}
|
||||
|
||||
operator const char**() {
|
||||
return mXPIDLString.StartAssignmentByReference();
|
||||
}
|
||||
|
||||
friend GetterShares getter_Shares(nsXPIDLCString& aXPIDLString);
|
||||
};
|
||||
|
||||
friend class GetterShares;
|
||||
|
||||
private:
|
||||
// not to be implemented
|
||||
nsXPIDLCString(nsXPIDLCString& /* aXPIDLString */) {}
|
||||
nsXPIDLCString& operator =(nsXPIDLCString& /* aXPIDLCString */) { return *this; }
|
||||
};
|
||||
|
||||
/**
|
||||
* Use this function to "wrap" the nsXPIDLCString object that is to
|
||||
* receive an |out| value.
|
||||
*/
|
||||
inline nsXPIDLCString::GetterCopies
|
||||
getter_Copies(nsXPIDLCString& aXPIDLString)
|
||||
{
|
||||
return nsXPIDLCString::GetterCopies(aXPIDLString);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Use this function to "wrap" the nsXPIDLCString object that is to
|
||||
* receive a |[shared] out| value.
|
||||
*/
|
||||
inline nsXPIDLCString::GetterShares
|
||||
getter_Shares(nsXPIDLCString& aXPIDLString)
|
||||
{
|
||||
return nsXPIDLCString::GetterShares(aXPIDLString);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // nsXPIDLString_h__
|
||||
@@ -1,104 +0,0 @@
|
||||
# a) Install me in public/htdocs/.htaccess, or
|
||||
# b) Create a <Directory> entry in your Apache conf
|
||||
|
||||
# You MUST define YOURPATH/inc as an include_path!
|
||||
php_value include_path /YOURPATH/v2/public/inc:.:/usr/share/pear:/YOURPATH/v2/shared/lib
|
||||
|
||||
# Init script to set up required libraries.
|
||||
php_value auto_prepend_file init.php
|
||||
|
||||
# Finish script that calls $tpl->display for global Smarty object.
|
||||
php_value auto_append_file finish.php
|
||||
|
||||
# Rewrite engine must be used to simplify URLs so they are human readable.
|
||||
RewriteEngine On
|
||||
RewriteBase /YOURPATH/public/htdocs
|
||||
|
||||
# Rewrites to be compatible with older versions of addons.
|
||||
RewriteRule ^update/VersionCheck.php(.*)$ update.php$1
|
||||
RewriteRule ^rss/index.php(.*)$ rss.php$1
|
||||
|
||||
# Send search-engine requests to search-engines.php.
|
||||
RewriteRule ^search-engines[/]{0,1}$ search-engines.php [L]
|
||||
|
||||
# Compatibility for v1 extension and theme links.
|
||||
# Old example URLs:
|
||||
# /extensions/moreinfo.php?application=thunderbird&id=123
|
||||
# /extensions/moreinfo.php?id=123
|
||||
# /themes/moreinfo.php?id=321&application=seamonkey
|
||||
# /themes/moreinfo.php?id=321
|
||||
# New:
|
||||
# /thunderbird/123/
|
||||
# /firefox/123/
|
||||
# /seamonkey/321/
|
||||
# /firefox/321/
|
||||
RewriteCond %{QUERY_STRING} application=(\w+)&.*id=([0-9]+)
|
||||
RewriteRule ^(extensions|themes)/moreinfo.php$ %1/%2/? [R=301,L]
|
||||
RewriteCond %{QUERY_STRING} id=([0-9]+)&.*application=(\w+)
|
||||
RewriteRule ^(extensions|themes)/moreinfo.php$ %2/%1/? [R=301,L]
|
||||
RewriteCond %{QUERY_STRING} id=([0-9]+)
|
||||
RewriteRule ^(extensions|themes)/moreinfo.php$ firefox/%1/? [R=301,L]
|
||||
|
||||
# Compatibility for v1 of extensions. The hardcoded URL's in the old
|
||||
# browsers need this to get to the right pages: (the strings are the GUIDs)
|
||||
# Old example URL:
|
||||
# /extensions/?application={3550f703-e582-4d05-9a08-453d09bdfdc6}
|
||||
# New:
|
||||
# /extensions.php?app={3550f703-e582-4d05-9a08-453d09bdfdc6}
|
||||
RewriteCond %{QUERY_STRING} ^application=(.*)$
|
||||
RewriteRule ^extensions/$ extensions.php?app=%1 [R=301,L]
|
||||
|
||||
# Compatibility for v1 of extensions. The hardcoded URL's in the old
|
||||
# browsers need this to get to the right pages: (the strings are the GUIDs)
|
||||
# Old example URL:
|
||||
# /themes/?application={3550f703-e582-4d05-9a08-453d09bdfdc6}
|
||||
# New:
|
||||
# /themes.php?app={3550f703-e582-4d05-9a08-453d09bdfdc6}
|
||||
RewriteCond %{QUERY_STRING} ^application=(.*)$
|
||||
RewriteRule ^themes/$ themes.php?app=%1 [R=301,L]
|
||||
|
||||
# Send rss/* to rss.php.
|
||||
# Example:
|
||||
# /rss/firefox/extensions/popular/ -> rss.php?app=firefox&type=extensions&list=popular
|
||||
RewriteRule ^rss/(\w+)/(\w+)/(\w+)[/]{0,1}$ rss.php?app=$1&type=$2&list=$3
|
||||
|
||||
# Rewrite to addon.php if all we have is a numerical id after appname.
|
||||
# Example:
|
||||
# /firefox/220/ -> addon.php?app=firefox&id=220
|
||||
RewriteRule ^(\w+)/(\d+)[/]{0,1}$ addon.php?app=$1&id=$2
|
||||
|
||||
# Rewrite to an addon-specific page, passing app and id.
|
||||
# Example:
|
||||
# /firefox/220/previews/ -> previews.php?app=firefox&id=220
|
||||
RewriteRule ^(\w+)/(\d+)/(\w+)[/]{0,1}$ $3.php?app=$1&id=$2
|
||||
|
||||
# Rewrite to addon.php if there is a name given plus overview (special case for addon.php).
|
||||
# Example:
|
||||
# /firefox/flashgot/overview/ -> addon.php?app=firefox&name=flashgot
|
||||
RewriteRule ^(\w+)/(\w+)/overview[/]{0,1}$ addon.php?app=$1&name=$2
|
||||
|
||||
# Rewrite to addon-specific page, passing app and addon name.
|
||||
# Example:
|
||||
# /firefox/flashgot/previews/ -> previews.php?app=firefox&name=flashgot
|
||||
RewriteRule ^(\w+)/(\w+)/(\w+)[/]{0,1}$ $3.php?app=$1&name=$2
|
||||
|
||||
# Special rewrite for dictionaries
|
||||
# Example:
|
||||
# /en-US/firefox/1.5/dictionaries/ -> search.php?cat=68&app=firefox&type=E
|
||||
RewriteRule ^([a-zA-Z]{2}(-[a-zA-Z]{2})?)/(\w+)/([0-9A-Za-z.-]+)/dictionaries[/]{0,1}$ search.php?cat=68&app=$2&type=E [L]
|
||||
|
||||
# Rewrite top-level pages.
|
||||
# Examples:
|
||||
# /firefox/extensions/ -> extensions.php?app=firefox
|
||||
# /firefox/themes/ -> themes.php?app=firefox
|
||||
RewriteRule ^(\w+)/([\w-]+)[/]{0,1}$ $2.php?app=$1
|
||||
|
||||
# Rewrite for main page & app.
|
||||
# Example:
|
||||
# /firefox/ -> /?app=firefox
|
||||
RewriteRule ^(\w+)[/]{0,1}$ index.php?app=$1
|
||||
|
||||
# Rewrite for client blocklist requests.
|
||||
# Example:
|
||||
# /blocklist/1/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/1.5 -> blocklist.php?reqVersion=1&appGuid={ec8030f7-c20a-464f-9b0e-13a3a9e97384}&appVersion=1.5
|
||||
RewriteRule ^blocklist/(.+)/(.+)/(.+)[/]{0,1}$ blocklist.php?reqVersion=$1&appGuid=$2&appVersion=$3
|
||||
@@ -1,130 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Add a comment to any Addon.
|
||||
*
|
||||
* @package amo
|
||||
* @subpackage docs
|
||||
*
|
||||
* Variables:
|
||||
* $_GET['aid'] = Addon ID (integer)
|
||||
*/
|
||||
|
||||
startProcessing('addcomment.tpl', null, null,'rustico');
|
||||
require_once 'includes.php';
|
||||
|
||||
session_start();
|
||||
|
||||
if ((!array_key_exists('aid', $_GET)) || !is_numeric($_GET['aid'])) {
|
||||
triggerError('There was an error processing your request.');
|
||||
}
|
||||
|
||||
//This is a secure page, so we'll check the session
|
||||
if (!$_auth->validSession()) {
|
||||
//id is already verified to be numeric from above
|
||||
header('Location: '.WEB_PATH."/login.php?dest=comment&aid={$_GET['aid']}");
|
||||
exit;
|
||||
}
|
||||
|
||||
// If there are errors, this will be populated
|
||||
$_errors = array();
|
||||
|
||||
// This will be used in queries and the template
|
||||
$addon = new AddOn($_GET['aid']);
|
||||
|
||||
// If the comment is added successfully, this will toggle (used in the template)
|
||||
$added_comment = false;
|
||||
|
||||
// They're posting a comment
|
||||
if (isset($_POST['c_submit'])) {
|
||||
|
||||
if (! (array_key_exists('c_rating', $_POST)
|
||||
&& array_key_exists('c_title', $_POST)
|
||||
&& array_key_exists('c_comments', $_POST))) {
|
||||
//This should never happen, but hey...
|
||||
triggerError('There was an error processing your request.');
|
||||
}
|
||||
|
||||
// Check all our input to make sure something is there, and it is appropriate.
|
||||
// If it isn't, make $_bad_input=true which means we'll print the form back out
|
||||
// with an error message. (By using booleans here, we keep the error messages in
|
||||
// the .tpl)
|
||||
$_bad_input = false;
|
||||
if (!is_numeric($_POST['c_rating']) || $_POST['c_rating'] < 0 || $_POST['c_rating'] > 5) {
|
||||
$_errors['c_rating'] = true;
|
||||
$_bad_input = true;
|
||||
}
|
||||
if (empty($_POST['c_title'])) {
|
||||
$_errors['c_title'] = true;
|
||||
$_bad_input = true;
|
||||
}
|
||||
if (empty($_POST['c_comments'])) {
|
||||
$_errors['c_comments'] = true;
|
||||
$_bad_input = true;
|
||||
}
|
||||
|
||||
// If bad_input is true, we'll skip the rest of the processing and dump them
|
||||
// back out to the from with an error.
|
||||
if ($_bad_input === false) {
|
||||
|
||||
// I got a little carried away with the escaping, but it's not gonna hurt anything.
|
||||
$_c_id = mysql_real_escape_string($addon->ID);
|
||||
$_c_user_id = mysql_real_escape_string($_auth->getId());
|
||||
$_c_rating = mysql_real_escape_string($_POST['c_rating']);
|
||||
$_c_title = mysql_real_escape_string(strip_tags($_POST['c_title']));
|
||||
$_c_comments = mysql_real_escape_string(strip_tags($_POST['c_comments']));
|
||||
$_c_commentip = mysql_real_escape_string($_SERVER['REMOTE_ADDR']);
|
||||
|
||||
$_sql = "INSERT INTO `feedback`
|
||||
(
|
||||
`ID`,
|
||||
`UserId`,
|
||||
`CommentVote`,
|
||||
`CommentTitle`,
|
||||
`CommentNote`,
|
||||
`CommentDate`,
|
||||
`commentip`
|
||||
) VALUES (
|
||||
{$_c_id},
|
||||
{$_c_user_id},
|
||||
{$_c_rating},
|
||||
'{$_c_title}',
|
||||
'{$_c_comments}',
|
||||
NOW(),
|
||||
'{$_c_commentip}'
|
||||
)";
|
||||
|
||||
$db->query($_sql);
|
||||
|
||||
if (!DB::isError($db->record)) {
|
||||
// Calculate the lookup value in main for comment avg if our INSERT was successful.
|
||||
$_ratingSql = "UPDATE `main` SET `Rating` = ROUND((SELECT AVG(`CommentVote`) FROM `feedback` WHERE `ID` = {$_c_id}),2) WHERE `ID` = {$_c_id}";
|
||||
$db->query($_ratingSql);
|
||||
}
|
||||
|
||||
// For the template
|
||||
$added_comment = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Put values back into the form - if something went wrong this will populate the
|
||||
// form again
|
||||
$c_rating_value = array_key_exists('c_rating', $_POST) ? $_POST['c_rating'] : '';
|
||||
$c_title_value = array_key_exists('c_title', $_POST) ? $_POST['c_title'] : '';
|
||||
$c_comments_value = array_key_exists('c_comments', $_POST) ? $_POST['c_comments'] : '';
|
||||
|
||||
// Assign template variables.
|
||||
$tpl->assign(
|
||||
array( 'title' => 'Add Comment',
|
||||
'currentTab' => null,
|
||||
'rate_select_value' => array('','5','4','3','2','1','0'),
|
||||
'rate_select_name' => array('Rating:','5 stars', '4 stars', '3 stars', '2 stars', '1 star', '0 stars'),
|
||||
'addon' => $addon,
|
||||
'c_added_comment' => $added_comment,
|
||||
'c_errors' => $_errors,
|
||||
'c_rating_value' => $c_rating_value,
|
||||
'c_title_value' => $c_title_value,
|
||||
'c_comments_value' => $c_comments_value,
|
||||
'sidebar' => 'inc/addon-sidebar.tpl'
|
||||
)
|
||||
);
|
||||
?>
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Addon summary page. Displays a top-down view of all Addon properties.
|
||||
*
|
||||
* @package amo
|
||||
* @subpackage docs
|
||||
*/
|
||||
|
||||
// Get the int value of our addon ID.
|
||||
$clean['ID'] = intval($_GET['id']);
|
||||
$sql['ID'] =& $clean['ID'];
|
||||
|
||||
startProcessing('addon.tpl',$clean['ID'],$compileId,"rustico");
|
||||
require_once('includes.php');
|
||||
|
||||
// Create our AddOn object using the ID.
|
||||
$addon = new AddOn($sql['ID']);
|
||||
|
||||
/* This is kind of a cheesy hack to determine how to display
|
||||
download links on the addon page. If only one link is shown,
|
||||
there will just be an "Install Now" link, otherwise there will
|
||||
be links for each version. */
|
||||
if (sizeof($addon->OsVersions) == 1) {
|
||||
$multiDownloadLinks = false;
|
||||
} else {
|
||||
$multiDownloadLinks = true;
|
||||
}
|
||||
|
||||
// Assign template variables.
|
||||
$tpl->assign(
|
||||
array( 'addon' => $addon,
|
||||
'multiDownloadLinks' => $multiDownloadLinks,
|
||||
'title' => $addon->Name,
|
||||
'content' => 'addon.tpl',
|
||||
'sidebar' => 'inc/addon-sidebar.tpl')
|
||||
);
|
||||
?>
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Author information.
|
||||
* @package amo
|
||||
* @subpackage docs
|
||||
*/
|
||||
|
||||
// Get our addon ID.
|
||||
$clean['UserID'] = intval($_GET['id']);
|
||||
$sql['UserID'] =& $clean['UserID'];
|
||||
|
||||
startProcessing('author.tpl',$clean['UserID'],$compileId,'rustico');
|
||||
require_once('includes.php');
|
||||
|
||||
$user = new User($sql['UserID']);
|
||||
|
||||
// Assign template variables.
|
||||
$tpl->assign(
|
||||
array( 'user' => $user,
|
||||
'title' => $user->UserName,
|
||||
'content' => 'author.tpl',
|
||||
'sidebar' => 'inc/author-sidebar.tpl')
|
||||
);
|
||||
?>
|
||||
@@ -1,190 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This script tells clients whether or not a given add-on is blocklisted.
|
||||
*
|
||||
* It should always be well-formed and won't be seen by users,
|
||||
* at least initially.
|
||||
*
|
||||
* At some point we should consider generating an XSLT in case we want to
|
||||
* publish this list.
|
||||
*
|
||||
* @todo stylesheet for client viewing of blocklists
|
||||
* @package amo
|
||||
* @subpackage pub
|
||||
*/
|
||||
startProcessing('blocklist.tpl', $memcacheId, $compileId, 'xml');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* VARIABLES
|
||||
*
|
||||
* Initialize, set up and clean variables.
|
||||
*/
|
||||
|
||||
// Required variables that we need to run the script.
|
||||
$required_vars = array('reqVersion', // Used as a marker for the current URI scheme, in case it changes later.
|
||||
'appGuid', // GUID of the client requesting the blocklist.
|
||||
'appVersion'); // Version of the client requesting the blocklist (not used).
|
||||
|
||||
// Debug flag.
|
||||
$debug = (isset($_GET['debug']) && $_GET['debug'] == 'true') ? true : false;
|
||||
|
||||
// Array to hold errors for debugging.
|
||||
$errors = array();
|
||||
|
||||
// Iterate through required variables, and escape/assign them as necessary.
|
||||
foreach ($required_vars as $var) {
|
||||
if (empty($_GET[$var])) {
|
||||
$errors[] = 'Required variable '.$var.' not set.'; // set debug error
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// If we have all of our data, clean it up for our queries.
|
||||
if (empty($errors)) {
|
||||
|
||||
// We will need our DB in order to perform our query.
|
||||
require_once('includes.php');
|
||||
|
||||
// Iterate through required variables, and escape/assign them as necessary.
|
||||
foreach ($required_vars as $var) {
|
||||
$sql[$var] = mysql_real_escape_string($_GET[$var]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* QUERIES
|
||||
*
|
||||
* All of our variables are cleaned.
|
||||
* Now attempt to retrieve blocklist information for this application.
|
||||
*/
|
||||
$query = "
|
||||
SELECT
|
||||
blitems.id as itemId,
|
||||
blitems.guid as itemGuid,
|
||||
blitems.min as itemMin,
|
||||
blitems.max as itemMax,
|
||||
blapps.id as appId,
|
||||
blapps.item_id as appItemId,
|
||||
blapps.guid as appGuid,
|
||||
blapps.min as appMin,
|
||||
blapps.max as appMax
|
||||
FROM
|
||||
blitems
|
||||
LEFT JOIN blapps on blitems.id = blapps.item_id
|
||||
WHERE
|
||||
blapps.guid = '{$sql['appGuid']}'
|
||||
OR blapps.guid IS NULL
|
||||
ORDER BY
|
||||
itemGuid, appGuid, itemMin, appMin
|
||||
";
|
||||
|
||||
$db->query($query, SQL_ALL, SQL_ASSOC);
|
||||
|
||||
if (DB::isError($db->record)) {
|
||||
$errors[] = 'MySQL query for blocklist failed.';
|
||||
} elseif (empty($db->record)) {
|
||||
$errors[] = 'No matching blocklist for given application GUID.';
|
||||
} else {
|
||||
$blocklist = array();
|
||||
|
||||
foreach ($db->record as $row) {
|
||||
|
||||
// If we have item itemMin/itemMax values or an appId possible ranges, we create
|
||||
// hashes for each itemId and its related range.
|
||||
//
|
||||
// Since itemGuids can have different itemIds, they are the first hash. Each
|
||||
// itemId is effectively an item's versionRange. For each one of these we create
|
||||
// a corresponding array containing the range values, which could be NULL.
|
||||
if (!empty($row['itemMin']) && !empty($row['itemMax']) || !empty($row['appItemId'])) {
|
||||
$blocklist['items'][$row['itemGuid']][$row['itemId']] = array(
|
||||
'itemMin' => $row['itemMin'],
|
||||
'itemMax' => $row['itemMax']
|
||||
);
|
||||
|
||||
// Otherwise, our items array only contains a top-level containing the itemGuid.
|
||||
//
|
||||
// Doing so tells our template to terminate the item with /> because there is
|
||||
// nothing left to display.
|
||||
} else {
|
||||
$blocklist['items'][$row['itemGuid']] = null;
|
||||
}
|
||||
|
||||
// If we retrieved non-null blapp data, store it in the apps array.
|
||||
//
|
||||
// These are referenced later by their foreign key relationship to items (appItemId).
|
||||
if ($row['appItemId']) {
|
||||
$blocklist['apps'][$row['itemGuid']][$row['appItemId']][$row['appGuid']][] = array(
|
||||
'appMin' => $row['appMin'],
|
||||
'appMax' => $row['appMax']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Send our array to the template.
|
||||
$tpl->assign('blocklist',$blocklist);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* DEBUG
|
||||
*
|
||||
* If we get here, something went wrong. For testing purposes, we can
|
||||
* optionally display errers based on $_GET['debug'].
|
||||
*
|
||||
* By default, no errors are ever displayed because humans do not read this
|
||||
* script.
|
||||
*
|
||||
* Until there is some sort of API for how clients handle errors,
|
||||
* things should remain this way.
|
||||
*/
|
||||
if ($debug == true) {
|
||||
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
|
||||
echo '<html lang="en">';
|
||||
|
||||
echo '<head>';
|
||||
echo '<title>blocklist.php Debug Information</title>';
|
||||
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
|
||||
echo '</head>';
|
||||
|
||||
echo '<body>';
|
||||
|
||||
echo '<h1>Parameters</h1>';
|
||||
echo '<pre>';
|
||||
print_r($_GET);
|
||||
echo '</pre>';
|
||||
|
||||
if (!empty($query)) {
|
||||
echo '<h1>Query</h1>';
|
||||
echo '<pre>';
|
||||
echo $query;
|
||||
echo '</pre>';
|
||||
}
|
||||
|
||||
if (!empty($blocklist)) {
|
||||
echo '<h1>Result</h1>';
|
||||
echo '<pre>';
|
||||
print_r($blocklist);
|
||||
echo '</pre>';
|
||||
}
|
||||
|
||||
if (!empty($errors) && is_array($errors)) {
|
||||
echo '<h1>Errors Found</h1>';
|
||||
echo '<pre>';
|
||||
print_r($errors);
|
||||
echo '</pre>';
|
||||
} else {
|
||||
echo '<h1>No Errors Found</h1>';
|
||||
}
|
||||
|
||||
echo '</body>';
|
||||
|
||||
echo '</html>';
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Home page for extensions, switchable on application.
|
||||
*
|
||||
* @package amo
|
||||
* @subpackage docs
|
||||
* @todo make this dynamic based on an SQL field (recommended)
|
||||
*/
|
||||
|
||||
startProcessing('bookmarks.tpl', 'bookmarks', $compileId, 'rustico');
|
||||
require_once('includes.php');
|
||||
|
||||
setApp();
|
||||
|
||||
$amo = new AMO_Object();
|
||||
|
||||
$primary = $amo->getAddons(array(3615));
|
||||
if (is_array($primary) && !empty($primary)) {
|
||||
$primary = $primary[0];
|
||||
}
|
||||
|
||||
$other = $amo->getAddons(array(2410, 1833));
|
||||
|
||||
// Assign template variables.
|
||||
$tpl->assign(
|
||||
array( 'primary' => $primary,
|
||||
'other' => $other,
|
||||
'content' => 'bookmarks.tpl',
|
||||
'currentTab' => 'bookmarks')
|
||||
);
|
||||
?>
|
||||
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Comments listing for an addon.
|
||||
*
|
||||
* @package amo
|
||||
* @subpackage docs
|
||||
* @TODO Disallow comments for addon authors (authors should not be allowed to comment on their own addon).
|
||||
* @TODO Throttle comment entry.
|
||||
*/
|
||||
|
||||
// Get our addon id.
|
||||
$clean['id'] = intval($_GET['id']);
|
||||
$sql['id'] =& $clean['id'];
|
||||
|
||||
// Sort.
|
||||
if (isset($_GET['sort'])&&ctype_alpha($_GET['sort'])) {
|
||||
$clean['sort'] = $_GET['sort'];
|
||||
}
|
||||
|
||||
// Starting point.
|
||||
$page['left'] = (isset($_GET['left'])) ? intval($_GET['left']) : 0;
|
||||
|
||||
// Ending point.
|
||||
$page['right'] = $page['left'] + 10;
|
||||
|
||||
// Order by.
|
||||
$page['orderby'] = (!empty($_GET['orderby'])&&ctype_alpha($_GET['orderby'])) ? $_GET['orderby'] : "";
|
||||
|
||||
startProcessing('comments.tpl',$clean['id'],$compileId,'rustico');
|
||||
require_once('includes.php');
|
||||
|
||||
$addon = new AddOn($sql['id']);
|
||||
$addon->getComments($page['left'],10,$page['orderby']);
|
||||
|
||||
// Get our result count.
|
||||
$db->query("SELECT FOUND_ROWS()", SQL_INIT);
|
||||
$resultCount = !empty($db->record) ? $db->record[0] : $page['right'];
|
||||
if ($resultCount<$page['right']) {
|
||||
$page['right'] = $resultCount;
|
||||
}
|
||||
|
||||
// Do we even have a next or previous page?
|
||||
$page['previous'] = ($page['left'] >= 10) ? $page['left']-10 : null;
|
||||
$page['next'] = ($page['left']+10 < $resultCount) ? $page['left']+10 : null;
|
||||
$page['resultCount'] = $resultCount;
|
||||
$page['leftDisplay'] = $page['left']+1;
|
||||
|
||||
// Build the URL based on passed arguments.
|
||||
foreach ($clean as $key=>$val) {
|
||||
if (!empty($val)) {
|
||||
$buf[] = $key.'='.$val;
|
||||
}
|
||||
}
|
||||
$page['url'] = implode('&',$buf);
|
||||
unset($buf);
|
||||
|
||||
// Assign template variables.
|
||||
$tpl->assign(
|
||||
array( 'addon' => $addon,
|
||||
'title' => $addon->Name.' Comments',
|
||||
'content' => 'comments.tpl',
|
||||
'sidebar' => 'inc/addon-sidebar.tpl',
|
||||
'page' => $page)
|
||||
);
|
||||
?>
|
||||
@@ -1,132 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Create a new account
|
||||
*
|
||||
* @package amo
|
||||
* @subpackage docs
|
||||
*
|
||||
*/
|
||||
|
||||
startProcessing('createaccount.tpl', null, null, 'rustico');
|
||||
require_once 'includes.php';
|
||||
|
||||
// If there are problems, these will be set to true and used in the template. By
|
||||
// using null/booleans, error messages are kept in the template.
|
||||
$error_email_empty = null;
|
||||
$error_email_malformed = null;
|
||||
$error_emailconfirm_empty = null;
|
||||
$error_emailconfirm_nomatch = null;
|
||||
$error_email_duplicate = null;
|
||||
$error_name_empty = null;
|
||||
$error_password_empty = null;
|
||||
$error_passwordconfirm_empty = null;
|
||||
$error_passwordconfirm_nomatch = null;
|
||||
|
||||
$_bad_input = false; // think positive :)
|
||||
$account_created = false;
|
||||
|
||||
if (array_key_exists('submit', $_POST) && isset($_POST['submit'])) {
|
||||
/* Verify Input */
|
||||
// Check email - a little long and confusing. Basically, throw an error if
|
||||
// the following is not met (in order):
|
||||
// $email is set, $emailconfirm is set, $email=$emailconfirm, and $email is a valid address
|
||||
if (!array_key_exists('email', $_POST) || empty($_POST['email'])) {
|
||||
$error_email_empty = true;
|
||||
$_bad_input = true;
|
||||
} else {
|
||||
if (!array_key_exists('emailconfirm', $_POST) || empty($_POST['emailconfirm'])) {
|
||||
$error_emailconfirm_empty = true;
|
||||
$_bad_input = true;
|
||||
} else {
|
||||
// technically this would catch if emailconfirm was empty to, but
|
||||
// waiting until here could make php throw a warning.
|
||||
if ($_POST['email'] != $_POST['emailconfirm']) {
|
||||
$error_emailconfirm_nomatch = true;
|
||||
$_bad_input = true;
|
||||
}
|
||||
}
|
||||
// Regex from Gavin Sharp -- thanks Gavin.
|
||||
if (!preg_match('/^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$/',$_POST['email'])) {
|
||||
$error_email_malformed = true;
|
||||
$_bad_input = true;
|
||||
}
|
||||
}
|
||||
// name is required
|
||||
if (!array_key_exists('name', $_POST) || empty($_POST['name'])) {
|
||||
$error_name_empty = true;
|
||||
$_bad_input = true;
|
||||
}
|
||||
// password is required and match
|
||||
if (!array_key_exists('password', $_POST) || empty($_POST['password'])) {
|
||||
$error_password_empty = true;
|
||||
$_bad_input = true;
|
||||
} else {
|
||||
if (!array_key_exists('passwordconfirm', $_POST) || empty($_POST['passwordconfirm'])) {
|
||||
$error_passwordconfirm_empty = true;
|
||||
$_bad_input = true;
|
||||
} else {
|
||||
if ($_POST['password'] != $_POST['passwordconfirm']) {
|
||||
$error_passwordconfirm_nomatch = true;
|
||||
$_bad_input = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// This is a little out of order because we're trying to save a query. If we
|
||||
// haven't had any bad input yet, do one last check to make sure the email
|
||||
// address isn't already in use.
|
||||
if ($_bad_input === false) {
|
||||
$_user_test = user::getUserByEmail($_POST['email']);
|
||||
|
||||
if (is_object($_user_test)) {
|
||||
$_bad_input = true;
|
||||
$error_email_duplicate = true;
|
||||
}
|
||||
}
|
||||
|
||||
// We're happy with the input, make a new account
|
||||
if ($_bad_input === false) {
|
||||
$_user_info = array();
|
||||
$_user_info['email'] = $_POST['email'];
|
||||
$_user_info['name'] = $_POST['name'];
|
||||
$_user_info['website'] = $_POST['website'];
|
||||
$_user_info['password'] = $_POST['password'];
|
||||
$user_id = user::addUser($_user_info);
|
||||
if ($user_id === false) {
|
||||
triggerError('There was an error processing your request.');
|
||||
}
|
||||
$user = new User($user_id[0]);
|
||||
// we're emailing them their plain text password
|
||||
$user->sendConfirmation($_user_info['password']);
|
||||
$account_created = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Pull values from POST to put back in the form
|
||||
$email_value = array_key_exists('email', $_POST) ? $_POST['email'] : '';
|
||||
$emailconfirm_value = array_key_exists('emailconfirm', $_POST) ? $_POST['emailconfirm'] : '';
|
||||
$name_value = array_key_exists('name', $_POST) ? $_POST['name'] : '';
|
||||
$website_value = array_key_exists('website', $_POST) ? $_POST['website'] : '';
|
||||
|
||||
// Assign template variables.
|
||||
$tpl->assign(
|
||||
array( 'title' => 'Create an Account',
|
||||
'currentTab' => null,
|
||||
'account_created' => $account_created,
|
||||
'bad_input' => $_bad_input,
|
||||
'error_email_empty' => $error_email_empty,
|
||||
'error_email_malformed' => $error_email_malformed,
|
||||
'error_emailconfirm_empty' => $error_emailconfirm_empty,
|
||||
'error_emailconfirm_nomatch' => $error_emailconfirm_nomatch,
|
||||
'error_email_duplicate' => $error_email_duplicate,
|
||||
'error_name_empty' => $error_name_empty,
|
||||
'error_password_empty' => $error_password_empty,
|
||||
'error_passwordconfirm_empty' => $error_passwordconfirm_empty,
|
||||
'error_passwordconfirm_nomatch' => $error_passwordconfirm_nomatch,
|
||||
'email_value' => $email_value,
|
||||
'emailconfirm_value' => $emailconfirm_value,
|
||||
'name_value' => $name_value,
|
||||
'website_value' => $website_value
|
||||
)
|
||||
);
|
||||
?>
|
||||
@@ -1,115 +0,0 @@
|
||||
body, td, th, h3, input { /* redundant rules for bad browsers */
|
||||
font-family: verdana, sans-serif;
|
||||
font-size: x-small;
|
||||
voice-family: "\"}\"";
|
||||
voice-family: inherit;
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
body {
|
||||
color: #333;
|
||||
line-height: 140%;
|
||||
}
|
||||
|
||||
a:link { color: #039; }
|
||||
a:visited { color: #609; }
|
||||
a:hover { color: #333; }
|
||||
a:active { color: #000; }
|
||||
|
||||
#header a:visited { color: #039; }
|
||||
#header a:hover { color: #333; }
|
||||
|
||||
#mBody li { padding-bottom: 0.5em; }
|
||||
|
||||
.sidebar_content > h1,.sidebar_content > h2,.sidebar_content > h3,.sidebar_content > h4,.sidebar_content > h5,.sidebar_content > h6,.sidebar > h1,.sidebar_general > h2,.sidebar_general > h3,.sidebar_general > h4,.sidebar_general > h5,.sidebar_general > h6 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.sidebar_right {
|
||||
margin-left: 65%;
|
||||
}
|
||||
|
||||
.sidebar_general ul {
|
||||
margin-left: 0;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.sidebar_general li {
|
||||
padding: 0.2em 0;
|
||||
}
|
||||
|
||||
img.imgright {
|
||||
float: right;
|
||||
margin: .3em .3em .3em 0;
|
||||
padding: .3em .3em .3em 0;
|
||||
}
|
||||
|
||||
img {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
dt {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
dd {
|
||||
margin: 0 0 1em 1em;
|
||||
}
|
||||
|
||||
.skipLink {
|
||||
position: absolute;
|
||||
left: -1200px;
|
||||
width: 990px;
|
||||
}
|
||||
|
||||
.hide {
|
||||
display: none;
|
||||
}
|
||||
|
||||
ul.compact {
|
||||
margin-left: 0;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
img.rss {
|
||||
float: right;
|
||||
margin: 0;
|
||||
padding: 4px 4px 0 0;
|
||||
}
|
||||
|
||||
.first { margin-top: 0.2em; }
|
||||
|
||||
.requires img {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* Headers */
|
||||
|
||||
#mainContent > h1:first-child,
|
||||
#mainContent > h2:first-child,
|
||||
#mainContent > h3:first-child,
|
||||
#mainContent > h4:first-child,
|
||||
#mainContent > h5:first-child,
|
||||
#mainContent > h6:first-child,
|
||||
#side > h1:first-child,
|
||||
#side > h2:first-child,
|
||||
#side > h3:first-child,
|
||||
#side > h4:first-child,
|
||||
#side > h5:first-child,
|
||||
#side > h6:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.appversions {
|
||||
border: 1px solid #ccc;
|
||||
margin: .5em 0;
|
||||
}
|
||||
|
||||
.appversions th {
|
||||
background-color: #ccc;
|
||||
padding: .2em;
|
||||
}
|
||||
|
||||
.appversions .row1 {
|
||||
background-color: #eee;
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
body {
|
||||
min-width: 700px;
|
||||
margin: 0 0 2em 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#container {
|
||||
width: 740px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
#mBody {
|
||||
clear: both;
|
||||
padding: .2em 0;
|
||||
}
|
||||
|
||||
.sidebar_content {
|
||||
width: 60%;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#footer {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
#side {
|
||||
float: left;
|
||||
width: 23%;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
#mainContent {
|
||||
margin-left: 25%;
|
||||
}
|
||||
.nomenu #mainContent {
|
||||
margin-left: 0;
|
||||
}
|
||||
.bodyleft {
|
||||
margin-left: 25% ! important
|
||||
}
|
||||
#mainContent.right {
|
||||
float: left;
|
||||
width: 62%;
|
||||
margin-bottom: 1em;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
#side.right {
|
||||
float: none;
|
||||
width: auto;
|
||||
margin-left: 65%;
|
||||
}
|
||||
|
||||
p.security-update {
|
||||
padding-left: 35px;
|
||||
background: url(../../images/security-update.png) no-repeat;
|
||||
margin-top: 0;
|
||||
min-height: 30px;
|
||||
}
|
||||
|
||||
/* Sidebar */
|
||||
|
||||
#nav:before {
|
||||
line-height: 0.1;
|
||||
font-size: 1px;
|
||||
background: transparent url("../../images/menu_tr.gif") no-repeat top right;
|
||||
margin: 0;
|
||||
height: 9px;
|
||||
display: block;
|
||||
border-bottom: 1px solid #ddd;
|
||||
content: url("../../images/key-point_tl.gif");
|
||||
}
|
||||
#nav {
|
||||
background: #E0E9E9 url("../../images/menu_back.gif") right repeat-y;
|
||||
}
|
||||
#nav:after {
|
||||
display: block;
|
||||
padding-top: 0;
|
||||
line-height: 0.1;
|
||||
font-size: 1px;
|
||||
content: url("../../images/key-point_bl.gif");
|
||||
margin: 0 0 0 0;
|
||||
height: 8px;
|
||||
background: transparent url("../../images/menu_br.gif") scroll no-repeat bottom right ;
|
||||
border-top: 1px solid #fff;
|
||||
}
|
||||
|
||||
#nav, #nav ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
#nav {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
#nav li {
|
||||
display: inline;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#nav li span { /* used for un-linked menu items */
|
||||
display: block;
|
||||
padding: 6px 10px;
|
||||
font-weight: bold;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
#nav li span#configParent, #nav li span #configuration {
|
||||
display: inline;
|
||||
font-weight: normal;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#nav li a {
|
||||
display: block;
|
||||
padding: 6px 10px;
|
||||
text-decoration: none;
|
||||
background: #EDF2F2;
|
||||
border-bottom: 1px solid #ddd;
|
||||
border-top: 1px solid #fff;
|
||||
border-right: 1px solid #ddd;
|
||||
}
|
||||
|
||||
#nav li a:hover {
|
||||
background: #E0E9E9;
|
||||
}
|
||||
|
||||
#nav ul li span,#nav ul li a {
|
||||
padding: 4px 8px 4px 20px;
|
||||
}
|
||||
|
||||
.clear-both {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.center {
|
||||
text-align: center;
|
||||
}
|
||||
@@ -1,454 +0,0 @@
|
||||
#mBody h2 {
|
||||
font: 140% arial,helvetica,verdana,sans-serif;
|
||||
border-bottom: 1px solid #ccc;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
#mBody h2 a {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#mBody h3 {
|
||||
font: 120% arial,helvetica,verdana,sans-serif;
|
||||
border-bottom: 1px solid #ccc;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
#mBody h1 {
|
||||
font: 180% arial,helvetica,sans-serif;
|
||||
border-bottom: 1px solid #ccc;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.key-point:before {
|
||||
line-height: 0.1;
|
||||
font-size: 1px;
|
||||
background: transparent url("../../images/key-point_tr.gif") no-repeat top right;
|
||||
margin: -15px -15px 0 -15px;
|
||||
height: 15px;
|
||||
display: block;
|
||||
border: none;
|
||||
content: url("../../images/key-point_tl.gif");
|
||||
}
|
||||
.key-point {
|
||||
background: #EFF8CE url("../../images/key-point_back.gif") right repeat-y;
|
||||
padding: 15px;
|
||||
margin-top: 18px;
|
||||
}
|
||||
.key-point:after {
|
||||
display: block;
|
||||
padding-top: 15px;
|
||||
line-height: 0.1;
|
||||
font-size: 1px;
|
||||
content: url("../../images/key-point_bl.gif");
|
||||
margin: -15px;
|
||||
height: 8px;
|
||||
background: transparent url("../../images/key-point_br.gif") scroll no-repeat bottom right ;
|
||||
}
|
||||
|
||||
#header form #submit {
|
||||
font-size: 100%;
|
||||
padding: 1px;
|
||||
font-family: tahoma, arial, sans-serif;
|
||||
}
|
||||
|
||||
#header form #q {
|
||||
width: 10em;
|
||||
font-size: 100%;
|
||||
font-weight: normal;
|
||||
border: 1px solid #9097A2;
|
||||
padding: 2px;
|
||||
font-family: tahoma, arial, sans-serif;
|
||||
}
|
||||
|
||||
#sectionsearch {
|
||||
font-size: 100%;
|
||||
font-weight: normal;
|
||||
font-family: tahoma, arial, sans-serif;
|
||||
}
|
||||
|
||||
.popularlist {
|
||||
font-size: 85%;
|
||||
}
|
||||
|
||||
.popularlist span {
|
||||
color: #666;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.install a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.install a strong {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.install-box {
|
||||
width: 20em;
|
||||
}
|
||||
.key-point {
|
||||
background-color:#bee6a1;
|
||||
}
|
||||
|
||||
.install div {
|
||||
background: url(../../images/install.png) no-repeat;
|
||||
padding: 3px 0 8px 30px;
|
||||
|
||||
}
|
||||
|
||||
#opinions h4 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.opinions-info {
|
||||
font-size: 85%;
|
||||
margin: 0 0 0.5em 0;
|
||||
}
|
||||
|
||||
.opinions-info a {
|
||||
text-decoration: none;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.opinions-info a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.opinions-text {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.opinions-rating img {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.rating {
|
||||
float: right;
|
||||
font-size: 85%;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.rating img {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.more-links {
|
||||
margin: 0.5em 0 0 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.more-links li {
|
||||
display: inline;
|
||||
margin: 0;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.screenshot {
|
||||
float: right;
|
||||
background: #fff;
|
||||
padding: 0 0 2em 2em;
|
||||
}
|
||||
|
||||
.screenshot a {
|
||||
text-align: center;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Remaining Original Update Styles */
|
||||
|
||||
.item {
|
||||
border: #D2D6D6 1px solid;
|
||||
padding-left: 5px;
|
||||
padding-right: 6px;
|
||||
MARGIN-bottom: 10px;
|
||||
-moz-border-radius: 10px;
|
||||
}
|
||||
|
||||
.item a {
|
||||
color: #00129c;
|
||||
text-decoration: none;
|
||||
}
|
||||
.item a:visited {
|
||||
color: #00129c;
|
||||
text-decoration: none;
|
||||
}
|
||||
.item a:hover {
|
||||
color: #fc5900;
|
||||
}
|
||||
|
||||
.item h2 {
|
||||
margin-top: 0.2em;
|
||||
}
|
||||
|
||||
.recommended {
|
||||
clear: both;
|
||||
padding: 1em 0;
|
||||
}
|
||||
|
||||
.recommended h2 {
|
||||
padding: 1em 0 0 215px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.recommended p {
|
||||
padding-left: 215px;
|
||||
}
|
||||
|
||||
.recommended-download h3 {
|
||||
font: small tahoma, verdana, sans-serif;
|
||||
margin: 0;
|
||||
background: url("../../images/download.gif") 0 100%;
|
||||
font-size: small;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
.recommended-download h3 a {
|
||||
display: block;
|
||||
background: url("../../images/download.gif") 0 0;
|
||||
font-size: 65%;
|
||||
font-weight: bold;
|
||||
width: 165px;
|
||||
padding: 12px 25px 5px 10px;
|
||||
text-decoration: none;
|
||||
color: #5A9A3B;
|
||||
}
|
||||
|
||||
.recommended-download h3 a:hover {
|
||||
text-decoration: underline;
|
||||
color: #275113;
|
||||
}
|
||||
|
||||
.recommended-download {
|
||||
display: block;
|
||||
width: 200px;
|
||||
padding: 15px 0 0 215px;
|
||||
}
|
||||
|
||||
.recommended-img {
|
||||
border: 2px outset #eee;
|
||||
float: left;
|
||||
margin: 1em 1em 0 0;
|
||||
}
|
||||
|
||||
.iconbar {
|
||||
padding-right: 15px;
|
||||
float: left;
|
||||
width: auto;
|
||||
height: 34px;
|
||||
}
|
||||
|
||||
.iconbar img {
|
||||
float:left;
|
||||
}
|
||||
|
||||
.iconbar a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.selected a, .selected a:visited {
|
||||
color: #fc5900;
|
||||
}
|
||||
|
||||
.baseline {
|
||||
clear: right;
|
||||
margin-top: 5px;
|
||||
border-top: #ccc 1px solid;
|
||||
padding: 3px;
|
||||
padding-left: 10px;
|
||||
font-size: 8pt;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
#opinions {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#opinions li {
|
||||
border-top: 1px solid #eee;
|
||||
padding: 1em 0;
|
||||
}
|
||||
|
||||
#opinions h4 {
|
||||
clear: right;
|
||||
margin: 0;
|
||||
padding: .5em 0 0 0;
|
||||
}
|
||||
|
||||
.opinions-info {
|
||||
color: #666;
|
||||
margin: 0;
|
||||
padding: 0 0 .5em 0;
|
||||
|
||||
}
|
||||
|
||||
.opinions-info a {
|
||||
text-decoration: none;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.opinions-info a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.opinions-text {
|
||||
margin: .8em 0 0 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.opinions-vote {
|
||||
background-color: #cfc;
|
||||
border: 1px solid #000;
|
||||
float: left;
|
||||
font-style: italic;
|
||||
font-weight: bold;
|
||||
font-size: x-large;
|
||||
padding: 5px;
|
||||
margin: 4px;
|
||||
text-align: center;
|
||||
|
||||
}
|
||||
|
||||
.opinions-caption {
|
||||
display: block;
|
||||
font-size: x-small;
|
||||
font-weight: normal;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
}
|
||||
|
||||
.opinions-rating {
|
||||
margin: 0;
|
||||
padding: .5em 0;
|
||||
}
|
||||
|
||||
.opinions-helpful {
|
||||
font-style: italic;
|
||||
border: 1px dashed #eee;
|
||||
padding: .2em;
|
||||
margin: .7em 0;
|
||||
}
|
||||
|
||||
.tooltip {
|
||||
cursor: help;
|
||||
border-bottom: 1px dotted;
|
||||
}
|
||||
|
||||
.pages {
|
||||
color: #999;
|
||||
font-weight: bold;
|
||||
height: 2em;
|
||||
}
|
||||
|
||||
.next {
|
||||
border-left: 1px solid #000;
|
||||
display: inline;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.prev {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.pages a {
|
||||
color: blue;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#comment-rate {
|
||||
margin: .5em;
|
||||
padding: .5em;
|
||||
background-color: #eee;
|
||||
border: 1px solid #999;
|
||||
}
|
||||
|
||||
#search-block:before {
|
||||
line-height: 0.1;
|
||||
font-size: 1px;
|
||||
background: transparent url("../../img/key-point_tr.gif") no-repeat top right;
|
||||
margin: -10px -10px 0 -10px;
|
||||
height: 10px;
|
||||
display: block;
|
||||
border: none;
|
||||
content: url("../../img/key-point_tl.gif");
|
||||
}
|
||||
|
||||
#search-block{
|
||||
background: #EFF8CE url("../../img/key-point_back.gif") right repeat-y;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
#search-block label{
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#search-block select {
|
||||
width: 13em;
|
||||
}
|
||||
|
||||
#search-block input[type=text] {
|
||||
width: 9.2em;
|
||||
}
|
||||
|
||||
.right #search-block select {
|
||||
width: 20em;
|
||||
}
|
||||
|
||||
.right #search-block input[type=text] {
|
||||
width: 16.2em;
|
||||
}
|
||||
|
||||
#search-block:after {
|
||||
display: block;
|
||||
padding-top: 10px;
|
||||
line-height: 0.1;
|
||||
font-size: 1px;
|
||||
content: url("../../img/key-point_bl.gif");
|
||||
margin: -10px;
|
||||
height: 8px;
|
||||
background: transparent url("../../img/key-point_br.gif") scroll no-repeat bottom right ;
|
||||
}
|
||||
|
||||
#search-options {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#hide-search-options {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#show-search-options {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#comments-sort {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.disclaimer {
|
||||
text-align: center;
|
||||
color: #ccc;
|
||||
font-size: x-small;
|
||||
width: 600px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.install-thunderbird {
|
||||
background-color: #eee;
|
||||
border: 1px solid #ccc;
|
||||
margin: .5em 0;
|
||||
padding: .5em;
|
||||
}
|
||||
|
||||
.install-thunderbird p {
|
||||
font-weight: bold;
|
||||
color: blue;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
@@ -1,317 +0,0 @@
|
||||
body {
|
||||
background: #fff url("../../images/body_back.gif") repeat-x;
|
||||
}
|
||||
|
||||
#footer {
|
||||
background: url("../../images/footer.gif") 0 8px no-repeat;
|
||||
margin: 10px 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#footer span,#footer a {
|
||||
white-space: nowrap;
|
||||
padding: 0 1em;
|
||||
color: #666;
|
||||
font-size: 85%;
|
||||
}
|
||||
|
||||
#footer p a:hover {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#footer .switch-fx,
|
||||
#footer .switch-tb,
|
||||
#footer .switch-suite {
|
||||
padding-left: 30px;
|
||||
font-size: 100%;
|
||||
background: #fff 9px 0 no-repeat;
|
||||
}
|
||||
|
||||
#footer .switch-tb {
|
||||
background-image: url("../../images/switch-tb.gif");
|
||||
}
|
||||
|
||||
#footer .switch-suite {
|
||||
background-image: url("../../images/switch-suite.gif");
|
||||
}
|
||||
|
||||
#footer .switch-fx {
|
||||
background-image: url("../../images/switch-fx.gif");
|
||||
}
|
||||
|
||||
/* Site Header */
|
||||
|
||||
#header {
|
||||
clear: both;
|
||||
padding-top: 40px;
|
||||
position: relative;
|
||||
} * html #header { padding-top: 20px; }
|
||||
|
||||
#header h1 {
|
||||
height: 46px;
|
||||
margin: 0;
|
||||
font-size: 2px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: -4px;
|
||||
border: none;
|
||||
z-index: 5000;
|
||||
}
|
||||
|
||||
#header form {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 9px;
|
||||
margin-left: 200px;
|
||||
font-family: tahoma, arial, sans-serif;
|
||||
font-size: 85%;
|
||||
}
|
||||
|
||||
#header div#auth {
|
||||
display:inline;
|
||||
position:absolute;
|
||||
top:11px;
|
||||
right:0px;
|
||||
margin-right: 200px;
|
||||
}
|
||||
|
||||
#key-menu {
|
||||
background: #B2C1C8 url("../../images/header-bottom.gif") 0 100% no-repeat;
|
||||
padding: 0 0 10px 0;
|
||||
overflow: auto;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
* html #key-menu {
|
||||
overflow: visible;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
#key-menu ul, #key-menu li {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
#key-menu ul {
|
||||
padding: 14px 12px 0 12px;
|
||||
background: url("../../images/header-top.gif") 0 0 no-repeat;
|
||||
}
|
||||
|
||||
#key-menu li {
|
||||
float: left;
|
||||
background: url("../../images/tabs.gif") 100% -50px;
|
||||
padding-right: 5px;
|
||||
margin-right: 2px;
|
||||
border-bottom: 1px solid #849CA4;
|
||||
margin-bottom: -10px;
|
||||
}
|
||||
|
||||
#key-menu li a, #key-menu li span {
|
||||
display: block;
|
||||
float: left;
|
||||
padding: 3px 15px 2px 20px;
|
||||
background: url("../../images/tabs.gif") 0 -50px;
|
||||
color: #5A7CBA;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#key-menu li:hover a {
|
||||
background-position: 0 -100px;
|
||||
}
|
||||
|
||||
#key-menu li:hover {
|
||||
background-position: 100% -100px;
|
||||
}
|
||||
|
||||
#key-menu li.current {
|
||||
background: url("../../images/tabs.gif") 100% 0;
|
||||
border-bottom-color: white;
|
||||
}
|
||||
|
||||
#key-menu li.current a, #key-menu li.current span {
|
||||
background: url("../../images/tabs.gif") 0 0;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
#mozilla-com a {
|
||||
float: right;
|
||||
display: block;
|
||||
text-indent: -5000em;
|
||||
width: 110px;
|
||||
height: 25px;
|
||||
text-decoration: none;
|
||||
background: url("../../images/mozilla-org.gif") no-repeat;
|
||||
}
|
||||
|
||||
/* End Site Header */
|
||||
|
||||
/* Front Feature */
|
||||
.split-feature {
|
||||
background: url("../../images/feature-back.png") 0 100% no-repeat;
|
||||
overflow: auto;
|
||||
padding-bottom: 10px;
|
||||
margin-right: -2px;
|
||||
} * html .split-feature { overflow: visible; height: 1px; }
|
||||
|
||||
.split-feature-one, .split-feature-two {
|
||||
padding: 15px 15px 0 15px;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.split-feature-one {
|
||||
width: 485px;
|
||||
background: url("../../images/feature-back.png") 0 0 no-repeat;
|
||||
}
|
||||
|
||||
.split-feature-two {
|
||||
width: 185px;
|
||||
padding-left: 25px;
|
||||
background: url("../../images/feature-back.png") 100% 0 no-repeat;
|
||||
}
|
||||
|
||||
.split-feature h2 {
|
||||
margin: 0 0 0.2em 0;
|
||||
font-family: verdana, arial, sans-serif;
|
||||
font-size: 1.4em;
|
||||
}
|
||||
|
||||
.split-feature h2 a {
|
||||
text-decoration: none;
|
||||
font-size: medium;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.split-feature-one p {
|
||||
margin-left: 220px;
|
||||
}
|
||||
|
||||
.feature-download h3 {
|
||||
font: 85% tahoma, verdana, sans-serif;
|
||||
margin: 5px 0 0 0;
|
||||
background: url("../../images/download.gif") 0 100%;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
.feature-download h3 a {
|
||||
display: block;
|
||||
background: url("../../images/download.gif") 0 0;
|
||||
font-weight: bold;
|
||||
width: 165px;
|
||||
padding: 12px 25px 5px 10px;
|
||||
text-decoration: none;
|
||||
color: #5A9A3B;
|
||||
}
|
||||
|
||||
.feature-download h3 a:hover {
|
||||
text-decoration: underline;
|
||||
color: #275113;
|
||||
}
|
||||
|
||||
.feature-download {
|
||||
float: left;
|
||||
width: 200px;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
ol.top-10, ol.top-10 li {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
ol.top-10 li a {
|
||||
display: block;
|
||||
text-align: right;
|
||||
padding: 1px 0 1px 20px;
|
||||
border-top: 1px solid #eee;
|
||||
text-decoration: none;
|
||||
width: 160px;
|
||||
background: url("../../images/top-10.gif") 0 0 no-repeat;
|
||||
cursor: pointer; /* for IE as it ignores floating <strong>s */
|
||||
font-size: 85%;
|
||||
}
|
||||
|
||||
ol.top-10 li a:hover strong {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
ol.top-10 li.top-10-2 a { background-position: 0 -50px; }
|
||||
ol.top-10 li.top-10-3 a { background-position: 0 -100px; }
|
||||
ol.top-10 li.top-10-4 a { background-position: 0 -150px; }
|
||||
ol.top-10 li.top-10-5 a { background-position: 0 -200px; }
|
||||
ol.top-10 li.top-10-6 a { background-position: 0 -250px; }
|
||||
ol.top-10 li.top-10-7 a { background-position: 0 -300px; }
|
||||
ol.top-10 li.top-10-8 a { background-position: 0 -350px; }
|
||||
ol.top-10 li.top-10-9 a { background-position: 0 -400px; }
|
||||
ol.top-10 li.top-10-10 a { background-position: 0 -450px; }
|
||||
|
||||
ol.top-10 li strong {
|
||||
float: left;
|
||||
}
|
||||
|
||||
#front-search {
|
||||
text-align: center;
|
||||
margin: 1.5em 0 1em 0;
|
||||
}
|
||||
|
||||
.front-section-left, .front-section-right {
|
||||
width: 220px;
|
||||
float: left;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.front-section-left {
|
||||
padding: 5px 0 5px 190px;
|
||||
}
|
||||
|
||||
.front-section-right {
|
||||
padding: 5px 70px 5px 0;
|
||||
}
|
||||
|
||||
.front-section-left h2, .front-section-right h2{
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.front-section-left ul, .front-section-right ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
.front-section-left li, .front-section-right li {
|
||||
padding: 0.2em 0;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.front-section {
|
||||
width: 220px;
|
||||
padding: 5px 0 5px 25px;
|
||||
float: left;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.front-section h2 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.front-section ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
.front-section li {
|
||||
padding: 0.2em 0;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
a.top-feature {
|
||||
float: left;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
a.top-feature img {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
.amo-form div {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
.amo-submit {
|
||||
background-color: #eee;
|
||||
border: 2px #999 outset;
|
||||
}
|
||||
|
||||
.amo-submit:hover {
|
||||
background-color: #fff;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.amo-cancel {
|
||||
}
|
||||
|
||||
.amo-label-large, .amo-label-medium, .amo-label-small {
|
||||
border-bottom: 1px dashed #eee;
|
||||
float: left;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.amo-label-large {
|
||||
width: 14em;
|
||||
}
|
||||
|
||||
.amo-label-medium {
|
||||
width: 10em;
|
||||
}
|
||||
|
||||
.amo-label-small {
|
||||
width: 8em;
|
||||
}
|
||||
|
||||
.amo-label-xsmall {
|
||||
width: 6em;
|
||||
}
|
||||
|
||||
.amo-form-error {
|
||||
background-color: #eee;
|
||||
border: 1px dashed #c66;
|
||||
color: #c00;
|
||||
margin: 5px 0;
|
||||
padding: .5em;
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
<xsl:template match="/rss">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title><xsl:value-of select="channel/title"/></title>
|
||||
<meta name="keywords" content="mozilla update, mozilla extensions, mozilla plugins, thunderbird themes, thunderbird extensions, firefox extensions, firefox themes" />
|
||||
<link rel="stylesheet" type="text/css" href="/css/print.css" media="print" />
|
||||
<link rel="stylesheet" type="text/css" href="/css/base/content.css" media="all" />
|
||||
<link rel="stylesheet" type="text/css" href="/css/cavendish/content.css" title="Cavendish" media="all" />
|
||||
<link rel="stylesheet" type="text/css" href="/css/base/template.css" media="screen" />
|
||||
<link rel="stylesheet" type="text/css" href="/css/cavendish/template.css" title="Cavendish" media="screen" />
|
||||
<link rel="stylesheet" type="text/css" href="/css/forms.css" media="screen" />
|
||||
<link rel="home" title="Home" href="https://addons.mozilla.org/" />
|
||||
<link rel="alternate" type="application/rss+xml" href="{self}" title="{title}" />
|
||||
<link rel="shortcut icon" href="{channel/image/url}" />
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="container">
|
||||
<p class="skipLink"><a href="#firefox-feature" accesskey="2">Skip to main content</a></p>
|
||||
<div id="mozilla-com"><a href="http://www.mozilla.com/">Visit Mozilla.com</a></div>
|
||||
<div id="header">
|
||||
<div id="key-title">
|
||||
<h1>
|
||||
<a href="/firefox/" title="Return to home page" accesskey="1">
|
||||
<img src="/images/title-firefox.gif" width="276" height="54" alt="Firefox Add-ons Beta" />
|
||||
</a>
|
||||
</h1>
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
addUsernameToHeader();
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
<form id="search" method="get" action="/search.php" title="Search Mozilla Update">
|
||||
<div>
|
||||
<label for="q" title="Search Mozilla Update">search:</label>
|
||||
<input type="text" id="q" name="q" accesskey="s" size="10" />
|
||||
<input type="hidden" name="app" value="firefox" />
|
||||
<input type="submit" id="submit" value="Go" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="key-menu">
|
||||
<ul id="menu-firefox">
|
||||
<li><a href="/firefox/">Home</a></li>
|
||||
<li><a href="/firefox/extensions/">Extensions</a></li>
|
||||
<li><a href="/firefox/plugins/">Plugins</a></li>
|
||||
<li><a href="/firefox/search-engines/">Search Engines</a></li>
|
||||
<li><a href="/firefox/themes/">Themes</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- end key-menu -->
|
||||
</div>
|
||||
<!-- end header -->
|
||||
<hr class="hide" />
|
||||
<div id="mBody">
|
||||
<h1><xsl:value-of select="channel/title"/></h1>
|
||||
<p>
|
||||
This is an RSS feed designed to be read by an RSS reader. Which you aren't.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>What's an RSS Feed?</strong><br />
|
||||
<acronym title="Really Simple Syndication">RSS</acronym> feeds
|
||||
allow you to take the latest content from our site and view it in other places
|
||||
such as a feed reader, your browser or your website. Feeds make it easy and
|
||||
convenient to stay on top of the latest from Mozilla Add-ons.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>How do I use this feed?</strong><br/>
|
||||
To add this feed as a live bookmark in Firefox, simply click on the orange icon
|
||||
(<img src="/images/rss.png" alt="RSS" />) in the address bar. Otherwise, take the
|
||||
URL of this feed and add it to your favorite RSS reader.
|
||||
</p>
|
||||
|
||||
<p>Preview of this feed:</p>
|
||||
<ul>
|
||||
<xsl:for-each select="channel/item">
|
||||
<li>
|
||||
<strong><a href="{link}"><xsl:value-of select="title"/></a></strong>
|
||||
</li>
|
||||
</xsl:for-each>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<hr class="hide" />
|
||||
|
||||
<div id="footer">
|
||||
|
||||
<p><a href="/firefox/" class="switch-fx">Firefox Add-ons </a><a href="/thunderbird/" class="switch-tb">Thunderbird Add-ons </a><a href="/mozilla/" class="switch-suite">Mozilla Suite Add-ons </a></p>
|
||||
<p><a href="/faq.php">FAQ</a> <a href="/feeds.php">Feeds/RSS</a> <a href="/login.php">Log In</a> <a href="/logout.php">Logout</a> <a href="/createaccount.php">Register</a></p>
|
||||
<p><a href="http://www.mozilla.org/privacy-policy.html">Privacy Policy</a> <a href="http://www.mozilla.org/foundation/donate.html">Donate to Mozilla</a> <a href="http://mozilla.org/">The Mozilla Organization</a></p>
|
||||
|
||||
<p><span>Copyright © 2004-2006</span> <a href="http://www.xramp.com/">256-bit SSL Encryption provided by XRamp</a></p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- close container -->
|
||||
|
||||
<div class="disclaimer">
|
||||
Mozilla is providing links to these applications as a courtesy, and makes no representations
|
||||
regarding the applications or any information related thereto. Any questions, complaints or
|
||||
claims regarding the applications must be directed to the appropriate software vendor. See
|
||||
our <a href="/support.php">Support Page</a> for support information and contacts.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
@@ -1,740 +0,0 @@
|
||||
/* General Structure */
|
||||
/* copied from Mozilla.com */
|
||||
|
||||
body, td, th, input { /* redundant rules for bad browsers */
|
||||
font-family: verdana, sans-serif;
|
||||
font-size: x-small;
|
||||
voice-family: "\"}\"";
|
||||
voice-family: inherit;
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
body {
|
||||
background: #fff;
|
||||
color: #333;
|
||||
min-width: 610px;
|
||||
margin: 0 0 1em 0;
|
||||
padding: 0; /* need for Opera */
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-family: arial, verdana, sans-serif;
|
||||
margin: 1em 0 0.2em 0;
|
||||
}
|
||||
|
||||
li h1, li h2, li h3, li h4, li h5, li h6 {
|
||||
border: none;
|
||||
}
|
||||
|
||||
#header h1 { border: 0; }
|
||||
|
||||
h1 { font-size: 160%; font-weight: normal; }
|
||||
h2 { font-size: 150%; font-weight: normal; }
|
||||
h3 { font-size: 120%; }
|
||||
h4 { font-size: 100%; }
|
||||
h5 { font-size: 90%; }
|
||||
h6 { font-size: 90%; border: 0; }
|
||||
|
||||
/* Navigation */
|
||||
|
||||
:link { color: #039; }
|
||||
:visited { color: #636; }
|
||||
:link:hover, :visited:hover { color: #333; }
|
||||
:link:active, :link:active { color: #000; }
|
||||
|
||||
/* header copied from Mozilla.com */
|
||||
|
||||
#header {
|
||||
background: #33415d url("../../images/rustico/header/header-background.png") top repeat-x;
|
||||
position: relative;
|
||||
height: 38px;
|
||||
padding: 0 50px;
|
||||
border-bottom: 1px solid #a1a6b1;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
#header div {
|
||||
position: relative;
|
||||
max-width: 900px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
#header h1 { margin: 0; }
|
||||
|
||||
#header h1 img {
|
||||
font-weight: bold;
|
||||
color: #7f7c45;
|
||||
}
|
||||
|
||||
#header ul {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border-left: 1px solid #576178;
|
||||
border-right: 1px solid #1f2635;
|
||||
} * html #header ul { right: 50px; }
|
||||
|
||||
#header li {
|
||||
float: left;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#header ul span, #header ul a:link, #header ul a:visited {
|
||||
display: block;
|
||||
float: left;
|
||||
padding: 10px 15px;
|
||||
text-decoration: none;
|
||||
border-right: 1px solid #576178;
|
||||
border-left: 1px solid #1f2635;
|
||||
color: #dee0e5;
|
||||
height: 36px;
|
||||
voice-family: "\"}\"";
|
||||
voice-family: inherit;
|
||||
height: 16px;
|
||||
} #ignored {}
|
||||
|
||||
#header ul li span,
|
||||
#header ul li a.current,
|
||||
#header ul li a:hover {
|
||||
background: #475470;
|
||||
color: #fff;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#header ul li span,
|
||||
#header ul li a.current {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* page title */
|
||||
|
||||
#page-title {
|
||||
background: url("../../images/rustico/common/bg-header-small.jpg") repeat-x 50% 0;
|
||||
}
|
||||
|
||||
#page-title div, #container {
|
||||
max-width: 750px;
|
||||
margin: 0 auto;
|
||||
padding: 0 50px;
|
||||
}
|
||||
|
||||
#page-title div {
|
||||
background: url("../../images/rustico/common/firefox-addons-hdr.jpg") no-repeat 50% 0;
|
||||
height: 170px;
|
||||
} body>#page-title div { height: auto; min-height: 170px; }
|
||||
|
||||
#page-title div h2 {
|
||||
margin: 0;
|
||||
padding: 40px 0;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
#page-title div h2 img {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
/* mainContent */
|
||||
|
||||
#mainContent {
|
||||
color: #3c475b;
|
||||
line-height: 150%;
|
||||
margin-left: 180px;
|
||||
}
|
||||
|
||||
#mainContent hr {
|
||||
margin: 2em;
|
||||
}
|
||||
|
||||
#mainContent h3 {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
/* front page features */
|
||||
|
||||
.frontpage-intro {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
#top-extensions,
|
||||
.front-recommended {
|
||||
float: left;
|
||||
width: 45%;
|
||||
margin-right: 4%;
|
||||
}
|
||||
|
||||
#home-rec-link img {
|
||||
border: none;
|
||||
float: right;
|
||||
text-decoration: none;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.front-recommended img {
|
||||
float: right;
|
||||
margin: 0 20px;
|
||||
}
|
||||
|
||||
.newest-extensions h3,
|
||||
.top-extensions h3,
|
||||
.front-recommended h3 {
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
.front-search-container {
|
||||
float: left;
|
||||
width: 45%;
|
||||
}
|
||||
|
||||
.front-search-container img {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.front-search-container h3 {
|
||||
margin-left: 40px;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
/* addon features */
|
||||
|
||||
.divider-bottom,
|
||||
.bookmarkaddon-feature {
|
||||
background: url(../../images/rustico/firefox-featured-divider.png) no-repeat bottom center;
|
||||
|
||||
margin-bottom: 1.5em;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
#primary-feature {
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
.addon-feature h2 {
|
||||
font-weight: bold;
|
||||
margin: 0 0 5px 0;
|
||||
}
|
||||
|
||||
.eula {
|
||||
font-size: 75%;
|
||||
}
|
||||
|
||||
.addon-feature h2 span {
|
||||
font-weight: normal;
|
||||
font-size: 80%;
|
||||
}
|
||||
|
||||
.addon-feature h3,
|
||||
.bookmarkaddon-feature h3 {
|
||||
margin: 0 0 10px 0;
|
||||
}
|
||||
|
||||
.addon-feature h4,
|
||||
.bookmarkaddon-feature h4 {
|
||||
margin: 0 0 10px 0;
|
||||
}
|
||||
|
||||
.addon-feature h4 span,
|
||||
.bookmarkaddon-feature h4 span {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.addon-feature h1 span {
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
.addon-feature h1 span.author {
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
.addon-feature .search-result-image {
|
||||
float: right;
|
||||
margin: 10px 0 5px 10px;
|
||||
}
|
||||
|
||||
.addon-feature .addon-feature-image,
|
||||
.bookmarkaddon-feature .addon-feature-image {
|
||||
float: left;
|
||||
margin: 0 10px 0 0;
|
||||
}
|
||||
|
||||
.preview-image a {
|
||||
text-decoration: none;
|
||||
text-align: center;
|
||||
display: block;
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
.addon-display .preview-image {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.addon-display .version-and-date {
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
.addon-feature .addon-feature-text { margin-left: 220px; }
|
||||
.bookmarkaddon-feature .addon-feature-text { margin-left: 190px; }
|
||||
|
||||
.addon-feature a, .bookmarkaddon-feature a { color: #f7941d; }
|
||||
.addon-feature a:visited, .bookmarkaddon-feature a:visited { color: #f7941d; }
|
||||
.addon-feature a:hover, .bookmarkaddon-feature a:hover { color: #333; }
|
||||
|
||||
.recommended a, .recommended a:visited { color: #f7941d; }
|
||||
.recommended a:hover { color: #333; }
|
||||
|
||||
.bookmarkstitle {
|
||||
background: url(../../images/rustico/bookmarks/firefox-bm-puzzle-ico.png) no-repeat top left;
|
||||
height: 27px;
|
||||
padding: 5px 0 0 35px;
|
||||
}
|
||||
|
||||
/* install button */
|
||||
.install-button,
|
||||
p.install-button {
|
||||
width: 230px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
span.install-button-text {
|
||||
padding-right: 30px;
|
||||
}
|
||||
|
||||
.install-button a:link span.install-green-button,
|
||||
.install-button a:visited span.install-green-button,
|
||||
.install-button a:hover span.install-green-button,
|
||||
.install-button a:active span.install-green-button {
|
||||
background: url(../../images/rustico/install-button.png) no-repeat bottom left;
|
||||
display: block;
|
||||
min-height: 20px;
|
||||
padding: 10px;
|
||||
}
|
||||
* html .install-button a:link span.install-green-button,
|
||||
* html .install-button a:visited span.install-green-button,
|
||||
* html .install-button a:hover span.install-green-button,
|
||||
* html .install-button a:active span.install-green-button { height: 20px; }
|
||||
|
||||
.install-button a:link,
|
||||
.install-button a:visited,
|
||||
.install-button a:hover,
|
||||
.install-button a:active {
|
||||
background: #a8ed2d url(../../images/rustico/install-button.png) no-repeat top left;
|
||||
display: block;
|
||||
color: #005825;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.install-button a:hover span.install-green-button,
|
||||
.install-button a:active span.install-green-button {
|
||||
background: url(../../images/rustico/install-button.png) no-repeat bottom right;
|
||||
}
|
||||
|
||||
.install-button a:hover,
|
||||
.install-button a:active {
|
||||
background: #89dc29 url(../../images/rustico/install-button.png) no-repeat top right;
|
||||
color: #000;
|
||||
cursor: hand;
|
||||
}
|
||||
|
||||
/* corner box */
|
||||
|
||||
.corner-box {
|
||||
background: url(../../images/rustico/left-top-corner-box.jpg) top left no-repeat;
|
||||
margin: 0 0 10px 0;
|
||||
padding: 12px 0 12px 15px;
|
||||
}
|
||||
|
||||
.corner-box h3 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
/* front page search */
|
||||
|
||||
#front-search {
|
||||
margin-top: 1.5em;
|
||||
}
|
||||
|
||||
#front-search label {
|
||||
float: left;
|
||||
width: 25%;
|
||||
}
|
||||
|
||||
#front-search div {
|
||||
float: left;
|
||||
width: 70%
|
||||
}
|
||||
|
||||
#front-search div .keywords {
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
/* search box */
|
||||
|
||||
.search-container img {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.search-container h3 {
|
||||
margin-left: 40px;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
#extensions-search {
|
||||
margin-top: 1.5em;
|
||||
}
|
||||
|
||||
#extensions-search .keywords {
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
#hide-search-options,
|
||||
#search-options {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#search-results .desc p {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
#search-results h2 {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#search-results h2 span {
|
||||
font-weight: normal;
|
||||
font-size: 80%;
|
||||
}
|
||||
|
||||
#pages #next-page {
|
||||
float: right;
|
||||
}
|
||||
|
||||
/* various lists */
|
||||
|
||||
.compact-list {
|
||||
font-size: 80%;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.category-list {
|
||||
padding-left: 3em;
|
||||
font-weight: bold;
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
.category-list td,
|
||||
.compact-list td {
|
||||
font-size: inherit;
|
||||
}
|
||||
|
||||
.category-list td {
|
||||
padding: 0 1.5em 0 1.5em;
|
||||
}
|
||||
|
||||
.category-list a:link,
|
||||
.category-list a:visited,
|
||||
.compact-list a:link,
|
||||
.compact-list a:visited {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.compact-list span {
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
/* menu box */
|
||||
|
||||
#menu-box {
|
||||
float: left;
|
||||
background: url(../../images/rustico/menu-box/menu-box-top.png) top left no-repeat;
|
||||
font-size: 80%;
|
||||
font-weight: bold;
|
||||
width: 160px;
|
||||
}
|
||||
|
||||
#menu-box ul {
|
||||
background: url(../../images/rustico/menu-box/menu-box-bottom.png) bottom left no-repeat;
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
#menu-box ul li a:link,
|
||||
#menu-box ul li a:visited,
|
||||
#menu-box ul li span {
|
||||
background: url(../../images/rustico/menu-box/menu-box-background.png) 0 0 no-repeat;
|
||||
display: block;
|
||||
width: 136px;
|
||||
margin: 0;
|
||||
padding: 8px 12px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#menu-box ul li span {
|
||||
background: url(../../images/rustico/menu-box/menu-box-background.png) -400px 0 no-repeat;
|
||||
}
|
||||
|
||||
#menu-box ul li a:hover,
|
||||
#menu-box ul li a:active {
|
||||
background: url(../../images/rustico/menu-box/menu-box-background.png) -200px 0 no-repeat;
|
||||
}
|
||||
|
||||
/* footer */
|
||||
|
||||
#doc-links a,
|
||||
#switch-links a,
|
||||
#tool-links a {
|
||||
padding: 0 1em;
|
||||
}
|
||||
|
||||
#footer {
|
||||
clear: both;
|
||||
color: #888;
|
||||
text-align: center;
|
||||
margin: 0;
|
||||
padding: 1em 0;
|
||||
}
|
||||
|
||||
#footer ul {
|
||||
margin: 1.5em 0;
|
||||
}
|
||||
|
||||
#footer ul li {
|
||||
display: inline;
|
||||
margin: 0 0.5em;
|
||||
}
|
||||
|
||||
#footer-addons-menu {
|
||||
font-size: 110%;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#footer-addons-menu li {
|
||||
white-space: nowrap;
|
||||
padding: 10px 0 5px 25px;
|
||||
}
|
||||
|
||||
#footer-addons-menu li.firefox { background: url(../../images/rustico/footer/footer-icon-firefox.png) no-repeat center left; }
|
||||
#footer-addons-menu li.thunderbird { background: url(../../images/rustico/footer/footer-icon-thunderbird.png) no-repeat center left; }
|
||||
#footer-addons-menu li.mozilla { background: url(../../images/rustico/footer/footer-icon-mozilla.png) no-repeat center left; }
|
||||
|
||||
/* disclaimer */
|
||||
|
||||
#disclaimer {
|
||||
clear: both;
|
||||
background: url(../../images/rustico/footer/disclaimer.png) top repeat-x;
|
||||
}
|
||||
|
||||
#disclaimer form {
|
||||
float: right;
|
||||
margin: 1em 50px 2em 25px;
|
||||
}
|
||||
|
||||
#disclaimer form select {
|
||||
font-size: 80%;
|
||||
}
|
||||
|
||||
#disclaimer p {
|
||||
max-width: 750px;
|
||||
font-size: 80%;
|
||||
margin: 0 auto;
|
||||
padding: 10px 50px 20px 50px;
|
||||
}
|
||||
|
||||
#disclaimer a { color: #f7941d; }
|
||||
|
||||
.clearfix:after {
|
||||
content: ".";
|
||||
display: block;
|
||||
height: 0;
|
||||
clear: both;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.clearfix {display: inline-block;}
|
||||
|
||||
/* Hides from IE-mac \*/
|
||||
* html .clearfix {height: 1%;}
|
||||
.clearfix {display: block;}
|
||||
/* End hide from IE-mac */
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border: none;
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
table.dalvay-table {
|
||||
border-collapse: separate;
|
||||
}
|
||||
|
||||
table.dalvay-table thead th {
|
||||
background: none;
|
||||
}
|
||||
|
||||
table.dalvay-table thead td,
|
||||
table.dalvay-table thead th {
|
||||
background: #f9fafa url(/img/dalvay/table/header.png) top repeat-x;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
table.dalvay-table thead .top-left {
|
||||
background: url(/img/dalvay/table/top-left.png) top left no-repeat;
|
||||
}
|
||||
|
||||
table.dalvay-table thead .top-right {
|
||||
background: url(/img/dalvay/table/top-right.png) top right no-repeat;
|
||||
}
|
||||
|
||||
td.left { border-left: 1px solid #d7d7d7; }
|
||||
td.right { border-right: 1px solid #d7d7d7; }
|
||||
|
||||
table.dalvay-table tfoot td {
|
||||
background: #f9fafa url(/img/dalvay/table/footer.png) bottom repeat-x;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
table.dalvay-table tfoot .bottom-left {
|
||||
background: url(/img/dalvay/table/bottom-left.png) bottom left no-repeat;
|
||||
}
|
||||
|
||||
table.dalvay-table tfoot .bottom-right {
|
||||
background: url(/img/dalvay/table/bottom-right.png) bottom right no-repeat;
|
||||
}
|
||||
|
||||
table.dalvay-table tfoot td { height: 12px; }
|
||||
|
||||
|
||||
table.dalvay-table tr.odd td { background: #fff; }
|
||||
table.dalvay-table tr.even td { background: #eee; }
|
||||
table.dalvay-table tr:target td { background: yellow; }
|
||||
table.dalvay-table td.curVersion { font-weight: bold; }
|
||||
table.dalvay-table td.nya { text-align: center; }
|
||||
|
||||
table.dalvay-table td,
|
||||
table.dalvay-table th {
|
||||
margin: 0;
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
table.dalvay-table td.dl,
|
||||
table.dalvay-table th.dl {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
table.dalvay-table th {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/* search-engines */
|
||||
|
||||
.front-section {
|
||||
width: 220px;
|
||||
padding: 5px 0 5px 25px;
|
||||
float: left;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
#switch-links {
|
||||
align: right;
|
||||
padding-left: 5em;
|
||||
}
|
||||
|
||||
#switch-links .switch-tb,
|
||||
#switch-links .switch-suite {
|
||||
padding: 1px 0 1px 30px;
|
||||
font-size: 100%;
|
||||
background: #fff 9px 0 no-repeat;
|
||||
}
|
||||
|
||||
#switch-links .switch-tb {
|
||||
background-image: url("../../images/switch-tb.gif");
|
||||
}
|
||||
|
||||
#switch-links .switch-suite {
|
||||
background-image: url("../../images/switch-suite.gif");
|
||||
}
|
||||
|
||||
|
||||
/* ported from cavendish */
|
||||
|
||||
.item {
|
||||
border: #D2D6D6 1px solid;
|
||||
padding-left: 5px;
|
||||
padding-right: 6px;
|
||||
MARGIN-bottom: 10px;
|
||||
-moz-border-radius: 10px;
|
||||
}
|
||||
|
||||
.item a {
|
||||
color: #00129c;
|
||||
text-decoration: none;
|
||||
}
|
||||
.item a:visited {
|
||||
color: #00129c;
|
||||
text-decoration: none;
|
||||
}
|
||||
.item a:hover {
|
||||
color: #fc5900;
|
||||
}
|
||||
|
||||
.item h2 {
|
||||
margin-top: 0.2em;
|
||||
}
|
||||
|
||||
.iconbar {
|
||||
padding-right: 15px;
|
||||
float: left;
|
||||
width: auto;
|
||||
height: 34px;
|
||||
}
|
||||
|
||||
.iconbar img {
|
||||
float:left;
|
||||
}
|
||||
|
||||
.iconbar a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* user comments */
|
||||
|
||||
div.averagerating {
|
||||
float:right;
|
||||
font-size:85%;
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
div.usercomment {
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
|
||||
p.commenttext {
|
||||
margin-left: 2em;
|
||||
}
|
||||
|
||||
p.commentmeta {
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
.pages {
|
||||
color: #999;
|
||||
font-weight: bold;
|
||||
height: 2em;
|
||||
}
|
||||
|
||||
.next {
|
||||
border-left: 1px solid #000;
|
||||
display: inline;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.prev {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#comments-sort {
|
||||
float: right;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Dictionaries page.
|
||||
*
|
||||
* @package amo
|
||||
* @subpackage docs
|
||||
*/
|
||||
|
||||
startProcessing('dictionaries.tpl', 'dictionaries', $compileId, 'rustico');
|
||||
require_once('includes.php');
|
||||
|
||||
setApp();
|
||||
|
||||
$amo = new AMO_Object();
|
||||
|
||||
$dicts = $amo->getDictionaries();
|
||||
|
||||
// Assign template variables.
|
||||
$tpl->assign(
|
||||
array( 'dicts' => $dicts,
|
||||
'content' => 'dictionaries.tpl',
|
||||
'currentTab' => 'dictionaries')
|
||||
);
|
||||
?>
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
require_once(LIB.'/error.php');
|
||||
|
||||
$error = 'Test Error<br>';
|
||||
$error .= 'Generated: '.date("r");
|
||||
$error .= '<pre>'.print_r($_SERVER, true).'</pre>';
|
||||
|
||||
triggerError($error, 'site-down.tpl');
|
||||
|
||||
?>
|
||||
@@ -1,59 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Home page for extensions, switchable on application. Since v1 used GUIDs, the
|
||||
* flow on this page is a little confusing (we need to support both name and GUID.
|
||||
*
|
||||
* @package amo
|
||||
* @subpackage docs
|
||||
*/
|
||||
|
||||
$currentTab = 'extensions';
|
||||
|
||||
startProcessing('extensions.tpl', 'extensions', $compileId, "rustico");
|
||||
require_once('includes.php');
|
||||
|
||||
$_app = array_key_exists('app', $_GET) ? $_GET['app'] : null;
|
||||
|
||||
// Determine our application.
|
||||
switch( $_app ) {
|
||||
case 'mozilla':
|
||||
$clean['app'] = 'Mozilla';
|
||||
break;
|
||||
case 'thunderbird':
|
||||
$clean['app'] = 'Thunderbird';
|
||||
break;
|
||||
case 'sunbird':
|
||||
$clean['app'] = 'Sunbird';
|
||||
break;
|
||||
case 'firefox':
|
||||
default:
|
||||
$clean['app'] = 'Firefox';
|
||||
break;
|
||||
}
|
||||
|
||||
$amo = new AMO_Object();
|
||||
|
||||
// Despite what $clean holds, GUIDs were used in v1 so we have to support them
|
||||
if (preg_match('/^(\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}|[a-z0-9-\._]*\@[a-z0-9-\._]+)$/i',$_app)) {
|
||||
$newestExtensions = $amo->getNewestAddonsByGuid($_app,'E',10);
|
||||
$popularExtensions = $amo->getPopularAddonsByGuid($_app,'E',10);
|
||||
/* This is a bit of a cheesy hack because of the way the templates are written.
|
||||
* It's looking for the name of the app in $_GET, so here we are...*/
|
||||
$_GET['app'] = strtolower($amo->getAppNameFromGuid($_app));
|
||||
} else {
|
||||
$newestExtensions = $amo->getNewestAddons($clean['app'],'E',10);
|
||||
$popularExtensions = $amo->getPopularAddons($clean['app'],'E',10);
|
||||
}
|
||||
|
||||
// Assign template variables.
|
||||
$tpl->assign(
|
||||
array( 'newestExtensions' => $newestExtensions,
|
||||
'popularExtensions' => $popularExtensions,
|
||||
'title' => 'Add-ons',
|
||||
'currentTab' => $currentTab,
|
||||
'content' => 'extensions.tpl',
|
||||
'sidebar' => 'inc/category-sidebar.tpl',
|
||||
'cats' => $amo->getCats('E'),
|
||||
'type' => 'E')
|
||||
);
|
||||
?>
|
||||
@@ -1,73 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* FAQ page.
|
||||
*
|
||||
* @package amo
|
||||
* @subpackage docs
|
||||
*
|
||||
* @todo FAQ search?
|
||||
*/
|
||||
|
||||
startProcessing('faq.tpl','faq',$compileId, "rustico");
|
||||
require_once('includes.php');
|
||||
|
||||
$db->query("
|
||||
SELECT
|
||||
`title`,
|
||||
`text`
|
||||
FROM
|
||||
`faq`
|
||||
WHERE
|
||||
`active` = 'YES'
|
||||
ORDER BY
|
||||
`index` ASC,
|
||||
`title` ASC
|
||||
",SQL_ALL, SQL_ASSOC);
|
||||
|
||||
$faq = $db->record;
|
||||
|
||||
$sql = "
|
||||
SELECT
|
||||
`AppName`,
|
||||
`GUID`,
|
||||
`Version`
|
||||
FROM
|
||||
`applications`
|
||||
WHERE
|
||||
`public_ver`='YES'
|
||||
ORDER BY
|
||||
Appname, Version
|
||||
";
|
||||
|
||||
$db->query($sql,SQL_ALL,SQL_ASSOC);
|
||||
|
||||
if (is_array($db->record)) {
|
||||
foreach ($db->record as $row) {
|
||||
$appVersions[] = array(
|
||||
'displayVersion' => $row['Version'],
|
||||
'appName' => $row['AppName'],
|
||||
'guid' => $row['GUID']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$links = array(
|
||||
array( 'href' => './faq.php',
|
||||
'title' => 'Frequently Asked Questions',
|
||||
'text' => 'FAQ'),
|
||||
|
||||
array( 'href' => './policy.php',
|
||||
'title' => 'Addons Policies',
|
||||
'text' => 'Policy')
|
||||
);
|
||||
|
||||
// Send FAQ data to Smarty object.
|
||||
$tpl->assign(
|
||||
array( 'faq' => $faq,
|
||||
'links' => $links,
|
||||
'sidebar' => 'inc/nav.tpl',
|
||||
'content' => 'faq.tpl',
|
||||
'title' => 'Frequently Asked Questions',
|
||||
'appVersions' => $appVersions )
|
||||
);
|
||||
?>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Home page for extensions, switchable on application.
|
||||
*
|
||||
* @package amo
|
||||
* @subpackage docs
|
||||
*/
|
||||
|
||||
startProcessing('feeds.tpl', null, $compileId,'rustico');
|
||||
require_once('includes.php');
|
||||
|
||||
// Assign template variables.
|
||||
$tpl->assign(
|
||||
array( 'title' => 'Feeds',
|
||||
'content' => 'feeds.tpl')
|
||||
);
|
||||
?>
|
||||
@@ -1,175 +0,0 @@
|
||||
<?php
|
||||
// ***** 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 Update.
|
||||
//
|
||||
// The Initial Developer of the Original Code is
|
||||
// Chris "Wolf" Crews.
|
||||
// Portions created by the Initial Developer are Copyright (C) 2004
|
||||
// the Initial Developer. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
// Chris "Wolf" Crews <psychoticwolf@carolina.rr.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 *****
|
||||
|
||||
startProcessing('finalists.tpl',null,$compileId,'nonav');
|
||||
require_once('includes.php');
|
||||
|
||||
/**
|
||||
* Setting up variables.
|
||||
*/
|
||||
$guids = array(
|
||||
'{34274bf4-1d97-a289-e984-17e546307e4f}',
|
||||
'{097d3191-e6fa-4728-9826-b533d755359d}',
|
||||
'{B9DAB69C-460E-4085-AE6C-F95B0D858581}',
|
||||
'{DDC359D1-844A-42a7-9AA1-88A850A938A8}',
|
||||
'{89506680-e3f4-484c-a2c0-ed711d481eda}',
|
||||
'{3CE993BF-A3D9-4fd2-B3B6-768CBBC337F8}',
|
||||
'{268ad77e-cff8-42d7-b479-da60a7b93305}',
|
||||
'{77b819fa-95ad-4f2c-ac7c-486b356188a9}',
|
||||
'{bbc21d30-1cff-11da-8cd6-0800200c9a66}',
|
||||
'{37E4D8EA-8BDA-4831-8EA1-89053939A250}',
|
||||
'{a089fffd-e0cb-431b-8d3a-ebb8afb26dcf}',
|
||||
'Reveal@sourmilk.net',
|
||||
'{a6ca9b3b-5e52-4f47-85d8-cca35bb57596}',
|
||||
'{53A03D43-5363-4669-8190-99061B2DEBA5}',
|
||||
'separe@m4ng0.lilik.it',
|
||||
'xpose@viamatic.com',
|
||||
'{c45c406e-ab73-11d8-be73-000a95be3b12}',
|
||||
'{D5EDC062-A372-4936-B782-BD611DD18D86}'
|
||||
);
|
||||
|
||||
$guids_tmp = array();
|
||||
foreach ($guids as $guid) {
|
||||
$guids_tmp[] = "'".$guid."'";
|
||||
}
|
||||
$guids_imploded = implode(',',$guids_tmp);
|
||||
|
||||
$descriptions = array(
|
||||
'{34274bf4-1d97-a289-e984-17e546307e4f}'=>"Block ads including Flash ads from their source. Right click on an ad and select Adblock to block ads. Hit the status-element and see what has or hasn't been blocked.",
|
||||
'{097d3191-e6fa-4728-9826-b533d755359d}'=>"Manage Extensions, Themes, Downloads, and more including Web content via Firefox’s sidebar.",
|
||||
'{B9DAB69C-460E-4085-AE6C-F95B0D858581}'=>"Blog directly within Firefox to LiveJournal, WordPress or Blogger. Select Deepest Sender from the ‘Tools’ menu.",
|
||||
'{DDC359D1-844A-42a7-9AA1-88A850A938A8}'=>"DownThemAll lets you filter and download all the links contained in any web-page, and lets you pause and resume downloads from previous Firefox sessions.",
|
||||
'{89506680-e3f4-484c-a2c0-ed711d481eda}'=>"View open Tabs and Windows with Showcase. You can use it in two ways: global mode (F12) or local mode (Shift + F12). In global mode, a new window will be opened with thumbnails of the pages you've opened in all windows. In local mode, only content in tabs of your current window will be shown.
|
||||
|
||||
You can also right click in those thumbnails to perform the most usual operations on them. Mouse middle button can be used to zoom a thumbnail, although other actions can be assigned to it.",
|
||||
'{3CE993BF-A3D9-4fd2-B3B6-768CBBC337F8}'=>"Get international weather forecasts and display it in any toolbar or status bar.",
|
||||
'{268ad77e-cff8-42d7-b479-da60a7b93305}'=>"Select from several of your favorite toolbars including including Google, Yahoo, Ask Jeeves, Teoma, Amazon, Download.com and others with one toolbar. The entire toolbar reconfigures when you select a different engine and it includes many advanced features found in each engine.
|
||||
You can also easily repeat your search on all engines included in toolbar.",
|
||||
'{77b819fa-95ad-4f2c-ac7c-486b356188a9}'=>"View pages with in Internet Explorer with IE Tab. Select the Firefox icon on the bottom right of the browser to switch to using the Internet Explorer engine or Firefox to switch to IE.",
|
||||
'{bbc21d30-1cff-11da-8cd6-0800200c9a66}'=>"Allows sticky notes to be added to any web page, and viewed upon visiting the Web page again. You can also share sticky notes. Requires account.",
|
||||
'{37E4D8EA-8BDA-4831-8EA1-89053939A250}'=>"PDF Download Extension allows you to choose if you want to view a PDF file inside the browser (as PDF or HTML), if you want to view it outside Firefox with your default or custom PDF reader, or if you want to download it.",
|
||||
'{a089fffd-e0cb-431b-8d3a-ebb8afb26dcf}'=>"Platypus is a Firefox extension which lets you modify a Web page from your browser -- \"What You See Is What You Get\" -- and then save those changes as a GreaseMonkey script so that they'll be repeated the next time you visit the page.",
|
||||
'Reveal@sourmilk.net'=>"Reveal allows you to see thumbnails of pages in your history by mousing over the back and forward buttons. With many tabs open, quickly find the page you want, by pressing F2. Reveal also has a rectangular magnifying glass you can use to zoom in on areas of any web page. Comes with a quick tour of all the features. ",
|
||||
'{a6ca9b3b-5e52-4f47-85d8-cca35bb57596}'=>"A lightweight RSS and Atom feed aggregator. Alt+S to open Sage in the Sidebar to start reading feed content.",
|
||||
'{53A03D43-5363-4669-8190-99061B2DEBA5}'=>"Highlight text, create sticky notes, and more to Web pages and Web sites that are saved to your desktop. Scrapbook Includes full text search and quick filtering of saved pages.",
|
||||
'separe@m4ng0.lilik.it'=>"Manage tabs by creating a tab separator. Right click on a Tab to add a new Tab separator. Click on the Tab separator to view thumbnail images of web sites that are to the left and right of the Tab separator.",
|
||||
'xpose@viamatic.com'=>"Click on the icon in the status bar to view all Web pages in Tabbed windows as thumbnail images. Press F8 to activate foXpose.",
|
||||
'{c45c406e-ab73-11d8-be73-000a95be3b12}'=>"Web developer toolbar includes various development tools such as window resizing, form and image debugging, links to page validation and optimization tools and much more.",
|
||||
'{D5EDC062-A372-4936-B782-BD611DD18D86}'=>"RSS news reader with integrated with services such as Feedster and weather information. Includes online help documentation."
|
||||
);
|
||||
|
||||
$screenshots = array(
|
||||
'{34274bf4-1d97-a289-e984-17e546307e4f}'=>'adblock-mini.png',
|
||||
'{097d3191-e6fa-4728-9826-b533d755359d}'=>'all-in-one-mini.png',
|
||||
'{B9DAB69C-460E-4085-AE6C-F95B0D858581}'=>'deepest-sender-mini.png',
|
||||
'{DDC359D1-844A-42a7-9AA1-88A850A938A8}'=>'downthemall-small.png',
|
||||
'{89506680-e3f4-484c-a2c0-ed711d481eda}'=>'firefox-showcase.png',
|
||||
'{3CE993BF-A3D9-4fd2-B3B6-768CBBC337F8}'=>'forecastfoxenhanced-small.png',
|
||||
'{268ad77e-cff8-42d7-b479-da60a7b93305}'=>'groowe-small.png',
|
||||
'{77b819fa-95ad-4f2c-ac7c-486b356188a9}'=>'IE-Tab.png',
|
||||
'{bbc21d30-1cff-11da-8cd6-0800200c9a66}'=>'stickies-small.png',
|
||||
'{37E4D8EA-8BDA-4831-8EA1-89053939A250}'=>'pdf-download.png',
|
||||
'{a089fffd-e0cb-431b-8d3a-ebb8afb26dcf}'=>'platypus.png',
|
||||
'Reveal@sourmilk.net'=>'reveal.png',
|
||||
'{a6ca9b3b-5e52-4f47-85d8-cca35bb57596}'=>'sage.png',
|
||||
'{53A03D43-5363-4669-8190-99061B2DEBA5}'=>'scrapbook-final.png',
|
||||
'separe@m4ng0.lilik.it'=>'separe.png',
|
||||
'xpose@viamatic.com'=>'xpose-small.png',
|
||||
'{c45c406e-ab73-11d8-be73-000a95be3b12}'=>'web-developer-toolbar-small.png',
|
||||
'{D5EDC062-A372-4936-B782-BD611DD18D86}'=>'wizz-small.png'
|
||||
);
|
||||
|
||||
$authors = array(
|
||||
'{34274bf4-1d97-a289-e984-17e546307e4f}'=>'Ben Karel (and the Adblock Crew)',
|
||||
'{DDC359D1-844A-42a7-9AA1-88A850A938A8}'=>'Federico Parodi',
|
||||
'{a6ca9b3b-5e52-4f47-85d8-cca35bb57596}'=>'Peter Andrews (and the Sage Team)',
|
||||
'{53A03D43-5363-4669-8190-99061B2DEBA5}'=>'Taiga Gomibuchi',
|
||||
'separe@m4ng0.lilik.it'=>'Massimo Mangoni',
|
||||
'{77b819fa-95ad-4f2c-ac7c-486b356188a9}'=>'yuoo2k and Hong Jen Yee (PCMan)'
|
||||
);
|
||||
|
||||
$finalists = array();
|
||||
|
||||
// Get data for GUIDs.
|
||||
$finalists_sql = "
|
||||
SELECT
|
||||
m.guid,
|
||||
m.id,
|
||||
m.name,
|
||||
m.downloadcount,
|
||||
m.homepage,
|
||||
v.dateupdated,
|
||||
v.uri,
|
||||
v.size,
|
||||
v.version,
|
||||
(
|
||||
SELECT u.username
|
||||
FROM userprofiles u
|
||||
JOIN authorxref a ON u.userid = a.userid
|
||||
WHERE a.id = m.id
|
||||
ORDER BY u.userid DESC
|
||||
LIMIT 1
|
||||
) as username
|
||||
FROM
|
||||
main m
|
||||
JOIN version v ON m.id = v.id
|
||||
WHERE
|
||||
v.vid = (SELECT max(vid) FROM version WHERE id=m.id AND approved='YES') AND
|
||||
type = 'E' AND
|
||||
m.guid IN({$guids_imploded})
|
||||
ORDER BY
|
||||
LTRIM(m.name)
|
||||
";
|
||||
|
||||
$db->query($finalists_sql, SQL_ALL, SQL_ASSOC);
|
||||
|
||||
foreach ($db->record as $var => $val) {
|
||||
$val['author'] = !empty($authors[$val['guid']]) ? $authors[$val['guid']] : $val['username'];
|
||||
$finalists[] = $val;
|
||||
}
|
||||
|
||||
// Assign template variables.
|
||||
$tpl->assign(
|
||||
array(
|
||||
'title' => 'Extend Firefox Contest Finalists',
|
||||
'screenshots' => $screenshots,
|
||||
'descriptions' => $descriptions,
|
||||
'finalists' => $finalists,
|
||||
'content' => 'finalists.tpl')
|
||||
);
|
||||
?>
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Addon history page. Displays all the previous releases for a particular
|
||||
* addon or theme
|
||||
*
|
||||
* @package amo
|
||||
* @subpackage docs
|
||||
*
|
||||
* @todo break this into a simpler design, probably a smaller table with an abbreviated desc.
|
||||
* @todo do we still want to allow users access to old versions?
|
||||
*/
|
||||
|
||||
// Get our addon ID.
|
||||
$clean['ID'] = intval($_GET['id']);
|
||||
$sql['ID'] =& $clean['ID'];
|
||||
|
||||
startProcessing('history.tpl',$clean['ID'],$compileId, 'rustico');
|
||||
require_once('includes.php');
|
||||
|
||||
$addon = new AddOn($sql['ID']);
|
||||
$addon->getHistory();
|
||||
|
||||
// Assign template variables.
|
||||
$tpl->assign(
|
||||
array( 'addon' => $addon,
|
||||
'title' => $addon->Name.' Version History',
|
||||
'content' => 'history.tpl',
|
||||
'sidebar' => 'inc/addon-sidebar.tpl')
|
||||
);
|
||||
?>
|
||||
|
Before Width: | Height: | Size: 181 B |
|
Before Width: | Height: | Size: 526 B |
|
Before Width: | Height: | Size: 776 B |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 757 B |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 95 KiB |
|
Before Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 112 KiB |
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 115 KiB |
|
Before Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 132 KiB |
|
Before Width: | Height: | Size: 107 KiB |
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 349 B |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 394 B |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 988 B |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 741 B |
|
Before Width: | Height: | Size: 791 B |
|
Before Width: | Height: | Size: 936 B |
|
Before Width: | Height: | Size: 877 B |
|
Before Width: | Height: | Size: 917 B |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 162 B |
|
Before Width: | Height: | Size: 495 B |
|
Before Width: | Height: | Size: 103 B |
|
Before Width: | Height: | Size: 161 B |
|
Before Width: | Height: | Size: 86 B |
|
Before Width: | Height: | Size: 160 B |
|
Before Width: | Height: | Size: 386 B |
|
Before Width: | Height: | Size: 159 B |
|
Before Width: | Height: | Size: 384 B |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 94 B |