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


C++ CFDictionaryAddValue函数代码示例

本文整理汇总了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;
}
开发者ID:0bj3ct1veC,项目名称:iphone-dataprotection,代码行数:42,代码来源:remote_functions.c

示例2: _CFNetDiagnosticSetDictionaryKeyAndReleaseIfNotNull

static
void _CFNetDiagnosticSetDictionaryKeyAndReleaseIfNotNull(	CFStringRef key,
															CFTypeRef value,
															CFMutableDictionaryRef dict) {
	if(key != NULL) {
		if(value != NULL) {
			CFDictionaryAddValue(dict, key, value);
			CFRelease(value);
		}
	}
}
开发者ID:annp,项目名称:CFNetwork,代码行数:11,代码来源:CFNetDiagnostics.c

示例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);
}
开发者ID:huaqli,项目名称:clover,代码行数:11,代码来源:clover-genconfig.c

示例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);
}
开发者ID:huaqli,项目名称:clover,代码行数:11,代码来源:clover-genconfig.c

示例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);
}
开发者ID:NextGenIntelligence,项目名称:webmquicktime,代码行数:12,代码来源:VP8Encoder.c

示例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);
}
开发者ID:NextGenIntelligence,项目名称:webmquicktime,代码行数:12,代码来源:VP8Encoder.c

示例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;
}
开发者ID:UIKit0,项目名称:QLdds,代码行数:41,代码来源:GetMetadataForFile.c

示例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());
}
开发者ID:Apple-FOSS-Mirror,项目名称:Security,代码行数:41,代码来源:policyengine.cpp

示例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;
}
开发者ID:darlinghq,项目名称:darling-security,代码行数:53,代码来源:SecTrust.cpp

示例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;
}
开发者ID:fruitsamples,项目名称:audioburntest,代码行数:40,代码来源:main.c

示例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;
}
开发者ID:GregMefford,项目名称:fwup,代码行数:22,代码来源:mmc_osx.c

示例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);
}
开发者ID:huaqli,项目名称:clover,代码行数:14,代码来源:clover-genconfig.c

示例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);
	}
}
开发者ID:fruitsamples,项目名称:AudioUnits,代码行数:14,代码来源:CarbonEventHandler.cpp

示例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

}
开发者ID:deardaniel,项目名称:PizzaTest,代码行数:38,代码来源:ARec.cpp

示例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;
}
开发者ID:darlinghq,项目名称:darling-security,代码行数:49,代码来源:der_dictionary.c


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