本文整理汇总了C++中nsCString::Insert方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCString::Insert方法的具体用法?C++ nsCString::Insert怎么用?C++ nsCString::Insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsCString
的用法示例。
在下文中一共展示了nsCString::Insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetIcon
static HPOINTER GetIcon(nsCString& file, bool fExists,
bool fMini, bool *fWpsIcon)
{
HPOINTER hRtn = 0;
*fWpsIcon = false;
if (file.IsEmpty()) {
// append something so that we get at least the generic icon
file.Append("pmwrlw");
}
// if RWS is enabled, try to get the icon from the WPS
if (sUseRws) {
nsCOMPtr<nsIRwsService> rwsSvc(do_GetService("@mozilla.org/rwsos2;1"));
if (!rwsSvc)
sUseRws = false;
else {
if (fExists) {
rwsSvc->IconFromPath(file.get(), false, fMini, (uint32_t*)&hRtn);
} else {
const char *ptr = file.get();
if (*ptr == '.')
ptr++;
rwsSvc->IconFromExtension(ptr, fMini, (uint32_t*)&hRtn);
}
}
}
// if we got an icon from the WPS, set the flag & exit
if (hRtn) {
*fWpsIcon = true;
return hRtn;
}
// if the file exists already, get its icon
if (fExists)
return WinLoadFileIcon(file.get(), FALSE);
// otherwise, create a temporary file with the correct extension,
// then retrieve whatever icon PM assigns it
if (file.First() == '.')
file.Insert("moztmp", 0);
nsCOMPtr<nsIFile> tempPath;
if (NS_FAILED(NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tempPath))) ||
NS_FAILED(tempPath->AppendNative(file)))
return 0;
nsAutoCString pathStr;
tempPath->GetNativePath(pathStr);
FILE* fp = fopen(pathStr.get(), "wb+");
if (fp) {
fclose(fp);
hRtn = WinLoadFileIcon(pathStr.get(), FALSE);
remove(pathStr.get());
}
return hRtn;
}
示例2: MangleKeywordIntoURI
static nsresult MangleKeywordIntoURI(const char *aKeyword, const char *aURL,
nsCString& query)
{
query = (*aKeyword == '?') ? (aKeyword + 1) : aKeyword;
query.Trim(" "); // pull leading/trailing spaces.
// encode
char * encQuery = nsEscape(query.get(), url_XPAlphas);
if (!encQuery) return NS_ERROR_OUT_OF_MEMORY;
query.Adopt(encQuery);
// prepend the query with the keyword url
// XXX this url should come from somewhere else
query.Insert(aURL, 0);
return NS_OK;
}