本文整理汇总了C++中OSArray::replaceObject方法的典型用法代码示例。如果您正苦于以下问题:C++ OSArray::replaceObject方法的具体用法?C++ OSArray::replaceObject怎么用?C++ OSArray::replaceObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSArray
的用法示例。
在下文中一共展示了OSArray::replaceObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
OSCollection * OSArray::copyCollection(OSDictionary *cycleDict)
{
bool allocDict = !cycleDict;
OSCollection *ret = 0;
OSArray *newArray = 0;
if (allocDict) {
cycleDict = OSDictionary::withCapacity(16);
if (!cycleDict)
return 0;
}
do {
// Check for a cycle
ret = super::copyCollection(cycleDict);
if (ret)
continue;
newArray = OSArray::withArray(this);
if (!newArray)
continue;
// Insert object into cycle Dictionary
cycleDict->setObject((const OSSymbol *) this, newArray);
for (unsigned int i = 0; i < count; i++) {
OSCollection *coll =
OSDynamicCast(OSCollection, EXT_CAST(newArray->array[i]));
if (coll) {
OSCollection *newColl = coll->copyCollection(cycleDict);
if (!newColl)
goto abortCopy;
newArray->replaceObject(i, newColl);
newColl->release();
};
};
ret = newArray;
newArray = 0;
} while (false);
abortCopy:
if (newArray)
newArray->release();
if (allocDict)
cycleDict->release();
return ret;
}
示例2: replaceAvailableSelection
IOReturn IOAudioSelectorControl::replaceAvailableSelection(SInt32 selectionValue, OSString *selectionDescription)
{
OSCollectionIterator *iterator;
OSArray *newSelections;
OSArray *oldAvailableSelections;
IOReturn result = kIOReturnSuccess;
assert(availableSelections);
oldAvailableSelections = availableSelections;
newSelections = OSArray::withArray(availableSelections);
if (!newSelections)
return kIOReturnNoMemory;
iterator = OSCollectionIterator::withCollection(newSelections);
if (iterator) {
OSDictionary * selection;
UInt32 index;
index = 0;
while ( (selection = (OSDictionary *)iterator->getNextObject() )) {
OSNumber * sValue;
sValue = (OSNumber *)selection->getObject(kIOAudioSelectorControlSelectionValueKey);
if (sValue && ((SInt32)sValue->unsigned32BitValue() == selectionValue)) {
// Replace the selected dictionary in the array
newSelections->replaceObject(index, selectionDescription);
result = kIOReturnSuccess;
break;
}
index++;
}
availableSelections = newSelections;
setProperty(kIOAudioSelectorControlAvailableSelectionsKey, availableSelections);
oldAvailableSelections->release();
iterator->release();
}
if (kIOReturnSuccess == result) {
sendChangeNotification(kIOAudioControlRangeChangeNotification);
}
return result;
}