當前位置: 首頁>>代碼示例>>C++>>正文


C++ CFStringCreateMutableCopy函數代碼示例

本文整理匯總了C++中CFStringCreateMutableCopy函數的典型用法代碼示例。如果您正苦於以下問題:C++ CFStringCreateMutableCopy函數的具體用法?C++ CFStringCreateMutableCopy怎麽用?C++ CFStringCreateMutableCopy使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了CFStringCreateMutableCopy函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: CFURLCopyFileSystemPath

void TestController::initializeInjectedBundlePath()
{
    CFStringRef exeContainerPath = CFURLCopyFileSystemPath(CFURLCreateCopyDeletingLastPathComponent(0, CFBundleCopyExecutableURL(CFBundleGetMainBundle())), kCFURLWindowsPathStyle);
    CFMutableStringRef bundlePath = CFStringCreateMutableCopy(0, 0, exeContainerPath);
    CFStringAppendCString(bundlePath, injectedBundleDLL, kCFStringEncodingWindowsLatin1);
    m_injectedBundlePath.adopt(WKStringCreateWithCFString(bundlePath));
}
開發者ID:SchleunigerAG,項目名稱:WinEC7_Qt5.3.1_Fixes,代碼行數:7,代碼來源:TestControllerWin.cpp

示例2: convertChars

int convertChars(char *from, int fromLen, void *fromCode, char *to, int toLen, void *toCode, int norm, int term)
{
  CFStringRef	     cfs= CFStringCreateWithBytes(NULL, (UInt8 *) from, fromLen, (CFStringEncoding)fromCode, 0);
  if (cfs == NULL) {
      toLen = 0;
	  to[toLen]= '\0';
	  return toLen;
	}
	
  CFMutableStringRef str= CFStringCreateMutableCopy(NULL, 0, cfs);
  CFRelease(cfs);
  if (norm) // HFS+ imposes Unicode2.1 decomposed UTF-8 encoding on all path elements
    CFStringNormalize(str, kCFStringNormalizationFormD); // canonical decomposition
  else
    CFStringNormalize(str, kCFStringNormalizationFormC); // pre-combined
  {
    CFRange rng= CFRangeMake(0, CFStringGetLength(str));
    CFIndex len= 0;
    CFIndex num= CFStringGetBytes(str, rng, (CFStringEncoding)toCode, '?', 0, (UInt8 *)to, toLen - term, &len);
    CFRelease(str);
    if (!num)
      return convertCopy(from, fromLen, to, toLen, term);
    if (term)
      to[len]= '\0';
    return len;
  }
}
開發者ID:Geal,項目名稱:Squeak-VM,代碼行數:27,代碼來源:sqMacUnixFileInterface.c

示例3: PathToFileViaFSRef

void PathToFileViaFSRef(char *pathName, int pathNameMax, FSRef *theFSRef,CFStringEncoding encoding) {        
        CFURLRef sillyThing;
        CFStringRef filePath;
        Boolean isDirectory;
		
		pathName[0]=  0x00;
        sillyThing =  CFURLCreateFromFSRef (kCFAllocatorDefault, theFSRef);
		if (sillyThing == NULL)
			return;
        isDirectory = CFURLHasDirectoryPath(sillyThing);
        
        filePath = CFURLCopyFileSystemPath (sillyThing, kCFURLPOSIXPathStyle);
        CFRelease(sillyThing);
        
  		CFMutableStringRef mutableStr= CFStringCreateMutableCopy(NULL, 0, filePath);
          CFRelease(filePath);
  
  		// HFS+ imposes Unicode2.1 decomposed UTF-8 encoding on all path elements
  		if (encoding == kCFStringEncodingUTF8) 
  			CFStringNormalize(mutableStr, kCFStringNormalizationFormC); // pre-combined
  
          CFStringGetCString (mutableStr, pathName,pathNameMax, encoding);
			CFRelease(mutableStr);
        
        if (isDirectory)
            strcat(pathName,"/");
}
開發者ID:Geal,項目名稱:Squeak-VM,代碼行數:27,代碼來源:sqMacUnixFileInterface.c

示例4: setPlayerWinTitle

bool setPlayerWinTitle(CFStringRef sTitle)
{
    CFMutableStringRef sFinalStr = NULL;
    OSStatus iErr = noErr;

    if (NULL == (sFinalStr = CFStringCreateMutableCopy(NULL, 8 + CFStringGetLength(sTitle), CFSTR("Frogg - "))))
    {
        fprintf(stderr, "setPlayerWinTitle() - CFStringCreateMutableCopy() failed!\n");
        return false;
    }
    else
    {
        CFStringAppend(sFinalStr, sTitle);

        if (noErr != (iErr = SetWindowTitleWithCFString(g_refPlayerWin, sFinalStr)))
        {
            CFRelease(sFinalStr);
            fprintf(stderr, "setPlayerWinTitle() - SetWindowTitleWithCFString() failed, returning %lu!\n", (unsigned long) iErr);
            return false;
        }
        
        CFRelease(sFinalStr);
        return true;
    }
}
開發者ID:ullerrm,項目名稱:frogg,代碼行數:25,代碼來源:PlayerWin.cpp

示例5: 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);
}
開發者ID:carriercomm,項目名稱:osx-2,代碼行數:31,代碼來源:ev_ipv6.c

示例6: CFBundleCopyLocalizedStringForLocalization

CF_EXPORT CFStringRef CFBundleCopyLocalizedStringForLocalization(CFBundleRef bundle, CFStringRef key, CFStringRef value, CFStringRef tableName, CFStringRef localizationName) {
    if (!key) { return (value ? (CFStringRef)CFRetain(value) : (CFStringRef)CFRetain(CFSTR(""))); }
    
    // Make sure to check the mixed localizations key early -- if the main bundle has not yet been cached, then we need to create the cache of the Info.plist before we start asking for resources (11172381)
    (void)CFBundleAllowMixedLocalizations();
    
    if (!tableName || CFEqual(tableName, CFSTR(""))) tableName = _CFBundleDefaultStringTableName;
    
    CFStringRef result = _copyStringFromTable(bundle, tableName, key, localizationName);
    
    if (!result) {
        if (!value) {
            result = (CFStringRef)CFRetain(key);
        } else if (CFEqual(value, CFSTR(""))) {
            result = (CFStringRef)CFRetain(key);
        } else {
            result = (CFStringRef)CFRetain(value);
        }
        static Boolean capitalize = false;
        if (capitalize) {
            CFMutableStringRef capitalizedResult = CFStringCreateMutableCopy(kCFAllocatorSystemDefault, 0, result);
            os_log_error(_CFBundleLocalizedStringLogger(), "ERROR: %@ not found in table %@ of bundle %@", key, tableName, bundle);
            CFStringUppercase(capitalizedResult, NULL);
            CFRelease(result);
            result = capitalizedResult;
        }
    }
    os_log_debug(_CFBundleLocalizedStringLogger(), "Bundle: %{private}@, key: %{public}@, value: %{public}@, table: %{public}@, localizationName: %{public}@, result: %{public}@", bundle, key, value, tableName, localizationName, result);
    return result;
}
開發者ID:JGiola,項目名稱:swift-corelibs-foundation,代碼行數:30,代碼來源:CFBundle_Strings.c

示例7: AudioComponentCopyName

void 		CAComponent::SetCompNames () const
{
	if (!mCompName) {
	
		CFStringRef compName;
		OSStatus result = AudioComponentCopyName (Comp(), &compName);
		if (result) return;
		
		const_cast<CAComponent*>(this)->mCompName = compName;
		if (compName)
		{
			CFArrayRef splitStrArray = CFStringCreateArrayBySeparatingStrings(NULL, compName, CFSTR(":"));
			
			// we need to retain these values so the strings are not lost when the array is released
			const_cast<CAComponent*>(this)->mManuName = (CFStringRef)CFArrayGetValueAtIndex(splitStrArray, 0);
            CFRetain(this->mManuName);
			if (CFArrayGetCount(splitStrArray) > 1)
			{
				CFStringRef str = (CFStringRef)CFArrayGetValueAtIndex(splitStrArray, 1);
				
				CFMutableStringRef mstr = CFStringCreateMutableCopy (NULL, CFStringGetLength(str), str);

				// this needs to trim out white space:
				
				CFStringTrimWhitespace (mstr);
			
				const_cast<CAComponent*>(this)->mAUName = mstr;
			} else
				const_cast<CAComponent*>(this)->mAUName = NULL;
			
			CFRelease(splitStrArray);
		}
	}
}
開發者ID:AdamDiment,項目名稱:CocoaSampleCode,代碼行數:34,代碼來源:CAComponent.cpp

示例8: TargetNameCreatedWithHostName

/* 
 * Create the target name using the host name. Note we will use the 
 * GSS_C_NT_HOSTBASE name type of [email protected]<server> and will return a CFString
 */
CFStringRef TargetNameCreatedWithHostName(struct smb_ctx *ctx)
{
	CFStringRef hostName;
	CFMutableStringRef kerbHintsHostname;
	
	/* We need to add "[email protected] server part" */
	kerbHintsHostname = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, 
												  CFSTR("[email protected]"));
	if (kerbHintsHostname == NULL) {
		return NULL;
	}
	/*
	 * The old code would return an IP dot address if the name was NetBIOS. This
	 * was done for Leopard gss. After talking this over with LHA we now always
	 * return the server name. The IP dot address never worked and was causing
	 * Dfs links to fail.
	 */
	hostName = CFStringCreateWithCString(kCFAllocatorDefault, ctx->serverName, kCFStringEncodingUTF8);
	if (hostName) {
		CFStringAppend(kerbHintsHostname, hostName);
		CFRelease(hostName);
	} else {
		CFRelease(kerbHintsHostname);
		kerbHintsHostname = NULL;
	}
	return kerbHintsHostname;
}
開發者ID:B1NG0,項目名稱:cifs,代碼行數:31,代碼來源:gss.c

示例9: _CFPreferencesGetByHostIdentifierString

__private_extern__ CFStringRef _CFPreferencesGetByHostIdentifierString(void) {
    static CFStringRef __byHostIdentifierString = NULL;

    if (!__byHostIdentifierString) {
        CFStringRef hostID = _CFGetHostUUIDString();
        if (hostID) {
            if (CFStringHasPrefix(hostID, CFSTR("00000000-0000-1000-8000-"))) {
                // If the host UUID is prefixed by "00000000-0000-1000-8000-" then the UUID returned is the "compatible" type. The last field of the string will be the MAC address of the primary ethernet interface of the computer. We use this for compatibility with existing by-host preferences.
                CFStringRef lastField = CFStringCreateWithSubstring(kCFAllocatorSystemDefault, hostID, CFRangeMake(24, 12));
                CFMutableStringRef tmpstr = CFStringCreateMutableCopy(kCFAllocatorSystemDefault, 0, lastField);
                CFStringLowercase(tmpstr, NULL);
                CFStringRef downcasedField = CFStringCreateCopy(kCFAllocatorSystemDefault, tmpstr);
                
                if (!OSAtomicCompareAndSwapPtrBarrier(NULL, (void *)downcasedField, (void *)&__byHostIdentifierString)) {
                    CFRelease(downcasedField);
                }
                
                CFRelease(tmpstr);
                CFRelease(lastField);
            } else {
                // The host UUID is a full UUID, and we should just use that. This doesn't involve any additional string creation, so we should just be able to do the assignment.
                __byHostIdentifierString = hostID;
            }
        } else {
            __byHostIdentifierString = CFSTR("UnknownHostID");
        }
    }
    
    return __byHostIdentifierString;
}
開發者ID:CoherentLabs,項目名稱:CoherentWebCoreDependencies,代碼行數:30,代碼來源:CFPreferences.c

示例10: __NCParseExtendedFormatString

CFStringRef
__NCParseExtendedFormatString(
  CFStringRef format
)
{
  CFMutableStringRef    newFormat = CFStringCreateMutableCopy(
                                        kCFAllocatorDefault,
                                        0,
                                        format);
  CFIndex               length = CFStringGetLength(newFormat);
  CFRange               searchRange = CFRangeMake(0,length);
  CFRange               foundRange;
  
  //  Scan through the mutable copy looking for '%!' sequences to
  //  parse-out:
  while (CFStringFindWithOptions(newFormat,CFSTR("%!"),searchRange,0,&foundRange)) {
    CFIndex     start = foundRange.location;
    CFIndex     end;
    
    if (CFStringFindWithOptions(newFormat,CFSTR(";"),CFRangeMake(start,length - start),0,&foundRange))
      end = foundRange.location;
    else
      end = length;
    __NCReplaceFormatToken(newFormat,start,end);
    length = CFStringGetLength(newFormat);
    if (end >= length)
      break;
    searchRange = CFRangeMake(start,length - start);
  }
  return newFormat;
}
開發者ID:justindelliott,項目名稱:ncutil,代碼行數:31,代碼來源:NCError.c

示例11: makeFSSpec

OSErr makeFSSpec(char *pathString, int pathStringLength,FSSpec *spec)
{	
    CFURLRef    sillyThing;
    CFStringRef tmpStrRef;
	CFMutableStringRef filePath;
    FSRef	theFSRef;
    OSErr	err;
    
    tmpStrRef = CFStringCreateWithBytes(kCFAllocatorDefault,(UInt8 *) pathString,
										pathStringLength, gCurrentVMEncoding, true);
    if (tmpStrRef == nil)
        return -1000;
	filePath = CFStringCreateMutableCopy(NULL, 0, tmpStrRef);
	if (gCurrentVMEncoding == kCFStringEncodingUTF8) 
		CFStringNormalize(filePath, kCFStringNormalizationFormD);
    sillyThing = CFURLCreateWithFileSystemPath (kCFAllocatorDefault,filePath,kCFURLHFSPathStyle,false);
	if (sillyThing == NULL) 
		return -2000;
		
    if (CFURLGetFSRef(sillyThing,&theFSRef) == false) {
        // name contains multiple aliases or does not exist, so fallback to lookupPath
        CFRelease(filePath);
        CFRelease(sillyThing);
        return lookupPath(pathString,pathStringLength,spec,true,true);
    } 
            
    CFRelease(filePath);
    err = FSGetCatalogInfo (&theFSRef,kFSCatInfoNone,nil,nil,spec,nil);
    CFRelease(sillyThing);
    return err;
}
開發者ID:fniephaus,項目名稱:squeak,代碼行數:31,代碼來源:sqMacFileLogic.c

示例12: MultiByteToUnicodeString

UString MultiByteToUnicodeString(const AString &srcString, UINT codePage)
{
  if (!srcString.IsEmpty())
  {
    UString resultString;
    const char * path = &srcString[0];

    CFStringRef cfpath = CFStringCreateWithCString(NULL,path,kCFStringEncodingUTF8);

    if (cfpath)
    {

       CFMutableStringRef cfpath2 = CFStringCreateMutableCopy(NULL,0,cfpath);
       CFRelease(cfpath);
       CFStringNormalize(cfpath2,kCFStringNormalizationFormC);
    
       size_t n = CFStringGetLength(cfpath2);
       for(size_t i =   0 ; i< n ;i++) {
         UniChar uc = CFStringGetCharacterAtIndex(cfpath2,i);
         resultString += (wchar_t)uc; // FIXME
       }

       CFRelease(cfpath2);  

       return resultString;
    }
  }

  UString resultString;
  for (int i = 0; i < srcString.Len(); i++)
    resultString += wchar_t(srcString[i] & 255);

  return resultString;
}
開發者ID:abidrahmank,項目名稱:cherrytree,代碼行數:34,代碼來源:StringConvert.cpp

示例13: makeHFSFromPosixPath

int makeHFSFromPosixPath(char *pathString, int pathStringLength,char *dst,char *lastpart) {
		CFStringRef filePath;
        CFURLRef 	sillyThing;
        CFStringRef	filePath2,lastPathPart;
		
        dst[0] = 0x00;
		if (lastpart)
			lastpart[0] = 0x00;
		filePath   = CFStringCreateWithBytes(kCFAllocatorDefault,
                    (UInt8 *)pathString,pathStringLength,gCurrentVMEncoding,false);
        if (filePath == nil)
            return -1;
			
		// HFS+ imposes Unicode2.1 decomposed UTF-8 encoding on all path elements
		CFMutableStringRef str= CFStringCreateMutableCopy(NULL, 0, filePath);
		if (gCurrentVMEncoding == kCFStringEncodingUTF8) 
			CFStringNormalize(str, kCFStringNormalizationFormKC); // canonical decomposition

		sillyThing = CFURLCreateWithFileSystemPath (kCFAllocatorDefault, str, kCFURLPOSIXPathStyle,false);
		CFRelease(str);
		if (sillyThing == NULL) 
			return -2;
		
		filePath2 = CFURLCopyFileSystemPath (sillyThing, kCFURLHFSPathStyle);
		CFStringGetCString (filePath2,dst,1000, gCurrentVMEncoding);
		if (lastpart) {
			lastPathPart = CFURLCopyLastPathComponent(sillyThing);
			CFStringGetCString(lastPathPart,lastpart,256, gCurrentVMEncoding);
			CFRelease(lastPathPart);
		}
        CFRelease(filePath);
        CFRelease(sillyThing);
        CFRelease(filePath2);
        return 0;
}
開發者ID:fniephaus,項目名稱:squeak,代碼行數:35,代碼來源:sqMacFileLogic.c

示例14: GetServiceTypeToLookup

void
GetServiceTypeToLookup(CFMutableStringRef * serviceString, UInt16 * serviceMenuItem)
{
    ControlID 		controlID = { kNSLSample, kServicesTypePopup };
    ControlRef		control;
    CFStringRef		outString;
    MenuRef		menu;
    SInt16		value;
    OSStatus		err;
    
    err = GetControlByID(gMainWindow, &controlID, &control);
    if (err == noErr)
    {
        value = GetControlValue(control);
        if (serviceString)
        {
            menu = GetControlPopupMenuHandle(control);
            if (menu)
            {
                CopyMenuItemTextAsCFString(menu, value, &outString);
                if (serviceString)
                {
                    *serviceString = CFStringCreateMutableCopy(NULL, CFStringGetLength(outString), outString);
                    CFStringLowercase(*serviceString, NULL);
                }
                if (outString) CFRelease(outString);
            }
        }
        
        if (serviceMenuItem) *serviceMenuItem = value;
    }
}
開發者ID:fruitsamples,項目名稱:NSLMiniBrowser,代碼行數:32,代碼來源:ExtraStuff.c

示例15: BIMCreatePortName

static CFStringRef BIMCreatePortName( const ProcessSerialNumber *inProcessSerialNumber )
{
    CFMutableStringRef	portName;
    CFStringRef		processSerialNumberStringRef;
    Str255		processSerialNumberString;
    Str255		processSerialNumberLowString;

    //  Convert the high and low parts of the process serial number into a string.

    NumToString( inProcessSerialNumber->highLongOfPSN, processSerialNumberString );
    NumToString( inProcessSerialNumber->lowLongOfPSN, processSerialNumberLowString );
    BlockMoveData( processSerialNumberLowString + 1,
                   processSerialNumberString + processSerialNumberString [0] + 1,
                   processSerialNumberLowString [0] );
    processSerialNumberString [0] += processSerialNumberLowString [0];

    //  Create a CFString and append the process serial number string onto the end.

    portName = CFStringCreateMutableCopy( NULL, 255, CFSTR( kBasicServerPortName ) );
    processSerialNumberStringRef = CFStringCreateWithPascalString( NULL,
                                                                   processSerialNumberString,
                                                                   CFStringGetSystemEncoding() );
    CFStringAppend( portName, processSerialNumberStringRef );
    CFRelease( processSerialNumberStringRef );
    return portName;
}
開發者ID:fruitsamples,項目名稱:BasicInputMethod,代碼行數:26,代碼來源:BIMMessageReceive.c


注:本文中的CFStringCreateMutableCopy函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。