本文整理匯總了C++中CFNumberCreate函數的典型用法代碼示例。如果您正苦於以下問題:C++ CFNumberCreate函數的具體用法?C++ CFNumberCreate怎麽用?C++ CFNumberCreate使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CFNumberCreate函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: decode
bool decode(ArgumentDecoder* decoder, RetainPtr<CFNumberRef>& result)
{
CFNumberType numberType;
if (!decoder->decodeEnum(numberType))
return false;
CoreIPC::DataReference dataReference;
if (!decoder->decode(dataReference))
return false;
size_t neededBufferSize = sizeForNumberType(numberType);
if (!neededBufferSize || dataReference.size() != neededBufferSize)
return false;
ASSERT(dataReference.data());
CFNumberRef number = CFNumberCreate(0, numberType, dataReference.data());
result.adoptCF(number);
return true;
}
示例2: kim_os_preferences_set_lifetime_for_key
kim_error kim_os_preferences_set_lifetime_for_key (kim_preference_key in_key,
kim_lifetime in_lifetime)
{
kim_error err = KIM_NO_ERROR;
CFNumberRef value = NULL;
SInt32 number = (SInt32) in_lifetime;
if (!err) {
value = CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt32Type, &number);
if (!value) { err = KIM_OUT_OF_MEMORY_ERR; }
}
if (!err) {
err = kim_os_preferences_set_value (in_key, value);
}
if (value) { CFRelease (value); }
return check_error (err);
}
示例3: CFQDictionarySetNumber
extern pascal OSStatus CFQDictionarySetNumber(CFMutableDictionaryRef dict, const void *key, long value)
// See comment in header.
{
OSStatus err;
CFNumberRef valueNum;
// Create a CFNumber and add it to the dictionary.
err = noErr;
valueNum = CFNumberCreate(NULL, kCFNumberLongType, &value);
if (valueNum == NULL) {
err = coreFoundationUnknownErr;
}
if (err == noErr) {
CFDictionarySetValue(dict, key, valueNum);
}
CFQRelease(valueNum);
return err;
}
示例4: MovieWriterExcAlreadyFinished
void MovieWriter::Obj::addFrame( const ImageSourceRef &imageSource, float duration )
{
if( mFinished )
throw MovieWriterExcAlreadyFinished();
if( duration <= 0 )
duration = mFormat.mDefaultTime;
::CVPixelBufferRef pixelBuffer = createCvPixelBuffer( imageSource, false );
::CFNumberRef gammaLevel = CFNumberCreate( kCFAllocatorDefault, kCFNumberFloatType, &mFormat.mGamma );
::CVBufferSetAttachment( pixelBuffer, kCVImageBufferGammaLevelKey, gammaLevel, kCVAttachmentMode_ShouldPropagate );
::CFRelease( gammaLevel );
::ICMValidTimeFlags validTimeFlags = kICMValidTime_DisplayTimeStampIsValid | kICMValidTime_DisplayDurationIsValid;
::ICMCompressionFrameOptionsRef frameOptions = NULL;
int64_t durationVal = static_cast<int64_t>( duration * mFormat.mTimeBase );
OSStatus err = ::ICMCompressionSessionEncodeFrame( mCompressionSession, pixelBuffer,
mCurrentTimeValue, durationVal, validTimeFlags,
frameOptions, NULL, NULL );
mFrameTimes.push_back( std::pair<int64_t,int64_t>( mCurrentTimeValue, durationVal ) );
if( mDoingMultiPass ) {
mMultiPassFrameCache->write( (uint32_t)::CVPixelBufferGetWidth( pixelBuffer ) );
mMultiPassFrameCache->write( (uint32_t)::CVPixelBufferGetHeight( pixelBuffer ) );
mMultiPassFrameCache->write( (uint32_t)::CVPixelBufferGetPixelFormatType( pixelBuffer ) );
mMultiPassFrameCache->write( (uint32_t)::CVPixelBufferGetBytesPerRow( pixelBuffer ) );
::CVPixelBufferLockBaseAddress( pixelBuffer, 0 );
mMultiPassFrameCache->write( (uint32_t) ::CVPixelBufferGetDataSize( pixelBuffer ) );
mMultiPassFrameCache->writeData( ::CVPixelBufferGetBaseAddress( pixelBuffer ), ::CVPixelBufferGetDataSize( pixelBuffer ) );
::CVPixelBufferUnlockBaseAddress( pixelBuffer, 0 );
}
mCurrentTimeValue += durationVal;
++mNumFrames;
::CVPixelBufferRelease( pixelBuffer );
if( err )
throw MovieWriterExcFrameEncode();
}
示例5: DoGetVersion
static OSStatus DoGetVersion(
AuthorizationRef auth,
const void * userData,
CFDictionaryRef request,
CFMutableDictionaryRef response,
aslclient asl,
aslmsg aslMsg
)
// Implements the kGetVersionCommand. Returns the version number of
// the helper tool.
{
OSStatus retval = noErr;
CFNumberRef value;
static const int kCurrentVersion = kToolCurrentVersion; // something very easy to spot
asl_log(asl, aslMsg, ASL_LEVEL_DEBUG, "DoGetVersion()");
// Pre-conditions
assert(auth != NULL);
// userData may be NULL
assert(request != NULL);
assert(response != NULL);
// asl may be NULL
// aslMsg may be NULL
// Add them to the response.
value = CFNumberCreate(NULL, kCFNumberIntType, &kCurrentVersion);
if (value == NULL) {
retval = coreFoundationUnknownErr;
} else {
CFDictionaryAddValue(response, CFSTR(kGetVersionResponse), value);
}
if (value != NULL) {
CFRelease(value);
}
return retval;
}
示例6: GPDuplexClient_AddObserver
// FIXME: Make these thread-safe / re-entrant.
extern void GPDuplexClient_AddObserver(GPDuplexClientRef client, void* observer, GPDuplexClientCallback callback, SInt32 type) {
if (client != NULL) {
CFNumberRef typeNumber = CFNumberCreate(NULL, kCFNumberSInt32Type, &type);
CFMutableSetRef observerSet = (CFMutableSetRef)CFDictionaryGetValue(client->observers, typeNumber);
Boolean needRelease = false;
if (observerSet == NULL) {
needRelease = true;
observerSet = CFSetCreateMutable(NULL, 0, &kCFTypeSetCallBacks);
}
CFDataRef observerData = GPDuplexClientCreateObserver(observer, callback);
CFSetAddValue(observerSet, observerData);
CFRelease(observerData);
CFDictionarySetValue(client->observers, typeNumber, observerSet);
if (needRelease)
CFRelease(observerSet);
CFRelease(typeNumber);
}
}
示例7: CreateStringToNumDictionary
static
CFDictionaryRef CreateStringToNumDictionary()
{
int numItems = (sizeof(gValues) / sizeof(sint32));
CFMutableDictionaryRef tempDict = CFDictionaryCreateMutable(kCFAllocatorDefault, numItems, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
for (int iCnt = 0; iCnt < numItems; iCnt++)
{
sint32 aNumber = gValues[iCnt];
CFNumberRef aNum = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &aNumber);
CFStringRef aString = gKeys[iCnt];
CFDictionaryAddValue(tempDict, aString, aNum);
CFRelease(aNum);
}
CFDictionaryRef result = CFDictionaryCreateCopy(kCFAllocatorDefault, tempDict);
CFRelease(tempDict);
return result;
}
示例8: outOfSpace
bool outOfSpace(CFStringRef pathName)
{
Boolean validKey;
unsigned int minMeg;
struct statfs fileSys;
minMeg = CFPreferencesGetAppIntegerValue(MINMEG_PREF_KEY,PREF_DOMAIN,&validKey);
if (!validKey)
{
minMeg = DEFAULT_MEG;
CFPreferencesSetAppValue(MINMEG_PREF_KEY,CFNumberCreate(kCFAllocatorDefault,kCFNumberIntType,&minMeg),PREF_DOMAIN);
}
if (statfs(CFStringGetCStringPtr(pathName,CFStringGetFastestEncoding(pathName)),&fileSys))
return false;
if ((fileSys.f_bsize/1024)*(fileSys.f_bavail/1024) < minMeg)
return true;
return false;
}
示例9: static_assert
CFDictionaryRef
AppleVDADecoder::CreateOutputConfiguration()
{
// Construct IOSurface Properties
const void* IOSurfaceKeys[] = { MacIOSurfaceLib::kPropIsGlobal };
const void* IOSurfaceValues[] = { kCFBooleanTrue };
static_assert(ArrayLength(IOSurfaceKeys) == ArrayLength(IOSurfaceValues),
"Non matching keys/values array size");
// Contruct output configuration.
AutoCFRelease<CFDictionaryRef> IOSurfaceProperties =
CFDictionaryCreate(kCFAllocatorDefault,
IOSurfaceKeys,
IOSurfaceValues,
ArrayLength(IOSurfaceKeys),
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
SInt32 PixelFormatTypeValue = kCVPixelFormatType_32BGRA;
AutoCFRelease<CFNumberRef> PixelFormatTypeNumber =
CFNumberCreate(kCFAllocatorDefault,
kCFNumberSInt32Type,
&PixelFormatTypeValue);
const void* outputKeys[] = { kCVPixelBufferIOSurfacePropertiesKey,
kCVPixelBufferPixelFormatTypeKey,
kCVPixelBufferOpenGLCompatibilityKey };
const void* outputValues[] = { IOSurfaceProperties,
PixelFormatTypeNumber,
kCFBooleanTrue };
static_assert(ArrayLength(outputKeys) == ArrayLength(outputValues),
"Non matching keys/values array size");
return CFDictionaryCreate(kCFAllocatorDefault,
outputKeys,
outputValues,
ArrayLength(outputKeys),
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
}
示例10: rb_add_value_to_cf_dictionary
static void rb_add_value_to_cf_dictionary(CFMutableDictionaryRef dict, CFStringRef key, VALUE value){
switch(TYPE(value)){
case T_STRING:
{
if(!CFStringCompare(key, kSecValueData,0) || !CFStringCompare(key, kSecAttrGeneric,0)){
CFDataRef dataValue = rb_create_cf_data(value);
CFDictionarySetValue(dict,key,dataValue);
CFRelease(dataValue);
}
else{
CFStringRef stringValue = rb_create_cf_string(value);
CFDictionarySetValue(dict,key,stringValue);
CFRelease(stringValue);
}
}
break;
case T_BIGNUM:
case T_FIXNUM:
{
long long longLongValue = NUM2LL(value);
CFNumberRef numberValue = CFNumberCreate(NULL,kCFNumberLongLongType,&longLongValue);
CFDictionarySetValue(dict,key,numberValue);
CFRelease(numberValue);
break;
}
case T_DATA:
{
if(rb_obj_is_kind_of(value, rb_cTime)){
VALUE floatTime = rb_funcall(value, rb_intern("to_f"),0);
CFAbsoluteTime abstime = RFLOAT_VALUE(floatTime) - kCFAbsoluteTimeIntervalSince1970;
CFDateRef cfdate = CFDateCreate(NULL, abstime);
CFDictionarySetValue(dict, key, cfdate);
CFRelease(cfdate);
break;
}
}
default:
rb_raise(rb_eTypeError, "Can't convert value to cftype: %s", rb_obj_classname(value));
}
}
示例11: appendScopeID
static void
appendScopeID(CFMutableDictionaryRef dict, struct sockaddr_in6 *sin6)
{
CFNumberRef scope;
CFArrayRef scopes;
CFMutableArrayRef newScopes;
scopes = CFDictionaryGetValue(dict, kSCPropNetIPv6ScopeID);
if (scopes) {
newScopes = CFArrayCreateMutableCopy(NULL, 0, scopes);
} else {
newScopes = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
}
scope = CFNumberCreate(NULL, kCFNumberSInt32Type, &sin6->sin6_scope_id);
CFArrayAppendValue(newScopes, scope);
CFRelease(scope);
CFDictionarySetValue(dict, kSCPropNetIPv6ScopeID, newScopes);
CFRelease(newScopes);
return;
}
示例12: appendFlags
static void
appendFlags(CFMutableDictionaryRef dict, int flags6)
{
CFArrayRef flags;
CFMutableArrayRef newFlags;
CFNumberRef v6Flags;
flags = CFDictionaryGetValue(dict, kSCPropNetIPv6Flags);
if (flags) {
newFlags = CFArrayCreateMutableCopy(NULL, 0, flags);
} else {
newFlags = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
}
v6Flags = CFNumberCreate(NULL, kCFNumberIntType, &flags6);
CFArrayAppendValue(newFlags, v6Flags);
CFRelease(v6Flags);
CFDictionarySetValue(dict, kSCPropNetIPv6Flags, newFlags);
CFRelease(newFlags);
return;
}
示例13: adoptCF
CFDictionaryRef Font::getCFStringAttributes(bool enableKerning, FontOrientation orientation) const
{
auto& attributesDictionary = enableKerning ? m_kernedCFStringAttributes : m_nonKernedCFStringAttributes;
if (attributesDictionary)
return attributesDictionary.get();
attributesDictionary = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 4, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
CFMutableDictionaryRef mutableAttributes = (CFMutableDictionaryRef)attributesDictionary.get();
CFDictionarySetValue(mutableAttributes, kCTFontAttributeName, platformData().ctFont());
if (!enableKerning) {
const float zero = 0;
static CFNumberRef zeroKerningValue = CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &zero);
CFDictionarySetValue(mutableAttributes, kCTKernAttributeName, zeroKerningValue);
}
if (orientation == Vertical)
CFDictionarySetValue(mutableAttributes, kCTVerticalFormsAttributeName, kCFBooleanTrue);
return attributesDictionary.get();
}
示例14: DisconnectFromSkype
void DisconnectFromSkype(void)
{
CFNotificationCenterRef center = CFNotificationCenterGetDistributedCenter();
if (client_id)
{
CFNumberRef id_number = CFNumberCreate(NULL, kCFNumberIntType, &client_id);
const void *keys[] = {(void *)CFSTR("SKYPE_API_CLIENT_ID")};
const void *values[] = {id_number};
CFDictionaryRef userInfo = CFDictionaryCreate(NULL, keys, values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
//disconnect
CFNotificationCenterPostNotification(
center,
CFSTR("SKSkypeAPIDetachRequest"),
NULL,
userInfo,
FALSE);
client_id = 0;
}
}
示例15: os_updateindicators
void os_updateindicators(usbdevice* kb, int force){
// Set NumLock on permanently
char ileds = 1;
// Set Caps Lock if enabled. Unlike Linux, OSX keyboards have independent caps lock states, so
// we use the last-assigned value rather than fetching it from the system
if(kb->modifiers & kCGEventFlagMaskAlphaShift)
ileds |= 2;
kb->hw_ileds = ileds;
if(kb->active){
usbmode* mode = kb->profile->currentmode;
ileds = (ileds & ~mode->ioff) | mode->ion;
}
if(force || ileds != kb->ileds){
kb->ileds = ileds;
// Get a list of LED elements from handle 0
long ledpage = kHIDPage_LEDs;
const void* keys[] = { CFSTR(kIOHIDElementUsagePageKey) };
const void* values[] = { CFNumberCreate(kCFAllocatorDefault, kCFNumberLongType, &ledpage) };
CFDictionaryRef matching = CFDictionaryCreate(kCFAllocatorDefault, keys, values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFRelease(values[0]);
CFArrayRef leds;
kern_return_t res = (*kb->handles[0])->copyMatchingElements(kb->handles[0], matching, &leds, 0);
CFRelease(matching);
if(res != kIOReturnSuccess)
return;
// Iterate through them and update the LEDs which have changed
DELAY_SHORT(kb);
CFIndex count = CFArrayGetCount(leds);
for(CFIndex i = 0; i < count; i++){
IOHIDElementRef led = (void*)CFArrayGetValueAtIndex(leds, i);
uint32_t usage = IOHIDElementGetUsage(led);
IOHIDValueRef value = IOHIDValueCreateWithIntegerValue(kCFAllocatorDefault, led, 0, !!(ileds & (1 << (usage - 1))));
(*kb->handles[0])->setValue(kb->handles[0], led, value, 5000, 0, 0, 0);
CFRelease(value);
}
CFRelease(leds);
}
}