本文整理汇总了C++中nsAString::SetCapacity方法的典型用法代码示例。如果您正苦于以下问题:C++ nsAString::SetCapacity方法的具体用法?C++ nsAString::SetCapacity怎么用?C++ nsAString::SetCapacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsAString
的用法示例。
在下文中一共展示了nsAString::SetCapacity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
NS_IMETHODIMP
nsFileView::GetCellText(PRInt32 aRow, nsITreeColumn* aCol,
nsAString& aCellText)
{
PRUint32 dirCount, fileCount;
mDirList->Count(&dirCount);
mFilteredFiles->Count(&fileCount);
bool isDirectory;
nsCOMPtr<nsIFile> curFile;
if (aRow < (PRInt32) dirCount) {
isDirectory = true;
curFile = do_QueryElementAt(mDirList, aRow);
} else if (aRow < mTotalRows) {
isDirectory = false;
curFile = do_QueryElementAt(mFilteredFiles, aRow - dirCount);
} else {
// invalid row
aCellText.SetCapacity(0);
return NS_OK;
}
const PRUnichar* colID;
aCol->GetIdConst(&colID);
if (NS_LITERAL_STRING("FilenameColumn").Equals(colID)) {
curFile->GetLeafName(aCellText);
} else if (NS_LITERAL_STRING("LastModifiedColumn").Equals(colID)) {
PRInt64 lastModTime;
curFile->GetLastModifiedTime(&lastModTime);
// XXX FormatPRTime could take an nsAString&
nsAutoString temp;
mDateFormatter->FormatPRTime(nsnull, kDateFormatShort, kTimeFormatSeconds,
lastModTime * 1000, temp);
aCellText = temp;
} else {
// file size
if (isDirectory)
aCellText.SetCapacity(0);
else {
PRInt64 fileSize;
curFile->GetFileSize(&fileSize);
CopyUTF8toUTF16(nsPrintfCString("%lld", fileSize), aCellText);
}
}
return NS_OK;
}
示例2: if
NS_IMETHODIMP
nsFileView::GetCellText(int32_t aRow, nsITreeColumn* aCol,
nsAString& aCellText)
{
uint32_t dirCount = mDirList.Length();
bool isDirectory;
nsIFile* curFile = nullptr;
if (aRow < (int32_t) dirCount) {
isDirectory = true;
curFile = mDirList[aRow];
} else if (aRow < mTotalRows) {
isDirectory = false;
curFile = mFilteredFiles[aRow - dirCount];
} else {
// invalid row
aCellText.SetCapacity(0);
return NS_OK;
}
const char16_t* colID;
aCol->GetIdConst(&colID);
if (NS_LITERAL_STRING("FilenameColumn").Equals(colID)) {
curFile->GetLeafName(aCellText);
} else if (NS_LITERAL_STRING("LastModifiedColumn").Equals(colID)) {
PRTime lastModTime;
curFile->GetLastModifiedTime(&lastModTime);
// XXX FormatPRTime could take an nsAString&
nsAutoString temp;
mDateFormatter->FormatPRTime(nullptr, kDateFormatShort, kTimeFormatSeconds,
lastModTime * 1000, temp);
aCellText = temp;
} else {
// file size
if (isDirectory)
aCellText.SetCapacity(0);
else {
int64_t fileSize;
curFile->GetFileSize(&fileSize);
CopyUTF8toUTF16(nsPrintfCString("%lld", fileSize), aCellText);
}
}
return NS_OK;
}