本文整理汇总了C++中UStringVector::Reserve方法的典型用法代码示例。如果您正苦于以下问题:C++ UStringVector::Reserve方法的具体用法?C++ UStringVector::Reserve怎么用?C++ UStringVector::Reserve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UStringVector
的用法示例。
在下文中一共展示了UStringVector::Reserve方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetSelectedNames
void CPanel::GetSelectedNames(UStringVector &selectedNames)
{
selectedNames.Clear();
CRecordVector<UInt32> indices;
GetSelectedItemsIndices(indices);
selectedNames.Reserve(indices.Size());
for (int i = 0; i < indices.Size(); i++)
selectedNames.Add(GetItemRelPath(indices[i]));
/*
for (int i = 0; i < _listView.GetItemCount(); i++)
{
const int kSize = 1024;
WCHAR name[kSize + 1];
LVITEMW item;
item.iItem = i;
item.pszText = name;
item.cchTextMax = kSize;
item.iSubItem = 0;
item.mask = LVIF_TEXT | LVIF_PARAM;
if (!_listView.GetItem(&item))
continue;
int realIndex = GetRealIndex(item);
if (realIndex == kParentIndex)
continue;
if (_selectedStatusVector[realIndex])
selectedNames.Add(item.pszText);
}
*/
selectedNames.Sort();
}
示例2: QueryFileNames
void CDrop::QueryFileNames(UStringVector &fileNames)
{
fileNames.Clear();
UINT numFiles = QueryCountOfFiles();
fileNames.Reserve(numFiles);
for(UINT i = 0; i < numFiles; i++)
fileNames.Add(QueryFileName(i));
}
示例3: EnumerateDirItemsAndSort
void EnumerateDirItemsAndSort(NWildcard::CCensor &wildcardCensor,
UStringVector &sortedPaths,
UStringVector &sortedFullPaths)
{
UStringVector paths;
{
CDirItems dirItems;
{
UStringVector errorPaths;
CRecordVector<DWORD> errorCodes;
HRESULT res = EnumerateItems(wildcardCensor, dirItems, NULL, errorPaths, errorCodes);
if (res != S_OK || errorPaths.Size() > 0)
throw "cannot find archive";
}
for (int i = 0; i < dirItems.Items.Size(); i++)
{
const CDirItem &dirItem = dirItems.Items[i];
if (!dirItem.IsDir())
paths.Add(dirItems.GetPhyPath(i));
}
}
if (paths.Size() == 0)
throw "there is no such archive";
UStringVector fullPaths;
int i;
for (i = 0; i < paths.Size(); i++)
{
UString fullPath;
NFile::NDirectory::MyGetFullPathName(paths[i], fullPath);
fullPaths.Add(fullPath);
}
CIntVector indices;
SortFileNames(fullPaths, indices);
sortedPaths.Reserve(indices.Size());
sortedFullPaths.Reserve(indices.Size());
for (i = 0; i < indices.Size(); i++)
{
int index = indices[i];
sortedPaths.Add(paths[index]);
sortedFullPaths.Add(fullPaths[index]);
}
}
示例4: SortStrings
void SortStrings(const UStringVector &src, UStringVector &dest)
{
CIntVector indices;
SortStringsToIndices(src, indices);
dest.Clear();
dest.Reserve(indices.Size());
for (int i = 0; i < indices.Size(); i++)
dest.Add(src[indices[i]]);
}
示例5: PutFiles
//.........这里部分代码省略.........
throw 51751;
compressionInfo.Save();
CWorkDirTempFile tempFile;;
if (tempFile.CreateTempFile(m_FileName) != S_OK)
return NFileOperationReturnCode::kError;
/*
CSysStringVector fileNames;
for (int i = 0; i < numItems; i++)
{
const PluginPanelItem &panelItem = panelItems[i];
CSysString fullName;
if (!MyGetFullPathName(panelItem.FindData.cFileName, fullName))
return NFileOperationReturnCode::kError;
fileNames.Add(fullName);
}
*/
CScreenRestorer screenRestorer;
CProgressBox progressBox;
CProgressBox *progressBoxPointer = NULL;
if ((opMode & OPM_SILENT) == 0 && (opMode & OPM_FIND ) == 0)
{
screenRestorer.Save();
progressBoxPointer = &progressBox;
progressBox.Init(
// g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
g_StartupInfo.GetMsgString(NMessageID::kUpdating), 48);
}
UStringVector pathVector;
GetPathParts(pathVector);
UStringVector fileNames;
fileNames.Reserve(numItems);
for (i = 0; i < numItems; i++)
fileNames.Add(MultiByteToUnicodeString(panelItems[i].FindData.cFileName, CP_OEMCP));
CRecordVector<const wchar_t *> fileNamePointers;
fileNamePointers.Reserve(numItems);
for (i = 0; i < numItems; i++)
fileNamePointers.Add(fileNames[i]);
CMyComPtr<IOutFolderArchive> outArchive;
HRESULT result = m_ArchiveHandler.QueryInterface(IID_IOutFolderArchive, &outArchive);
if (result != S_OK)
{
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
return NFileOperationReturnCode::kError;
}
outArchive->SetFolder(_folder);
outArchive->SetFiles(L"", &fileNamePointers.Front(), fileNamePointers.Size());
BYTE actionSetByte[NUpdateArchive::NPairState::kNumValues];
for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
actionSetByte[i] = (BYTE)actionSet->StateActions[i];
CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp;
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
updateCallbackSpec->Init(/* m_ArchiveHandler, */ progressBoxPointer);
if (SetOutProperties(outArchive, compressionInfo.Level) != S_OK)
return NFileOperationReturnCode::kError;
result = outArchive->DoOperation2(tempFile.OutStream, actionSetByte, NULL, updateCallback);
updateCallback.Release();
outArchive.Release();
if (result == S_OK)
{
result = AfterUpdate(tempFile, pathVector);
}
if (result != S_OK)
{
ShowErrorMessage(result);
return NFileOperationReturnCode::kError;
}
/*
if (moveMode != 0)
{
for (int i = 0; i < numItems; i++)
{
const PluginPanelItem &pluginPanelItem = panelItems[i];
bool result;
if (NFile::NFind::NAttributes::IsDir(pluginPanelItem.FindData.dwFileAttributes))
result = NFile::NDirectory::RemoveDirectoryWithSubItems(pluginPanelItem.FindData.cFileName);
else
result = NFile::NDirectory::DeleteFileAlways(pluginPanelItem.FindData.cFileName);
if (!result)
return NFileOperationReturnCode::kError;
}
}
*/
return NFileOperationReturnCode::kSuccess;
}
示例6: OnCopy
//.........这里部分代码省略.........
}
}
else
{
int pos = destPath.ReverseFind(CHAR_PATH_SEPARATOR);
if (pos >= 0)
{
UString prefix = destPath.Left(pos + 1);
NDirectory::CreateComplexDirectory(prefix);
if (!CheckFolderPath(prefix))
{
srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return;
}
}
}
AddUniqueStringToHeadOfList(copyFolders, destPath);
while (copyFolders.Size() > 20)
copyFolders.DeleteBack();
SaveCopyHistory(copyFolders);
}
bool useSrcPanel = (!useDestPanel || !srcPanel.IsFSFolder() || destPanel.IsFSFolder());
bool useTemp = useSrcPanel && useDestPanel;
// FIXME NFile::NDirectory::CTempDirectoryW tempDirectory;
UString tempDirPrefix;
if (useTemp)
{
/* FIXME
tempDirectory.Create(kTempDirPrefix);
tempDirPrefix = tempDirectory.GetPath();
NFile::NName::NormalizeDirPathPrefix(tempDirPrefix);
*/
printf("useTemp : Not Implemented\n");
exit(EXIT_FAILURE);
}
CSelectedState srcSelState;
CSelectedState destSelState;
srcPanel.SaveSelectedState(srcSelState);
destPanel.SaveSelectedState(destSelState);
HRESULT result;
if (useSrcPanel)
{
UString folder = useTemp ? tempDirPrefix : destPath;
result = srcPanel.CopyTo(indices, folder, move, true, 0);
if (result != S_OK)
{
disableTimerProcessing1.Restore();
disableTimerProcessing2.Restore();
// For Password:
srcPanel.SetFocusToList();
if (result != E_ABORT)
srcPanel.MessageBoxError(result, L"Error");
return;
}
}
if (useDestPanel)
{
UStringVector filePaths;
UString folderPrefix;
if (useTemp)
folderPrefix = tempDirPrefix;
else
folderPrefix = srcPanel._currentFolderPrefix;
filePaths.Reserve(indices.Size());
for(int i = 0; i < indices.Size(); i++)
filePaths.Add(srcPanel.GetItemRelPath(indices[i]));
result = destPanel.CopyFrom(folderPrefix, filePaths, true, 0);
if (result != S_OK)
{
disableTimerProcessing1.Restore();
disableTimerProcessing2.Restore();
// For Password:
srcPanel.SetFocusToList();
if (result != E_ABORT)
srcPanel.MessageBoxError(result, L"Error");
return;
}
}
RefreshTitleAlways();
if (copyToSame || move)
{
srcPanel.RefreshListCtrl(srcSelState);
}
if (!copyToSame)
{
destPanel.RefreshListCtrl(destSelState);
srcPanel.KillSelection();
}
disableTimerProcessing1.Restore();
disableTimerProcessing2.Restore();
srcPanel.SetFocusToList();
}
示例7: OnCopy
//.........这里部分代码省略.........
int pos = destPath.ReverseFind(WCHAR_PATH_SEPARATOR);
if (pos >= 0)
{
UString prefix = destPath.Left(pos + 1);
NDirectory::CreateComplexDirectory(us2fs(prefix));
if (!CheckFolderPath(prefix))
{
srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
return;
}
}
}
AddUniqueStringToHeadOfList(copyFolders, destPath);
while (copyFolders.Size() > 20)
copyFolders.DeleteBack();
SaveCopyHistory(copyFolders);
}
/*
if (destPath == destPanel._currentFolderPrefix)
{
if (destPanel.GetFolderTypeID() == L"PhysDrive")
useDestPanel = true;
}
*/
bool useSrcPanel = (!useDestPanel || !srcPanel.IsFsOrDrivesFolder() || destPanel.IsFSFolder());
bool useTemp = useSrcPanel && useDestPanel;
NFile::NDirectory::CTempDir tempDirectory;
FString tempDirPrefix;
if (useTemp)
{
tempDirectory.Create(kTempDirPrefix);
tempDirPrefix = tempDirectory.GetPath();
NFile::NName::NormalizeDirPathPrefix(tempDirPrefix);
}
CSelectedState srcSelState;
CSelectedState destSelState;
srcPanel.SaveSelectedState(srcSelState);
destPanel.SaveSelectedState(destSelState);
HRESULT result;
if (useSrcPanel)
{
UString folder = useTemp ? fs2us(tempDirPrefix) : destPath;
result = srcPanel.CopyTo(indices, folder, move, true, 0);
if (result != S_OK)
{
disableTimerProcessing1.Restore();
disableTimerProcessing2.Restore();
// For Password:
srcPanel.SetFocusToList();
if (result != E_ABORT)
srcPanel.MessageBoxError(result, L"Error");
return;
}
}
if (useDestPanel)
{
UStringVector filePaths;
UString folderPrefix;
if (useTemp)
folderPrefix = fs2us(tempDirPrefix);
else
folderPrefix = srcPanel._currentFolderPrefix;
filePaths.Reserve(indices.Size());
for (int i = 0; i < indices.Size(); i++)
filePaths.Add(srcPanel.GetItemRelPath(indices[i]));
result = destPanel.CopyFrom(folderPrefix, filePaths, true, 0);
if (result != S_OK)
{
disableTimerProcessing1.Restore();
disableTimerProcessing2.Restore();
// For Password:
srcPanel.SetFocusToList();
if (result != E_ABORT)
srcPanel.MessageBoxError(result, L"Error");
return;
}
}
RefreshTitleAlways();
if (copyToSame || move)
{
srcPanel.RefreshListCtrl(srcSelState);
}
if (!copyToSame)
{
destPanel.RefreshListCtrl(destSelState);
srcPanel.KillSelection();
}
disableTimerProcessing1.Restore();
disableTimerProcessing2.Restore();
srcPanel.SetFocusToList();
}