Incremental changes. These files are not yet part of the build. a=don

This commit is contained in:
scc%netscape.com 2000-03-08 21:57:14 +00:00
Родитель 171aa51206
Коммит 5cda0d317c
6 изменённых файлов: 342 добавлений и 90 удалений

Просмотреть файл

@ -119,15 +119,14 @@ class basic_nsAReadableString
CharT
operator*()
{
normalize_forward();
return *mPosition;
}
ConstIterator&
operator++()
{
normalize_forward();
++mPosition;
normalize_forward();
return *this;
}
@ -135,8 +134,8 @@ class basic_nsAReadableString
operator++( int )
{
ConstIterator result(*this);
normalize_forward();
++mPosition;
normalize_forward();
return result;
}
@ -144,7 +143,7 @@ class basic_nsAReadableString
operator--()
{
normalize_backward();
++mPosition;
--mPosition;
return *this;
}
@ -153,17 +152,17 @@ class basic_nsAReadableString
{
ConstIterator result(*this);
normalize_backward();
++mPosition;
--mPosition;
return result;
}
bool
PRBool
operator==( const ConstIterator& rhs )
{
return mPosition == rhs.mPosition;
}
bool
PRBool
operator!=( const ConstIterator& rhs )
{
return mPosition != rhs.mPosition;
@ -185,7 +184,7 @@ class basic_nsAReadableString
End( PRUint32 aOffset = 0 ) const
{
ConstFragment fragment(this);
const CharT* startPos = GetFragment(fragment, kFragmentAt, min(0U, Length()-aOffset));
const CharT* startPos = GetFragment(fragment, kFragmentAt, max(0U, Length()-aOffset));
return ConstIterator(fragment, startPos);
}
@ -202,8 +201,8 @@ class basic_nsAReadableString
PRBool IsUnicode() const { return PR_FALSE; }
// ...but note specialization for |PRUnichar|, below
const CharT* GetBuffer() const { return 0; }
const CharT* GetUnicode() const { return 0; }
const char* GetBuffer() const { return 0; }
const PRUnichar* GetUnicode() const { return 0; }
// ...but note specializations for |char| and |PRUnichar|, below
// CharT operator[]( PRUint32 ) const;
@ -362,35 +361,98 @@ basic_nsAReadableString<CharT>::Right( basic_nsAWritableString<CharT>& aResult,
return aLengthToCopy;
}
template <class CharT>
int
Compare( const basic_nsAReadableString<CharT>& lhs, const basic_nsAReadableString<CharT>& rhs )
{
PRUint32 lLength = lhs.Length();
PRUint32 rLength = rhs.Length();
int result = 0;
if ( lLength < rLength )
result = -1;
else if ( lLength > rLength )
result = 1;
PRUint32 lengthToCompare = min(lLength, rLength);
typedef typename basic_nsAReadableString<CharT>::ConstIterator ConstIterator;
ConstIterator lPos = lhs.Begin();
ConstIterator lEnd = lhs.Begin(lengthToCompare);
ConstIterator rPos = rhs.Begin();
while ( lPos != lEnd )
{
if ( *lPos < *rPos )
return -1;
if ( *rPos < *lPos )
return 1;
++lPos;
++rPos;
}
return result;
}
template <class CharT>
inline
int
basic_nsAReadableString<CharT>::Compare( const basic_nsAReadableString<CharT>& rhs ) const
{
// ...
return ::Compare(*this, rhs);
}
// readable != readable
template <class CharT>
PRBool
operator!=( const basic_nsAReadableString<CharT>& lhs, const basic_nsAReadableString<CharT>& rhs )
{
return lhs.Compare(rhs) != 0;
}
// readable != CharT*
// CharT* != readable
// readable < readable
template <class CharT>
PRBool
operator<( const basic_nsAReadableString<CharT>& lhs, const basic_nsAReadableString<CharT>& rhs )
{
return lhs.Compare(rhs) < 0;
}
// readable < CharT*
// CharT* < readable
// readable <= readable
template <class CharT>
PRBool
operator<=( const basic_nsAReadableString<CharT>& lhs, const basic_nsAReadableString<CharT>& rhs )
{
return lhs.Compare(rhs) <= 0;
}
// readable <= CharT*
// CharT* <= readable
// readable == readable
template <class CharT>
PRBool
operator==( const basic_nsAReadableString<CharT>& lhs, const basic_nsAReadableString<CharT>& rhs )
{
return lhs.Compare(rhs) == 0;
}
// readable == CharT*
// CharT* == readable
// readable >= readable
template <class CharT>
PRBool
operator>=( const basic_nsAReadableString<CharT>& lhs, const basic_nsAReadableString<CharT>& rhs )
{
return lhs.Compare(rhs) >= 0;
}
// readable >= CharT*
// CharT* >= readable
// readable > readable
template <class CharT>
PRBool
operator>( const basic_nsAReadableString<CharT>& lhs, const basic_nsAReadableString<CharT>& rhs )
{
return lhs.Compare(rhs) > 0;
}
// readable > CharT*
// CharT* > readable
@ -419,7 +481,7 @@ template <class CharT>
class nsConcatString
: public basic_nsAReadableString<CharT>
/*
...not unlike RickG's original |nsSubsumeString| in intent.
...not unlike RickG's original |nsSubsumeString| in _intent_.
*/
{
public:
@ -427,9 +489,26 @@ class nsConcatString
// ...
};
// readable + readable --> concat
// readable + CharT* --> concat
// CharT* + readable --> concat
template <class CharT>
nsConcatString<CharT>
operator+( const basic_nsAReadableString<CharT>&, const basic_nsAReadableString<CharT>& )
{
// ...
}
template <class CharT>
nsConcatString<CharT>
operator+( const basic_nsAReadableString<CharT>&, const CharT* )
{
// ...
}
template <class CharT>
nsConcatString<CharT>
operator+( const CharT*, const basic_nsAReadableString<CharT>& )
{
// ...
}
template <class CharT, class TraitsT>
basic_ostream<CharT, class TraitsT>&

Просмотреть файл

@ -108,15 +108,14 @@ class basic_nsAWritableString
CharT&
operator*()
{
normalize_forward();
return *mPosition;
}
Iterator&
operator++()
{
normalize_forward();
++mPosition;
normalize_forward();
return *this;
}
@ -124,8 +123,8 @@ class basic_nsAWritableString
operator++( int )
{
Iterator result(*this);
normalize_forward();
++mPosition;
normalize_forward();
return result;
}
@ -133,7 +132,7 @@ class basic_nsAWritableString
operator--()
{
normalize_backward();
++mPosition;
--mPosition;
return *this;
}
@ -142,14 +141,20 @@ class basic_nsAWritableString
{
Iterator result(*this);
normalize_backward();
++mPosition;
--mPosition;
return result;
}
const CharT*
get() const
PRBool
operator==( const ConstIterator& rhs )
{
return mPosition;
return mPosition == rhs.mPosition;
}
PRBool
operator!=( const ConstIterator& rhs )
{
return mPosition != rhs.mPosition;
}
};
@ -170,7 +175,7 @@ class basic_nsAWritableString
End( PRUint32 aOffset = 0 )
{
Fragment fragment(this);
CharT* startPos = GetFragment(fragment, kFragmentAt, min(0U, Length()-aOffset));
CharT* startPos = GetFragment(fragment, kFragmentAt, max(0U, Length()-aOffset));
return Iterator(fragment, startPos);
}

Просмотреть файл

@ -119,15 +119,14 @@ class basic_nsAReadableString
CharT
operator*()
{
normalize_forward();
return *mPosition;
}
ConstIterator&
operator++()
{
normalize_forward();
++mPosition;
normalize_forward();
return *this;
}
@ -135,8 +134,8 @@ class basic_nsAReadableString
operator++( int )
{
ConstIterator result(*this);
normalize_forward();
++mPosition;
normalize_forward();
return result;
}
@ -144,7 +143,7 @@ class basic_nsAReadableString
operator--()
{
normalize_backward();
++mPosition;
--mPosition;
return *this;
}
@ -153,17 +152,17 @@ class basic_nsAReadableString
{
ConstIterator result(*this);
normalize_backward();
++mPosition;
--mPosition;
return result;
}
bool
PRBool
operator==( const ConstIterator& rhs )
{
return mPosition == rhs.mPosition;
}
bool
PRBool
operator!=( const ConstIterator& rhs )
{
return mPosition != rhs.mPosition;
@ -185,7 +184,7 @@ class basic_nsAReadableString
End( PRUint32 aOffset = 0 ) const
{
ConstFragment fragment(this);
const CharT* startPos = GetFragment(fragment, kFragmentAt, min(0U, Length()-aOffset));
const CharT* startPos = GetFragment(fragment, kFragmentAt, max(0U, Length()-aOffset));
return ConstIterator(fragment, startPos);
}
@ -202,8 +201,8 @@ class basic_nsAReadableString
PRBool IsUnicode() const { return PR_FALSE; }
// ...but note specialization for |PRUnichar|, below
const CharT* GetBuffer() const { return 0; }
const CharT* GetUnicode() const { return 0; }
const char* GetBuffer() const { return 0; }
const PRUnichar* GetUnicode() const { return 0; }
// ...but note specializations for |char| and |PRUnichar|, below
// CharT operator[]( PRUint32 ) const;
@ -362,35 +361,98 @@ basic_nsAReadableString<CharT>::Right( basic_nsAWritableString<CharT>& aResult,
return aLengthToCopy;
}
template <class CharT>
int
Compare( const basic_nsAReadableString<CharT>& lhs, const basic_nsAReadableString<CharT>& rhs )
{
PRUint32 lLength = lhs.Length();
PRUint32 rLength = rhs.Length();
int result = 0;
if ( lLength < rLength )
result = -1;
else if ( lLength > rLength )
result = 1;
PRUint32 lengthToCompare = min(lLength, rLength);
typedef typename basic_nsAReadableString<CharT>::ConstIterator ConstIterator;
ConstIterator lPos = lhs.Begin();
ConstIterator lEnd = lhs.Begin(lengthToCompare);
ConstIterator rPos = rhs.Begin();
while ( lPos != lEnd )
{
if ( *lPos < *rPos )
return -1;
if ( *rPos < *lPos )
return 1;
++lPos;
++rPos;
}
return result;
}
template <class CharT>
inline
int
basic_nsAReadableString<CharT>::Compare( const basic_nsAReadableString<CharT>& rhs ) const
{
// ...
return ::Compare(*this, rhs);
}
// readable != readable
template <class CharT>
PRBool
operator!=( const basic_nsAReadableString<CharT>& lhs, const basic_nsAReadableString<CharT>& rhs )
{
return lhs.Compare(rhs) != 0;
}
// readable != CharT*
// CharT* != readable
// readable < readable
template <class CharT>
PRBool
operator<( const basic_nsAReadableString<CharT>& lhs, const basic_nsAReadableString<CharT>& rhs )
{
return lhs.Compare(rhs) < 0;
}
// readable < CharT*
// CharT* < readable
// readable <= readable
template <class CharT>
PRBool
operator<=( const basic_nsAReadableString<CharT>& lhs, const basic_nsAReadableString<CharT>& rhs )
{
return lhs.Compare(rhs) <= 0;
}
// readable <= CharT*
// CharT* <= readable
// readable == readable
template <class CharT>
PRBool
operator==( const basic_nsAReadableString<CharT>& lhs, const basic_nsAReadableString<CharT>& rhs )
{
return lhs.Compare(rhs) == 0;
}
// readable == CharT*
// CharT* == readable
// readable >= readable
template <class CharT>
PRBool
operator>=( const basic_nsAReadableString<CharT>& lhs, const basic_nsAReadableString<CharT>& rhs )
{
return lhs.Compare(rhs) >= 0;
}
// readable >= CharT*
// CharT* >= readable
// readable > readable
template <class CharT>
PRBool
operator>( const basic_nsAReadableString<CharT>& lhs, const basic_nsAReadableString<CharT>& rhs )
{
return lhs.Compare(rhs) > 0;
}
// readable > CharT*
// CharT* > readable
@ -419,7 +481,7 @@ template <class CharT>
class nsConcatString
: public basic_nsAReadableString<CharT>
/*
...not unlike RickG's original |nsSubsumeString| in intent.
...not unlike RickG's original |nsSubsumeString| in _intent_.
*/
{
public:
@ -427,9 +489,26 @@ class nsConcatString
// ...
};
// readable + readable --> concat
// readable + CharT* --> concat
// CharT* + readable --> concat
template <class CharT>
nsConcatString<CharT>
operator+( const basic_nsAReadableString<CharT>&, const basic_nsAReadableString<CharT>& )
{
// ...
}
template <class CharT>
nsConcatString<CharT>
operator+( const basic_nsAReadableString<CharT>&, const CharT* )
{
// ...
}
template <class CharT>
nsConcatString<CharT>
operator+( const CharT*, const basic_nsAReadableString<CharT>& )
{
// ...
}
template <class CharT, class TraitsT>
basic_ostream<CharT, class TraitsT>&

Просмотреть файл

@ -108,15 +108,14 @@ class basic_nsAWritableString
CharT&
operator*()
{
normalize_forward();
return *mPosition;
}
Iterator&
operator++()
{
normalize_forward();
++mPosition;
normalize_forward();
return *this;
}
@ -124,8 +123,8 @@ class basic_nsAWritableString
operator++( int )
{
Iterator result(*this);
normalize_forward();
++mPosition;
normalize_forward();
return result;
}
@ -133,7 +132,7 @@ class basic_nsAWritableString
operator--()
{
normalize_backward();
++mPosition;
--mPosition;
return *this;
}
@ -142,14 +141,20 @@ class basic_nsAWritableString
{
Iterator result(*this);
normalize_backward();
++mPosition;
--mPosition;
return result;
}
const CharT*
get() const
PRBool
operator==( const ConstIterator& rhs )
{
return mPosition;
return mPosition == rhs.mPosition;
}
PRBool
operator!=( const ConstIterator& rhs )
{
return mPosition != rhs.mPosition;
}
};
@ -170,7 +175,7 @@ class basic_nsAWritableString
End( PRUint32 aOffset = 0 )
{
Fragment fragment(this);
CharT* startPos = GetFragment(fragment, kFragmentAt, min(0U, Length()-aOffset));
CharT* startPos = GetFragment(fragment, kFragmentAt, max(0U, Length()-aOffset));
return Iterator(fragment, startPos);
}

Просмотреть файл

@ -119,15 +119,14 @@ class basic_nsAReadableString
CharT
operator*()
{
normalize_forward();
return *mPosition;
}
ConstIterator&
operator++()
{
normalize_forward();
++mPosition;
normalize_forward();
return *this;
}
@ -135,8 +134,8 @@ class basic_nsAReadableString
operator++( int )
{
ConstIterator result(*this);
normalize_forward();
++mPosition;
normalize_forward();
return result;
}
@ -144,7 +143,7 @@ class basic_nsAReadableString
operator--()
{
normalize_backward();
++mPosition;
--mPosition;
return *this;
}
@ -153,17 +152,17 @@ class basic_nsAReadableString
{
ConstIterator result(*this);
normalize_backward();
++mPosition;
--mPosition;
return result;
}
bool
PRBool
operator==( const ConstIterator& rhs )
{
return mPosition == rhs.mPosition;
}
bool
PRBool
operator!=( const ConstIterator& rhs )
{
return mPosition != rhs.mPosition;
@ -185,7 +184,7 @@ class basic_nsAReadableString
End( PRUint32 aOffset = 0 ) const
{
ConstFragment fragment(this);
const CharT* startPos = GetFragment(fragment, kFragmentAt, min(0U, Length()-aOffset));
const CharT* startPos = GetFragment(fragment, kFragmentAt, max(0U, Length()-aOffset));
return ConstIterator(fragment, startPos);
}
@ -202,8 +201,8 @@ class basic_nsAReadableString
PRBool IsUnicode() const { return PR_FALSE; }
// ...but note specialization for |PRUnichar|, below
const CharT* GetBuffer() const { return 0; }
const CharT* GetUnicode() const { return 0; }
const char* GetBuffer() const { return 0; }
const PRUnichar* GetUnicode() const { return 0; }
// ...but note specializations for |char| and |PRUnichar|, below
// CharT operator[]( PRUint32 ) const;
@ -362,35 +361,98 @@ basic_nsAReadableString<CharT>::Right( basic_nsAWritableString<CharT>& aResult,
return aLengthToCopy;
}
template <class CharT>
int
Compare( const basic_nsAReadableString<CharT>& lhs, const basic_nsAReadableString<CharT>& rhs )
{
PRUint32 lLength = lhs.Length();
PRUint32 rLength = rhs.Length();
int result = 0;
if ( lLength < rLength )
result = -1;
else if ( lLength > rLength )
result = 1;
PRUint32 lengthToCompare = min(lLength, rLength);
typedef typename basic_nsAReadableString<CharT>::ConstIterator ConstIterator;
ConstIterator lPos = lhs.Begin();
ConstIterator lEnd = lhs.Begin(lengthToCompare);
ConstIterator rPos = rhs.Begin();
while ( lPos != lEnd )
{
if ( *lPos < *rPos )
return -1;
if ( *rPos < *lPos )
return 1;
++lPos;
++rPos;
}
return result;
}
template <class CharT>
inline
int
basic_nsAReadableString<CharT>::Compare( const basic_nsAReadableString<CharT>& rhs ) const
{
// ...
return ::Compare(*this, rhs);
}
// readable != readable
template <class CharT>
PRBool
operator!=( const basic_nsAReadableString<CharT>& lhs, const basic_nsAReadableString<CharT>& rhs )
{
return lhs.Compare(rhs) != 0;
}
// readable != CharT*
// CharT* != readable
// readable < readable
template <class CharT>
PRBool
operator<( const basic_nsAReadableString<CharT>& lhs, const basic_nsAReadableString<CharT>& rhs )
{
return lhs.Compare(rhs) < 0;
}
// readable < CharT*
// CharT* < readable
// readable <= readable
template <class CharT>
PRBool
operator<=( const basic_nsAReadableString<CharT>& lhs, const basic_nsAReadableString<CharT>& rhs )
{
return lhs.Compare(rhs) <= 0;
}
// readable <= CharT*
// CharT* <= readable
// readable == readable
template <class CharT>
PRBool
operator==( const basic_nsAReadableString<CharT>& lhs, const basic_nsAReadableString<CharT>& rhs )
{
return lhs.Compare(rhs) == 0;
}
// readable == CharT*
// CharT* == readable
// readable >= readable
template <class CharT>
PRBool
operator>=( const basic_nsAReadableString<CharT>& lhs, const basic_nsAReadableString<CharT>& rhs )
{
return lhs.Compare(rhs) >= 0;
}
// readable >= CharT*
// CharT* >= readable
// readable > readable
template <class CharT>
PRBool
operator>( const basic_nsAReadableString<CharT>& lhs, const basic_nsAReadableString<CharT>& rhs )
{
return lhs.Compare(rhs) > 0;
}
// readable > CharT*
// CharT* > readable
@ -419,7 +481,7 @@ template <class CharT>
class nsConcatString
: public basic_nsAReadableString<CharT>
/*
...not unlike RickG's original |nsSubsumeString| in intent.
...not unlike RickG's original |nsSubsumeString| in _intent_.
*/
{
public:
@ -427,9 +489,26 @@ class nsConcatString
// ...
};
// readable + readable --> concat
// readable + CharT* --> concat
// CharT* + readable --> concat
template <class CharT>
nsConcatString<CharT>
operator+( const basic_nsAReadableString<CharT>&, const basic_nsAReadableString<CharT>& )
{
// ...
}
template <class CharT>
nsConcatString<CharT>
operator+( const basic_nsAReadableString<CharT>&, const CharT* )
{
// ...
}
template <class CharT>
nsConcatString<CharT>
operator+( const CharT*, const basic_nsAReadableString<CharT>& )
{
// ...
}
template <class CharT, class TraitsT>
basic_ostream<CharT, class TraitsT>&

Просмотреть файл

@ -108,15 +108,14 @@ class basic_nsAWritableString
CharT&
operator*()
{
normalize_forward();
return *mPosition;
}
Iterator&
operator++()
{
normalize_forward();
++mPosition;
normalize_forward();
return *this;
}
@ -124,8 +123,8 @@ class basic_nsAWritableString
operator++( int )
{
Iterator result(*this);
normalize_forward();
++mPosition;
normalize_forward();
return result;
}
@ -133,7 +132,7 @@ class basic_nsAWritableString
operator--()
{
normalize_backward();
++mPosition;
--mPosition;
return *this;
}
@ -142,14 +141,20 @@ class basic_nsAWritableString
{
Iterator result(*this);
normalize_backward();
++mPosition;
--mPosition;
return result;
}
const CharT*
get() const
PRBool
operator==( const ConstIterator& rhs )
{
return mPosition;
return mPosition == rhs.mPosition;
}
PRBool
operator!=( const ConstIterator& rhs )
{
return mPosition != rhs.mPosition;
}
};
@ -170,7 +175,7 @@ class basic_nsAWritableString
End( PRUint32 aOffset = 0 )
{
Fragment fragment(this);
CharT* startPos = GetFragment(fragment, kFragmentAt, min(0U, Length()-aOffset));
CharT* startPos = GetFragment(fragment, kFragmentAt, max(0U, Length()-aOffset));
return Iterator(fragment, startPos);
}