当前位置: 首页>>代码示例>>C++>>正文


C++ OSString::retain方法代码示例

本文整理汇总了C++中OSString::retain方法的典型用法代码示例。如果您正苦于以下问题:C++ OSString::retain方法的具体用法?C++ OSString::retain怎么用?C++ OSString::retain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OSString的用法示例。


在下文中一共展示了OSString::retain方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: newProductString

OSString* org_litio_OzoneStrikeBattle::newProductString() const {
    OSString * string = OSDynamicCast(OSString, getProperty("ProductString"));

    if (!string)
        return NULL;

    string->retain();

    return string;
}
开发者ID:gloob,项目名称:Ozone-Strike-OSX-Driver,代码行数:10,代码来源:OzoneStrikeBattle.cpp

示例2: OSDynamicCast

//----------------------------------------------------------------------------------------------------
// IOHIDUserDevice::newSerialNumberString
//----------------------------------------------------------------------------------------------------
OSString *IOHIDUserDevice::newSerialNumberString() const
{
    OSString * string = OSDynamicCast(OSString, _properties->getObject(kIOHIDSerialNumberKey));
    
    if ( !string ) 
        return NULL;
        
    string->retain();
        
    return string;
}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:14,代码来源:IOHIDUserDevice.cpp

示例3: withCString

OSString * IOHIDDeviceShim::newSerialNumberString() const
{
    OSNumber * number;
	OSString * string;
    char str[33];
    
	if (_device) {
		if (number = OSDynamicCast(OSNumber, _device->getProperty("iSerialNumber")))
		{
			sprintf(str, "%d", number->unsigned32BitValue());
			str[32] = 0;
			return OSString::withCString(str);
		} 
		else if (string = OSDynamicCast(OSString, _device->getProperty(kIOHIDSerialNumberKey)))
		{
			string->retain();
			return string;
		}
	}

    return 0;
}
开发者ID:MomandDad,项目名称:netbook-installer,代码行数:22,代码来源:IOHIDDeviceShim.cpp

示例4: copyProperty

bool
ZFSDatasetProxy::start(IOService *provider)
{
	OSObject *property = NULL, *size = NULL;
	OSString *nameString = NULL;
	OSNumber *sizeNum = NULL;
	OSDictionary *deviceDict = NULL, *protocolDict = NULL;
	const OSSymbol *virtualSymbol = NULL, *internalSymbol = NULL;
	const char *cstr = NULL;
	char *pstring = NULL;
	int plen = 0;
	bool started = false;

	size = copyProperty(kZFSPoolSizeKey, gIOServicePlane,
	    (kIORegistryIterateRecursively|kIORegistryIterateParents));
	property = copyProperty(kZFSPoolNameKey, gIOServicePlane,
	    (kIORegistryIterateRecursively|kIORegistryIterateParents));

	if (!size || !property) {
		dprintf("couldn't get pool name or size");
		goto error;
	}

	nameString = OSDynamicCast(OSString, property);
	if (!nameString) {
		dprintf("missing pool name");
		goto error;
	}
#if 0
	/* Try hard to get the name string */
	do {
		nameString = OSDynamicCast(OSString, property);

		if (nameString) nameString->retain();

		if (!nameString) {
			OSSymbol *nameSymbol;
		       	nameSymbol = OSDynamicCast(OSSymbol, property);
			if (!nameSymbol) {
				dprintf("couldn't get name");
				goto error;
			}
			nameString = OSString::withCString(
			    nameSymbol->getCStringNoCopy());
		}
	} while (0);
#endif

	sizeNum = OSDynamicCast(OSNumber, size);
	if (!sizeNum) {
		dprintf("invalid size");
		goto error;
	}
	_pool_bcount = sizeNum->unsigned64BitValue() / DEV_BSIZE;
	sizeNum = 0;
	size->release();
	size = 0;

	cstr = nameString->getCStringNoCopy();
	if (!cstr || (plen = strlen(cstr) + 1) == 1) {
		goto error;
	}
	pstring = (char *)IOMalloc(plen);
	if (!pstring) {
		goto error;
	}
	snprintf(pstring, plen, "%s", cstr);
	productString = pstring;
	pstring = 0;

	if (IOBlockStorageDevice::start(provider) == false) {
		dprintf("BlockStorageDevice start failed");
		goto error;
	}
	started = true;

	deviceDict = OSDynamicCast(OSDictionary,
	    getProperty(kIOPropertyDeviceCharacteristicsKey));
	if (deviceDict) {
		/* Clone a new dictionary */
		deviceDict = OSDictionary::withDictionary(deviceDict);
		if (!deviceDict) {
			dprintf("dict clone failed");
			goto error;
		}
	}

	if (!deviceDict) {
		dprintf("creating new device dict");
		deviceDict = OSDictionary::withCapacity(1);
	}

	if (!deviceDict) {
		dprintf("missing device dict");
		goto error;
	}

	deviceDict->setObject(kIOPropertyProductNameKey, nameString);
	OSSafeReleaseNULL(nameString);

//.........这里部分代码省略.........
开发者ID:cbreak-black,项目名称:zfs,代码行数:101,代码来源:ZFSDatasetProxy.cpp


注:本文中的OSString::retain方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。