mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
bug #75220: rs=brendan, r=axel@pike.org. fixing string names.
This commit is contained in:
parent
6ffc96481f
commit
9e7566bb09
@ -21,11 +21,11 @@
|
||||
* Scott Collins <scc@mozilla.org> (original author)
|
||||
*/
|
||||
|
||||
/* nsPromiseConcatenation.h --- string concatenation machinery lives here, but don't include this file
|
||||
/* nsDependentConcatenation.h --- string concatenation machinery lives here, but don't include this file
|
||||
directly, always get it by including either "nsAString.h" or one of the compatibility headers */
|
||||
|
||||
#ifndef nsPromiseConcatenation_h___
|
||||
#define nsPromiseConcatenation_h___
|
||||
#ifndef nsDependentConcatenation_h___
|
||||
#define nsDependentConcatenation_h___
|
||||
|
||||
/**
|
||||
NOT FOR USE BY HUMANS
|
||||
@ -35,7 +35,7 @@
|
||||
character copies are required unless and until a final assignment is made. It works
|
||||
its magic by overriding and forwarding calls to |GetReadableFragment()|.
|
||||
|
||||
Note: |nsPromiseConcatenation| imposes some limits on string concatenation with |operator+()|.
|
||||
Note: |nsDependentConcatenation| imposes some limits on string concatenation with |operator+()|.
|
||||
- no more than 33 strings, e.g., |s1 + s2 + s3 + ... s32 + s33|
|
||||
- left to right evaluation is required ... do not use parentheses to override this
|
||||
|
||||
@ -47,11 +47,11 @@
|
||||
|GetReadableFragment()|.
|
||||
*/
|
||||
|
||||
class NS_COM nsPromiseConcatenation
|
||||
class NS_COM nsDependentConcatenation
|
||||
: public nsAPromiseString
|
||||
{
|
||||
public:
|
||||
typedef nsPromiseConcatenation self_type;
|
||||
typedef nsDependentConcatenation self_type;
|
||||
typedef PRUnichar char_type;
|
||||
typedef nsAString string_type;
|
||||
typedef string_type::const_iterator const_iterator;
|
||||
@ -83,22 +83,22 @@ class NS_COM nsPromiseConcatenation
|
||||
}
|
||||
|
||||
public:
|
||||
nsPromiseConcatenation( const string_type& aLeftString, const string_type& aRightString, PRUint32 aMask = 1 )
|
||||
nsDependentConcatenation( const string_type& aLeftString, const string_type& aRightString, PRUint32 aMask = 1 )
|
||||
: mFragmentIdentifierMask(aMask)
|
||||
{
|
||||
mStrings[kLeftString] = &aLeftString;
|
||||
mStrings[kRightString] = &aRightString;
|
||||
}
|
||||
|
||||
nsPromiseConcatenation( const self_type& aLeftString, const string_type& aRightString )
|
||||
nsDependentConcatenation( const self_type& aLeftString, const string_type& aRightString )
|
||||
: mFragmentIdentifierMask(aLeftString.mFragmentIdentifierMask<<1)
|
||||
{
|
||||
mStrings[kLeftString] = &aLeftString;
|
||||
mStrings[kRightString] = &aRightString;
|
||||
}
|
||||
|
||||
// nsPromiseConcatenation( const self_type& ); // auto-generated copy-constructor should be OK
|
||||
// ~nsPromiseConcatenation(); // auto-generated destructor OK
|
||||
// nsDependentConcatenation( const self_type& ); // auto-generated copy-constructor should be OK
|
||||
// ~nsDependentConcatenation(); // auto-generated destructor OK
|
||||
|
||||
private:
|
||||
// NOT TO BE IMPLEMENTED
|
||||
@ -124,11 +124,11 @@ class NS_COM nsPromiseConcatenation
|
||||
PRUint32 mFragmentIdentifierMask;
|
||||
};
|
||||
|
||||
class NS_COM nsPromiseCConcatenation
|
||||
class NS_COM nsDependentCConcatenation
|
||||
: public nsAPromiseCString
|
||||
{
|
||||
public:
|
||||
typedef nsPromiseCConcatenation self_type;
|
||||
typedef nsDependentCConcatenation self_type;
|
||||
typedef char char_type;
|
||||
typedef nsACString string_type;
|
||||
typedef string_type::const_iterator const_iterator;
|
||||
@ -160,22 +160,22 @@ class NS_COM nsPromiseCConcatenation
|
||||
}
|
||||
|
||||
public:
|
||||
nsPromiseCConcatenation( const string_type& aLeftString, const string_type& aRightString, PRUint32 aMask = 1 )
|
||||
nsDependentCConcatenation( const string_type& aLeftString, const string_type& aRightString, PRUint32 aMask = 1 )
|
||||
: mFragmentIdentifierMask(aMask)
|
||||
{
|
||||
mStrings[kLeftString] = &aLeftString;
|
||||
mStrings[kRightString] = &aRightString;
|
||||
}
|
||||
|
||||
nsPromiseCConcatenation( const self_type& aLeftString, const string_type& aRightString )
|
||||
nsDependentCConcatenation( const self_type& aLeftString, const string_type& aRightString )
|
||||
: mFragmentIdentifierMask(aLeftString.mFragmentIdentifierMask<<1)
|
||||
{
|
||||
mStrings[kLeftString] = &aLeftString;
|
||||
mStrings[kRightString] = &aRightString;
|
||||
}
|
||||
|
||||
// nsPromiseCConcatenation( const self_type& ); // auto-generated copy-constructor should be OK
|
||||
// ~nsPromiseCConcatenation(); // auto-generated destructor OK
|
||||
// nsDependentCConcatenation( const self_type& ); // auto-generated copy-constructor should be OK
|
||||
// ~nsDependentCConcatenation(); // auto-generated destructor OK
|
||||
|
||||
private:
|
||||
// NOT TO BE IMPLEMENTED
|
||||
@ -214,7 +214,7 @@ class NS_COM nsPromiseCConcatenation
|
||||
will really want to do with the result. What might be better, though,
|
||||
is to return a `promise' to concatenate some strings...
|
||||
|
||||
By making |nsPromiseConcatenation| inherit from readable strings, we automatically handle
|
||||
By making |nsDependentConcatenation| inherit from readable strings, we automatically handle
|
||||
assignment and other interesting uses within writable strings, plus we drastically reduce
|
||||
the number of cases we have to write |operator+()| for. The cost is extra temporary concat strings
|
||||
in the evaluation of strings of '+'s, e.g., |A + B + C + D|, and that we have to do some work
|
||||
@ -222,48 +222,52 @@ class NS_COM nsPromiseCConcatenation
|
||||
*/
|
||||
|
||||
inline
|
||||
const nsPromiseConcatenation
|
||||
operator+( const nsPromiseConcatenation& lhs, const nsAString& rhs )
|
||||
const nsDependentConcatenation
|
||||
operator+( const nsDependentConcatenation& lhs, const nsAString& rhs )
|
||||
{
|
||||
return nsPromiseConcatenation(lhs, rhs, lhs.GetFragmentIdentifierMask()<<1);
|
||||
return nsDependentConcatenation(lhs, rhs, lhs.GetFragmentIdentifierMask()<<1);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsPromiseCConcatenation
|
||||
operator+( const nsPromiseCConcatenation& lhs, const nsACString& rhs )
|
||||
const nsDependentCConcatenation
|
||||
operator+( const nsDependentCConcatenation& lhs, const nsACString& rhs )
|
||||
{
|
||||
return nsPromiseCConcatenation(lhs, rhs, lhs.GetFragmentIdentifierMask()<<1);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsPromiseConcatenation
|
||||
operator+( const nsAString& lhs, const nsAString& rhs )
|
||||
{
|
||||
return nsPromiseConcatenation(lhs, rhs);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsPromiseCConcatenation
|
||||
operator+( const nsACString& lhs, const nsACString& rhs )
|
||||
{
|
||||
return nsPromiseCConcatenation(lhs, rhs);
|
||||
return nsDependentCConcatenation(lhs, rhs, lhs.GetFragmentIdentifierMask()<<1);
|
||||
}
|
||||
|
||||
#if 0
|
||||
// temporarily comment these two global operators out, until |nsPromiseConcatenation| is removed
|
||||
|
||||
inline
|
||||
const nsPromiseConcatenation
|
||||
nsPromiseConcatenation::operator+( const string_type& rhs ) const
|
||||
const nsDependentConcatenation
|
||||
operator+( const nsAString& lhs, const nsAString& rhs )
|
||||
{
|
||||
return nsPromiseConcatenation(*this, rhs, mFragmentIdentifierMask<<1);
|
||||
return nsDependentConcatenation(lhs, rhs);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsPromiseCConcatenation
|
||||
nsPromiseCConcatenation::operator+( const string_type& rhs ) const
|
||||
const nsDependentCConcatenation
|
||||
operator+( const nsACString& lhs, const nsACString& rhs )
|
||||
{
|
||||
return nsPromiseCConcatenation(*this, rhs, mFragmentIdentifierMask<<1);
|
||||
return nsDependentCConcatenation(lhs, rhs);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
inline
|
||||
const nsDependentConcatenation
|
||||
nsDependentConcatenation::operator+( const string_type& rhs ) const
|
||||
{
|
||||
return nsDependentConcatenation(*this, rhs, mFragmentIdentifierMask<<1);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsDependentCConcatenation
|
||||
nsDependentCConcatenation::operator+( const string_type& rhs ) const
|
||||
{
|
||||
return nsDependentCConcatenation(*this, rhs, mFragmentIdentifierMask<<1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* !defined(nsPromiseConcatenation_h___) */
|
||||
#endif /* !defined(nsDependentConcatenation_h___) */
|
||||
|
@ -21,8 +21,8 @@
|
||||
* Scott Collins <scc@mozilla.org> (original author)
|
||||
*/
|
||||
|
||||
#ifndef nsLocalString_h___
|
||||
#define nsLocalString_h___
|
||||
#ifndef nsDependentString_h___
|
||||
#define nsDependentString_h___
|
||||
|
||||
#ifndef nsAFlatString_h___
|
||||
#include "nsAFlatString.h"
|
||||
@ -41,24 +41,21 @@
|
||||
|
||||
This class just holds a pointer. If you don't supply the length, it must calculate it.
|
||||
No copying or allocations are performed.
|
||||
|
||||
|const nsLocalString&| appears frequently in interfaces because it
|
||||
allows the automatic conversion of a |PRUnichar*|.
|
||||
*/
|
||||
|
||||
class NS_COM nsLocalString
|
||||
class NS_COM nsDependentString
|
||||
: public nsAFlatString
|
||||
{
|
||||
public:
|
||||
|
||||
explicit
|
||||
nsLocalString( const PRUnichar* aLiteral )
|
||||
nsDependentString( const PRUnichar* aLiteral )
|
||||
: mHandle(NS_CONST_CAST(PRUnichar*, aLiteral), aLiteral ? (NS_CONST_CAST(PRUnichar*, aLiteral)+nsCharTraits<PRUnichar>::length(aLiteral)) : NS_CONST_CAST(PRUnichar*, aLiteral))
|
||||
{
|
||||
// nothing else to do here
|
||||
}
|
||||
|
||||
nsLocalString( const PRUnichar* aLiteral, PRUint32 aLength )
|
||||
nsDependentString( const PRUnichar* aLiteral, PRUint32 aLength )
|
||||
: mHandle(NS_CONST_CAST(PRUnichar*, aLiteral), NS_CONST_CAST(PRUnichar*, aLiteral)+aLength)
|
||||
{
|
||||
// This is an annoying hack. Callers should be fixed to use the other
|
||||
@ -70,8 +67,8 @@ class NS_COM nsLocalString
|
||||
}
|
||||
}
|
||||
|
||||
// nsLocalString( const nsLocalString& ); // auto-generated copy-constructor OK
|
||||
// ~nsLocalString(); // auto-generated destructor OK
|
||||
// nsDependentString( const nsDependentString& ); // auto-generated copy-constructor OK
|
||||
// ~nsDependentString(); // auto-generated destructor OK
|
||||
|
||||
virtual const nsBufferHandle<PRUnichar>* GetFlatBufferHandle() const { return &mHandle; }
|
||||
virtual const nsBufferHandle<PRUnichar>* GetBufferHandle() const { return &mHandle; }
|
||||
@ -81,24 +78,24 @@ class NS_COM nsLocalString
|
||||
|
||||
private:
|
||||
// NOT TO BE IMPLEMENTED
|
||||
void operator=( const nsLocalString& ); // we're immutable
|
||||
void operator=( const nsDependentString& ); // we're immutable
|
||||
};
|
||||
|
||||
|
||||
|
||||
class NS_COM nsLocalCString
|
||||
class NS_COM nsDependentCString
|
||||
: public nsAFlatCString
|
||||
{
|
||||
public:
|
||||
|
||||
explicit
|
||||
nsLocalCString( const char* aLiteral )
|
||||
nsDependentCString( const char* aLiteral )
|
||||
: mHandle(NS_CONST_CAST(char*, aLiteral), aLiteral ? (NS_CONST_CAST(char*, aLiteral)+nsCharTraits<char>::length(aLiteral)) : NS_CONST_CAST(char*, aLiteral))
|
||||
{
|
||||
// nothing else to do here
|
||||
}
|
||||
|
||||
nsLocalCString( const char* aLiteral, PRUint32 aLength )
|
||||
nsDependentCString( const char* aLiteral, PRUint32 aLength )
|
||||
: mHandle(NS_CONST_CAST(char*, aLiteral), NS_CONST_CAST(char*, aLiteral)+aLength)
|
||||
{
|
||||
// This is an annoying hack. Callers should be fixed to use the other
|
||||
@ -110,8 +107,8 @@ class NS_COM nsLocalCString
|
||||
}
|
||||
}
|
||||
|
||||
// nsLocalCString( const nsLocalCString& ); // auto-generated copy-constructor OK
|
||||
// ~nsLocalCString(); // auto-generated destructor OK
|
||||
// nsDependentCString( const nsDependentCString& ); // auto-generated copy-constructor OK
|
||||
// ~nsDependentCString(); // auto-generated destructor OK
|
||||
|
||||
virtual const nsBufferHandle<char>* GetFlatBufferHandle() const { return &mHandle; }
|
||||
virtual const nsBufferHandle<char>* GetBufferHandle() const { return &mHandle; }
|
||||
@ -121,7 +118,7 @@ class NS_COM nsLocalCString
|
||||
|
||||
private:
|
||||
// NOT TO BE IMPLEMENTED
|
||||
void operator=( const nsLocalCString& ); // we're immutable
|
||||
void operator=( const nsDependentCString& ); // we're immutable
|
||||
};
|
||||
|
||||
#endif /* !defined(nsLocalString_h___) */
|
||||
#endif /* !defined(nsDependentString_h___) */
|
||||
|
@ -21,8 +21,8 @@
|
||||
* Scott Collins <scc@mozilla.org> (original author)
|
||||
*/
|
||||
|
||||
#ifndef nsPromiseSubstring_h___
|
||||
#define nsPromiseSubstring_h___
|
||||
#ifndef nsDependentSubstring_h___
|
||||
#define nsDependentSubstring_h___
|
||||
|
||||
#ifndef nsAString_h___
|
||||
#include "nsAString.h"
|
||||
@ -35,16 +35,16 @@
|
||||
|
||||
|
||||
//
|
||||
// nsPromiseSubstring
|
||||
// nsDependentSubstring
|
||||
//
|
||||
|
||||
class NS_COM nsPromiseSubstring
|
||||
class NS_COM nsDependentSubstring
|
||||
: public nsAPromiseString
|
||||
/*
|
||||
NOT FOR USE BY HUMANS (mostly)
|
||||
|
||||
...not unlike |nsPromiseConcatenation|. Instances of this class exist only as anonymous
|
||||
temporary results from |Substring()|. Like |nsPromiseConcatenation|, this class only
|
||||
...not unlike |nsDependentConcatenation|. Instances of this class exist only as anonymous
|
||||
temporary results from |Substring()|. Like |nsDependentConcatenation|, this class only
|
||||
holds a pointer, no string data of its own. It does its magic by overriding and forwarding
|
||||
calls to |GetReadableFragment()|.
|
||||
*/
|
||||
@ -57,7 +57,7 @@ class NS_COM nsPromiseSubstring
|
||||
virtual PRUnichar* GetWritableFragment( nsWritableFragment<PRUnichar>&, nsFragmentRequest, PRUint32 ) { return 0; }
|
||||
|
||||
public:
|
||||
nsPromiseSubstring( const string_type& aString, PRUint32 aStartPos, PRUint32 aLength )
|
||||
nsDependentSubstring( const string_type& aString, PRUint32 aStartPos, PRUint32 aLength )
|
||||
: mString(aString),
|
||||
mStartPos( NS_MIN(aStartPos, aString.Length()) ),
|
||||
mLength( NS_MIN(aLength, aString.Length()-mStartPos) )
|
||||
@ -65,7 +65,7 @@ class NS_COM nsPromiseSubstring
|
||||
// nothing else to do here
|
||||
}
|
||||
|
||||
nsPromiseSubstring( const const_iterator& aStart, const const_iterator& aEnd )
|
||||
nsDependentSubstring( const const_iterator& aStart, const const_iterator& aEnd )
|
||||
: mString(aStart.string())
|
||||
{
|
||||
const_iterator zeroPoint;
|
||||
@ -74,12 +74,12 @@ class NS_COM nsPromiseSubstring
|
||||
mLength = Distance(aStart, aEnd);
|
||||
}
|
||||
|
||||
// nsPromiseSubstring( const nsPromiseSubstring& ); // auto-generated copy-constructor should be OK
|
||||
// ~nsPromiseSubstring(); // auto-generated destructor OK
|
||||
// nsDependentSubstring( const nsDependentSubstring& ); // auto-generated copy-constructor should be OK
|
||||
// ~nsDependentSubstring(); // auto-generated destructor OK
|
||||
|
||||
private:
|
||||
// NOT TO BE IMPLEMENTED
|
||||
void operator=( const nsPromiseSubstring& ); // we're immutable, you can't assign into a substring
|
||||
void operator=( const nsDependentSubstring& ); // we're immutable, you can't assign into a substring
|
||||
|
||||
public:
|
||||
virtual PRUint32 Length() const;
|
||||
@ -91,13 +91,13 @@ class NS_COM nsPromiseSubstring
|
||||
PRUint32 mLength;
|
||||
};
|
||||
|
||||
class NS_COM nsPromiseCSubstring
|
||||
class NS_COM nsDependentCSubstring
|
||||
: public nsAPromiseCString
|
||||
/*
|
||||
NOT FOR USE BY HUMANS (mostly)
|
||||
|
||||
...not unlike |nsPromiseConcatenation|. Instances of this class exist only as anonymous
|
||||
temporary results from |Substring()|. Like |nsPromiseConcatenation|, this class only
|
||||
...not unlike |nsDependentConcatenation|. Instances of this class exist only as anonymous
|
||||
temporary results from |Substring()|. Like |nsDependentConcatenation|, this class only
|
||||
holds a pointer, no string data of its own. It does its magic by overriding and forwarding
|
||||
calls to |GetReadableFragment()|.
|
||||
*/
|
||||
@ -110,7 +110,7 @@ class NS_COM nsPromiseCSubstring
|
||||
virtual char* GetWritableFragment( nsWritableFragment<char>&, nsFragmentRequest, PRUint32 ) { return 0; }
|
||||
|
||||
public:
|
||||
nsPromiseCSubstring( const string_type& aString, PRUint32 aStartPos, PRUint32 aLength )
|
||||
nsDependentCSubstring( const string_type& aString, PRUint32 aStartPos, PRUint32 aLength )
|
||||
: mString(aString),
|
||||
mStartPos( NS_MIN(aStartPos, aString.Length()) ),
|
||||
mLength( NS_MIN(aLength, aString.Length()-mStartPos) )
|
||||
@ -118,7 +118,7 @@ class NS_COM nsPromiseCSubstring
|
||||
// nothing else to do here
|
||||
}
|
||||
|
||||
nsPromiseCSubstring( const const_iterator& aStart, const const_iterator& aEnd )
|
||||
nsDependentCSubstring( const const_iterator& aStart, const const_iterator& aEnd )
|
||||
: mString(aStart.string())
|
||||
{
|
||||
const_iterator zeroPoint;
|
||||
@ -127,12 +127,12 @@ class NS_COM nsPromiseCSubstring
|
||||
mLength = Distance(aStart, aEnd);
|
||||
}
|
||||
|
||||
// nsPromiseCSubstring( const nsPromiseCSubstring& ); // auto-generated copy-constructor should be OK
|
||||
// ~nsPromiseCSubstring(); // auto-generated destructor OK
|
||||
// nsDependentCSubstring( const nsDependentCSubstring& ); // auto-generated copy-constructor should be OK
|
||||
// ~nsDependentCSubstring(); // auto-generated destructor OK
|
||||
|
||||
private:
|
||||
// NOT TO BE IMPLEMENTED
|
||||
void operator=( const nsPromiseCSubstring& ); // we're immutable, you can't assign into a substring
|
||||
void operator=( const nsDependentCSubstring& ); // we're immutable, you can't assign into a substring
|
||||
|
||||
public:
|
||||
virtual PRUint32 Length() const;
|
||||
@ -151,32 +151,32 @@ class NS_COM nsPromiseCSubstring
|
||||
|
||||
|
||||
inline
|
||||
const nsPromiseCSubstring
|
||||
const nsDependentCSubstring
|
||||
Substring( const nsACString& aString, PRUint32 aStartPos, PRUint32 aSubstringLength )
|
||||
{
|
||||
return nsPromiseCSubstring(aString, aStartPos, aSubstringLength);
|
||||
return nsDependentCSubstring(aString, aStartPos, aSubstringLength);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsPromiseSubstring
|
||||
const nsDependentSubstring
|
||||
Substring( const nsAString& aString, PRUint32 aStartPos, PRUint32 aSubstringLength )
|
||||
{
|
||||
return nsPromiseSubstring(aString, aStartPos, aSubstringLength);
|
||||
return nsDependentSubstring(aString, aStartPos, aSubstringLength);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsPromiseCSubstring
|
||||
const nsDependentCSubstring
|
||||
Substring( const nsReadingIterator<char>& aStart, const nsReadingIterator<char>& aEnd )
|
||||
{
|
||||
return nsPromiseCSubstring(aStart, aEnd);
|
||||
return nsDependentCSubstring(aStart, aEnd);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsPromiseSubstring
|
||||
const nsDependentSubstring
|
||||
Substring( const nsReadingIterator<PRUnichar>& aStart, const nsReadingIterator<PRUnichar>& aEnd )
|
||||
{
|
||||
return nsPromiseSubstring(aStart, aEnd);
|
||||
return nsDependentSubstring(aStart, aEnd);
|
||||
}
|
||||
|
||||
|
||||
#endif /* !defined(nsPromiseSubstring_h___) */
|
||||
#endif /* !defined(nsDependentSubstring_h___) */
|
||||
|
@ -24,24 +24,29 @@
|
||||
//-------1---------2---------3---------4---------5---------6---------7---------8
|
||||
|
||||
#include "nsAString.h"
|
||||
// remember, no one should include "nsPromiseConcatenation.h" themselves
|
||||
// remember, no one should include "nsDependentConcatenation.h" themselves
|
||||
// one always gets it through "nsAString.h"
|
||||
|
||||
#ifndef nsDependentConcatenation_h___
|
||||
#include "nsDependentConcatenation.h"
|
||||
#endif
|
||||
|
||||
|
||||
PRUint32
|
||||
nsPromiseConcatenation::Length() const
|
||||
nsDependentConcatenation::Length() const
|
||||
{
|
||||
return mStrings[kLeftString]->Length() + mStrings[kRightString]->Length();
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsPromiseConcatenation::Promises( const string_type& aString ) const
|
||||
nsDependentConcatenation::Promises( const string_type& aString ) const
|
||||
{
|
||||
return mStrings[0]->Promises(aString) || mStrings[1]->Promises(aString);
|
||||
}
|
||||
|
||||
#if 0
|
||||
PRBool
|
||||
nsPromiseConcatenation::PromisesExactly( const string_type& aString ) const
|
||||
nsDependentConcatenation::PromisesExactly( const string_type& aString ) const
|
||||
{
|
||||
// Not really like this, test for the empty string, etc
|
||||
return mStrings[0] == &aString && !mStrings[1] || !mStrings[0] && mStrings[1] == &aString;
|
||||
@ -49,7 +54,7 @@ nsPromiseConcatenation::PromisesExactly( const string_type& aString ) const
|
||||
#endif
|
||||
|
||||
const PRUnichar*
|
||||
nsPromiseConcatenation::GetReadableFragment( nsReadableFragment<char_type>& aFragment, nsFragmentRequest aRequest, PRUint32 aPosition ) const
|
||||
nsDependentConcatenation::GetReadableFragment( nsReadableFragment<char_type>& aFragment, nsFragmentRequest aRequest, PRUint32 aPosition ) const
|
||||
{
|
||||
int whichString;
|
||||
|
||||
@ -113,20 +118,20 @@ nsPromiseConcatenation::GetReadableFragment( nsReadableFragment<char_type>& aFra
|
||||
|
||||
|
||||
PRUint32
|
||||
nsPromiseCConcatenation::Length() const
|
||||
nsDependentCConcatenation::Length() const
|
||||
{
|
||||
return mStrings[kLeftString]->Length() + mStrings[kRightString]->Length();
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsPromiseCConcatenation::Promises( const string_type& aString ) const
|
||||
nsDependentCConcatenation::Promises( const string_type& aString ) const
|
||||
{
|
||||
return mStrings[0]->Promises(aString) || mStrings[1]->Promises(aString);
|
||||
}
|
||||
|
||||
#if 0
|
||||
PRBool
|
||||
nsPromiseCConcatenation::PromisesExactly( const string_type& aString ) const
|
||||
nsDependentCConcatenation::PromisesExactly( const string_type& aString ) const
|
||||
{
|
||||
// Not really like this, test for the empty string, etc
|
||||
return mStrings[0] == &aString && !mStrings[1] || !mStrings[0] && mStrings[1] == &aString;
|
||||
@ -134,7 +139,7 @@ nsPromiseCConcatenation::PromisesExactly( const string_type& aString ) const
|
||||
#endif
|
||||
|
||||
const char*
|
||||
nsPromiseCConcatenation::GetReadableFragment( nsReadableFragment<char_type>& aFragment, nsFragmentRequest aRequest, PRUint32 aPosition ) const
|
||||
nsDependentCConcatenation::GetReadableFragment( nsReadableFragment<char_type>& aFragment, nsFragmentRequest aRequest, PRUint32 aPosition ) const
|
||||
{
|
||||
int whichString;
|
||||
|
||||
|
@ -21,5 +21,5 @@
|
||||
* Scott Collins <scc@mozilla.org> (original author)
|
||||
*/
|
||||
|
||||
#include "nsLocalString.h"
|
||||
#include "nsDependentString.h"
|
||||
|
||||
|
@ -21,16 +21,16 @@
|
||||
* Scott Collins <scc@mozilla.org> (original author)
|
||||
*/
|
||||
|
||||
#include "nsPromiseSubstring.h"
|
||||
#include "nsDependentSubstring.h"
|
||||
|
||||
PRUint32
|
||||
nsPromiseSubstring::Length() const
|
||||
nsDependentSubstring::Length() const
|
||||
{
|
||||
return mLength;
|
||||
}
|
||||
|
||||
const PRUnichar*
|
||||
nsPromiseSubstring::GetReadableFragment( nsReadableFragment<PRUnichar>& aFragment, nsFragmentRequest aRequest, PRUint32 aPosition ) const
|
||||
nsDependentSubstring::GetReadableFragment( nsReadableFragment<PRUnichar>& aFragment, nsFragmentRequest aRequest, PRUint32 aPosition ) const
|
||||
{
|
||||
// Offset any request for a specific position (First, Last, At) by our
|
||||
// substrings startpos within the owning string
|
||||
@ -75,13 +75,13 @@ nsPromiseSubstring::GetReadableFragment( nsReadableFragment<PRUnichar>& aFragmen
|
||||
|
||||
|
||||
PRUint32
|
||||
nsPromiseCSubstring::Length() const
|
||||
nsDependentCSubstring::Length() const
|
||||
{
|
||||
return mLength;
|
||||
}
|
||||
|
||||
const char*
|
||||
nsPromiseCSubstring::GetReadableFragment( nsReadableFragment<char>& aFragment, nsFragmentRequest aRequest, PRUint32 aPosition ) const
|
||||
nsDependentCSubstring::GetReadableFragment( nsReadableFragment<char>& aFragment, nsFragmentRequest aRequest, PRUint32 aPosition ) const
|
||||
{
|
||||
// Offset any request for a specific position (First, Last, At) by our
|
||||
// substrings startpos within the owning string
|
||||
|
@ -21,11 +21,11 @@
|
||||
* Scott Collins <scc@mozilla.org> (original author)
|
||||
*/
|
||||
|
||||
/* nsPromiseConcatenation.h --- string concatenation machinery lives here, but don't include this file
|
||||
/* nsDependentConcatenation.h --- string concatenation machinery lives here, but don't include this file
|
||||
directly, always get it by including either "nsAString.h" or one of the compatibility headers */
|
||||
|
||||
#ifndef nsPromiseConcatenation_h___
|
||||
#define nsPromiseConcatenation_h___
|
||||
#ifndef nsDependentConcatenation_h___
|
||||
#define nsDependentConcatenation_h___
|
||||
|
||||
/**
|
||||
NOT FOR USE BY HUMANS
|
||||
@ -35,7 +35,7 @@
|
||||
character copies are required unless and until a final assignment is made. It works
|
||||
its magic by overriding and forwarding calls to |GetReadableFragment()|.
|
||||
|
||||
Note: |nsPromiseConcatenation| imposes some limits on string concatenation with |operator+()|.
|
||||
Note: |nsDependentConcatenation| imposes some limits on string concatenation with |operator+()|.
|
||||
- no more than 33 strings, e.g., |s1 + s2 + s3 + ... s32 + s33|
|
||||
- left to right evaluation is required ... do not use parentheses to override this
|
||||
|
||||
@ -47,11 +47,11 @@
|
||||
|GetReadableFragment()|.
|
||||
*/
|
||||
|
||||
class NS_COM nsPromiseConcatenation
|
||||
class NS_COM nsDependentConcatenation
|
||||
: public nsAPromiseString
|
||||
{
|
||||
public:
|
||||
typedef nsPromiseConcatenation self_type;
|
||||
typedef nsDependentConcatenation self_type;
|
||||
typedef PRUnichar char_type;
|
||||
typedef nsAString string_type;
|
||||
typedef string_type::const_iterator const_iterator;
|
||||
@ -83,22 +83,22 @@ class NS_COM nsPromiseConcatenation
|
||||
}
|
||||
|
||||
public:
|
||||
nsPromiseConcatenation( const string_type& aLeftString, const string_type& aRightString, PRUint32 aMask = 1 )
|
||||
nsDependentConcatenation( const string_type& aLeftString, const string_type& aRightString, PRUint32 aMask = 1 )
|
||||
: mFragmentIdentifierMask(aMask)
|
||||
{
|
||||
mStrings[kLeftString] = &aLeftString;
|
||||
mStrings[kRightString] = &aRightString;
|
||||
}
|
||||
|
||||
nsPromiseConcatenation( const self_type& aLeftString, const string_type& aRightString )
|
||||
nsDependentConcatenation( const self_type& aLeftString, const string_type& aRightString )
|
||||
: mFragmentIdentifierMask(aLeftString.mFragmentIdentifierMask<<1)
|
||||
{
|
||||
mStrings[kLeftString] = &aLeftString;
|
||||
mStrings[kRightString] = &aRightString;
|
||||
}
|
||||
|
||||
// nsPromiseConcatenation( const self_type& ); // auto-generated copy-constructor should be OK
|
||||
// ~nsPromiseConcatenation(); // auto-generated destructor OK
|
||||
// nsDependentConcatenation( const self_type& ); // auto-generated copy-constructor should be OK
|
||||
// ~nsDependentConcatenation(); // auto-generated destructor OK
|
||||
|
||||
private:
|
||||
// NOT TO BE IMPLEMENTED
|
||||
@ -124,11 +124,11 @@ class NS_COM nsPromiseConcatenation
|
||||
PRUint32 mFragmentIdentifierMask;
|
||||
};
|
||||
|
||||
class NS_COM nsPromiseCConcatenation
|
||||
class NS_COM nsDependentCConcatenation
|
||||
: public nsAPromiseCString
|
||||
{
|
||||
public:
|
||||
typedef nsPromiseCConcatenation self_type;
|
||||
typedef nsDependentCConcatenation self_type;
|
||||
typedef char char_type;
|
||||
typedef nsACString string_type;
|
||||
typedef string_type::const_iterator const_iterator;
|
||||
@ -160,22 +160,22 @@ class NS_COM nsPromiseCConcatenation
|
||||
}
|
||||
|
||||
public:
|
||||
nsPromiseCConcatenation( const string_type& aLeftString, const string_type& aRightString, PRUint32 aMask = 1 )
|
||||
nsDependentCConcatenation( const string_type& aLeftString, const string_type& aRightString, PRUint32 aMask = 1 )
|
||||
: mFragmentIdentifierMask(aMask)
|
||||
{
|
||||
mStrings[kLeftString] = &aLeftString;
|
||||
mStrings[kRightString] = &aRightString;
|
||||
}
|
||||
|
||||
nsPromiseCConcatenation( const self_type& aLeftString, const string_type& aRightString )
|
||||
nsDependentCConcatenation( const self_type& aLeftString, const string_type& aRightString )
|
||||
: mFragmentIdentifierMask(aLeftString.mFragmentIdentifierMask<<1)
|
||||
{
|
||||
mStrings[kLeftString] = &aLeftString;
|
||||
mStrings[kRightString] = &aRightString;
|
||||
}
|
||||
|
||||
// nsPromiseCConcatenation( const self_type& ); // auto-generated copy-constructor should be OK
|
||||
// ~nsPromiseCConcatenation(); // auto-generated destructor OK
|
||||
// nsDependentCConcatenation( const self_type& ); // auto-generated copy-constructor should be OK
|
||||
// ~nsDependentCConcatenation(); // auto-generated destructor OK
|
||||
|
||||
private:
|
||||
// NOT TO BE IMPLEMENTED
|
||||
@ -214,7 +214,7 @@ class NS_COM nsPromiseCConcatenation
|
||||
will really want to do with the result. What might be better, though,
|
||||
is to return a `promise' to concatenate some strings...
|
||||
|
||||
By making |nsPromiseConcatenation| inherit from readable strings, we automatically handle
|
||||
By making |nsDependentConcatenation| inherit from readable strings, we automatically handle
|
||||
assignment and other interesting uses within writable strings, plus we drastically reduce
|
||||
the number of cases we have to write |operator+()| for. The cost is extra temporary concat strings
|
||||
in the evaluation of strings of '+'s, e.g., |A + B + C + D|, and that we have to do some work
|
||||
@ -222,48 +222,52 @@ class NS_COM nsPromiseCConcatenation
|
||||
*/
|
||||
|
||||
inline
|
||||
const nsPromiseConcatenation
|
||||
operator+( const nsPromiseConcatenation& lhs, const nsAString& rhs )
|
||||
const nsDependentConcatenation
|
||||
operator+( const nsDependentConcatenation& lhs, const nsAString& rhs )
|
||||
{
|
||||
return nsPromiseConcatenation(lhs, rhs, lhs.GetFragmentIdentifierMask()<<1);
|
||||
return nsDependentConcatenation(lhs, rhs, lhs.GetFragmentIdentifierMask()<<1);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsPromiseCConcatenation
|
||||
operator+( const nsPromiseCConcatenation& lhs, const nsACString& rhs )
|
||||
const nsDependentCConcatenation
|
||||
operator+( const nsDependentCConcatenation& lhs, const nsACString& rhs )
|
||||
{
|
||||
return nsPromiseCConcatenation(lhs, rhs, lhs.GetFragmentIdentifierMask()<<1);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsPromiseConcatenation
|
||||
operator+( const nsAString& lhs, const nsAString& rhs )
|
||||
{
|
||||
return nsPromiseConcatenation(lhs, rhs);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsPromiseCConcatenation
|
||||
operator+( const nsACString& lhs, const nsACString& rhs )
|
||||
{
|
||||
return nsPromiseCConcatenation(lhs, rhs);
|
||||
return nsDependentCConcatenation(lhs, rhs, lhs.GetFragmentIdentifierMask()<<1);
|
||||
}
|
||||
|
||||
#if 0
|
||||
// temporarily comment these two global operators out, until |nsPromiseConcatenation| is removed
|
||||
|
||||
inline
|
||||
const nsPromiseConcatenation
|
||||
nsPromiseConcatenation::operator+( const string_type& rhs ) const
|
||||
const nsDependentConcatenation
|
||||
operator+( const nsAString& lhs, const nsAString& rhs )
|
||||
{
|
||||
return nsPromiseConcatenation(*this, rhs, mFragmentIdentifierMask<<1);
|
||||
return nsDependentConcatenation(lhs, rhs);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsPromiseCConcatenation
|
||||
nsPromiseCConcatenation::operator+( const string_type& rhs ) const
|
||||
const nsDependentCConcatenation
|
||||
operator+( const nsACString& lhs, const nsACString& rhs )
|
||||
{
|
||||
return nsPromiseCConcatenation(*this, rhs, mFragmentIdentifierMask<<1);
|
||||
return nsDependentCConcatenation(lhs, rhs);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
inline
|
||||
const nsDependentConcatenation
|
||||
nsDependentConcatenation::operator+( const string_type& rhs ) const
|
||||
{
|
||||
return nsDependentConcatenation(*this, rhs, mFragmentIdentifierMask<<1);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsDependentCConcatenation
|
||||
nsDependentCConcatenation::operator+( const string_type& rhs ) const
|
||||
{
|
||||
return nsDependentCConcatenation(*this, rhs, mFragmentIdentifierMask<<1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* !defined(nsPromiseConcatenation_h___) */
|
||||
#endif /* !defined(nsDependentConcatenation_h___) */
|
||||
|
@ -21,8 +21,8 @@
|
||||
* Scott Collins <scc@mozilla.org> (original author)
|
||||
*/
|
||||
|
||||
#ifndef nsLocalString_h___
|
||||
#define nsLocalString_h___
|
||||
#ifndef nsDependentString_h___
|
||||
#define nsDependentString_h___
|
||||
|
||||
#ifndef nsAFlatString_h___
|
||||
#include "nsAFlatString.h"
|
||||
@ -41,24 +41,21 @@
|
||||
|
||||
This class just holds a pointer. If you don't supply the length, it must calculate it.
|
||||
No copying or allocations are performed.
|
||||
|
||||
|const nsLocalString&| appears frequently in interfaces because it
|
||||
allows the automatic conversion of a |PRUnichar*|.
|
||||
*/
|
||||
|
||||
class NS_COM nsLocalString
|
||||
class NS_COM nsDependentString
|
||||
: public nsAFlatString
|
||||
{
|
||||
public:
|
||||
|
||||
explicit
|
||||
nsLocalString( const PRUnichar* aLiteral )
|
||||
nsDependentString( const PRUnichar* aLiteral )
|
||||
: mHandle(NS_CONST_CAST(PRUnichar*, aLiteral), aLiteral ? (NS_CONST_CAST(PRUnichar*, aLiteral)+nsCharTraits<PRUnichar>::length(aLiteral)) : NS_CONST_CAST(PRUnichar*, aLiteral))
|
||||
{
|
||||
// nothing else to do here
|
||||
}
|
||||
|
||||
nsLocalString( const PRUnichar* aLiteral, PRUint32 aLength )
|
||||
nsDependentString( const PRUnichar* aLiteral, PRUint32 aLength )
|
||||
: mHandle(NS_CONST_CAST(PRUnichar*, aLiteral), NS_CONST_CAST(PRUnichar*, aLiteral)+aLength)
|
||||
{
|
||||
// This is an annoying hack. Callers should be fixed to use the other
|
||||
@ -70,8 +67,8 @@ class NS_COM nsLocalString
|
||||
}
|
||||
}
|
||||
|
||||
// nsLocalString( const nsLocalString& ); // auto-generated copy-constructor OK
|
||||
// ~nsLocalString(); // auto-generated destructor OK
|
||||
// nsDependentString( const nsDependentString& ); // auto-generated copy-constructor OK
|
||||
// ~nsDependentString(); // auto-generated destructor OK
|
||||
|
||||
virtual const nsBufferHandle<PRUnichar>* GetFlatBufferHandle() const { return &mHandle; }
|
||||
virtual const nsBufferHandle<PRUnichar>* GetBufferHandle() const { return &mHandle; }
|
||||
@ -81,24 +78,24 @@ class NS_COM nsLocalString
|
||||
|
||||
private:
|
||||
// NOT TO BE IMPLEMENTED
|
||||
void operator=( const nsLocalString& ); // we're immutable
|
||||
void operator=( const nsDependentString& ); // we're immutable
|
||||
};
|
||||
|
||||
|
||||
|
||||
class NS_COM nsLocalCString
|
||||
class NS_COM nsDependentCString
|
||||
: public nsAFlatCString
|
||||
{
|
||||
public:
|
||||
|
||||
explicit
|
||||
nsLocalCString( const char* aLiteral )
|
||||
nsDependentCString( const char* aLiteral )
|
||||
: mHandle(NS_CONST_CAST(char*, aLiteral), aLiteral ? (NS_CONST_CAST(char*, aLiteral)+nsCharTraits<char>::length(aLiteral)) : NS_CONST_CAST(char*, aLiteral))
|
||||
{
|
||||
// nothing else to do here
|
||||
}
|
||||
|
||||
nsLocalCString( const char* aLiteral, PRUint32 aLength )
|
||||
nsDependentCString( const char* aLiteral, PRUint32 aLength )
|
||||
: mHandle(NS_CONST_CAST(char*, aLiteral), NS_CONST_CAST(char*, aLiteral)+aLength)
|
||||
{
|
||||
// This is an annoying hack. Callers should be fixed to use the other
|
||||
@ -110,8 +107,8 @@ class NS_COM nsLocalCString
|
||||
}
|
||||
}
|
||||
|
||||
// nsLocalCString( const nsLocalCString& ); // auto-generated copy-constructor OK
|
||||
// ~nsLocalCString(); // auto-generated destructor OK
|
||||
// nsDependentCString( const nsDependentCString& ); // auto-generated copy-constructor OK
|
||||
// ~nsDependentCString(); // auto-generated destructor OK
|
||||
|
||||
virtual const nsBufferHandle<char>* GetFlatBufferHandle() const { return &mHandle; }
|
||||
virtual const nsBufferHandle<char>* GetBufferHandle() const { return &mHandle; }
|
||||
@ -121,7 +118,7 @@ class NS_COM nsLocalCString
|
||||
|
||||
private:
|
||||
// NOT TO BE IMPLEMENTED
|
||||
void operator=( const nsLocalCString& ); // we're immutable
|
||||
void operator=( const nsDependentCString& ); // we're immutable
|
||||
};
|
||||
|
||||
#endif /* !defined(nsLocalString_h___) */
|
||||
#endif /* !defined(nsDependentString_h___) */
|
||||
|
@ -21,8 +21,8 @@
|
||||
* Scott Collins <scc@mozilla.org> (original author)
|
||||
*/
|
||||
|
||||
#ifndef nsPromiseSubstring_h___
|
||||
#define nsPromiseSubstring_h___
|
||||
#ifndef nsDependentSubstring_h___
|
||||
#define nsDependentSubstring_h___
|
||||
|
||||
#ifndef nsAString_h___
|
||||
#include "nsAString.h"
|
||||
@ -35,16 +35,16 @@
|
||||
|
||||
|
||||
//
|
||||
// nsPromiseSubstring
|
||||
// nsDependentSubstring
|
||||
//
|
||||
|
||||
class NS_COM nsPromiseSubstring
|
||||
class NS_COM nsDependentSubstring
|
||||
: public nsAPromiseString
|
||||
/*
|
||||
NOT FOR USE BY HUMANS (mostly)
|
||||
|
||||
...not unlike |nsPromiseConcatenation|. Instances of this class exist only as anonymous
|
||||
temporary results from |Substring()|. Like |nsPromiseConcatenation|, this class only
|
||||
...not unlike |nsDependentConcatenation|. Instances of this class exist only as anonymous
|
||||
temporary results from |Substring()|. Like |nsDependentConcatenation|, this class only
|
||||
holds a pointer, no string data of its own. It does its magic by overriding and forwarding
|
||||
calls to |GetReadableFragment()|.
|
||||
*/
|
||||
@ -57,7 +57,7 @@ class NS_COM nsPromiseSubstring
|
||||
virtual PRUnichar* GetWritableFragment( nsWritableFragment<PRUnichar>&, nsFragmentRequest, PRUint32 ) { return 0; }
|
||||
|
||||
public:
|
||||
nsPromiseSubstring( const string_type& aString, PRUint32 aStartPos, PRUint32 aLength )
|
||||
nsDependentSubstring( const string_type& aString, PRUint32 aStartPos, PRUint32 aLength )
|
||||
: mString(aString),
|
||||
mStartPos( NS_MIN(aStartPos, aString.Length()) ),
|
||||
mLength( NS_MIN(aLength, aString.Length()-mStartPos) )
|
||||
@ -65,7 +65,7 @@ class NS_COM nsPromiseSubstring
|
||||
// nothing else to do here
|
||||
}
|
||||
|
||||
nsPromiseSubstring( const const_iterator& aStart, const const_iterator& aEnd )
|
||||
nsDependentSubstring( const const_iterator& aStart, const const_iterator& aEnd )
|
||||
: mString(aStart.string())
|
||||
{
|
||||
const_iterator zeroPoint;
|
||||
@ -74,12 +74,12 @@ class NS_COM nsPromiseSubstring
|
||||
mLength = Distance(aStart, aEnd);
|
||||
}
|
||||
|
||||
// nsPromiseSubstring( const nsPromiseSubstring& ); // auto-generated copy-constructor should be OK
|
||||
// ~nsPromiseSubstring(); // auto-generated destructor OK
|
||||
// nsDependentSubstring( const nsDependentSubstring& ); // auto-generated copy-constructor should be OK
|
||||
// ~nsDependentSubstring(); // auto-generated destructor OK
|
||||
|
||||
private:
|
||||
// NOT TO BE IMPLEMENTED
|
||||
void operator=( const nsPromiseSubstring& ); // we're immutable, you can't assign into a substring
|
||||
void operator=( const nsDependentSubstring& ); // we're immutable, you can't assign into a substring
|
||||
|
||||
public:
|
||||
virtual PRUint32 Length() const;
|
||||
@ -91,13 +91,13 @@ class NS_COM nsPromiseSubstring
|
||||
PRUint32 mLength;
|
||||
};
|
||||
|
||||
class NS_COM nsPromiseCSubstring
|
||||
class NS_COM nsDependentCSubstring
|
||||
: public nsAPromiseCString
|
||||
/*
|
||||
NOT FOR USE BY HUMANS (mostly)
|
||||
|
||||
...not unlike |nsPromiseConcatenation|. Instances of this class exist only as anonymous
|
||||
temporary results from |Substring()|. Like |nsPromiseConcatenation|, this class only
|
||||
...not unlike |nsDependentConcatenation|. Instances of this class exist only as anonymous
|
||||
temporary results from |Substring()|. Like |nsDependentConcatenation|, this class only
|
||||
holds a pointer, no string data of its own. It does its magic by overriding and forwarding
|
||||
calls to |GetReadableFragment()|.
|
||||
*/
|
||||
@ -110,7 +110,7 @@ class NS_COM nsPromiseCSubstring
|
||||
virtual char* GetWritableFragment( nsWritableFragment<char>&, nsFragmentRequest, PRUint32 ) { return 0; }
|
||||
|
||||
public:
|
||||
nsPromiseCSubstring( const string_type& aString, PRUint32 aStartPos, PRUint32 aLength )
|
||||
nsDependentCSubstring( const string_type& aString, PRUint32 aStartPos, PRUint32 aLength )
|
||||
: mString(aString),
|
||||
mStartPos( NS_MIN(aStartPos, aString.Length()) ),
|
||||
mLength( NS_MIN(aLength, aString.Length()-mStartPos) )
|
||||
@ -118,7 +118,7 @@ class NS_COM nsPromiseCSubstring
|
||||
// nothing else to do here
|
||||
}
|
||||
|
||||
nsPromiseCSubstring( const const_iterator& aStart, const const_iterator& aEnd )
|
||||
nsDependentCSubstring( const const_iterator& aStart, const const_iterator& aEnd )
|
||||
: mString(aStart.string())
|
||||
{
|
||||
const_iterator zeroPoint;
|
||||
@ -127,12 +127,12 @@ class NS_COM nsPromiseCSubstring
|
||||
mLength = Distance(aStart, aEnd);
|
||||
}
|
||||
|
||||
// nsPromiseCSubstring( const nsPromiseCSubstring& ); // auto-generated copy-constructor should be OK
|
||||
// ~nsPromiseCSubstring(); // auto-generated destructor OK
|
||||
// nsDependentCSubstring( const nsDependentCSubstring& ); // auto-generated copy-constructor should be OK
|
||||
// ~nsDependentCSubstring(); // auto-generated destructor OK
|
||||
|
||||
private:
|
||||
// NOT TO BE IMPLEMENTED
|
||||
void operator=( const nsPromiseCSubstring& ); // we're immutable, you can't assign into a substring
|
||||
void operator=( const nsDependentCSubstring& ); // we're immutable, you can't assign into a substring
|
||||
|
||||
public:
|
||||
virtual PRUint32 Length() const;
|
||||
@ -151,32 +151,32 @@ class NS_COM nsPromiseCSubstring
|
||||
|
||||
|
||||
inline
|
||||
const nsPromiseCSubstring
|
||||
const nsDependentCSubstring
|
||||
Substring( const nsACString& aString, PRUint32 aStartPos, PRUint32 aSubstringLength )
|
||||
{
|
||||
return nsPromiseCSubstring(aString, aStartPos, aSubstringLength);
|
||||
return nsDependentCSubstring(aString, aStartPos, aSubstringLength);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsPromiseSubstring
|
||||
const nsDependentSubstring
|
||||
Substring( const nsAString& aString, PRUint32 aStartPos, PRUint32 aSubstringLength )
|
||||
{
|
||||
return nsPromiseSubstring(aString, aStartPos, aSubstringLength);
|
||||
return nsDependentSubstring(aString, aStartPos, aSubstringLength);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsPromiseCSubstring
|
||||
const nsDependentCSubstring
|
||||
Substring( const nsReadingIterator<char>& aStart, const nsReadingIterator<char>& aEnd )
|
||||
{
|
||||
return nsPromiseCSubstring(aStart, aEnd);
|
||||
return nsDependentCSubstring(aStart, aEnd);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsPromiseSubstring
|
||||
const nsDependentSubstring
|
||||
Substring( const nsReadingIterator<PRUnichar>& aStart, const nsReadingIterator<PRUnichar>& aEnd )
|
||||
{
|
||||
return nsPromiseSubstring(aStart, aEnd);
|
||||
return nsDependentSubstring(aStart, aEnd);
|
||||
}
|
||||
|
||||
|
||||
#endif /* !defined(nsPromiseSubstring_h___) */
|
||||
#endif /* !defined(nsDependentSubstring_h___) */
|
||||
|
@ -24,24 +24,29 @@
|
||||
//-------1---------2---------3---------4---------5---------6---------7---------8
|
||||
|
||||
#include "nsAString.h"
|
||||
// remember, no one should include "nsPromiseConcatenation.h" themselves
|
||||
// remember, no one should include "nsDependentConcatenation.h" themselves
|
||||
// one always gets it through "nsAString.h"
|
||||
|
||||
#ifndef nsDependentConcatenation_h___
|
||||
#include "nsDependentConcatenation.h"
|
||||
#endif
|
||||
|
||||
|
||||
PRUint32
|
||||
nsPromiseConcatenation::Length() const
|
||||
nsDependentConcatenation::Length() const
|
||||
{
|
||||
return mStrings[kLeftString]->Length() + mStrings[kRightString]->Length();
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsPromiseConcatenation::Promises( const string_type& aString ) const
|
||||
nsDependentConcatenation::Promises( const string_type& aString ) const
|
||||
{
|
||||
return mStrings[0]->Promises(aString) || mStrings[1]->Promises(aString);
|
||||
}
|
||||
|
||||
#if 0
|
||||
PRBool
|
||||
nsPromiseConcatenation::PromisesExactly( const string_type& aString ) const
|
||||
nsDependentConcatenation::PromisesExactly( const string_type& aString ) const
|
||||
{
|
||||
// Not really like this, test for the empty string, etc
|
||||
return mStrings[0] == &aString && !mStrings[1] || !mStrings[0] && mStrings[1] == &aString;
|
||||
@ -49,7 +54,7 @@ nsPromiseConcatenation::PromisesExactly( const string_type& aString ) const
|
||||
#endif
|
||||
|
||||
const PRUnichar*
|
||||
nsPromiseConcatenation::GetReadableFragment( nsReadableFragment<char_type>& aFragment, nsFragmentRequest aRequest, PRUint32 aPosition ) const
|
||||
nsDependentConcatenation::GetReadableFragment( nsReadableFragment<char_type>& aFragment, nsFragmentRequest aRequest, PRUint32 aPosition ) const
|
||||
{
|
||||
int whichString;
|
||||
|
||||
@ -113,20 +118,20 @@ nsPromiseConcatenation::GetReadableFragment( nsReadableFragment<char_type>& aFra
|
||||
|
||||
|
||||
PRUint32
|
||||
nsPromiseCConcatenation::Length() const
|
||||
nsDependentCConcatenation::Length() const
|
||||
{
|
||||
return mStrings[kLeftString]->Length() + mStrings[kRightString]->Length();
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsPromiseCConcatenation::Promises( const string_type& aString ) const
|
||||
nsDependentCConcatenation::Promises( const string_type& aString ) const
|
||||
{
|
||||
return mStrings[0]->Promises(aString) || mStrings[1]->Promises(aString);
|
||||
}
|
||||
|
||||
#if 0
|
||||
PRBool
|
||||
nsPromiseCConcatenation::PromisesExactly( const string_type& aString ) const
|
||||
nsDependentCConcatenation::PromisesExactly( const string_type& aString ) const
|
||||
{
|
||||
// Not really like this, test for the empty string, etc
|
||||
return mStrings[0] == &aString && !mStrings[1] || !mStrings[0] && mStrings[1] == &aString;
|
||||
@ -134,7 +139,7 @@ nsPromiseCConcatenation::PromisesExactly( const string_type& aString ) const
|
||||
#endif
|
||||
|
||||
const char*
|
||||
nsPromiseCConcatenation::GetReadableFragment( nsReadableFragment<char_type>& aFragment, nsFragmentRequest aRequest, PRUint32 aPosition ) const
|
||||
nsDependentCConcatenation::GetReadableFragment( nsReadableFragment<char_type>& aFragment, nsFragmentRequest aRequest, PRUint32 aPosition ) const
|
||||
{
|
||||
int whichString;
|
||||
|
||||
|
@ -21,5 +21,5 @@
|
||||
* Scott Collins <scc@mozilla.org> (original author)
|
||||
*/
|
||||
|
||||
#include "nsLocalString.h"
|
||||
#include "nsDependentString.h"
|
||||
|
||||
|
@ -21,16 +21,16 @@
|
||||
* Scott Collins <scc@mozilla.org> (original author)
|
||||
*/
|
||||
|
||||
#include "nsPromiseSubstring.h"
|
||||
#include "nsDependentSubstring.h"
|
||||
|
||||
PRUint32
|
||||
nsPromiseSubstring::Length() const
|
||||
nsDependentSubstring::Length() const
|
||||
{
|
||||
return mLength;
|
||||
}
|
||||
|
||||
const PRUnichar*
|
||||
nsPromiseSubstring::GetReadableFragment( nsReadableFragment<PRUnichar>& aFragment, nsFragmentRequest aRequest, PRUint32 aPosition ) const
|
||||
nsDependentSubstring::GetReadableFragment( nsReadableFragment<PRUnichar>& aFragment, nsFragmentRequest aRequest, PRUint32 aPosition ) const
|
||||
{
|
||||
// Offset any request for a specific position (First, Last, At) by our
|
||||
// substrings startpos within the owning string
|
||||
@ -75,13 +75,13 @@ nsPromiseSubstring::GetReadableFragment( nsReadableFragment<PRUnichar>& aFragmen
|
||||
|
||||
|
||||
PRUint32
|
||||
nsPromiseCSubstring::Length() const
|
||||
nsDependentCSubstring::Length() const
|
||||
{
|
||||
return mLength;
|
||||
}
|
||||
|
||||
const char*
|
||||
nsPromiseCSubstring::GetReadableFragment( nsReadableFragment<char>& aFragment, nsFragmentRequest aRequest, PRUint32 aPosition ) const
|
||||
nsDependentCSubstring::GetReadableFragment( nsReadableFragment<char>& aFragment, nsFragmentRequest aRequest, PRUint32 aPosition ) const
|
||||
{
|
||||
// Offset any request for a specific position (First, Last, At) by our
|
||||
// substrings startpos within the owning string
|
||||
|
Loading…
Reference in New Issue
Block a user