本文整理匯總了C++中CFStringAppendFormat函數的典型用法代碼示例。如果您正苦於以下問題:C++ CFStringAppendFormat函數的具體用法?C++ CFStringAppendFormat怎麽用?C++ CFStringAppendFormat使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CFStringAppendFormat函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: __CFArrayCopyDescription
static CFStringRef __CFArrayCopyDescription(CFTypeRef cf) {
CFArrayRef array = (CFArrayRef)cf;
CFMutableStringRef result;
const CFArrayCallBacks *cb;
CFAllocatorRef allocator;
CFIndex idx, cnt;
cnt = __CFArrayGetCount(array);
allocator = CFGetAllocator(array);
result = CFStringCreateMutable(allocator, 0);
switch (__CFArrayGetType(array)) {
case __kCFArrayImmutable:
CFStringAppendFormat(result, NULL, CFSTR("<CFArray %p [%p]>{type = immutable, count = %lu, values = (%s"), cf, allocator, (unsigned long)cnt, cnt ? "\n" : "");
break;
case __kCFArrayDeque:
CFStringAppendFormat(result, NULL, CFSTR("<CFArray %p [%p]>{type = mutable-small, count = %lu, values = (%s"), cf, allocator, (unsigned long)cnt, cnt ? "\n" : "");
break;
}
cb = __CFArrayGetCallBacks(array);
for (idx = 0; idx < cnt; idx++) {
CFStringRef desc = NULL;
const void *val = __CFArrayGetBucketAtIndex(array, idx)->_item;
if (NULL != cb->copyDescription) {
desc = (CFStringRef)INVOKE_CALLBACK1(cb->copyDescription, val);
}
if (NULL != desc) {
CFStringAppendFormat(result, NULL, CFSTR("\t%lu : %@\n"), (unsigned long)idx, desc);
CFRelease(desc);
} else {
CFStringAppendFormat(result, NULL, CFSTR("\t%lu : <%p>\n"), (unsigned long)idx, val);
}
}
CFStringAppend(result, CFSTR(")}"));
return result;
}
示例2: rlsCopyDescription
static CFStringRef
rlsCopyDescription(const void *info)
{
CFMutableStringRef result;
SCDynamicStoreRef store = (SCDynamicStoreRef)info;
SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store;
result = CFStringCreateMutable(NULL, 0);
CFStringAppendFormat(result, NULL, CFSTR("<SCDynamicStore RLS> {"));
CFStringAppendFormat(result, NULL, CFSTR("store = %p"), store);
if (storePrivate->notifyStatus == Using_NotifierInformViaRunLoop) {
CFStringRef description = NULL;
CFStringAppendFormat(result, NULL, CFSTR(", callout = %p"), storePrivate->rlsFunction);
if ((storePrivate->rlsContext.info != NULL) && (storePrivate->rlsContext.copyDescription != NULL)) {
description = (*storePrivate->rlsContext.copyDescription)(storePrivate->rlsContext.info);
}
if (description == NULL) {
description = CFStringCreateWithFormat(NULL, NULL, CFSTR("<SCDynamicStore context %p>"), storePrivate->rlsContext.info);
}
if (description == NULL) {
description = CFRetain(CFSTR("<no description>"));
}
CFStringAppendFormat(result, NULL, CFSTR(", context = %@"), description);
CFRelease(description);
}
CFStringAppendFormat(result, NULL, CFSTR("}"));
return result;
}
示例3: ipv6_duplicated_address
__private_extern__
void
ipv6_duplicated_address(const char * if_name, const struct in6_addr * addr,
int hw_len, const void * hw_addr)
{
uint8_t * hw_addr_bytes = (uint8_t *)hw_addr;
int i;
CFStringRef if_name_cf;
CFMutableStringRef key;
char ntopbuf[INET6_ADDRSTRLEN];
CFStringRef prefix;
if_name_cf = CFStringCreateWithCString(NULL, if_name,
kCFStringEncodingASCII);
prefix = SCDynamicStoreKeyCreateNetworkInterfaceEntity(NULL,
kSCDynamicStoreDomainState,
if_name_cf,
kSCEntNetIPv6DuplicatedAddress);
ntopbuf[0] = '\0';
(void)inet_ntop(AF_INET6, addr, ntopbuf, sizeof(ntopbuf));
key = CFStringCreateMutableCopy(NULL, 0, prefix);
CFStringAppendFormat(key, NULL, CFSTR("/%s"), ntopbuf);
for (i = 0; i < hw_len; i++) {
CFStringAppendFormat(key, NULL, CFSTR("%s%02x"),
(i == 0) ? "/" : ":", hw_addr_bytes[i]);
}
cache_SCDynamicStoreNotifyValue(store, key);
CFRelease(key);
CFRelease(prefix);
CFRelease(if_name_cf);
}
示例4: __CFSetCopyDescription
static CFStringRef __CFSetCopyDescription(CFTypeRef cf) {
CFSetRef set = (CFSetRef)cf;
const CFSetCallBacks *cb;
const struct __CFSetBucket *buckets;
CFIndex idx, nbuckets;
CFMutableStringRef result;
cb = __CFSetGetCallBacks(set);
buckets = set->_buckets;
nbuckets = set->_bucketsNum;
result = CFStringCreateMutable(kCFAllocatorSystemDefault, 0);
CFStringAppendFormat(result, NULL, CFSTR("<CFSet %p [%p]>{count = %u, capacity = %u, values = (\n"), set, CFGetAllocator(set), set->_count, set->_capacity);
for (idx = 0; idx < nbuckets; idx++) {
if (__CFSetBucketIsOccupied(set, &buckets[idx])) {
CFStringRef desc = NULL;
if (NULL != cb->copyDescription) {
desc = (CFStringRef)INVOKE_CALLBACK2(((CFStringRef (*)(const void *, void *))cb->copyDescription), buckets[idx]._key, set->_context);
}
if (NULL != desc) {
CFStringAppendFormat(result, NULL, CFSTR("\t%u : %@\n"), idx, desc, NULL);
CFRelease(desc);
} else {
CFStringAppendFormat(result, NULL, CFSTR("\t%u : <%p>\n"), idx, buckets[idx]._key, NULL);
}
}
}
CFStringAppend(result, CFSTR(")}"));
return result;
}
示例5: format_message
static VALUE
format_message(VALUE exc)
{
CFMutableStringRef result = CFStringCreateMutable(NULL, 0);
VALUE message = rb_vm_call(exc, sel_registerName("message"), 0, NULL);
VALUE bt = rb_vm_call(exc, sel_registerName("backtrace"), 0, NULL);
message = rb_check_string_type(message);
const char *msg = message == Qnil ? "" : RSTRING_PTR(message);
const long count = (bt != Qnil ? RARRAY_LEN(bt) : 0);
if (count > 0) {
for (long i = 0; i < count; i++) {
const char *bte = RSTRING_PTR(RARRAY_AT(bt, i));
if (i == 0) {
CFStringAppendFormat(result, NULL, CFSTR("%s: %s (%s)\n"),
bte, msg, rb_class2name(*(VALUE *)exc));
}
else {
CFStringAppendFormat(result, NULL, CFSTR("\tfrom %s\n"), bte);
}
}
}
else {
CFStringAppendFormat(result, NULL, CFSTR("%s (%s)\n"),
msg, rb_class2name(*(VALUE *)exc));
}
CFMakeCollectable(result);
return (VALUE)result;
}
示例6: __CFBinaryHeapCopyDescription
static CFStringRef __CFBinaryHeapCopyDescription(CFTypeRef cf) {
CFBinaryHeapRef heap = (CFBinaryHeapRef)cf;
CFMutableStringRef result;
CFIndex idx;
CFIndex cnt;
const void **list, *buffer[256];
cnt = __CFBinaryHeapCount(heap);
result = CFStringCreateMutable(CFGetAllocator(heap), 0);
CFStringAppendFormat(result, NULL, CFSTR("<CFBinaryHeap %p [%p]>{count = %lu, capacity = %lu, objects = (\n"), cf, CFGetAllocator(heap), (unsigned long)cnt, (unsigned long)__CFBinaryHeapCapacity(heap));
list = (cnt <= 128) ? (const void **)buffer : (const void **)CFAllocatorAllocate(kCFAllocatorSystemDefault, cnt * sizeof(void *), 0); // GC OK
if (__CFOASafe && list != buffer) __CFSetLastAllocationEventName(list, "CFBinaryHeap (temp)");
CFBinaryHeapGetValues(heap, list);
for (idx = 0; idx < cnt; idx++) {
CFStringRef desc = NULL;
const void *item = list[idx];
if (NULL != heap->_callbacks.copyDescription) {
desc = heap->_callbacks.copyDescription(item);
}
if (NULL != desc) {
CFStringAppendFormat(result, NULL, CFSTR("\t%lu : %@\n"), (unsigned long)idx, desc);
CFRelease(desc);
} else {
CFStringAppendFormat(result, NULL, CFSTR("\t%lu : <%p>\n"), (unsigned long)idx, item);
}
}
CFStringAppend(result, CFSTR(")}"));
if (list != buffer) CFAllocatorDeallocate(CFGetAllocator(heap), list); // GC OK
return result;
}
示例7: __CFDataCopyDescription
static CFStringRef __CFDataCopyDescription(CFTypeRef cf) {
CFDataRef data = (CFDataRef)cf;
CFMutableStringRef result;
CFIndex idx;
CFIndex len;
const uint8_t *bytes;
len = __CFDataLength(data);
bytes = CFDataGetBytePtr(data);
result = CFStringCreateMutable(CFGetAllocator(data), 0);
CFStringAppendFormat(result, NULL, CFSTR("<CFData %p [%p]>{length = %u, capacity = %u, bytes = 0x"), cf, CFGetAllocator(data), len, __CFDataCapacity(data));
if (24 < len) {
for (idx = 0; idx < 16; idx += 4) {
CFStringAppendFormat(result, NULL, CFSTR("%02x%02x%02x%02x"), bytes[idx], bytes[idx + 1], bytes[idx + 2], bytes[idx + 3]);
}
CFStringAppend(result, CFSTR(" ... "));
for (idx = len - 8; idx < len; idx += 4) {
CFStringAppendFormat(result, NULL, CFSTR("%02x%02x%02x%02x"), bytes[idx], bytes[idx + 1], bytes[idx + 2], bytes[idx + 3]);
}
} else {
for (idx = 0; idx < len; idx++) {
CFStringAppendFormat(result, NULL, CFSTR("%02x"), bytes[idx]);
}
}
CFStringAppend(result, CFSTR("}"));
return result;
}
示例8: CGPathToCFStringApplierFunction
static void CGPathToCFStringApplierFunction(void* info, const CGPathElement *element)
{
CFMutableStringRef string = (CFMutableStringRef)info;
CFStringRef typeString = CFSTR("");
CGPoint* points = element->points;
switch (element->type) {
case kCGPathElementMoveToPoint:
CFStringAppendFormat(string, 0, CFSTR("M%.2f,%.2f "), points[0].x, points[0].y);
break;
case kCGPathElementAddLineToPoint:
CFStringAppendFormat(string, 0, CFSTR("L%.2f,%.2f "), points[0].x, points[0].y);
break;
case kCGPathElementAddQuadCurveToPoint:
CFStringAppendFormat(string, 0, CFSTR("Q%.2f,%.2f,%.2f,%.2f "),
points[0].x, points[0].y, points[1].x, points[1].y);
break;
case kCGPathElementAddCurveToPoint:
CFStringAppendFormat(string, 0, CFSTR("C%.2f,%.2f,%.2f,%.2f,%.2f,%.2f "),
points[0].x, points[0].y, points[1].x, points[1].y,
points[2].x, points[2].y);
break;
case kCGPathElementCloseSubpath:
typeString = CFSTR("X"); break;
}
}
示例9: _CFErrorCreateDebugDescription
/* The "debug" description, used by CFCopyDescription and -[NSObject description].
*/
CFStringRef _CFErrorCreateDebugDescription(CFErrorRef err) {
CFMutableStringRef result = CFStringCreateMutable(
kCFAllocatorSystemDefault, 0);
CFStringAppendFormat(
result, NULL,
CFSTR("Error Domain=%@ Code=%d"),
CFErrorGetDomain(err), (int)CFErrorGetCode(err));
CFDictionaryRef userInfo = _CFErrorGetUserInfo(err);
if (userInfo) {
CFStringAppendFormat(result, NULL, CFSTR(" UserInfo=%p"), userInfo);
}
CFStringRef desc = CFErrorCopyDescription(err);
if (desc) {
CFStringAppendFormat(result, NULL, CFSTR(" \"%@\""), desc);
CFRelease(desc);
}
CFStringRef debugDesc = _CFErrorCopyUserInfoKey(err, kCFErrorDebugDescriptionKey);
if (debugDesc) {
if (CFStringGetLength(debugDesc) > 0) {
CFStringAppendFormat(result, NULL, CFSTR(" (%@)"), debugDesc);
}
CFRelease(debugDesc);
}
return result;
}
示例10: userInfoKeyValueShow
/* The "debug" description, used by CFCopyDescription and -[NSObject description].
*/
static void userInfoKeyValueShow(const void *key, const void *value, void *context) {
CFStringRef desc;
if (CFEqual(key, kCFErrorUnderlyingErrorKey) && (desc = CFErrorCopyDescription((CFErrorRef)value))) { // We check desc, see <rdar://problem/8415727>
CFStringAppendFormat((CFMutableStringRef)context, NULL, CFSTR("%@=%p \"%@\", "), key, value, desc);
CFRelease(desc);
} else {
CFStringAppendFormat((CFMutableStringRef)context, NULL, CFSTR("%@=%@, "), key, value);
}
}
示例11: __SCPreferencesCopyDescription
static CFStringRef
__SCPreferencesCopyDescription(CFTypeRef cf) {
CFAllocatorRef allocator = CFGetAllocator(cf);
SCPreferencesPrivateRef prefsPrivate = (SCPreferencesPrivateRef)cf;
CFMutableStringRef result;
result = CFStringCreateMutable(allocator, 0);
CFStringAppendFormat(result, NULL, CFSTR("<SCPreferences %p [%p]> {"), cf, allocator);
CFStringAppendFormat(result, NULL, CFSTR("name = %@"), prefsPrivate->name);
CFStringAppendFormat(result, NULL, CFSTR(", id = %@"), prefsPrivate->prefsID);
CFStringAppendFormat(result, NULL, CFSTR(", path = %s"),
prefsPrivate->newPath ? prefsPrivate->newPath : prefsPrivate->path);
if (prefsPrivate->accessed) {
CFStringAppendFormat(result, NULL, CFSTR(", accessed"));
}
if (prefsPrivate->changed) {
CFStringAppendFormat(result, NULL, CFSTR(", changed"));
}
if (prefsPrivate->locked) {
CFStringAppendFormat(result, NULL, CFSTR(", locked"));
}
if (prefsPrivate->helper_port != MACH_PORT_NULL) {
CFStringAppendFormat(result, NULL, CFSTR(", helper port = 0x%x"), prefsPrivate->helper_port);
}
CFStringAppendFormat(result, NULL, CFSTR("}"));
return result;
}
示例12: __ACSharedArtImageSourceCopyFormat
static CFStringRef __ACSharedArtImageSourceCopyFormat(CFTypeRef cf, CFDictionaryRef format)
{
ACSharedArtImageSourceRef isrc = (ACSharedArtImageSourceRef) cf;
CFMutableStringRef description = CFStringCreateMutable(kCFAllocatorDefault,0);
CFStringAppendFormat(description,NULL,CFSTR("Type: %d EntryCount: %d\n"),isrc->header->type,isrc->header->entryCount);
for (int i = 0; i < isrc->header->entryCount; i++)
{
struct __ACSharedArtImageHeaderDataInfo dataInfoAtIndex = isrc->header->data_info[i];
CFStringAppendFormat(description,NULL,CFSTR("\tImage %d Size: %dx%d Length: %d @ %d \n"),i,dataInfoAtIndex.width,dataInfoAtIndex.height,
dataInfoAtIndex.length,dataInfoAtIndex.relativeOffset);
}
return (CFStringRef) description;
}
示例13: SOSCoderStart
// Start OTR negotiation if we haven't already done so.
SOSCoderStatus
SOSCoderStart(SOSCoderRef coder, CFErrorRef *error) {
CFMutableStringRef action = CFStringCreateMutable(kCFAllocatorDefault, 0);
CFStringRef beginState = NULL;
SOSCoderStatus result = kSOSCoderFailure;
CFMutableDataRef startPacket = NULL;
require_action_quiet(coder->sessRef, coderFailure, CFStringAppend(action, CFSTR("*** no otr session ***")));
beginState = CFCopyDescription(coder->sessRef);
require_action_quiet(!coder->waitingForDataPacket, negotiatingOut, CFStringAppend(action, CFSTR("waiting for peer to send first data packet")));
require_action_quiet(!SecOTRSGetIsReadyForMessages(coder->sessRef), coderFailure, CFStringAppend(action, CFSTR("otr session ready"));
result = kSOSCoderDataReturned);
require_action_quiet(SecOTRSGetIsIdle(coder->sessRef), negotiatingOut, CFStringAppend(action, CFSTR("otr negotiating already")));
require_action_quiet(startPacket = CFDataCreateMutable(kCFAllocatorDefault, 0), coderFailure, SOSCreateError(kSOSErrorAllocationFailure, CFSTR("alloc failed"), NULL, error));
require_quiet(SOSOTRSAppendStartPacket(coder->sessRef, startPacket, error), coderFailure);
CFRetainAssign(coder->pendingResponse, startPacket);
negotiatingOut:
result = kSOSCoderNegotiating;
coderFailure:
// Uber state log
if (result == kSOSCoderFailure && error && *error)
CFStringAppendFormat(action, NULL, CFSTR(" %@"), *error);
secnotice("coder", "%@ %s %@ %@ returned %s", beginState,
SecOTRPacketTypeString(startPacket), action, coder->sessRef, SOSCoderString(result));
CFReleaseNull(startPacket);
CFReleaseSafe(beginState);
CFRelease(action);
return result;
}
示例14: __SCBondStatusCopyDescription
static CFStringRef
__SCBondStatusCopyDescription(CFTypeRef cf)
{
CFAllocatorRef allocator = CFGetAllocator(cf);
CFMutableStringRef result;
SCBondStatusPrivateRef statusPrivate = (SCBondStatusPrivateRef)cf;
result = CFStringCreateMutable(allocator, 0);
CFStringAppendFormat(result, NULL, CFSTR("<SCBondStatus %p [%p]> {"), cf, allocator);
CFStringAppendFormat(result, NULL, CFSTR(" bond = %@"), statusPrivate->bond);
CFStringAppendFormat(result, NULL, CFSTR(", interface = %@"), statusPrivate->status_bond);
CFStringAppendFormat(result, NULL, CFSTR(", members = %@"), statusPrivate->status_interfaces);
CFStringAppendFormat(result, NULL, CFSTR(" }"));
return result;
}
示例15: run
static int run(CFArrayRef argv) {
if (CFArrayGetCount(argv) > 1) return -1;
CFStringRef build = DBGetCurrentBuild();
CFStringRef project = NULL;
CFDictionaryRef projectEnv = NULL;
CFDictionaryRef globalEnv = DBCopyPropDictionary(build, NULL, CFSTR("environment"));
if (CFArrayGetCount(argv) == 1) {
project = CFArrayGetValueAtIndex(argv, 0);
projectEnv = DBCopyPropDictionary(build, project, CFSTR("environment"));
}
CFMutableDictionaryRef env = NULL;
if (globalEnv && projectEnv) {
env = (CFMutableDictionaryRef)mergeDictionaries(projectEnv, globalEnv);
} else if (globalEnv) {
env = (CFMutableDictionaryRef)globalEnv;
} else if (projectEnv) {
env = (CFMutableDictionaryRef)projectEnv;
} else {
return 0;
}
// Auto-generate some variables based on RC_ARCHS and RC_NONARCH_CFLAGS
// RC_CFLAGS=$RC_NONARCH_CFLAGS -arch ${arch}
// RC_${arch}=YES
CFStringRef str = CFDictionaryGetValue(env, CFSTR("RC_NONARCH_CFLAGS"));
if (!str) str = CFSTR("");
CFMutableStringRef cflags = CFStringCreateMutableCopy(NULL, 0, str);
str = CFDictionaryGetValue(env, CFSTR("RC_ARCHS"));
if (str) {
CFMutableStringRef trimmed = CFStringCreateMutableCopy(NULL, 0, str);
CFStringTrimWhitespace(trimmed);
CFArrayRef archs = tokenizeString(trimmed);
CFIndex i, count = CFArrayGetCount(archs);
for (i = 0; i < count; ++i) {
CFStringRef arch = CFArrayGetValueAtIndex(archs, i);
// -arch ${arch}
CFStringAppendFormat(cflags, NULL, CFSTR(" -arch %@"), arch);
// RC_${arch}=YES
CFStringRef name = CFStringCreateWithFormat(NULL, NULL, CFSTR("RC_%@"), arch);
CFDictionarySetValue(env, name, CFSTR("YES"));
CFRelease(name);
}
CFRelease(trimmed);
}
CFDictionarySetValue(env, CFSTR("RC_CFLAGS"), cflags);
// print variables to stdout
CFArrayRef keys = dictionaryGetSortedKeys(env);
CFIndex i, count = CFArrayGetCount(keys);
for (i = 0; i < count; ++i) {
CFStringRef name = CFArrayGetValueAtIndex(keys, i);
CFStringRef value = CFDictionaryGetValue(env, name);
cfprintf(stdout, "%@=%@\n", name, value);
}
return 0;
}