当前位置: 首页>>代码示例>>C++>>正文


C++ NSString类代码示例

本文整理汇总了C++中NSString的典型用法代码示例。如果您正苦于以下问题:C++ NSString类的具体用法?C++ NSString怎么用?C++ NSString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了NSString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ej_getNativeClass

JSValueRef ej_getNativeClass(JSContextRef ctx, JSObjectRef object, JSStringRef propertyNameJS, JSValueRef* exception) {
    size_t classNameSize = JSStringGetMaximumUTF8CStringSize(propertyNameJS);
    char* className = (char*)malloc(classNameSize);
    JSStringGetUTF8CString(propertyNameJS, className, classNameSize);

    JSObjectRef obj = NULL;
    NSString * fullClassName = new NSString();

    NSLOG("ej_getNativeClass : EJBinding%s", className);

    fullClassName->initWithFormat("EJBinding%s",className);
    EJBindingBase* pClass = (EJBindingBase*)NSClassFromString(fullClassName->getCString());
    if( pClass ) {
        obj = JSObjectMake( ctx, ej_constructorClass, (void *)pClass );
    } else {
        NSLOG("%s is NULL ... ", fullClassName->getCString());
    }

    if (obj)
    {
        NSLOG("constructor js-obj for %s", className);
    }

    free(className);
    fullClassName->autorelease();
    return obj ? obj : ej_global_undefined;
}
开发者ID:,项目名称:,代码行数:27,代码来源:

示例2: EJ_BIND_SET

EJ_BIND_SET( EJBindingImage, src, ctx, value) {
	// If the texture is still loading, do nothing to avoid confusion
	// This will break some edge cases; FIXME
	if( loading ) { return; }

	NSString * newPath = JSValueToNSString( ctx, value );
	
	// Release the old path and texture?
	if( path ) {
	
		// Same as the old path? Nothing to do here
		if( path->isEqual(newPath) ) { return; }

		path->release();
		path = NULL;
		
		texture->release();
		texture = NULL;
	}
	
	if( newPath->length() ) {
		newPath->retain();
		path = newPath;
		beginLoad();
	}

}
开发者ID:aogilvie,项目名称:Ejecta-X,代码行数:27,代码来源:EJBindingImage.cpp

示例3: NSStringMake

JSValueRef EJApp::loadModuleWithId(NSString * moduleId, JSValueRef module, JSValueRef exports)
{
    NSString * path = NSStringMake(moduleId->getCString() + string(".js"));
    NSString * script = NSString::createWithContentsOfFile(pathForResource(path)->getCString());

    if( !script ) {
        NSLog("Error: Can't Find Module %s", moduleId->getCString() );
        return NULL;
    }

    NSLog("Loading Module: %s", moduleId->getCString() );

    JSStringRef scriptJS = JSStringCreateWithUTF8CString(script->getCString());
    JSStringRef pathJS = JSStringCreateWithUTF8CString(path->getCString());
    JSStringRef parameterNames[] = {
        JSStringCreateWithUTF8CString("module"),
        JSStringCreateWithUTF8CString("exports"),
    };

    JSValueRef exception = NULL;
    JSObjectRef func = JSObjectMakeFunction( jsGlobalContext, NULL, 2,  parameterNames, scriptJS, pathJS, 0, &exception );

    JSStringRelease( scriptJS );
    JSStringRelease( pathJS );
    JSStringRelease(parameterNames[0]);
    JSStringRelease(parameterNames[1]);

    if( exception ) {
        logException(exception, jsGlobalContext);
        return NULL;
    }

    JSValueRef params[] = { module, exports };
    return invokeCallback(func, NULL, 2, params);
}
开发者ID:,项目名称:,代码行数:35,代码来源:

示例4: plist_characters

void plist_characters(void *ctx, const xmlChar *ch, int len)
{
 	CCDictMaker * pMaker = (CCDictMaker*)(ctx);
	if (pMaker->m_tState == SAX_NONE)
	{
		return;
	}
 	NSString *pText = new NSString();
	pText->m_sString = std::string((char*)ch,0,len);

 	switch(pMaker->m_tState)
 	{
 	case SAX_KEY:
 		pMaker->m_sCurKey = pText->m_sString;
 		break;
 	case SAX_INT:
 	case SAX_REAL:
 	case SAX_STRING:
 		{
 			NSAssert(!pMaker->m_sCurKey.empty(), "not found key : <integet/real>");
 			pMaker->m_pCurDict->setObject(pText, pMaker->m_sCurKey);
 			break;
 		}
 	}
	pText->release();
}
开发者ID:mattjesson,项目名称:cocos2d-x,代码行数:26,代码来源:CCXFileUtils_android.cpp

示例5: EJ_BIND_GET

EJ_BIND_GET(EJBindingHttpRequest, statusText, ctx) {
    // FIXME: should be "200 OK" instead of just "200"

    NSString *code = new NSString();
    code->autorelease();
    code->initWithFormat("%d", getStatusCode());
    return NSStringToJSValue(ctx, code);
}
开发者ID:Alamantus,项目名称:Ejecta-X,代码行数:8,代码来源:EJBindingHttpRequest.cpp

示例6: ha1Passwd

/*
 * @param(IN)  name  user name
 * @param(IN)  realm user's realm
 * @param(IN)  cleartext user's password in clear text
 * @param(OUT) ha1 ha1 of digest auth RFC in ascii b64 format
 */
void ha1Passwd(const char*name,const char* realm,const char* cleartext,NSString& ha1)
{
    HASHHEX HA1;
    DigestCalcHA1((char*)"MD5", (char*)name, (char*)realm, (char*)cleartext,NULL,NULL,HA1);
    ha1.clear();
    ha1.append(HA1);
    return;
}
开发者ID:OldsSourcesBackups,项目名称:Heliod-Web-Server,代码行数:14,代码来源:FileRealmUser.cpp

示例7: EJ_BIND_FUNCTION

EJ_BIND_FUNCTION(EJBindingHttpRequest, setRequestHeader, ctx, argc, argv) {
    if (argc < 2) { return NULL; }
    
    NSString *header = JSValueToNSString(ctx, argv[0]);
    NSString *value = JSValueToNSString(ctx, argv[1]);
    
    requestHeaders->setObject(value, header->getCString());
    return NULL;
}
开发者ID:Alamantus,项目名称:Ejecta-X,代码行数:9,代码来源:EJBindingHttpRequest.cpp

示例8: fullPathFromRelativePath

const char *CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile)
{
	std::string relativeFile = fullPathFromRelativePath(pszRelativeFile);
	NSString *pRet = new NSString();
	pRet->autorelease();
	pRet->m_sString = relativeFile.substr(0, relativeFile.rfind('/')+1);
	pRet->m_sString += pszFilename;
	return pRet->m_sString.c_str();
}
开发者ID:charlesa101,项目名称:cocos2d-x,代码行数:9,代码来源:CCXFileUtils_android.cpp

示例9: NSString

void EJBindingImage::beginLoad() {
	// This will begin loading the texture in a background thread and will call the
	// JavaScript onload callback when done
	loading = true;
	
	NSString* sharegroup = new NSString();
	sharegroup->autorelease();
	load(sharegroup);
}
开发者ID:aogilvie,项目名称:Ejecta-X,代码行数:9,代码来源:EJBindingImage.cpp

示例10: textureId

EJTexture::EJTexture(int widthp, int heightp, GLenum formatp) : textureId(0), width(0), height(0), realWidth(0), realHeight(0) {
	// Create an empty texture
	contentScale = 1;
	NSString* empty = NSStringMake("[Empty]");
	empty->retain();
	fullPath = empty;
	setWidthAndHeight(widthp, heightp);
	createTextureWithPixels(NULL, formatp);
}
开发者ID:BenjaminHorn,项目名称:Ejecta-X,代码行数:9,代码来源:EJTexture.cpp

示例11: createWithFormat

NSString* NSString::createWithFormat(const char* format, ...)
{
    NSString* pRet = NSString::create("");
    va_list ap;
    va_start(ap, format);
    pRet->initWithFormatAndValist(format, ap);
    va_end(ap);

    return pRet;
}
开发者ID:,项目名称:,代码行数:10,代码来源:

示例12: context

void ConfigurationServerXMLException::setServerXMLContextDescription(ServerXMLSchema::Element& element)
{
    ServerXMLExceptionContext context(element);
    CString tagName(element.getTagName());

    NSString error;
    error.append(context.getContextPrefix());
    error.printf(XP_GetAdminStr(DBT_ErrorProcessingTagXPrefix),
                 tagName.getStringValue());
    error.append(getDescription());

    setDescription(error);
}
开发者ID:OldsSourcesBackups,项目名称:Heliod-Web-Server,代码行数:13,代码来源:configuration.cpp

示例13: sshaPasswd

/*
 * @param(IN) salt  salt in binary format
 * @param(IN) saltSize   number of bytes for the salt
 * @param(IN) clearPasswd clearPasswd
 * @param(OUT) the hashed password with salt in ascii b64 format
 *
 * #sample keyfile line
 * j2ee;{SSHA}WRWaz20fzw3zN9x5Uzyyk5Wfvrbe4m40rYTPrA==;staff,eng
 */
void sshaPasswd(const char* salt, const int saltSize,const char* clearPasswd,NSString& hashed)
{
    //PRBool workaround= PR_FALSE; //PR_TRUE;
    const int digestLen = SHA1_LENGTH;  //20
    unsigned char H[512];
    char* pwdAndSalt=NULL;
    
    hashed.clear();
    if (!clearPasswd) {
        return;
    }
    int tobeHashedLen = 0;
    pwdAndSalt = addSalt(clearPasswd, salt, saltSize,tobeHashedLen);

        //if (workaround==PR_TRUE) {
        //https_SHA1_Hash(H,pwdAndSalt); //refer lib/libadmin/password.cpp
        //} else {
        //const int keylen = PRIVATE_KEY_LEN;
        //unsigned char DigestPrivatekey[PRIVATE_KEY_LEN];
        //PK11_GenerateRandom(DigestPrivatekey, keylen);

        PK11Context * SHA1Ctx = PK11_CreateDigestContext(SEC_OID_SHA1);
        if (SHA1Ctx==NULL) {
            FREE(pwdAndSalt);
            return;            
        }
        PK11_DigestBegin(SHA1Ctx);
        //PK11_DigestOp(SHA1Ctx, (unsigned char*)pwdAndSalt, strlen(pwdAndSalt) );
        PK11_DigestOp(SHA1Ctx, (unsigned char*)pwdAndSalt, tobeHashedLen );
        PK11_DigestFinal(SHA1Ctx, (unsigned char *)H, (unsigned int*)&digestLen, sizeof(H));
        PK11_DestroyContext(SHA1Ctx, 1);
        PR_ASSERT(digestLen==20);
        //}

    char* base64Val=NULL;
    if (salt!=NULL && saltSize>0) {
        memcpy(H+20,salt,saltSize);   //append salt to hashed passwd
        base64Val = BTOA_DataToAscii(H,digestLen+saltSize);   //base64.h
    } else {
        base64Val = BTOA_DataToAscii(H,digestLen);   //base64.h
    }

    hashed.append(SSHA_TAG );
    hashed.append(base64Val);

    if (base64Val)
        PORT_Free(base64Val);
    base64Val = NULL;
    FREE(pwdAndSalt);
    return;
}
开发者ID:OldsSourcesBackups,项目名称:Heliod-Web-Server,代码行数:60,代码来源:FileRealmUser.cpp

示例14: setValue

void XMLElement::setValue(NSString &val)

{

  bool valid = 0;

  for(size_t i = 0; i <val.getLength(); i++)

    if(val[i] != ' '  &&

       val[i] != '\t' &&

       val[i] != '\n')

    {

      valid = true;

      break;

    }

  if(valid)

    value = val;

}
开发者ID:CPPEngine,项目名称:CPPEngine,代码行数:27,代码来源:XMLParser.cpp

示例15: EreportableException

ConfigurationServerXMLException::ConfigurationServerXMLException(ServerXMLSchema::Element& element,
                                                                 const char *message,
                                                                 NSErr_t *err)
: EreportableException(LOG_MISCONFIG, message)
{
    char aclErrorText[1024];
    aclErrorFmt(err, aclErrorText, sizeof(aclErrorText), 6);

    NSString error;
    error.append(getDescription());
    error.append(aclErrorText);

    setDescription(error);

    setServerXMLContextDescription(element);
}
开发者ID:OldsSourcesBackups,项目名称:Heliod-Web-Server,代码行数:16,代码来源:configuration.cpp


注:本文中的NSString类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。