Bug 70083: add nsASingleFragmentString to hierarchy. r=dbaron, sr=scc

This commit is contained in:
jaggernaut%netscape.com 2001-10-28 08:24:55 +00:00
Родитель 26fb7a934f
Коммит c79a0759cb
8 изменённых файлов: 44 добавлений и 380 удалений

Двоичные данные
string/macbuild/string.mcp

Двоичный файл не отображается.

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

@ -26,60 +26,24 @@
#ifndef nsAFlatString_h___
#define nsAFlatString_h___
#ifndef nsAString_h___
#include "nsAString.h"
#ifndef nsASingleFragmenttring_h___
#include "nsASingleFragmentString.h"
#endif
class NS_COM nsAFlatString
: public nsAString
: public nsASingleFragmentString
{
public:
// don't really want this to be virtual, and won't after |obsolete_nsString| is really dead
virtual const char_type* get() const;
char_type operator[]( PRUint32 i ) const { return get()[ i ]; }
char_type CharAt( PRUint32 ) const;
virtual PRUint32 Length() const;
// protected: // can't hide these (yet), since I call them from forwarding routines in |nsPromiseFlatString|
public:
virtual const char_type* GetReadableFragment( const_fragment_type&, nsFragmentRequest, PRUint32 ) const;
virtual char_type* GetWritableFragment( fragment_type&, nsFragmentRequest, PRUint32 );
virtual const char_type* get() const { const char_type* temp; return BeginReading(temp); }
};
class NS_COM nsAFlatCString
: public nsACString
: public nsASingleFragmentCString
{
public:
// don't really want this to be virtual, and won't after |obsolete_nsCString| is really dead
virtual const char_type* get() const;
char_type operator[]( PRUint32 i ) const { return get()[ i ]; }
char_type CharAt( PRUint32 ) const;
virtual PRUint32 Length() const;
// protected: // can't hide these (yet), since I call them from forwarding routines in |nsPromiseFlatCString|
public:
virtual const char_type* GetReadableFragment( const_fragment_type&, nsFragmentRequest, PRUint32 ) const;
virtual char_type* GetWritableFragment( fragment_type&, nsFragmentRequest, PRUint32 );
virtual const char_type* get() const { const char_type* temp; return BeginReading(temp); }
};
inline
nsAFlatString::char_type
nsAFlatString::CharAt( PRUint32 i ) const
{
NS_ASSERTION(i<Length(), "|CharAt| out-of-range");
return operator[](i);
}
inline
nsAFlatCString::char_type
nsAFlatCString::CharAt( PRUint32 i ) const
{
NS_ASSERTION(i<Length(), "|CharAt| out-of-range");
return operator[](i);
}
#endif /* !defined(nsAFlatString_h___) */

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

@ -112,6 +112,14 @@ class NS_COM nsXPIDLString
void Adopt( char_type* aNewValue ) { *PrepareForUseAsOutParam() = aNewValue; }
// overridden to make getter_Copies mechanism work
const char_type* get() const
{
const buffer_handle_type* handle = GetBufferHandle();
// NS_ASSERTION(handle, "handle is null!");
return handle ? handle->DataStart() : 0;
}
// deprecated, to be eliminated
operator const char_type*() const { return get(); }
char_type operator[]( int i ) const { return get()[ i ]; }
@ -209,6 +217,14 @@ class NS_COM nsXPIDLCString
void Adopt( char_type* aNewValue ) { *PrepareForUseAsOutParam() = aNewValue; }
// overridden to make getter_Copies mechanism work
const char_type* get() const
{
const buffer_handle_type* handle = GetBufferHandle();
// NS_ASSERTION(handle, "handle is null!");
return handle ? handle->DataStart() : 0;
}
// deprecated, to be eliminated
operator const char_type*() const { return get(); }
char_type operator[]( int i ) const { return get()[ i ]; }

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

@ -1,148 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* 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.
*
* The Initial Developer of the Original Code is Netscape
* Communications. Portions created by Netscape Communications are
* Copyright (C) 2001 by Netscape Communications. All
* Rights Reserved.
*
* Contributor(s):
* Scott Collins <scc@mozilla.org> (original author)
*/
#include "nsAFlatString.h"
const nsAFlatString::char_type*
nsAFlatString::GetReadableFragment( const_fragment_type& aFragment, nsFragmentRequest aRequest, PRUint32 aOffset ) const
{
switch ( aRequest )
{
case kFirstFragment:
case kLastFragment:
case kFragmentAt:
{
const buffer_handle_type* buffer = GetBufferHandle();
if ( !buffer )
return 0;
aFragment.mEnd = buffer->DataEnd();
return (aFragment.mStart = buffer->DataStart()) + aOffset;
}
case kPrevFragment:
case kNextFragment:
default:
return 0;
}
}
nsAFlatString::char_type*
nsAFlatString::GetWritableFragment( fragment_type& aFragment, nsFragmentRequest aRequest, PRUint32 aOffset )
{
switch ( aRequest )
{
case kFirstFragment:
case kLastFragment:
case kFragmentAt:
{
buffer_handle_type* buffer = NS_CONST_CAST(buffer_handle_type*, GetBufferHandle());
NS_ASSERTION(buffer, "trouble: no buffer!");
aFragment.mEnd = buffer->DataEnd();
return (aFragment.mStart = buffer->DataStart()) + aOffset;
}
case kPrevFragment:
case kNextFragment:
default:
return 0;
}
}
const nsAFlatCString::char_type*
nsAFlatCString::GetReadableFragment( const_fragment_type& aFragment, nsFragmentRequest aRequest, PRUint32 aOffset ) const
{
switch ( aRequest )
{
case kFirstFragment:
case kLastFragment:
case kFragmentAt:
{
const buffer_handle_type* buffer = GetBufferHandle();
NS_ASSERTION(buffer, "trouble: no buffer!");
aFragment.mEnd = buffer->DataEnd();
return (aFragment.mStart = buffer->DataStart()) + aOffset;
}
case kPrevFragment:
case kNextFragment:
default:
return 0;
}
}
nsAFlatCString::char_type*
nsAFlatCString::GetWritableFragment( fragment_type& aFragment, nsFragmentRequest aRequest, PRUint32 aOffset )
{
switch ( aRequest )
{
case kFirstFragment:
case kLastFragment:
case kFragmentAt:
{
buffer_handle_type* buffer = NS_CONST_CAST(buffer_handle_type*, GetBufferHandle());
NS_ASSERTION(buffer, "trouble: no buffer!");
aFragment.mEnd = buffer->DataEnd();
return (aFragment.mStart = buffer->DataStart()) + aOffset;
}
case kPrevFragment:
case kNextFragment:
default:
return 0;
}
}
PRUint32
nsAFlatString::Length() const
{
const buffer_handle_type* handle = GetBufferHandle();
return PRUint32(handle ? handle->DataLength() : 0);
}
PRUint32
nsAFlatCString::Length() const
{
const buffer_handle_type* handle = GetBufferHandle();
return PRUint32(handle ? handle->DataLength() : 0);
}
const nsAFlatString::char_type*
nsAFlatString::get() const
{
const buffer_handle_type* handle = GetBufferHandle();
// NS_ASSERTION(handle, "handle is null!");
return handle ? handle->DataStart() : 0;
}
const nsAFlatCString::char_type*
nsAFlatCString::get() const
{
const buffer_handle_type* handle = GetBufferHandle();
// NS_ASSERTION(handle, "handle is null!");
return handle ? handle->DataStart() : 0;
}

Двоичные данные
xpcom/string/macbuild/string.mcp

Двоичный файл не отображается.

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

@ -26,60 +26,24 @@
#ifndef nsAFlatString_h___
#define nsAFlatString_h___
#ifndef nsAString_h___
#include "nsAString.h"
#ifndef nsASingleFragmenttring_h___
#include "nsASingleFragmentString.h"
#endif
class NS_COM nsAFlatString
: public nsAString
: public nsASingleFragmentString
{
public:
// don't really want this to be virtual, and won't after |obsolete_nsString| is really dead
virtual const char_type* get() const;
char_type operator[]( PRUint32 i ) const { return get()[ i ]; }
char_type CharAt( PRUint32 ) const;
virtual PRUint32 Length() const;
// protected: // can't hide these (yet), since I call them from forwarding routines in |nsPromiseFlatString|
public:
virtual const char_type* GetReadableFragment( const_fragment_type&, nsFragmentRequest, PRUint32 ) const;
virtual char_type* GetWritableFragment( fragment_type&, nsFragmentRequest, PRUint32 );
virtual const char_type* get() const { const char_type* temp; return BeginReading(temp); }
};
class NS_COM nsAFlatCString
: public nsACString
: public nsASingleFragmentCString
{
public:
// don't really want this to be virtual, and won't after |obsolete_nsCString| is really dead
virtual const char_type* get() const;
char_type operator[]( PRUint32 i ) const { return get()[ i ]; }
char_type CharAt( PRUint32 ) const;
virtual PRUint32 Length() const;
// protected: // can't hide these (yet), since I call them from forwarding routines in |nsPromiseFlatCString|
public:
virtual const char_type* GetReadableFragment( const_fragment_type&, nsFragmentRequest, PRUint32 ) const;
virtual char_type* GetWritableFragment( fragment_type&, nsFragmentRequest, PRUint32 );
virtual const char_type* get() const { const char_type* temp; return BeginReading(temp); }
};
inline
nsAFlatString::char_type
nsAFlatString::CharAt( PRUint32 i ) const
{
NS_ASSERTION(i<Length(), "|CharAt| out-of-range");
return operator[](i);
}
inline
nsAFlatCString::char_type
nsAFlatCString::CharAt( PRUint32 i ) const
{
NS_ASSERTION(i<Length(), "|CharAt| out-of-range");
return operator[](i);
}
#endif /* !defined(nsAFlatString_h___) */

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

@ -112,6 +112,14 @@ class NS_COM nsXPIDLString
void Adopt( char_type* aNewValue ) { *PrepareForUseAsOutParam() = aNewValue; }
// overridden to make getter_Copies mechanism work
const char_type* get() const
{
const buffer_handle_type* handle = GetBufferHandle();
// NS_ASSERTION(handle, "handle is null!");
return handle ? handle->DataStart() : 0;
}
// deprecated, to be eliminated
operator const char_type*() const { return get(); }
char_type operator[]( int i ) const { return get()[ i ]; }
@ -209,6 +217,14 @@ class NS_COM nsXPIDLCString
void Adopt( char_type* aNewValue ) { *PrepareForUseAsOutParam() = aNewValue; }
// overridden to make getter_Copies mechanism work
const char_type* get() const
{
const buffer_handle_type* handle = GetBufferHandle();
// NS_ASSERTION(handle, "handle is null!");
return handle ? handle->DataStart() : 0;
}
// deprecated, to be eliminated
operator const char_type*() const { return get(); }
char_type operator[]( int i ) const { return get()[ i ]; }

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

@ -1,148 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* 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.
*
* The Initial Developer of the Original Code is Netscape
* Communications. Portions created by Netscape Communications are
* Copyright (C) 2001 by Netscape Communications. All
* Rights Reserved.
*
* Contributor(s):
* Scott Collins <scc@mozilla.org> (original author)
*/
#include "nsAFlatString.h"
const nsAFlatString::char_type*
nsAFlatString::GetReadableFragment( const_fragment_type& aFragment, nsFragmentRequest aRequest, PRUint32 aOffset ) const
{
switch ( aRequest )
{
case kFirstFragment:
case kLastFragment:
case kFragmentAt:
{
const buffer_handle_type* buffer = GetBufferHandle();
if ( !buffer )
return 0;
aFragment.mEnd = buffer->DataEnd();
return (aFragment.mStart = buffer->DataStart()) + aOffset;
}
case kPrevFragment:
case kNextFragment:
default:
return 0;
}
}
nsAFlatString::char_type*
nsAFlatString::GetWritableFragment( fragment_type& aFragment, nsFragmentRequest aRequest, PRUint32 aOffset )
{
switch ( aRequest )
{
case kFirstFragment:
case kLastFragment:
case kFragmentAt:
{
buffer_handle_type* buffer = NS_CONST_CAST(buffer_handle_type*, GetBufferHandle());
NS_ASSERTION(buffer, "trouble: no buffer!");
aFragment.mEnd = buffer->DataEnd();
return (aFragment.mStart = buffer->DataStart()) + aOffset;
}
case kPrevFragment:
case kNextFragment:
default:
return 0;
}
}
const nsAFlatCString::char_type*
nsAFlatCString::GetReadableFragment( const_fragment_type& aFragment, nsFragmentRequest aRequest, PRUint32 aOffset ) const
{
switch ( aRequest )
{
case kFirstFragment:
case kLastFragment:
case kFragmentAt:
{
const buffer_handle_type* buffer = GetBufferHandle();
NS_ASSERTION(buffer, "trouble: no buffer!");
aFragment.mEnd = buffer->DataEnd();
return (aFragment.mStart = buffer->DataStart()) + aOffset;
}
case kPrevFragment:
case kNextFragment:
default:
return 0;
}
}
nsAFlatCString::char_type*
nsAFlatCString::GetWritableFragment( fragment_type& aFragment, nsFragmentRequest aRequest, PRUint32 aOffset )
{
switch ( aRequest )
{
case kFirstFragment:
case kLastFragment:
case kFragmentAt:
{
buffer_handle_type* buffer = NS_CONST_CAST(buffer_handle_type*, GetBufferHandle());
NS_ASSERTION(buffer, "trouble: no buffer!");
aFragment.mEnd = buffer->DataEnd();
return (aFragment.mStart = buffer->DataStart()) + aOffset;
}
case kPrevFragment:
case kNextFragment:
default:
return 0;
}
}
PRUint32
nsAFlatString::Length() const
{
const buffer_handle_type* handle = GetBufferHandle();
return PRUint32(handle ? handle->DataLength() : 0);
}
PRUint32
nsAFlatCString::Length() const
{
const buffer_handle_type* handle = GetBufferHandle();
return PRUint32(handle ? handle->DataLength() : 0);
}
const nsAFlatString::char_type*
nsAFlatString::get() const
{
const buffer_handle_type* handle = GetBufferHandle();
// NS_ASSERTION(handle, "handle is null!");
return handle ? handle->DataStart() : 0;
}
const nsAFlatCString::char_type*
nsAFlatCString::get() const
{
const buffer_handle_type* handle = GetBufferHandle();
// NS_ASSERTION(handle, "handle is null!");
return handle ? handle->DataStart() : 0;
}