本文整理匯總了C++中CFDictionaryGetKeysAndValues函數的典型用法代碼示例。如果您正苦於以下問題:C++ CFDictionaryGetKeysAndValues函數的具體用法?C++ CFDictionaryGetKeysAndValues怎麽用?C++ CFDictionaryGetKeysAndValues使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CFDictionaryGetKeysAndValues函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: SetXiphCommentFromMetadata
bool
SetXiphCommentFromMetadata(const AudioMetadata& metadata, TagLib::Ogg::XiphComment *tag)
{
assert(NULL != tag);
// Standard tags
SetXiphComment(tag, "ALBUM", metadata.GetAlbumTitle());
SetXiphComment(tag, "ARTIST", metadata.GetArtist());
SetXiphComment(tag, "ALBUMARTIST", metadata.GetAlbumArtist());
SetXiphComment(tag, "COMPOSER", metadata.GetComposer());
SetXiphComment(tag, "GENRE", metadata.GetGenre());
SetXiphComment(tag, "DATE", metadata.GetReleaseDate());
SetXiphComment(tag, "DESCRIPTION", metadata.GetComment());
SetXiphComment(tag, "TITLE", metadata.GetTitle());
SetXiphCommentNumber(tag, "TRACKNUMBER", metadata.GetTrackNumber());
SetXiphCommentNumber(tag, "TRACKTOTAL", metadata.GetTrackTotal());
SetXiphCommentBoolean(tag, "COMPILATION", metadata.GetCompilation());
SetXiphCommentNumber(tag, "DISCNUMBER", metadata.GetDiscNumber());
SetXiphCommentNumber(tag, "DISCTOTAL", metadata.GetDiscTotal());
SetXiphComment(tag, "ISRC", metadata.GetISRC());
SetXiphComment(tag, "MCN", metadata.GetMCN());
// Additional metadata
CFDictionaryRef additionalMetadata = metadata.GetAdditionalMetadata();
if(NULL != additionalMetadata) {
CFIndex count = CFDictionaryGetCount(additionalMetadata);
const void * keys [count];
const void * values [count];
CFDictionaryGetKeysAndValues(additionalMetadata, reinterpret_cast<const void **>(keys), reinterpret_cast<const void **>(values));
for(CFIndex i = 0; i < count; ++i) {
CFIndex keySize = CFStringGetMaximumSizeForEncoding(CFStringGetLength(reinterpret_cast<CFStringRef>(keys[i])), kCFStringEncodingASCII);
char key [keySize + 1];
if(!CFStringGetCString(reinterpret_cast<CFStringRef>(keys[i]), key, keySize + 1, kCFStringEncodingASCII)) {
log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger("org.sbooth.AudioEngine");
LOG4CXX_ERROR(logger, "CFStringGetCString failed");
continue;
}
SetXiphComment(tag, key, reinterpret_cast<CFStringRef>(values[i]));
}
}
// ReplayGain info
SetXiphCommentDouble(tag, "REPLAYGAIN_REFERENCE_LOUDNESS", metadata.GetReplayGainReferenceLoudness(), CFSTR("%2.1f dB"));
SetXiphCommentDouble(tag, "REPLAYGAIN_TRACK_GAIN", metadata.GetReplayGainReferenceLoudness(), CFSTR("%+2.2f dB"));
SetXiphCommentDouble(tag, "REPLAYGAIN_TRACK_PEAK", metadata.GetReplayGainTrackGain(), CFSTR("%1.8f"));
SetXiphCommentDouble(tag, "REPLAYGAIN_ALBUM_GAIN", metadata.GetReplayGainAlbumGain(), CFSTR("%+2.2f dB"));
SetXiphCommentDouble(tag, "REPLAYGAIN_ALBUM_PEAK", metadata.GetReplayGainAlbumPeak(), CFSTR("%1.8f"));
return true;
}
示例2: nc_listvpn
static void
nc_listvpn(int argc, char **argv)
{
CFDictionaryRef appDict = NULL;
CFArrayRef appinfo = NULL;
int i, j, count, subtypecount;
const void * * keys = NULL;
CFMutableDictionaryRef optionsDict = NULL;
const void * * values = NULL;
CFStringRef vpntype = NULL;
optionsDict = CFDictionaryCreateMutable(NULL, 0,
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFDictionarySetValue(optionsDict, kLookupApplicationTypeKey, kApplicationTypeUser);
CFDictionarySetValue(optionsDict, kLookupAttributeKey, CFSTR("UIVPNPlugin"));
appDict = MobileInstallationLookup(optionsDict);
if (!isA_CFDictionary(appDict))
goto done;
count = CFDictionaryGetCount(appDict);
if (count > 0) {
keys = (const void * *)malloc(sizeof(CFTypeRef) * count);
values = (const void * *)malloc(sizeof(CFTypeRef) * count);
CFDictionaryGetKeysAndValues(appDict, keys, values);
for (i=0; i<count; i++) {
appinfo = CFDictionaryGetValue(values[i], CFSTR("UIVPNPlugin"));
if (appinfo) {
if (isA_CFString(appinfo)) {
nc_print_VPN_app_info((CFStringRef)appinfo, (CFDictionaryRef)values[i]);
}
else if (isA_CFArray(appinfo)) {
subtypecount = CFArrayGetCount((CFArrayRef)appinfo);
for(j=0; j<subtypecount; j++) {
vpntype = (CFStringRef)CFArrayGetValueAtIndex((CFArrayRef)appinfo, j);
nc_print_VPN_app_info(vpntype, (CFDictionaryRef)values[i]);
}
}
}
}
}
done:
if (keys) free(keys);
if (values) free(values);
my_CFRelease(&optionsDict);
my_CFRelease(&appDict);
exit(0);
}
示例3: CFQPropertyListShallowApplyFunction
extern pascal void CFQPropertyListShallowApplyFunction(CFPropertyListRef propList,
CFQPropertyListShallowApplierFunction func,
void *context)
// See comment in header.
{
assert(propList != NULL);
assert(func != NULL);
// If this node is a dictionary, call "func" for each element.
//
// If this node is an array, call "func" for each element and
// pass a CFNumber of the element's array index to its "key"
// parameter.
if ( CFGetTypeID(propList) == CFDictionaryGetTypeID() ) {
CFIndex count;
CFIndex index;
count = CFDictionaryGetCount( (CFDictionaryRef) propList);
if (count > 0) {
const void **keys;
keys = (const void **) malloc( count * sizeof(const void *));
if (keys != NULL) {
CFDictionaryGetKeysAndValues( (CFDictionaryRef) propList, keys, NULL);
for (index = 0; index < count; index++) {
func(keys[index], CFDictionaryGetValue( (CFDictionaryRef) propList, keys[index]), context);
}
free(keys);
}
}
} else if ( CFGetTypeID(propList) == CFArrayGetTypeID() ) {
CFIndex count;
CFIndex index;
count = CFArrayGetCount( (CFArrayRef) propList);
for (index = 0; index < count; index++) {
CFNumberRef key;
key = CFNumberCreate(NULL, kCFNumberLongType, &index);
if (key != NULL) {
func(key, CFArrayGetValueAtIndex( (CFArrayRef) propList, index), context);
CFRelease(key);
}
}
} else {
assert(false);
}
}
示例4: _CFPreferencesDomainSetDictionary
void _CFPreferencesDomainSetDictionary(CFPreferencesDomainRef domain, CFDictionaryRef dict) {
CFAllocatorRef alloc = __CFPreferencesAllocator();
CFDictionaryRef d = _CFPreferencesDomainDeepCopyDictionary(domain);
CFIndex idx, count = d ? CFDictionaryGetCount(d) : 0;
CFTypeRef *keys = (CFTypeRef *)CFAllocatorAllocate(alloc, count * sizeof(CFTypeRef), 0);
if (d) CFDictionaryGetKeysAndValues(d, keys, NULL);
for (idx = 0; idx < count; idx ++) {
_CFPreferencesDomainSet(domain, (CFStringRef)keys[idx], NULL);
}
CFAllocatorDeallocate(alloc, keys);
if (d) CFRelease(d);
if (dict && (count = CFDictionaryGetCount(dict)) != 0) {
CFStringRef *newKeys = (CFStringRef *)CFAllocatorAllocate(alloc, count * sizeof(CFStringRef), 0);
CFDictionaryGetKeysAndValues(dict, (const void **)newKeys, NULL);
for (idx = 0; idx < count; idx ++) {
CFStringRef key = newKeys[idx];
_CFPreferencesDomainSet(domain, key, (CFTypeRef)CFDictionaryGetValue(dict, key));
}
CFAllocatorDeallocate(alloc, newKeys);
}
}
示例5: GPDuplexClient_RemoveEveryObserver
extern void GPDuplexClient_RemoveEveryObserver(GPDuplexClientRef client, void* observer, GPDuplexClientCallback callback) {
if (client != NULL) {
CFIndex count = CFDictionaryGetCount(client->observers);
CFNumberRef* typeNumbers = malloc(count * sizeof(CFNumberRef));
CFMutableSetRef* observerSets = malloc(count * sizeof(CFMutableSetRef));
CFDictionaryGetKeysAndValues(client->observers, (const void**)typeNumbers, (const void**)observerSets);
for (CFIndex i = 0; i < count; ++ i)
GPDuplexClient_RemoveObserverWithNumberAndObserverSet(client, observer, callback, typeNumbers[i], observerSets[i]);
free(typeNumbers);
free(observerSets);
}
}
示例6: getVolatileKeysAndValues
static void getVolatileKeysAndValues(CFAllocatorRef alloc, CFTypeRef context, void *domain, void **buf[], CFIndex *numKeyValuePairs) {
CFMutableDictionaryRef dict = (CFMutableDictionaryRef)domain;
CFIndex count = CFDictionaryGetCount(dict);
if (buf) {
void **values;
if ( count < *numKeyValuePairs ) {
values = *buf + count;
CFDictionaryGetKeysAndValues(dict, (const void **)*buf, (const void **)values);
} else if (alloc != kCFAllocatorNull) {
if (*buf) {
*buf = (void **)CFAllocatorReallocate(alloc, *buf, count * 2 * sizeof(void *), 0);
} else {
*buf = (void **)CFAllocatorAllocate(alloc, count*2*sizeof(void *), 0);
}
if (*buf) {
values = *buf + count;
CFDictionaryGetKeysAndValues(dict, (const void **)*buf, (const void **)values);
}
}
}
*numKeyValuePairs = count;
}
示例7: CFDictionaryGetCount
CarbonEventHandler::~CarbonEventHandler()
{
if (mHandlers != NULL) {
int count = CFDictionaryGetCount(mHandlers);
EventHandlerRef *theHandlers = (EventHandlerRef*) malloc(count * sizeof(EventHandlerRef));
CFDictionaryGetKeysAndValues(mHandlers, NULL, (const void **)theHandlers);
for (int i = 0; i < count; i++)
RemoveEventHandler(theHandlers[i]);
CFDictionaryRemoveAllValues(mHandlers);
CFRelease (mHandlers);
free(theHandlers);
}
}
示例8: genKextstat
QueryData genKextstat(QueryContext &context) {
QueryData results;
// Populate dict of kernel extensions.
CFDictionaryRef dict = OSKextCopyLoadedKextInfo(NULL, NULL);
CFIndex count = CFDictionaryGetCount(dict);
// Allocate memory for each extension parse.
auto values = (void **)malloc(sizeof(void *) * count);
CFDictionaryGetKeysAndValues(dict, nullptr, (const void **)values);
for (CFIndex j = 0; j < count; j++) {
// name
auto name = getKextString(values[j], CFSTR("CFBundleIdentifier"));
auto kextTag = getKextInt(values[j], CFSTR("OSBundleLoadTag"));
// Possibly limit expensive lookups.
if (!context.constraints["name"].matches(name)) {
continue;
}
if (!context.constraints["idx"].matches<int>(kextTag)) {
continue;
}
auto references = getKextInt(values[j], CFSTR("OSBundleRetainCount"));
// size
auto load_size = getKextBigInt(values[j], CFSTR("OSBundleLoadSize"));
auto wired_size = getKextBigInt(values[j], CFSTR("OSBundleWiredSize"));
auto version = getKextString(values[j], CFSTR("CFBundleVersion"));
// linked_against
auto linked = getKextLinked(values[j], CFSTR("OSBundleDependencies"));
Row r;
r["idx"] = INTEGER(kextTag);
r["refs"] = INTEGER(references);
r["size"] = BIGINT(load_size);
r["wired"] = BIGINT(wired_size);
r["name"] = name;
r["version"] = version;
r["linked_against"] = linked;
results.push_back(r);
}
CFRelease(dict);
free(values);
return results;
}
示例9: CFURLRequestGetURL
void ResourceRequest::doUpdateResourceRequest()
{
if (!m_cfRequest) {
*this = ResourceRequest();
return;
}
m_url = CFURLRequestGetURL(m_cfRequest.get());
m_cachePolicy = (ResourceRequestCachePolicy)CFURLRequestGetCachePolicy(m_cfRequest.get());
m_timeoutInterval = CFURLRequestGetTimeoutInterval(m_cfRequest.get());
m_firstPartyForCookies = CFURLRequestGetMainDocumentURL(m_cfRequest.get());
if (CFStringRef method = CFURLRequestCopyHTTPRequestMethod(m_cfRequest.get())) {
m_httpMethod = method;
CFRelease(method);
}
m_allowCookies = CFURLRequestShouldHandleHTTPCookies(m_cfRequest.get());
if (httpPipeliningEnabled())
m_priority = toResourceLoadPriority(wkGetHTTPPipeliningPriority(m_cfRequest.get()));
m_httpHeaderFields.clear();
if (CFDictionaryRef headers = CFURLRequestCopyAllHTTPHeaderFields(m_cfRequest.get())) {
CFIndex headerCount = CFDictionaryGetCount(headers);
Vector<const void*, 128> keys(headerCount);
Vector<const void*, 128> values(headerCount);
CFDictionaryGetKeysAndValues(headers, keys.data(), values.data());
for (int i = 0; i < headerCount; ++i)
m_httpHeaderFields.set((CFStringRef)keys[i], (CFStringRef)values[i]);
CFRelease(headers);
}
m_responseContentDispositionEncodingFallbackArray.clear();
RetainPtr<CFArrayRef> encodingFallbacks(AdoptCF, copyContentDispositionEncodingFallbackArray(m_cfRequest.get()));
if (encodingFallbacks) {
CFIndex count = CFArrayGetCount(encodingFallbacks.get());
for (CFIndex i = 0; i < count; ++i) {
CFStringEncoding encoding = reinterpret_cast<CFIndex>(CFArrayGetValueAtIndex(encodingFallbacks.get(), i));
if (encoding != kCFStringEncodingInvalidId)
m_responseContentDispositionEncodingFallbackArray.append(CFStringConvertEncodingToIANACharSetName(encoding));
}
}
#if ENABLE(CACHE_PARTITIONING)
RetainPtr<CFStringRef> cachePartition(AdoptCF, static_cast<CFStringRef>(_CFURLRequestCopyProtocolPropertyForKey(m_cfRequest.get(), wkCachePartitionKey())));
if (cachePartition)
m_cachePartition = cachePartition.get();
#endif
}
示例10: getXMLKeysAndValues
static void getXMLKeysAndValues(CFAllocatorRef alloc, CFTypeRef context, void *xmlDomain, void **buf[], CFIndex *numKeyValuePairs) {
_CFXMLPreferencesDomain *domain = (_CFXMLPreferencesDomain *)xmlDomain;
CFIndex count;
__CFLock(&domain->_lock);
if (!domain->_domainDict) {
_loadXMLDomainIfStale((CFURLRef )context, domain);
}
count = CFDictionaryGetCount(domain->_domainDict);
if (buf) {
void **values;
if (count <= *numKeyValuePairs) {
values = *buf + count;
CFDictionaryGetKeysAndValues(domain->_domainDict, (const void **)*buf, (const void **)values);
} else if (alloc != kCFAllocatorNull) {
*buf = (void**) CFAllocatorReallocate(alloc, (*buf ? *buf : NULL), count * 2 * sizeof(void *), 0);
if (*buf) {
values = *buf + count;
CFDictionaryGetKeysAndValues(domain->_domainDict, (const void **)*buf, (const void **)values);
}
}
}
*numKeyValuePairs = count;
__CFUnlock(&domain->_lock);
}
示例11: setHeaderFields
static inline void setHeaderFields(CFMutableURLRequestRef request, const HTTPHeaderMap& requestHeaders)
{
// Remove existing headers first, as some of them may no longer be present in the map.
RetainPtr<CFDictionaryRef> oldHeaderFields = adoptCF(CFURLRequestCopyAllHTTPHeaderFields(request));
CFIndex oldHeaderFieldCount = CFDictionaryGetCount(oldHeaderFields.get());
if (oldHeaderFieldCount) {
Vector<CFStringRef> oldHeaderFieldNames(oldHeaderFieldCount);
CFDictionaryGetKeysAndValues(oldHeaderFields.get(), reinterpret_cast<const void**>(&oldHeaderFieldNames[0]), 0);
for (CFIndex i = 0; i < oldHeaderFieldCount; ++i)
CFURLRequestSetHTTPHeaderFieldValue(request, oldHeaderFieldNames[i], 0);
}
for (const auto& header : requestHeaders)
CFURLRequestSetHTTPHeaderFieldValue(request, header.key.createCFString().get(), header.value.createCFString().get());
}
示例12: setHeaderFields
static inline void setHeaderFields(CFMutableURLRequestRef request, const HTTPHeaderMap& requestHeaders)
{
// Remove existing headers first, as some of them may no longer be present in the map.
RetainPtr<CFDictionaryRef> oldHeaderFields(AdoptCF, CFURLRequestCopyAllHTTPHeaderFields(request));
CFIndex oldHeaderFieldCount = CFDictionaryGetCount(oldHeaderFields.get());
if (oldHeaderFieldCount) {
Vector<CFStringRef> oldHeaderFieldNames(oldHeaderFieldCount);
CFDictionaryGetKeysAndValues(oldHeaderFields.get(), reinterpret_cast<const void**>(&oldHeaderFieldNames[0]), 0);
for (CFIndex i = 0; i < oldHeaderFieldCount; ++i)
CFURLRequestSetHTTPHeaderFieldValue(request, oldHeaderFieldNames[i], 0);
}
for (HTTPHeaderMap::const_iterator it = requestHeaders.begin(), end = requestHeaders.end(); it != end; ++it)
CFURLRequestSetHTTPHeaderFieldValue(request, it->key.string().createCFString().get(), it->value.createCFString().get());
}
示例13: rsym_all_symbols
static VALUE
rsym_all_symbols(VALUE klass, SEL sel)
{
VALUE ary = rb_ary_new();
const long count = CFDictionaryGetCount(id_str);
if (count >= 0) {
const void **values = (const void **)malloc(sizeof(void *) * count);
CFDictionaryGetKeysAndValues(id_str, NULL, values);
for (long i = 0; i < count; i++) {
rb_ary_push(ary, (VALUE)values[i]);
}
free(values);
}
return ary;
}
示例14: _IOFileURLWritePropertiesToResource
static Boolean _IOFileURLWritePropertiesToResource(CFURLRef url, CFDictionaryRef propertyDict, SInt32 *errorCode) {
CFTypeRef buffer[16];
void **keys;
void **values;
Boolean result = TRUE;
SInt32 index, count;
char cPath[CFMaxPathSize];
if (!CFURLGetFileSystemRepresentation(url, TRUE, cPath, CFMaxPathSize)) {
if (errorCode) *errorCode = kIOURLImproperArgumentsError;
return FALSE;
}
count = CFDictionaryGetCount(propertyDict);
if (count < 8) {
keys = buffer;
values = buffer+8;
} else {
keys = CFAllocatorAllocate(CFGetAllocator(url), sizeof(void *) * count * 2, 0);
values = keys + count;
}
CFDictionaryGetKeysAndValues(propertyDict, keys, values);
for (index = 0; index < count; index ++) {
CFStringRef key = keys[index];
CFTypeRef value = values[index];
if (CFEqual(key, kIOFileURLPOSIXMode) || CFEqual(key, kIOURLFilePOSIXMode)) {
SInt32 mode;
int err;
if (CFEqual(key, kIOURLFilePOSIXMode)) {
CFNumberRef modeNum = (CFNumberRef)value;
CFNumberGetValue(modeNum, kCFNumberSInt32Type, &mode);
} else {
const mode_t *modePtr = (const mode_t *)CFDataGetBytePtr((CFDataRef)value);
mode = *modePtr;
}
err = chmod(cPath, mode);
if (err != 0) result = FALSE;
} else {
result = FALSE;
}
}
if (keys != &buffer[0]) CFAllocatorDeallocate(CFGetAllocator(url), keys);
if (errorCode) *errorCode = result ? 0 : kIOURLUnknownError;
return result;
}
示例15: SecTrustCopyFilteredDetails
//
// Returns a malloced array of CSSM_RETURN values, with the length in numStatusCodes,
// for the certificate specified by chain index in the given SecTrustRef.
//
// To match legacy behavior, the array actually allocates one element more than the
// value of numStatusCodes; if the certificate is revoked, the additional element
// at the end contains the CrlReason value.
//
// Caller must free the returned pointer.
//
static CSSM_RETURN *copyCssmStatusCodes(SecTrustRef trust,
unsigned int index, unsigned int *numStatusCodes)
{
if (!trust || !numStatusCodes) {
return NULL;
}
*numStatusCodes = 0;
CFArrayRef details = SecTrustCopyFilteredDetails(trust);
CFIndex chainLength = (details) ? CFArrayGetCount(details) : 0;
if (!(index < chainLength)) {
CFReleaseSafe(details);
return NULL;
}
CFDictionaryRef detail = (CFDictionaryRef)CFArrayGetValueAtIndex(details, index);
CFIndex ix, detailCount = CFDictionaryGetCount(detail);
*numStatusCodes = (unsigned int)detailCount;
// Allocate one more entry than we need; this is used to store a CrlReason
// at the end of the array.
CSSM_RETURN *statusCodes = (CSSM_RETURN*)malloc((detailCount+1) * sizeof(CSSM_RETURN));
statusCodes[*numStatusCodes] = 0;
const unsigned int resultmaplen = sizeof(cssmresultmap) / sizeof(resultmap_entry_t);
const void *keys[detailCount];
CFDictionaryGetKeysAndValues(detail, &keys[0], NULL);
for (ix = 0; ix < detailCount; ix++) {
CFStringRef key = (CFStringRef)keys[ix];
CSSM_RETURN statusCode = CSSM_OK;
for (unsigned int mapix = 0; mapix < resultmaplen; mapix++) {
CFStringRef str = (CFStringRef) cssmresultmap[mapix].checkstr;
if (CFStringCompare(str, key, 0) == kCFCompareEqualTo) {
statusCode = (CSSM_RETURN) cssmresultmap[mapix].resultcode;
break;
}
}
if (statusCode == CSSMERR_TP_CERT_REVOKED) {
SInt32 reason;
CFNumberRef number = (CFNumberRef)CFDictionaryGetValue(detail, key);
if (number && CFNumberGetValue(number, kCFNumberSInt32Type, &reason)) {
statusCodes[*numStatusCodes] = (CSSM_RETURN)reason;
}
}
statusCodes[ix] = statusCode;
}
CFReleaseSafe(details);
return statusCodes;
}