本文整理汇总了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;
}
示例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();
}
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}