|
str_tmp += in_str;
*out_str = (char*)malloc(str_tmp.length() + 1);
*out_str = (char*)str_tmp.c_str();
return NS_OK;
}
4、完成组件的工厂方法及注册模块。
组件本身的实现就上面两个类即可以了. 但是我们仅把上面的类生成动态库是不能作为组件工作的,我们还需要做一件事情.实现组件的注册及创建相关的功能.这几乎是一个固定的模式.
下面是该部分的代码,跟MS中的实现类似,用了许多的宏:
#include "nsIGenericFactory.h"
#include "nsMyCom.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMyCom)
static NS_METHOD nsMyComRegistrationProc(nsIComponentManager *aCompMgr,
nsIFile *aPath, const char *registryLocation, const char *componentType, const nsModuleComponentInfo *info)
{
return NS_OK;
}
static NS_METHOD nsMyComUnregistrationProc(nsIComponentManager *aCompMgr,
nsIFile *aPath, const char *registryLocation, const nsModuleComponentInfo *info)
{
return NS_OK;
上一篇:字符串NDS_trim.h
下一篇:PHP 面向对象程序设计资源
|