本文整理汇总了C++中nsString::get方法的典型用法代码示例。如果您正苦于以下问题:C++ nsString::get方法的具体用法?C++ nsString::get怎么用?C++ nsString::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsString
的用法示例。
在下文中一共展示了nsString::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pusher
bool
XPCShellEnvironment::EvaluateString(const nsString& aString,
nsString* aResult)
{
XPCShellEnvironment* env = Environment(mCx);
XPCShellEnvironment::AutoContextPusher pusher(env);
JSAutoRequest ar(mCx);
JS_ClearPendingException(mCx);
JSObject* global = GetGlobalObject();
JSAutoEnterCompartment ac;
if (!ac.enter(mCx, global)) {
NS_ERROR("Failed to enter compartment!");
return false;
}
JSScript* script =
JS_CompileUCScriptForPrincipals(mCx, global, GetPrincipal(),
aString.get(), aString.Length(),
"typein", 0);
if (!script) {
return false;
}
if (!ShouldCompileOnly()) {
if (aResult) {
aResult->Truncate();
}
jsval result;
JSBool ok = JS_ExecuteScript(mCx, global, script, &result);
if (ok && result != JSVAL_VOID) {
JSErrorReporter old = JS_SetErrorReporter(mCx, NULL);
JSString* str = JS_ValueToString(mCx, result);
nsDependentJSString depStr;
if (str)
depStr.init(mCx, str);
JS_SetErrorReporter(mCx, old);
if (!depStr.IsEmpty() && aResult) {
aResult->Assign(depStr);
}
}
}
return true;
}
示例2: request
bool
JetpackChild::RecvEvalScript(const nsString& code)
{
JSAutoRequest request(mCx);
JSObject *global = JS_GetGlobalObject(mCx);
JSAutoEnterCompartment ac;
if (!ac.enter(mCx, global))
return false;
jsval ignored;
(void) JS_EvaluateUCScript(mCx, global, code.get(),
code.Length(), "", 1, &ignored);
return true;
}
示例3:
gluezilla_setString (Handle *instance, nsString & ret)
{
Widget *widget = reinterpret_cast<Widget *> (instance);
nsCOMPtr<nsIDOMWindow> domWindow;
widget->browserWindow->webBrowser->GetContentDOMWindow( getter_AddRefs (domWindow) );
nsCOMPtr<nsIDOMDocument> domDoc;
domWindow->GetDocument (getter_AddRefs(domDoc));
nsCOMPtr<nsIDOMNode> node;
domDoc->GetFirstChild (getter_AddRefs (node));
node->GetLocalName (ret);
const PRUnichar * s = (PRUnichar *)ret.get ();
}
示例4: Conv_FE_06_WithReverse
nsresult Conv_FE_06_WithReverse(const nsString& aSrc, nsString& aDst)
{
PRUnichar *aSrcUnichars = (PRUnichar *)aSrc.get();
PRBool foundArabic = PR_FALSE;
PRUint32 i, endArabic, beginArabic, size;
beginArabic = 0;
size = aSrc.Length();
aDst.Truncate();
for (endArabic=0;endArabic<size;endArabic++) {
if (aSrcUnichars[endArabic] == 0x0000)
break; // no need to convert char after the NULL
while( (IS_FE_CHAR(aSrcUnichars[endArabic]))||
(IS_ARABIC_CHAR(aSrcUnichars[endArabic]))||
(IS_ARABIC_DIGIT(aSrcUnichars[endArabic]))||
(aSrcUnichars[endArabic]==0x0020))
{
if(! foundArabic ) {
beginArabic=endArabic;
foundArabic= PR_TRUE;
}
endArabic++;
}
if(foundArabic) {
endArabic--;
for (i=endArabic; i>=beginArabic; i--) {
if(IS_FE_CHAR(aSrcUnichars[i])) {
//ahmed for the bug of lamalf
aDst += PresentationToOriginal(aSrcUnichars[i], 0);
if (PresentationToOriginal(aSrcUnichars[i], 1)) {
// Two characters, we have to resize the buffer :(
aDst += PresentationToOriginal(aSrcUnichars[i], 1);
} // if expands to 2 char
} else {
// do we need to check the following if ?
if((IS_ARABIC_CHAR(aSrcUnichars[i]))||
(IS_ARABIC_DIGIT(aSrcUnichars[i]))||
(aSrcUnichars[i]==0x0020))
aDst += aSrcUnichars[i];
}
}
} else {
aDst += aSrcUnichars[endArabic];
}
foundArabic=PR_FALSE;
}// for : loop the buffer
return NS_OK;
}
示例5: splitString
static void splitString(nsString& aSource, nsString& aTarget)
{
aTarget.Truncate() ;
PRInt32 offset = aSource.FindChar('\n') ;
if (offset >= 0) {
const PRUnichar *source = aSource.get() + offset + 1 ;
while (*source) {
if (*source == '\n' || *source == '\r') { aTarget.Append(PRUnichar(' ')) ; }
else { aTarget.Append(*source) ; }
++ source ;
}
aSource.SetLength(offset);
}
}
示例6: ar
bool
XPCShellEnvironment::EvaluateString(const nsString& aString,
nsString* aResult)
{
XPCShellEnvironment* env = Environment(mCx);
nsCxPusher pusher;
pusher.Push(env->GetContext());
JSAutoRequest ar(mCx);
JS_ClearPendingException(mCx);
JS::Rooted<JSObject*> global(mCx, GetGlobalObject());
JSAutoCompartment ac(mCx, global);
JSScript* script =
JS_CompileUCScriptForPrincipals(mCx, global, GetPrincipal(),
aString.get(), aString.Length(),
"typein", 0);
if (!script) {
return false;
}
if (!ShouldCompileOnly()) {
if (aResult) {
aResult->Truncate();
}
JS::Rooted<JS::Value> result(mCx);
JSBool ok = JS_ExecuteScript(mCx, global, script, result.address());
if (ok && result != JSVAL_VOID) {
JSErrorReporter old = JS_SetErrorReporter(mCx, NULL);
JSString* str = JS_ValueToString(mCx, result);
nsDependentJSString depStr;
if (str)
depStr.init(mCx, str);
JS_SetErrorReporter(mCx, old);
if (!depStr.IsEmpty() && aResult) {
aResult->Assign(depStr);
}
}
}
return true;
}
示例7: ArrayLength
void
ErrorReporter::ReportUnexpected(const char *aMessage,
const nsString &aParam,
const nsString &aValue)
{
if (!ShouldReportErrors()) return;
nsAutoString qparam;
nsStyleUtil::AppendEscapedCSSIdent(aParam, qparam);
const char16_t *params[2] = { qparam.get(), aValue.get() };
nsAutoString str;
sStringBundle->FormatStringFromName(NS_ConvertASCIItoUTF16(aMessage).get(),
params, ArrayLength(params),
getter_Copies(str));
AddToError(str);
}
示例8: GetMessageServiceFromURI
nsresult
nsMsgPrintEngine::FireThatLoadOperation(const nsString& uri)
{
nsresult rv;
nsCString uriCStr;
LossyCopyUTF16toASCII(uri, uriCStr);
nsCOMPtr <nsIMsgMessageService> messageService;
// if this is a data: url, skip it, because
// we've already got something we can print
// and we know it is not a message.
//
// if this an about:blank url, skip it, because
// ...
//
// if this is an addbook: url, skip it, because
// we know that isn't a message.
//
// if this is a message part (or .eml file on disk)
// skip it, because we don't want to print the parent message
// we want to print the part.
// example: imap://[email protected]:143/fetch%3EUID%3E/INBOX%3E180958?part=1.1.2&type=application/x-message-display&filename=test"
if (!StringBeginsWith(uriCStr, NS_LITERAL_CSTRING(DATA_URL_PREFIX)) &&
!StringBeginsWith(uriCStr, NS_LITERAL_CSTRING(ADDBOOK_URL_PREFIX)) &&
!uriCStr.EqualsLiteral("about:blank") &&
uriCStr.Find(NS_LITERAL_CSTRING("type=application/x-message-display")) == -1) {
rv = GetMessageServiceFromURI(uriCStr, getter_AddRefs(messageService));
}
if (NS_SUCCEEDED(rv) && messageService)
rv = messageService->DisplayMessageForPrinting(uriCStr.get(), mDocShell, nsnull, nsnull, nsnull);
//If it's not something we know about, then just load try loading it directly.
else
{
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
if (webNav)
rv = webNav->LoadURI(uri.get(), // URI string
nsIWebNavigation::LOAD_FLAGS_NONE, // Load flags
nsnull, // Referring URI
nsnull, // Post data
nsnull); // Extra headers
}
return rv;
}
示例9: ComponentValue
NS_GFX_(bool) NS_HexToRGB(const nsString& aColorSpec,
nscolor* aResult)
{
const PRUnichar* buffer = aColorSpec.get();
int nameLen = aColorSpec.Length();
if ((nameLen == 3) || (nameLen == 6)) {
// Make sure the digits are legal
for (int i = 0; i < nameLen; i++) {
PRUnichar ch = buffer[i];
if (((ch >= '0') && (ch <= '9')) ||
((ch >= 'a') && (ch <= 'f')) ||
((ch >= 'A') && (ch <= 'F'))) {
// Legal character
continue;
}
// Whoops. Illegal character.
return false;
}
// Convert the ascii to binary
int dpc = ((3 == nameLen) ? 1 : 2);
// Translate components from hex to binary
int r = ComponentValue(buffer, nameLen, 0, dpc);
int g = ComponentValue(buffer, nameLen, 1, dpc);
int b = ComponentValue(buffer, nameLen, 2, dpc);
if (dpc == 1) {
// Scale single digit component to an 8 bit value. Replicate the
// single digit to compute the new value.
r = (r << 4) | r;
g = (g << 4) | g;
b = (b << 4) | b;
}
NS_ASSERTION((r >= 0) && (r <= 255), "bad r");
NS_ASSERTION((g >= 0) && (g <= 255), "bad g");
NS_ASSERTION((b >= 0) && (b <= 255), "bad b");
*aResult = NS_RGB(r, g, b);
return true;
}
// Improperly formatted color value
return false;
}
示例10: GetTempDirTask
// We store the records in files in the system temp dir.
static nsresult
GetGMPStorageDir(nsIFile** aTempDir, const nsString& aOrigin)
{
if (NS_WARN_IF(!aTempDir)) {
return NS_ERROR_INVALID_ARG;
}
// Directory service is main thread only...
nsRefPtr<GetTempDirTask> task = new GetTempDirTask();
nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
mozilla::SyncRunnable::DispatchToThread(mainThread, task);
nsCOMPtr<nsIFile> tmpFile;
nsresult rv = NS_NewLocalFile(task->mPath, false, getter_AddRefs(tmpFile));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = tmpFile->AppendNative(nsDependentCString("mozilla-gmp-storage"));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
// TODO: When aOrigin is the same node-id as the GMP sees in the child
// process (a UUID or somesuch), we can just append it un-hashed here.
// This should reduce the chance of hash collsions exposing data.
nsAutoString nodeIdHash;
nodeIdHash.AppendInt(HashString(static_cast<const char16_t*>(aOrigin.get())));
rv = tmpFile->Append(nodeIdHash);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = tmpFile->Create(nsIFile::DIRECTORY_TYPE, 0700);
if (rv != NS_ERROR_FILE_ALREADY_EXISTS && NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
tmpFile.forget(aTempDir);
return NS_OK;
}
示例11: inStr
nsresult
nsAddbookProtocolHandler::GenerateXMLOutputChannel( nsString &aOutput,
nsIAddbookUrl *addbookUrl,
nsIURI *aURI,
nsIChannel **_retval)
{
nsIChannel *channel;
nsresult rv;
nsCOMPtr<nsIStringInputStream> inStr(do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv));
NS_ENSURE_SUCCESS(rv, rv);
NS_ConvertUTF16toUTF8 utf8String(aOutput.get());
rv = inStr->SetData(utf8String.get(), utf8String.Length());
rv = NS_NewInputStreamChannel(&channel, aURI, inStr,
NS_LITERAL_CSTRING("text/xml"));
NS_ENSURE_SUCCESS(rv, rv);
*_retval = channel;
return rv;
}
示例12: sizeof
// static
already_AddRefed<nsStringBuffer>
nsCSSValue::BufferFromString(const nsString& aValue)
{
nsStringBuffer* buffer = nsStringBuffer::FromString(aValue);
if (buffer) {
buffer->AddRef();
return buffer;
}
PRUnichar length = aValue.Length();
// NOTE: Alloc prouduces a new, already-addref'd (refcnt = 1) buffer.
buffer = nsStringBuffer::Alloc((length + 1) * sizeof(PRUnichar));
if (NS_LIKELY(buffer != 0)) {
PRUnichar* data = static_cast<PRUnichar*>(buffer->Data());
nsCharTraits<PRUnichar>::copy(data, aValue.get(), length);
// Null-terminate.
data[length] = 0;
}
return buffer;
}
示例13: ensureSerialDispatch
void
HttpChannelChild::OnStatus(const nsresult& status,
const nsString& statusArg)
{
LOG(("HttpChannelChild::OnStatus [this=%p status=%x]\n", this, status));
if (mCanceled)
return;
// cache the progress sink so we don't have to query for it each time.
if (!mProgressSink)
GetCallback(mProgressSink);
AutoEventEnqueuer ensureSerialDispatch(this);
// block socket status event after Cancel or OnStopRequest has been called.
if (mProgressSink && NS_SUCCEEDED(mStatus) && mIsPending &&
!(mLoadFlags & LOAD_BACKGROUND))
{
mProgressSink->OnStatus(this, nsnull, status, statusArg.get());
}
}
示例14: ar
JSBool
TestShellCommandParent::RunCallback(const nsString& aResponse)
{
NS_ENSURE_TRUE(*mCallback.ToJSValPtr() != JSVAL_NULL && mCx, JS_FALSE);
JSAutoRequest ar(mCx);
NS_ENSURE_TRUE(mCallback.ToJSObject(), JS_FALSE);
JSAutoCompartment ac(mCx, mCallback.ToJSObject());
JS::Rooted<JSObject*> global(mCx, JS::CurrentGlobalOrNull(mCx));
JSString* str = JS_NewUCStringCopyN(mCx, aResponse.get(), aResponse.Length());
NS_ENSURE_TRUE(str, JS_FALSE);
JS::Rooted<JS::Value> strVal(mCx, JS::StringValue(str));
JS::Rooted<JS::Value> rval(mCx);
JSBool ok = JS_CallFunctionValue(mCx, global, mCallback, 1, strVal.address(),
rval.address());
NS_ENSURE_TRUE(ok, JS_FALSE);
return JS_TRUE;
}
示例15: ac
bool
XPCShellEnvironment::EvaluateString(const nsString& aString,
nsString* aResult)
{
AutoSafeJSContext cx;
JS::Rooted<JSObject*> global(cx, GetGlobalObject());
JSAutoCompartment ac(cx, global);
JS::CompileOptions options(cx);
options.setFileAndLine("typein", 0)
.setPrincipals(GetPrincipal());
JSScript* script = JS_CompileUCScript(cx, global, aString.get(),
aString.Length(), options);
if (!script) {
return false;
}
if (aResult) {
aResult->Truncate();
}
JS::Rooted<JS::Value> result(cx);
bool ok = JS_ExecuteScript(cx, global, script, result.address());
if (ok && result != JSVAL_VOID) {
JSErrorReporter old = JS_SetErrorReporter(cx, nullptr);
JSString* str = JS::ToString(cx, result);
nsDependentJSString depStr;
if (str)
depStr.init(cx, str);
JS_SetErrorReporter(cx, old);
if (!depStr.IsEmpty() && aResult) {
aResult->Assign(depStr);
}
}
return true;
}