Remove nsStringImpl and nsIString.
git-svn-id: svn://10.0.0.236/trunk@34627 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -12,7 +12,6 @@ nsIPageManager.h
|
||||
nsIProperties.h
|
||||
nsISimpleEnumerator.h
|
||||
nsISizeOfHandler.h
|
||||
nsIString.h
|
||||
nsISupportsArray.h
|
||||
nsIUnicharBuffer.h
|
||||
nsIVariant.h
|
||||
|
||||
@@ -61,7 +61,6 @@ CPPSRCS = \
|
||||
nsStr.cpp \
|
||||
nsString.cpp \
|
||||
nsString2.cpp \
|
||||
nsStringImpl.cpp \
|
||||
nsSupportsArray.cpp \
|
||||
nsSupportsArrayEnumerator.cpp \
|
||||
nsUnicharBuffer.cpp \
|
||||
@@ -86,7 +85,6 @@ EXPORTS = \
|
||||
nsIProperties.h \
|
||||
nsISimpleEnumerator.h \
|
||||
nsISizeOfHandler.h \
|
||||
nsIString.h \
|
||||
nsIUnicharBuffer.h \
|
||||
nsIVariant.h \
|
||||
nsInt64.h \
|
||||
|
||||
@@ -38,7 +38,6 @@ EXPORTS = \
|
||||
nsIProperties.h \
|
||||
nsISimpleEnumerator.h \
|
||||
nsISizeOfHandler.h \
|
||||
nsIString.h \
|
||||
nsISupportsArray.h \
|
||||
nsIUnicharBuffer.h \
|
||||
nsIVariant.h \
|
||||
@@ -101,7 +100,6 @@ CPP_OBJS = \
|
||||
.\$(OBJDIR)\nsStr.obj \
|
||||
.\$(OBJDIR)\nsString.obj \
|
||||
.\$(OBJDIR)\nsString2.obj \
|
||||
.\$(OBJDIR)\nsStringImpl.obj \
|
||||
.\$(OBJDIR)\nsSupportsArray.obj \
|
||||
.\$(OBJDIR)\nsSupportsArrayEnumerator.obj \
|
||||
.\$(OBJDIR)\nsUnicharBuffer.obj \
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
A reference-counted XPCOM wrapper for the nsStr structure. Allows for
|
||||
efficient passing of string objects through multiple layers.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIString_h__
|
||||
#define nsIString_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsStr.h" // need to include it for eCharSize
|
||||
|
||||
// {4C541410-E0B9-11d2-BDB3-000064657374}
|
||||
#define NS_ISTRING_IID \
|
||||
{ 0x4c541410, 0xe0b9, 0x11d2, { 0xbd, 0xb3, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
|
||||
|
||||
class nsIString : public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsID& GetIID() { static nsIID iid = NS_ISTRING_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Set the character size to something other than the default character
|
||||
* size. By default, nsIString objects will have kDefaultCharSize (as defined
|
||||
* in nsStr.h) as the default char size for their representation.
|
||||
*/
|
||||
NS_IMETHOD Init(eCharSize aCharSize) = 0;
|
||||
|
||||
/**
|
||||
* Copy the caller's nsStr into the object's internal nsStr by performing an
|
||||
* assignment operation.
|
||||
*/
|
||||
NS_IMETHOD SetStr(nsStr* aStr) = 0;
|
||||
|
||||
/**
|
||||
* Copy the object's internal nsStr into the caller's nsStr struct by performing
|
||||
* an assignment operation.
|
||||
*/
|
||||
NS_IMETHOD GetStr(nsStr* aStr) = 0;
|
||||
|
||||
/**
|
||||
* Return a pointer to the nsIString object's _actual_ string buffer. The caller
|
||||
* must treat this struct as an immutable object (hence the "const" qualifier).
|
||||
* The pointer will become invalid as soon as the nsIString interface is released.
|
||||
*/
|
||||
NS_IMETHOD GetImmutableStr(const nsStr** aStr) = 0;
|
||||
};
|
||||
|
||||
|
||||
PR_EXTERN(nsresult)
|
||||
NS_NewString(nsIString** aString);
|
||||
|
||||
#endif // nsIString_h__
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
The default implementation for nsIString.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "nsIString.h"
|
||||
#include "nsStr.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static NS_DEFINE_IID(kIStringIID, NS_ISTRING_IID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class nsStringImpl : public nsIString
|
||||
{
|
||||
protected:
|
||||
nsStr mStr;
|
||||
|
||||
public:
|
||||
nsStringImpl();
|
||||
virtual ~nsStringImpl();
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIString interface
|
||||
NS_IMETHOD Init(eCharSize aCharSize);
|
||||
NS_IMETHOD SetStr(nsStr* aStr);
|
||||
NS_IMETHOD GetStr(nsStr* aStr);
|
||||
NS_IMETHOD GetImmutableStr(const nsStr** aStr);
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsStringImpl::nsStringImpl()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
nsStr::Initialize(mStr, kDefaultCharSize);
|
||||
}
|
||||
|
||||
|
||||
nsStringImpl::~nsStringImpl()
|
||||
{
|
||||
nsStr::Destroy(mStr);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(nsresult)
|
||||
NS_NewString(nsIString** aString)
|
||||
{
|
||||
NS_PRECONDITION(aString != nsnull, "null ptr");
|
||||
if (! aString)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsStringImpl* s = new nsStringImpl();
|
||||
if (! s)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(s);
|
||||
*aString = s;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsISupports interface
|
||||
|
||||
NS_IMPL_ADDREF(nsStringImpl);
|
||||
NS_IMPL_RELEASE(nsStringImpl);
|
||||
NS_IMPL_QUERY_INTERFACE(nsStringImpl, kIStringIID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStringImpl::Init(eCharSize aCharSize)
|
||||
{
|
||||
nsStr::Initialize(mStr, aCharSize);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStringImpl::SetStr(nsStr* aStr)
|
||||
{
|
||||
NS_PRECONDITION(aStr != nsnull, "null ptr");
|
||||
if (! aStr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsStr::Assign(mStr, *aStr, 0, aStr->mLength);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStringImpl::GetStr(nsStr* aStr)
|
||||
{
|
||||
NS_PRECONDITION(aStr != nsnull, "null ptr");
|
||||
if (! aStr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsStr::Assign(*aStr, mStr, 0, mStr.mLength);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStringImpl::GetImmutableStr(const nsStr** aImmutableStr)
|
||||
{
|
||||
NS_PRECONDITION(aImmutableStr != nsnull, "null ptr");
|
||||
if (! aImmutableStr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aImmutableStr = &mStr;
|
||||
return NS_OK;
|
||||
}
|
||||
Reference in New Issue
Block a user