本文整理匯總了C++中CFDictionaryGetTypeID函數的典型用法代碼示例。如果您正苦於以下問題:C++ CFDictionaryGetTypeID函數的具體用法?C++ CFDictionaryGetTypeID怎麽用?C++ CFDictionaryGetTypeID使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CFDictionaryGetTypeID函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: GetDocTypeForExt
// Given a data structure representing document type data, or a list of such
// structures, find the one which matches a particular file extension
// The result will be a CFDictionary containining document type data
// if a match is found, or null otherwise
CFDictionaryRef GetDocTypeForExt( CFTypeRef docTypeData, CFStringRef requiredExt )
{
if( !docTypeData )
return NULL;
if( CFGetTypeID( docTypeData ) == CFArrayGetTypeID() )
{
CFTypeRef item;
CFArrayRef docTypes;
docTypes = reinterpret_cast< CFArrayRef >( docTypeData );
for( CFIndex i = 0, n = CFArrayGetCount( docTypes ); i < n; i++ )
{
item = CFArrayGetValueAtIndex( docTypes, i );
if( CFGetTypeID( item ) == CFDictionaryGetTypeID() )
{
CFDictionaryRef docType;
docType = reinterpret_cast< CFDictionaryRef >( item );
if( CheckDocTypeMatchesExt( docType, requiredExt ) )
return docType;
}
}
}
if( CFGetTypeID( docTypeData ) == CFDictionaryGetTypeID() )
{
CFDictionaryRef docType = reinterpret_cast< CFDictionaryRef >( docTypeData );
if( CheckDocTypeMatchesExt( docType, requiredExt ) )
return docType;
}
return NULL;
}
示例2: HIDTopLevelElementHandler
static void
HIDTopLevelElementHandler(const void *value, void *parameter)
{
CFTypeRef refCF = 0;
if (CFGetTypeID(value) != CFDictionaryGetTypeID())
return;
refCF = CFDictionaryGetValue(value, CFSTR(kIOHIDElementUsagePageKey));
if (!CFNumberGetValue
(refCF, kCFNumberLongType, &((recDevice *) parameter)->usagePage))
SDL_SetError("CFNumberGetValue error retrieving pDevice->usagePage.");
refCF = CFDictionaryGetValue(value, CFSTR(kIOHIDElementUsageKey));
if (!CFNumberGetValue
(refCF, kCFNumberLongType, &((recDevice *) parameter)->usage))
SDL_SetError("CFNumberGetValue error retrieving pDevice->usage.");
}
示例3: dict
// Given a CFData object generated by the save command, this will re-establish
// the CAStreamBasicDescription
OSStatus CAStreamBasicDescription::Restore (CFPropertyListRef& inData)
{
if (CFGetTypeID (inData) != CFDictionaryGetTypeID()) return -1;
CACFDictionary dict(static_cast<CFDictionaryRef>(inData), false);
if (!dict.GetFloat64 (kSampleRate, mSampleRate)) return -1;
if (!dict.GetUInt32 (kFormat, mFormatID)) return -1;
if (!dict.GetUInt32 (kFormatFlags, mFormatFlags)) return -1;
if (!dict.GetUInt32 (kPacketBytes, mBytesPerPacket)) return -1;
if (!dict.GetUInt32 (kFramePackets, mFramesPerPacket)) return -1;
if (!dict.GetUInt32 (kFrameBytes, mBytesPerFrame)) return -1;
if (!dict.GetUInt32 (kFrameChannels, mChannelsPerFrame)) return -1;
if (!dict.GetUInt32 (kChannelBits, mBitsPerChannel)) return -1;
return noErr;
}
示例4: CFGetTypeID
void mUSBHID::registerHIDProperties(CFTypeRef object){
CFTypeID type = CFGetTypeID(object);
if (type == CFArrayGetTypeID()){
registerHID_CFArray((const __CFArray*)object);
} else if (type == CFDictionaryGetTypeID()){
registerHID_CFDictionary((const __CFDictionary*)object);
} else if (type == CFBooleanGetTypeID()){
//MyCFBoolean(object);
} else if (type == CFNumberGetTypeID()){
//MyCFNumberShow(object);
} else if (type == CFStringGetTypeID()){
//MyCFStringShow(object);
} else{
//mprintf("<unknown hid object>");
}
}
示例5:
bool CACFDictionary::GetDictionary(const CFStringRef inKey, CFDictionaryRef& outValue) const
{
bool theAnswer = false;
CFTypeRef theValue = NULL;
if(GetCFType(inKey, theValue))
{
if((theValue != NULL) && (CFGetTypeID(theValue) == CFDictionaryGetTypeID()))
{
outValue = static_cast<CFDictionaryRef>(theValue);
theAnswer = true;
}
}
return theAnswer;
}
示例6:
bool CACFArray::GetDictionary(UInt32 inIndex, CFDictionaryRef& outItem) const
{
bool theAnswer = false;
CFTypeRef theItem = NULL;
if(GetCFType(inIndex, theItem))
{
if((theItem != NULL) && (CFGetTypeID(theItem) == CFDictionaryGetTypeID()))
{
outItem = static_cast<CFDictionaryRef>(theItem);
theAnswer = true;
}
}
return theAnswer;
}
示例7: _rd_prefs_load_recent_files
static void
_rd_prefs_load_recent_files(rd_recent_file_t *r, int num_files, CFStringRef app)
{
assert(r != NULL);
assert(app != NULL);
CFArrayRef the_array = CFPreferencesCopyAppValue(CFSTR("recent_files"), app);
if (the_array == NULL) {
return;
}
CFIndex array_count = CFArrayGetCount(the_array);
int i;
for (i = 0; i < num_files; i++) {
rd_recent_file_t *f = &r[i];
if (i >= array_count) {
bzero(f, sizeof(*f));
} else {
const void *f_val = CFArrayGetValueAtIndex(the_array, i);
if (CFGetTypeID(f_val) == CFStringGetTypeID()) {
// string. set the time to now.
if (CFStringGetCString(f_val, f->path, sizeof(f->path), kCFStringEncodingUTF8)) {
// success
f->path[sizeof(f->path) - 1] = '\0';
f->last_atime = (unsigned long) time(NULL);
}
} else if (CFGetTypeID(f_val) == CFDictionaryGetTypeID()) {
CFStringRef f_name = CFDictionaryGetValue(f_val, CFSTR("name"));
CFNumberRef f_atime = CFDictionaryGetValue(f_val, CFSTR("atime"));
if (CFStringGetCString(f_name, f->path, sizeof(f->path), kCFStringEncodingUTF8)) {
// success
f->path[sizeof(f->path) - 1] = '\0';
if (CFNumberGetValue(f_atime, kCFNumberLongType, (long*) &f->last_atime)) {
// success
} else {
f->last_atime = (unsigned long) time(NULL);
}
}
}
}
}
CFRelease(the_array);
}
示例8: MyBurnSessionDeviceCheckCallBack
static Boolean
MyBurnSessionDeviceCheckCallBack(DRBurnSessionRef burnSession, DRDeviceRef device)
{
#pragma unused(burnSession)
CFDictionaryRef deviceDict;
CFDictionaryRef writeCapDict;
CFBooleanRef canWriteDVDRAM;
CFStringRef vendorName;
CFStringRef productName;
char vendor[256];
char product[256];
Boolean showDeviceInList;
/* DRDeviceCopyInfo will return information that identifies the device and describes its
capabilities. The information includes the vendor's name, the product identifier, whether
the device can burn CDs or DVDs, and so on. */
deviceDict = DRDeviceCopyInfo(device);
assert(deviceDict != NULL);
vendorName = CFDictionaryGetValue(deviceDict, kDRDeviceVendorNameKey);
assert((vendorName != NULL) && (CFGetTypeID(vendorName) == CFStringGetTypeID()));
productName = CFDictionaryGetValue(deviceDict, kDRDeviceProductNameKey);
assert((productName != NULL) && (CFGetTypeID(productName) == CFStringGetTypeID()));
if (CFStringGetCString(vendorName, vendor, sizeof(vendor), kCFStringEncodingASCII)) {
if (CFStringGetCString(productName, product, sizeof(product), kCFStringEncodingASCII)) {
fprintf(stderr, "%s ", vendor);
fprintf(stderr, "%s Checked.\n", product);
}
}
writeCapDict = CFDictionaryGetValue(deviceDict, kDRDeviceWriteCapabilitiesKey);
assert((writeCapDict != NULL) && (CFGetTypeID(writeCapDict) == CFDictionaryGetTypeID()));
canWriteDVDRAM = CFDictionaryGetValue(writeCapDict, kDRDeviceCanWriteDVDRAMKey);
assert((canWriteDVDRAM != NULL) && (CFGetTypeID(canWriteDVDRAM) == CFBooleanGetTypeID()));
// Don't show DVD-RAM drives in the list.
showDeviceInList = !CFBooleanGetValue(canWriteDVDRAM);
CFRelease(deviceDict);
return showDeviceInList;
}
示例9: switch
//
// Process % scan forms.
// This delivers the object value, scanf-style, somehow.
//
bool CFScan::scanformat(CFTypeRef obj)
{
switch (*++format) {
case F_OBJECT:
store<CFTypeRef>(obj);
return true;
case F_ARRAY: // %a*
return typescan(obj, CFArrayGetTypeID()) == done;
case F_BOOLEAN:
if (Typescan rc = typescan(obj, CFBooleanGetTypeID()))
return rc == done;
switch (*format) {
case 'f': // %Bf - two arguments (value, &variable)
{
unsigned flag = va_arg(args, unsigned);
unsigned *value = va_arg(args, unsigned *);
if (obj == kCFBooleanTrue && !suppress)
*value |= flag;
return true;
}
default: // %b - CFBoolean as int boolean
store<int>(obj == kCFBooleanTrue);
return true;
}
case F_DICTIONARY:
return typescan(obj, CFDictionaryGetTypeID()) == done;
case 'd': // %d - int
return scannumber<int>(obj);
case F_NUMBER:
return typescan(obj, CFNumberGetTypeID()) == done;
case F_STRING:
case 's':
if (Typescan rc = typescan(obj, CFStringGetTypeID()))
return rc == done;
// %s
store<std::string>(cfString(CFStringRef(obj)));
return true;
case 'u':
return scannumber<unsigned int>(obj);
case F_DATA:
return typescan(obj, CFDataGetTypeID()) == done;
default:
assert(false);
return false;
}
}
示例10: print_keys
void print_keys(const void *key, const void *value, void *context)
{
CFStringRef k = (CFStringRef)key;
std::string key_str = CFStringGetCStringPtr(k, kCFStringEncodingMacRoman);
std::string value_str;
CFTypeID id = CFGetTypeID(value);
if(id == CFStringGetTypeID())
{
CFStringRef v = (CFStringRef)value;
if(CFStringGetCStringPtr(v, kCFStringEncodingMacRoman))
{
value_str = CFStringGetCStringPtr(v, kCFStringEncodingMacRoman);
if(key_str == "kCGWindowName")
window_lst[window_lst.size()-1].name = value_str;
else if(key_str == "kCGWindowOwnerName")
window_lst[window_lst.size()-1].owner = value_str;
}
}
else if(id == CFNumberGetTypeID())
{
CFNumberRef v = (CFNumberRef)value;
int myint;
CFNumberGetValue(v, kCFNumberSInt64Type, &myint);
value_str = std::to_string(myint);
if(key_str == "kCGWindowLayer")
window_lst[window_lst.size()-1].layer = myint;
else if(key_str == "kCGWindowOwnerPID")
window_lst[window_lst.size()-1].pid = myint;
else if(key_str == "X")
window_lst[window_lst.size()-1].x = myint;
else if(key_str == "Y")
window_lst[window_lst.size()-1].y = myint;
else if(key_str == "Width")
window_lst[window_lst.size()-1].width = myint;
else if(key_str == "Height")
window_lst[window_lst.size()-1].height = myint;
}
else if(id == CFDictionaryGetTypeID())
{
CFDictionaryRef elem = (CFDictionaryRef)value;
CFDictionaryApplyFunction(elem, print_keys, NULL);
CFRelease(elem);
}
}
示例11: CopyKeyFromFile
static CFTypeRef
CopyKeyFromFile(CFStringRef domain, CFStringRef key)
{
CFReadStreamRef s;
CFDictionaryRef d;
CFStringRef file;
CFErrorRef e;
CFURLRef url;
CFTypeRef val;
file = CFStringCreateWithFormat(NULL, 0, CFSTR("/Library/Preferences/%@.plist"), domain);
if (file == NULL)
return NULL;
url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, domain, kCFURLPOSIXPathStyle, false);
CFRelease(file);
if (url == NULL)
return NULL;
s = CFReadStreamCreateWithFile(kCFAllocatorDefault, url);
CFRelease(url);
if (s == NULL)
return NULL;
if (!CFReadStreamOpen(s)) {
CFRelease(s);
return NULL;
}
d = (CFDictionaryRef)CFPropertyListCreateWithStream (kCFAllocatorDefault, s, 0, kCFPropertyListImmutable, NULL, &e);
CFRelease(s);
if (d == NULL)
return NULL;
if (CFGetTypeID(d) != CFDictionaryGetTypeID()) {
CFRelease(d);
return NULL;
}
val = CFDictionaryGetValue(d, key);
if (val)
CFRetain(val);
CFRelease(d);
return val;
}
示例12: pkinit_get_pref_dict
/*
* Obtain the CFDictionary representing this user's PKINIT client cert prefs, if it
* exists. Returns noErr or errSecItemNotFound as appropriate.
*/
static OSStatus pkinit_get_pref_dict(
CFDictionaryRef *dict)
{
CFDictionaryRef theDict;
theDict = (CFDictionaryRef)CFPreferencesCopyValue(CFSTR(kPkinitClientCertKey),
CFSTR(kPkinitClientCertApp), kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
if(theDict == NULL) {
pkiDebug("pkinit_get_pref_dict: no kPkinitClientCertKey\n");
return errSecItemNotFound;
}
if(CFGetTypeID(theDict) != CFDictionaryGetTypeID()) {
pkiDebug("pkinit_get_pref_dict: bad kPkinitClientCertKey pref\n");
CFRelease(theDict);
return errSecItemNotFound;
}
*dict = theDict;
return noErr;
}
示例13: testPostGet
static bool testPostGet(CFStringRef key, CFTypeRef cfobj, dispatch_queue_t processQueue, dispatch_group_t dgroup)
{
CFErrorRef error = NULL;
bool result = false;
CFTypeRef cfv = NULL;
testPutObjectInCloud(key, cfobj, &error, dgroup, processQueue);
CFTypeRef cfvalue = testGetObjectFromCloud(key, processQueue, dgroup);
printTimeNow("finished getObjectFromCloud");
if (!cfvalue)
return false;
if (CFGetTypeID(cfvalue)==CFDictionaryGetTypeID())
cfv = CFDictionaryGetValue(cfvalue, key);
else
cfv = cfvalue;
result = CFEqual(cfobj, cfv);
return result;
}
示例14: genOSXPrefValues
void genOSXPrefValues(const CFTypeRef& value,
const Row& base,
QueryData& results,
size_t depth) {
if (value == nullptr) {
return;
}
// Since we recurse when parsing Arrays/Dicts, monitor stack limits.
if (++depth > kPreferenceDepthLimit) {
TLOG << "The macOS preference: " << base.at("domain")
<< " exceeded subkey depth limit: " << kPreferenceDepthLimit;
return;
}
// Emit a string representation for each preference type.
Row r = base;
if (CFGetTypeID(value) == CFNumberGetTypeID()) {
r["value"] = stringFromCFNumber(static_cast<CFDataRef>(value));
} else if (CFGetTypeID(value) == CFStringGetTypeID()) {
r["value"] = stringFromCFString(static_cast<CFStringRef>(value));
} else if (CFGetTypeID(value) == CFDateGetTypeID()) {
auto unix_time = CFDateGetAbsoluteTime(static_cast<CFDateRef>(value)) +
kCFAbsoluteTimeIntervalSince1970;
r["value"] = boost::lexical_cast<std::string>(std::llround(unix_time));
} else if (CFGetTypeID(value) == CFBooleanGetTypeID()) {
r["value"] = (CFBooleanGetValue(static_cast<CFBooleanRef>(value)) == TRUE)
? "true"
: "false";
} else if (CFGetTypeID(value) == CFDataGetTypeID()) {
// Do not include data preferences.
} else if (CFGetTypeID(value) == CFArrayGetTypeID()) {
genOSXListPref(static_cast<CFArrayRef>(value), base, results, depth);
return;
} else if (CFGetTypeID(value) == CFDictionaryGetTypeID()) {
// Generate a row for each hash key.
TRowResults trow(base, results, depth);
CFDictionaryApplyFunction(
static_cast<CFDictionaryRef>(value), &genOSXHashPref, &trow);
return;
}
results.push_back(std::move(r));
}
示例15: CFQPropertyListDeepApplyFunction
extern pascal void CFQPropertyListDeepApplyFunction(CFPropertyListRef propList,
CFQPropertyListDeepApplierFunction func,
void *context)
// See comment in header.
{
assert(propList != NULL);
assert(func != NULL);
// Call "func" for this node.
func(propList, context);
// If this node is a dictionary or an array, call func for
// each element.
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++) {
CFQPropertyListDeepApplyFunction(CFDictionaryGetValue( (CFDictionaryRef) propList, keys[index]), func, context);
}
free(keys);
}
}
} else if ( CFGetTypeID(propList) == CFArrayGetTypeID() ) {
CFIndex count;
long index;
count = CFArrayGetCount( (CFArrayRef) propList);
for (index = 0; index < count; index++) {
CFQPropertyListDeepApplyFunction(CFArrayGetValueAtIndex( (CFArrayRef) propList, index), func, context);
}
}
}