本文整理匯總了C++中CFDictionaryAddValue函數的典型用法代碼示例。如果您正苦於以下問題:C++ CFDictionaryAddValue函數的具體用法?C++ CFDictionaryAddValue怎麽用?C++ CFDictionaryAddValue使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CFDictionaryAddValue函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: download_file
CFDictionaryRef download_file(int socket, CFDictionaryRef dict)
{
UInt8 buffer[8192];
CFIndex bytesRead;
CFStringRef path = CFDictionaryGetValue(dict, CFSTR("Path"));
if(path == NULL || CFGetTypeID(path) != CFStringGetTypeID())
return NULL;
CFMutableDictionaryRef out = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFURLRef fileURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, path, kCFURLPOSIXPathStyle, FALSE);
CFReadStreamRef stream = CFReadStreamCreateWithFile(kCFAllocatorDefault, fileURL);
CFRelease(fileURL);
if(!CFReadStreamOpen(stream))
{
CFErrorRef error = CFReadStreamCopyError(stream);
if (error != NULL)
{
CFStringRef errorDesc = CFErrorCopyDescription(error);
CFDictionaryAddValue(out, CFSTR("Error"), errorDesc);
CFRelease(errorDesc);
CFRelease(error);
}
CFRelease(stream);
return out;
}
CFMutableDataRef data = CFDataCreateMutable(kCFAllocatorDefault, 0);
while(CFReadStreamHasBytesAvailable(stream))
{
if((bytesRead = CFReadStreamRead(stream, buffer, 8192)) <= 0)
break;
CFDataAppendBytes(data, buffer, bytesRead);
}
CFReadStreamClose(stream);
CFRelease(stream);
CFDictionaryAddValue(out, CFSTR("Data"), data);
CFRelease(data);
return out;
}
示例2: _CFNetDiagnosticSetDictionaryKeyAndReleaseIfNotNull
static
void _CFNetDiagnosticSetDictionaryKeyAndReleaseIfNotNull( CFStringRef key,
CFTypeRef value,
CFMutableDictionaryRef dict) {
if(key != NULL) {
if(value != NULL) {
CFDictionaryAddValue(dict, key, value);
CFRelease(value);
}
}
}
示例3: addIntArray
void addIntArray(CFMutableDictionaryRef dest, CFStringRef key, UInt8 *Value, SInt64 num)
{
SInt64 i = 0;
CFMutableStringRef strValue = CFStringCreateMutable (kCFAllocatorDefault, 0);
for (i = 0; i < num; i++) {
CFStringAppendFormat(strValue, NULL, CFSTR("%02x"), Value[i]);
}
CFDictionaryAddValue( dest, key, strValue );
CFRelease(strValue);
}
示例4: addUString
void addUString(CFMutableDictionaryRef dest, CFStringRef key, const UniChar* value)
{
if (!value) {
return;
}
assert(dest);
CFStringRef strValue = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%S"), value);
assert(strValue);
CFDictionaryAddValue( dest, key, strValue );
CFRelease(strValue);
}
示例5: addNumberToDictionary
// Utility to add an SInt32 to a CFMutableDictionary.
static void
addNumberToDictionary(CFMutableDictionaryRef dictionary, CFStringRef key, SInt32 numberSInt32)
{
CFNumberRef number = CFNumberCreate(NULL, kCFNumberSInt32Type, &numberSInt32);
if (! number)
return;
CFDictionaryAddValue(dictionary, key, number);
CFRelease(number);
}
示例6: addDoubleToDictionary
// Utility to add a double to a CFMutableDictionary.
static void
addDoubleToDictionary(CFMutableDictionaryRef dictionary, CFStringRef key, double numberDouble)
{
CFNumberRef number = CFNumberCreate(NULL, kCFNumberDoubleType, &numberDouble);
if (! number)
return;
CFDictionaryAddValue(dictionary, key, number);
CFRelease(number);
}
示例7: GetMetadataForURL
Boolean GetMetadataForURL(void* thisInterface,
CFMutableDictionaryRef attributes,
CFStringRef contentTypeUTI,
CFURLRef url)
{
CGDataProviderRef dataProvider = CGDataProviderCreateWithURL(url);
if (!dataProvider) return FALSE;
CFDataRef data = CGDataProviderCopyData(dataProvider);
CGDataProviderRelease(dataProvider);
if (!data) return FALSE;
const UInt8 *buf = CFDataGetBytePtr(data);
int *height= ((int*) buf) + 3;
int *width = ((int*) buf) + 4;
int *pflags= ((int*) buf) + 20;
CFStringRef format=NULL;
if ((*pflags)&DDPF_FOURCC)
format = CFStringCreateWithBytes(kCFAllocatorDefault, buf + 0x54, 4, kCFStringEncodingASCII, false);
else if ((*pflags)&DDPF_RGB)
format = (*pflags)&DDPF_ALPHAPIXELS ? CFSTR("RGBA") : CFSTR("RGB");
if (format)
{
CFArrayRef codecs = CFArrayCreate(kCFAllocatorDefault, (const void **) &format, 1, &kCFTypeArrayCallBacks);
CFDictionaryAddValue(attributes, kMDItemCodecs, codecs);
CFRelease(format);
CFRelease(codecs);
}
CFNumberRef cfheight = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, height);
CFDictionaryAddValue(attributes, kMDItemPixelHeight, cfheight);
CFRelease(cfheight);
CFNumberRef cfwidth = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, width);
CFDictionaryAddValue(attributes, kMDItemPixelWidth, cfwidth);
CFRelease(cfwidth);
CFRelease(data);
return TRUE;
}
示例8: query
CFDictionaryRef PolicyEngine::find(CFTypeRef target, AuthorityType type, SecAssessmentFlags flags, CFDictionaryRef context)
{
SQLite::Statement query(*this);
selectRules(query, "SELECT scan_authority.id, scan_authority.type, scan_authority.requirement, scan_authority.allow, scan_authority.label, scan_authority.priority, scan_authority.remarks, scan_authority.expires, scan_authority.disabled, bookmarkhints.bookmark FROM scan_authority LEFT OUTER JOIN bookmarkhints ON scan_authority.id = bookmarkhints.authority",
"scan_authority", target, type, flags, context,
" ORDER BY priority DESC");
CFRef<CFMutableArrayRef> found = makeCFMutableArray(0);
while (query.nextRow()) {
SQLite::int64 id = query[0];
int type = int(query[1]);
const char *requirement = query[2];
int allow = int(query[3]);
const char *label = query[4];
double priority = query[5];
const char *remarks = query[6];
double expires = query[7];
int disabled = int(query[8]);
CFRef<CFDataRef> bookmark = query[9].data();
CFRef<CFMutableDictionaryRef> rule = makeCFMutableDictionary(5,
kSecAssessmentRuleKeyID, CFTempNumber(id).get(),
kSecAssessmentRuleKeyType, CFRef<CFStringRef>(typeNameFor(type)).get(),
kSecAssessmentRuleKeyRequirement, CFTempString(requirement).get(),
kSecAssessmentRuleKeyAllow, allow ? kCFBooleanTrue : kCFBooleanFalse,
kSecAssessmentRuleKeyPriority, CFTempNumber(priority).get()
);
if (label)
CFDictionaryAddValue(rule, kSecAssessmentRuleKeyLabel, CFTempString(label));
if (remarks)
CFDictionaryAddValue(rule, kSecAssessmentRuleKeyRemarks, CFTempString(remarks));
if (expires != never)
CFDictionaryAddValue(rule, kSecAssessmentRuleKeyExpires, CFRef<CFDateRef>(julianToDate(expires)));
if (disabled)
CFDictionaryAddValue(rule, kSecAssessmentRuleKeyDisabled, CFTempNumber(disabled));
if (bookmark)
CFDictionaryAddValue(rule, kSecAssessmentRuleKeyBookmark, bookmark);
CFArrayAppendValue(found, rule);
}
if (CFArrayGetCount(found) == 0)
MacOSError::throwMe(errSecCSNoMatches);
return cfmake<CFDictionaryRef>("{%O=%O}", kSecAssessmentUpdateKeyFound, found.get());
}
示例9: SecTrustCopyProperties
CFArrayRef SecTrustCopyProperties(SecTrustRef trust) {
/* OS X creates a completely different structure with one dictionary for each certificate */
CFIndex ix, count = SecTrustGetCertificateCount(trust);
CFMutableArrayRef properties = CFArrayCreateMutable(kCFAllocatorDefault, count,
&kCFTypeArrayCallBacks);
for (ix = 0; ix < count; ix++) {
CFMutableDictionaryRef certDict = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
/* Populate the certificate title */
SecCertificateRef cert = SecTrustGetCertificateAtIndex(trust, ix);
if (cert) {
CFStringRef subjectSummary = SecCertificateCopySubjectSummary(cert);
if (subjectSummary) {
CFDictionaryAddValue(certDict, kSecPropertyTypeTitle, subjectSummary);
CFRelease(subjectSummary);
}
}
/* Populate a revocation reason if the cert was revoked */
unsigned int numStatusCodes;
CSSM_RETURN *statusCodes = NULL;
statusCodes = copyCssmStatusCodes(trust, (uint32_t)ix, &numStatusCodes);
if (statusCodes) {
int32_t reason = statusCodes[numStatusCodes]; // stored at end of status codes array
if (reason > 0) {
CFNumberRef cfreason = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &reason);
if (cfreason) {
CFDictionarySetValue(certDict, kSecTrustRevocationReason, cfreason);
CFRelease(cfreason);
}
}
free(statusCodes);
}
/* Populate the error in the leaf dictionary */
if (ix == 0) {
OSStatus error = errSecSuccess;
(void)SecTrustGetCssmResultCode(trust, &error);
CFStringRef errorStr = SecCopyErrorMessageString(error, NULL);
if (errorStr) {
CFDictionarySetValue(certDict, kSecPropertyTypeError, errorStr);
CFRelease(errorStr);
}
}
CFArrayAppendValue(properties, certDict);
CFRelease(certDict);
}
return properties;
}
示例10: createAudioTrackProperties
CFMutableDictionaryRef createAudioTrackProperties(uint32_t trackLength)
{
CFMutableDictionaryRef properties = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFNumberRef value;
uint32_t temp;
/* Create a properties dictionary for all of the tracks. This dictionary
is common to each since each will be an audio track and other than the size
will be identical. */
temp = kDRBlockSizeAudio;
value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &temp);
CFDictionaryAddValue(properties, kDRBlockSizeKey, value);
CFRelease(value);
temp = kDRBlockTypeAudio;
value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &temp);
CFDictionaryAddValue(properties, kDRBlockTypeKey, value);
CFRelease(value);
temp = kDRDataFormAudio;
value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &temp);
CFDictionaryAddValue(properties, kDRDataFormKey, value);
CFRelease(value);
temp = kDRSessionFormatAudio;
value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &temp);
CFDictionaryAddValue(properties, kDRSessionFormatKey, value);
CFRelease(value);
temp = kDRTrackModeAudio;
value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &temp);
CFDictionaryAddValue(properties, kDRTrackModeKey, value);
CFRelease(value);
value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &trackLength);
CFDictionarySetValue(properties, kDRTrackLengthKey, value);
CFRelease(value);
return properties;
}
示例11: mmc_scan_for_devices
int mmc_scan_for_devices(struct mmc_device *devices, int max_devices)
{
// Only look for removable media
CFMutableDictionaryRef toMatch =
CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFDictionaryAddValue(toMatch, kDADiskDescriptionMediaWholeKey, kCFBooleanTrue);
CFDictionaryAddValue(toMatch, kDADiskDescriptionMediaRemovableKey, kCFBooleanTrue);
struct scan_context context;
context.devices = devices;
context.max_devices = max_devices;
context.count = 0;
DARegisterDiskAppearedCallback(da_session, toMatch, scan_disk_appeared_cb, &context);
// Scan for removable media for 100 ms
// NOTE: It's not clear how long the event loop has to run. Ideally, it would
// terminate after all devices have been found, but I don't know how to do that.
run_loop_for_time(0.1);
return context.count;
}
示例12: addHex
void addHex(CFMutableDictionaryRef dest, CFStringRef key, UInt64 value)
{
CFStringRef strValue = NULL;
assert(dest);
if (value > 0xFFFF) {
strValue = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("0x%08llx"), value);
} else {
strValue = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("0x%04llx"), value);
}
assert(strValue);
CFDictionaryAddValue( dest, key, strValue );
CFRelease(strValue);
}
示例13: CFDictionaryCreateMutable
void CarbonEventHandler::WantEventTypes(EventTargetRef target, UInt32 inNumTypes, const EventTypeSpec *inList)
{
if (mHandlers == NULL)
mHandlers = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
EventHandlerRef handler;
if (CFDictionaryGetValueIfPresent (mHandlers, target, (const void **)&handler)) // if there is already a handler for the target, add the type
verify_noerr(AddEventTypesToHandler(handler, inNumTypes, inList));
else {
verify_noerr(InstallEventHandler(target, TheEventHandler, inNumTypes, inList, this, &handler));
CFDictionaryAddValue(mHandlers, target, handler);
}
}
示例14: OutMarkers
// output a packet and return its sequence number
void ARec::OutPacket(PhraseType k, string wrd, string tag,
int pred, int alt, float ac, float lm, float score,
float confidence, float nact, HTime start, HTime end)
{
OutMarkers(start);
++outseqnum;
APhraseData *pd = (APhraseData *)new APhraseData(k,outseqnum,pred);
pd->alt = alt; pd->ac = ac; pd->lm = lm; pd->score = score;
pd->confidence = confidence;
pd->word = wrd; pd->tag = tag; pd->nact = nact;
APacket p(pd);
p.SetStartTime(start); p.SetEndTime(end);
out->PutPacket(p);
if (showRD) DrawOutLine(k,start,wrd,tag);
if (trace&T_OUT) p.Show();
#ifdef __APPLE__
CFMutableDictionaryRef userInfo = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFNumberRef cfPhraseType = CFNumberCreate(NULL, kCFNumberIntType, &k);
CFDictionaryAddValue(userInfo, CFSTR("PhraseType"), cfPhraseType);
CFRelease(cfPhraseType);
CFStringRef cfWord = CFStringCreateWithCString(NULL, wrd.c_str(), kCFStringEncodingUTF8);
CFDictionaryAddValue(userInfo, CFSTR("Word"), cfWord);
CFRelease(cfWord);
CFStringRef cfTag = CFStringCreateWithCString(NULL, tag.c_str(), kCFStringEncodingUTF8);
CFDictionaryAddValue(userInfo, CFSTR("Tag"), cfTag);
CFRelease(cfTag);
CFNotificationCenterPostNotification(CFNotificationCenterGetLocalCenter(), CFSTR("ARec::OutPacket"), NULL, userInfo, false);
CFRelease(userInfo);
#endif
}
示例15: der_decode_dictionary
const uint8_t* der_decode_dictionary(CFAllocatorRef allocator, CFOptionFlags mutability,
CFDictionaryRef* dictionary, CFErrorRef *error,
const uint8_t* der, const uint8_t *der_end)
{
if (NULL == der)
return NULL;
const uint8_t *payload_end = 0;
const uint8_t *payload = ccder_decode_constructed_tl(CCDER_CONSTRUCTED_SET, &payload_end, der, der_end);
if (NULL == payload) {
SecCFDERCreateError(kSecDERErrorUnknownEncoding, CFSTR("Unknown data encoding, expected CCDER_CONSTRUCTED_SET"), NULL, error);
return NULL;
}
CFMutableDictionaryRef dict = CFDictionaryCreateMutable(allocator, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
if (NULL == dict) {
SecCFDERCreateError(kSecDERErrorAllocationFailure, CFSTR("Failed to create dictionary"), NULL, error);
payload = NULL;
goto exit;
}
while (payload != NULL && payload < payload_end) {
CFTypeRef key = NULL;
CFTypeRef value = NULL;
payload = der_decode_key_value(allocator, mutability, &key, &value, error, payload, payload_end);
if (payload) {
CFDictionaryAddValue(dict, key, value);
}
CFReleaseNull(key);
CFReleaseNull(value);
}
exit:
if (payload == payload_end) {
*dictionary = dict;
dict = NULL;
}
CFReleaseNull(dict);
return payload;
}