本文整理匯總了C++中CFStringCreateWithFormat函數的典型用法代碼示例。如果您正苦於以下問題:C++ CFStringCreateWithFormat函數的具體用法?C++ CFStringCreateWithFormat怎麽用?C++ CFStringCreateWithFormat使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CFStringCreateWithFormat函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: copy_device_support_path
CFStringRef copy_device_support_path(AMDeviceRef device) {
CFStringRef version = AMDeviceCopyValue(device, 0, CFSTR("ProductVersion"));
CFStringRef build = AMDeviceCopyValue(device, 0, CFSTR("BuildVersion"));
const char* home = getenv("HOME");
CFStringRef path;
bool found = false;
path = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s/Library/Developer/Xcode/iOS DeviceSupport/%@ (%@)"), home, version, build);
found = path_exists(path);
if (!found)
{
path = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s/Library/Developer/Xcode/iOS DeviceSupport/%@"), home, version);
found = path_exists(path);
}
if (!found)
{
path = CFStringCreateWithFormat(NULL, NULL, CFSTR("/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/%@"), version);
found = path_exists(path);
}
if (!found)
{
path = CFStringCreateWithFormat(NULL, NULL, CFSTR("/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/%@ (%@)"), version, build);
found = path_exists(path);
}
if (!found)
{
path = CFSTR("/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/Latest");
found = path_exists(path);
}
CFRelease(version);
CFRelease(build);
if (!found)
{
CFRelease(path);
printf("[ !! ] Unable to locate DeviceSupport directory.\n");
exit(1);
}
return path;
}
示例2: 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);
}
示例3: TraceKeyClassItem
static void
TraceKeyClassItem(void *token, CFStringRef keyclass, CFStringRef name, int64_t num)
{
CFStringRef key = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@.%@"), keyclass, name);
if (key) {
num = SecBucket2Significant(num);
AddKeyValuePairToKeychainLoggingTransaction(token, key, num);
CFReleaseNull(key);
}
}
示例4: CFStringCreateWithFormat
CFStringRef MonkeysAudioDecoder::CreateSourceFormatDescription() const
{
if(!IsOpen())
return nullptr;
return CFStringCreateWithFormat(kCFAllocatorDefault,
nullptr,
CFSTR("Monkey's Audio, %u channels, %u Hz"),
mSourceFormat.mChannelsPerFrame,
static_cast<unsigned int>(mSourceFormat.mSampleRate));
}
示例5: __CFLocaleCopyDescription
static CFStringRef __CFLocaleCopyDescription(CFTypeRef cf) {
CFLocaleRef locale = (CFLocaleRef)cf;
const char *type = NULL;
switch (__CFLocaleGetType(locale)) {
case __kCFLocaleOrdinary: type = "ordinary"; break;
case __kCFLocaleSystem: type = "system"; break;
case __kCFLocaleUser: type = "user"; break;
case __kCFLocaleCustom: type = "custom"; break;
}
return CFStringCreateWithFormat(CFGetAllocator(locale), NULL, CFSTR("<CFLocale %p [%p]>{type = %s, identifier = '%@'}"), cf, CFGetAllocator(locale), type, locale->_identifier);
}
示例6: cli_print_info_dict
static void cli_print_info_dict (const void *key,
const void *value,
void *context)
{
CFStringRef entry = CFStringCreateWithFormat(NULL, NULL,
CFSTR("%@:\n %@"), key, value);
if (entry) {
CFShow(entry);
CFRelease(entry);
}
}
示例7: CFStringCreateWithFormat
CFStringRef OggSpeexDecoder::CreateSourceFormatDescription() const
{
if(!IsOpen())
return NULL;
return CFStringCreateWithFormat(kCFAllocatorDefault,
NULL,
CFSTR("Ogg Speex, %u channels, %u Hz"),
mSourceFormat.mChannelsPerFrame,
static_cast<unsigned int>(mSourceFormat.mSampleRate));
}
示例8: __DAFileSystemCopyDescription
static CFStringRef __DAFileSystemCopyDescription( CFTypeRef object )
{
DAFileSystemRef filesystem = ( DAFileSystemRef ) object;
return CFStringCreateWithFormat( kCFAllocatorDefault,
NULL,
CFSTR( "<DAFileSystem %p [%p]>{id = %@}" ),
object,
CFGetAllocator( object ),
filesystem->_id );
}
示例9: DoSaveAsPDF
// this code originates from the NavServices sample code in the CarbonLib SDK
OSStatus DoSaveAsPDF(WindowRef w, void *ourDataP)
{
OSStatus err = noErr;
static NavEventUPP gNavEventProc = NULL; // event proc for our Nav Dialogs
NavDialogCreationOptions dialogOptions;
if(!gNavEventProc){
gNavEventProc = NewNavEventUPP(NavEventProc);
if(!gNavEventProc)
err = memFullErr;
}
if(!err && (( err = NavGetDefaultDialogCreationOptions( &dialogOptions )) == noErr ))
{
OurSaveDialogData *dialogDataP = NULL;
CFStringRef tempString;
CopyWindowTitleAsCFString(w, &tempString);
dialogOptions.saveFileName = CFStringCreateWithFormat(kCFAllocatorDefault, NULL,
kFileTypePDFCFStr, tempString);
CFRelease(tempString);
// make the dialog modal to our parent doc, AKA sheets
dialogOptions.parentWindow = w;
dialogOptions.modality = kWindowModalityWindowModal;
dialogDataP = (OurSaveDialogData *)malloc(sizeof(OurSaveDialogData));
if(dialogDataP){
dialogDataP->dialogRef = NULL;
dialogDataP->parentWindow = w;
dialogDataP->documentDataP = ourDataP;
err = NavCreatePutFileDialog(&dialogOptions, kFileTypePDF, kFileCreator,
gNavEventProc, dialogDataP,
&dialogDataP->dialogRef);
if (!err && dialogDataP->dialogRef != NULL)
{
err = NavDialogRun( dialogDataP->dialogRef );
if (err != noErr)
{
NavDialogDispose( dialogDataP->dialogRef );
dialogDataP->dialogRef = NULL;
free(dialogDataP);
}
}
}else
err = memFullErr;
if ( dialogOptions.saveFileName != NULL )
CFRelease( dialogOptions.saveFileName );
}
return err;
}
示例10: CFCopyDescription
// definition: produces a normally non-NULL debugging description of the object
CFStringRef CFCopyDescription(CFTypeRef cf) {
#if defined(DEBUG)
if (NULL == cf) HALT;
#endif
__CFGenericAssertIsCF(cf);
if (NULL != __CFRuntimeClassTable[__CFGenericTypeID_inline(cf)]->copyDebugDesc) {
CFStringRef result;
result = __CFRuntimeClassTable[__CFGenericTypeID_inline(cf)]->copyDebugDesc(cf);
if (NULL != result) return result;
}
return CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("<%s %p [%p]>"), __CFRuntimeClassTable[__CFGenericTypeID_inline(cf)]->className, cf, CFGetAllocator(cf));
}
示例11: odkerb_get_fabricated_im_handle
int
odkerb_get_fabricated_im_handle(ODRecordRef userRecord, CFStringRef allegedShortName, CFStringRef realm, char im_handle[], size_t im_handle_size)
{
int retval = -1;
CFArrayRef cfShortNames = NULL;
CFStringRef cfIMHandle = NULL;
CFErrorRef cfError = NULL;
CFStringRef shortName = allegedShortName;
ODKERB_PARAM_ASSERT(allegedShortName != NULL);
ODKERB_PARAM_ASSERT(realm != NULL);
ODKERB_PARAM_ASSERT(im_handle != 0);
ODKERB_PARAM_ASSERT(im_handle_size > 0);
*im_handle = '\0';
if (userRecord != NULL) {
/* attempt to get the primary short name from the user record */
cfShortNames = ODRecordCopyValues(userRecord, kODAttributeTypeRecordName, &cfError);
if (cfShortNames == NULL || cfError != NULL) {
ODKERB_LOG_CFERROR(LOG_DEBUG, "Unable to find the short names", cfError);
/* ignore this error, use the passed in allegedShortName parameter */
}
else if (CFArrayGetCount(cfShortNames) == 0) {
ODKERB_LOG_CFSTRING(LOG_DEBUG, "Unable to find the short names", allegedShortName);
/* ignore this error, use the passed in allegedShortName parameter */
}
else {
CFStringRef cfShortName = CFArrayGetValueAtIndex(cfShortNames, 0);
assert(cfShortName != 0);
shortName = cfShortName;
}
}
cfIMHandle = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%@@%@"), shortName, realm);
if (cfIMHandle == NULL) {
ODKERB_LOG_ERRNO(LOG_ERR, ENOMEM);
goto failure;
}
if (CFStringGetCString(cfIMHandle, im_handle, im_handle_size-1, kCFStringEncodingUTF8) == FALSE)
goto failure;
retval = 0;
failure:
CF_SAFE_RELEASE(cfError);
CF_SAFE_RELEASE(cfIMHandle);
CF_SAFE_RELEASE(cfShortNames);
return retval;
}
示例12: __CFNumberCopyFormattingDescription
static CFStringRef __CFNumberCopyFormattingDescription(CFTypeRef cf, CFDictionaryRef formatOptions) {
CFNumberRef number = (CFNumberRef)cf;
CFNumberType type = __CFNumberGetType(number);
if (__CFNumberTypeTable[type].floatBit) {
return _CFNumberCopyFormattingDescriptionAsFloat64(number);
}
CFSInt128Struct i;
__CFNumberGetValue(number, kCFNumberSInt128Type, &i);
char buffer[128];
__CFSInt128Format(buffer, &i, false);
return CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("%s"), buffer);
}
示例13: GetSignedIntegerBEDataAsString
CFStringRef GetSignedIntegerBEDataAsString(QTPropertyValuePtr keyValuePtr, ByteCount propValueSizeUsed)
{
require (propValueSizeUsed != 0, NULLVALUEPTR);
SInt32 *keyValAsInt = (SInt32 *)keyValuePtr;
return (CFStringCreateWithFormat( NULL, NULL,
CFSTR("%#.*x"),
propValueSizeUsed,
*keyValAsInt));
NULLVALUEPTR:
return nil;
}
示例14: CFStringCreateWithFormat
// ---------------------------------
void USys::openURL(const char *url) {
CFStringRef urlString = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s"), url);
if (urlString) {
CFURLRef pathRef = CFURLCreateWithString(NULL, urlString, NULL);
if (pathRef) {
//OSStatus err = LSOpenCFURLRef( pathRef, NULL );
CFRelease(pathRef);
}
CFRelease(urlString);
}
}
示例15: stamp_file
void stamp_file(CFStringRef inStamp)
{
time_t the_time;
char timeBuf[32]={0};
time(&the_time);
ctime_r(&the_time, timeBuf);
char* newlin=strchr(timeBuf, '\n');
if (newlin)
*newlin=0;
CFStringRef stamp = CFStringCreateWithFormat(kCFAllocatorDefault,NULL,CFSTR("\n![%@ : %s]\n"),inStamp,timeBuf);
write_buffer(stamp);
}