当前位置: 首页>>代码示例>>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;未经允许,请勿转载。