本文整理汇总了C++中nsACString::AppendPrintf方法的典型用法代码示例。如果您正苦于以下问题:C++ nsACString::AppendPrintf方法的具体用法?C++ nsACString::AppendPrintf怎么用?C++ nsACString::AppendPrintf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsACString
的用法示例。
在下文中一共展示了nsACString::AppendPrintf方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AssembleCacheKey
nsresult _OldStorage::AssembleCacheKey(nsIURI *aURI,
nsACString const & aIdExtension,
nsACString & aCacheKey)
{
// Copied from nsHttpChannel::AssembleCacheKey
aCacheKey.Truncate();
if (mLoadInfo->IsAnonymous()) {
aCacheKey.AssignLiteral("anon&");
}
if (!aIdExtension.IsEmpty()) {
aCacheKey.AppendPrintf("id=%s&", aIdExtension.BeginReading());
}
nsresult rv;
nsCOMPtr<nsIURI> noRefURI;
rv = aURI->CloneIgnoringRef(getter_AddRefs(noRefURI));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString uriSpec;
rv = noRefURI->GetAsciiSpec(uriSpec);
NS_ENSURE_SUCCESS(rv, rv);
if (!aCacheKey.IsEmpty()) {
aCacheKey.AppendLiteral("uri=");
}
aCacheKey.Append(uriSpec);
return NS_OK;
}
示例2: GetWindowURI
static void
AppendWindowURI(nsGlobalWindow *aWindow, nsACString& aStr, bool aAnonymize)
{
nsCOMPtr<nsIURI> uri = GetWindowURI(aWindow);
if (uri) {
if (aAnonymize && !aWindow->IsChromeWindow()) {
aStr.AppendPrintf("<anonymized-%llu>", aWindow->WindowID());
} else {
nsCString spec;
uri->GetSpec(spec);
// A hack: replace forward slashes with '\\' so they aren't
// treated as path separators. Users of the reporters
// (such as about:memory) have to undo this change.
spec.ReplaceChar('/', '\\');
aStr += spec;
}
} else {
// If we're unable to find a URI, we're dealing with a chrome window with
// no document in it (or somesuch), so we call this a "system window".
aStr += NS_LITERAL_CSTRING("[system]");
}
}
示例3:
NS_IMETHODIMP
DOMException::ToString(nsACString& aReturn)
{
aReturn.Truncate();
static const char defaultMsg[] = "<no message>";
static const char defaultLocation[] = "<unknown>";
static const char defaultName[] = "<unknown>";
static const char format[] =
"[Exception... \"%s\" code: \"%d\" nsresult: \"0x%x (%s)\" location: \"%s\"]";
nsAutoCString location;
if (location.IsEmpty()) {
location = defaultLocation;
}
const char* msg = !mMessage.IsEmpty() ? mMessage.get() : defaultMsg;
const char* resultName = !mName.IsEmpty() ? mName.get() : defaultName;
aReturn.AppendPrintf(format, msg, mCode, mResult, resultName,
location.get());
return NS_OK;
}
示例4:
NS_IMETHODIMP
DOMException::ToString(nsACString& aReturn)
{
aReturn.Truncate();
static const char defaultMsg[] = "<no message>";
static const char defaultLocation[] = "<unknown>";
static const char defaultName[] = "<unknown>";
static const char format[] =
"[Exception... \"%s\" code: \"%d\" nsresult: \"0x%x (%s)\" location: \"%s\"]";
nsAutoCString location;
if (mInner) {
nsString filename;
mInner->GetFilename(filename);
if (!filename.IsEmpty()) {
uint32_t line_nr = 0;
mInner->GetLineNumber(&line_nr);
char *temp = PR_smprintf("%s Line: %d",
NS_ConvertUTF16toUTF8(filename).get(),
line_nr);
if (temp) {
location.Assign(temp);
PR_smprintf_free(temp);
}
}
}
if (location.IsEmpty()) {
location = defaultLocation;
}
const char* msg = !mMessage.IsEmpty() ? mMessage.get() : defaultMsg;
const char* resultName = !mName.IsEmpty() ? mName.get() : defaultName;
aReturn.AppendPrintf(format, msg, mCode, mResult, resultName,
location.get());
return NS_OK;
}
示例5:
void
DOMException::ToString(JSContext* aCx, nsACString& aReturn)
{
aReturn.Truncate();
static const char defaultMsg[] = "<no message>";
static const char defaultLocation[] = "<unknown>";
static const char defaultName[] = "<unknown>";
static const char format[] =
"[Exception... \"%s\" code: \"%d\" nsresult: \"0x%" PRIx32 " (%s)\" location: \"%s\"]";
nsAutoCString location;
if (location.IsEmpty()) {
location = defaultLocation;
}
const char* msg = !mMessage.IsEmpty() ? mMessage.get() : defaultMsg;
const char* resultName = !mName.IsEmpty() ? mName.get() : defaultName;
aReturn.AppendPrintf(format, msg, mCode, static_cast<uint32_t>(mResult), resultName,
location.get());
}
示例6: VariantToString
bool
Logger::VariantToString(const VARIANT& aVariant, nsACString& aOut, LONG aIndex)
{
switch (aVariant.vt) {
case VT_DISPATCH: {
aOut.AppendPrintf("(IDispatch*) 0x%0p", aVariant.pdispVal);
return true;
}
case VT_DISPATCH | VT_BYREF: {
aOut.AppendPrintf("(IDispatch*) 0x%0p", (aVariant.ppdispVal)[aIndex]);
return true;
}
case VT_UNKNOWN: {
aOut.AppendPrintf("(IUnknown*) 0x%0p", aVariant.punkVal);
return true;
}
case VT_UNKNOWN | VT_BYREF: {
aOut.AppendPrintf("(IUnknown*) 0x%0p", (aVariant.ppunkVal)[aIndex]);
return true;
}
case VT_VARIANT | VT_BYREF: {
return VariantToString((aVariant.pvarVal)[aIndex], aOut);
}
case VT_I4 | VT_BYREF: {
aOut.AppendPrintf("%d", aVariant.plVal[aIndex]);
return true;
}
case VT_UI4 | VT_BYREF: {
aOut.AppendPrintf("%u", aVariant.pulVal[aIndex]);
return true;
}
case VT_I4: {
aOut.AppendPrintf("%d", aVariant.lVal);
return true;
}
case VT_UI4: {
aOut.AppendPrintf("%u", aVariant.ulVal);
return true;
}
case VT_EMPTY: {
aOut.AppendLiteral("(empty VARIANT)");
return true;
}
case VT_NULL: {
aOut.AppendLiteral("(null VARIANT)");
return true;
}
case VT_BSTR: {
aOut.AppendPrintf("\"%S\"", aVariant.bstrVal);
return true;
}
case VT_BSTR | VT_BYREF: {
aOut.AppendPrintf("\"%S\"", *aVariant.pbstrVal);
return true;
}
default: {
aOut.AppendPrintf("(VariantToString failed, VARTYPE == 0x%04hx)",
aVariant.vt);
return false;
}
}
}