本文整理汇总了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;
}
示例2: OSDynamicCast
//----------------------------------------------------------------------------------------------------
// IOHIDUserDevice::newSerialNumberString
//----------------------------------------------------------------------------------------------------
OSString *IOHIDUserDevice::newSerialNumberString() const
{
OSString * string = OSDynamicCast(OSString, _properties->getObject(kIOHIDSerialNumberKey));
if ( !string )
return NULL;
string->retain();
return string;
}
示例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;
}
示例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);
//.........这里部分代码省略.........