📄 moz0813ex.txt
字号:
#include "plstr.h"
#include "stdio.h"
#include "nsSimple.h"
#include "nsCOMPtr.h"
#include "nsMemory.h"
// c++ constructor
nsSimpleImpl::nsSimpleImpl( ) : mName(nsnull)
{
NS_INIT_REFCNT( );
= PL_strdup("default value");
}
// c++ destructor
nsSimpleImpl::~nsSimpleImpl( )
{
if ( )
PL_strfree( );
}
// This macro implements the nsISupports interface methods
// QueryInterface, AddRef and Release
NS_IMPL_ISUPPORTS1_CI(nsSimpleImpl, nsISimple);
NS_IMETHODIMP
nsSimpleImpl::GetYourName(char** aName)
{
NS_PRECONDITION(aName != nsnull, "null ptr");
if (!aName)
return NS_ERROR_NULL_POINTER;
if ( ) {
*aName = (char*) nsMemory::Alloc(PL_strlen( ) + 1);
if (! *aName)
return NS_ERROR_NULL_POINTER;
PL_strcpy(*aName, );
}
else {
*aName = nsnull;
}
return NS_OK;
}
NS_IMETHODIMP
nsSimpleImpl::SetYourName(const char* aName)
{
NS_PRECONDITION(aName != nsnull, "null ptr");
if (!aName)
return NS_ERROR_NULL_POINTER;
if ( ) {
PL_strfree( );
}
= PL_strdup(aName);
return NS_OK;
}
NS_IMETHODIMP
nsSimpleImpl::Write( )
{
printf("%s\n", );
return NS_OK;
}
NS_IMETHODIMP
nsSimpleImpl::Change(const char* aName)
{
return SetYourName(aName);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -