Revision: 5786
http://winmerge.svn.sourceforge.net/winmerge/?rev=5786&view=rev
Author: marcelgosselin
Date: 2008-08-11 03:28:03 +0000 (Mon, 11 Aug 2008)
Log Message:
-----------
Replace CList by std::vector in Patch generation
Modified Paths:
--------------
trunk/Src/PatchDlg.cpp
trunk/Src/PatchDlg.h
trunk/Src/PatchTool.cpp
trunk/Src/PatchTool.h
Modified: trunk/Src/PatchDlg.cpp
===================================================================
--- trunk/Src/PatchDlg.cpp 2008-08-10 08:32:37 UTC (rev 5785)
+++ trunk/Src/PatchDlg.cpp 2008-08-11 03:28:03 UTC (rev 5786)
@@ -22,11 +22,11 @@
// ID line follows -- this is updated by SVN
// $Id$
-#include "stdafx.h"
-#include "merge.h"
+#include "StdAfx.h"
+#include "Merge.h"
#include "PatchTool.h"
#include "PatchDlg.h"
-#include "diff.h"
+#include "DIFF.H"
#include "coretools.h"
#include "paths.h"
#include "CompareOptions.h"
@@ -112,7 +112,7 @@
// multiple files. Multiple files are selected from DirView.
// Only if single files selected, filenames are checked here.
// Filenames read from Dirview must be valid ones.
- int selectCount = m_fileList.GetCount();
+ int selectCount = m_fileList.size();
if (selectCount == 1)
{
BOOL file1Ok = (paths_DoesPathExist(m_file1) == IS_EXISTING_FILE);
@@ -203,12 +203,12 @@
m_ctlFile2.LoadState(_T("Files\\DiffFile2"));
m_ctlResult.LoadState(_T("Files\\DiffFileResult"));
- int count = m_fileList.GetCount();
+ int count = m_fileList.size();
// If one file added, show filenames on dialog
if (count == 1)
{
- PATCHFILES files = m_fileList.GetHead();
+ const PATCHFILES& files = m_fileList.front();
m_file1 = files.lfile.c_str();
m_ctlFile1.SetWindowText(files.lfile.c_str());
m_file2 = files.rfile.c_str();
@@ -292,8 +292,7 @@
if (count == 1)
{
- POSITION pos = GetFirstItem();
- pf = GetNextItem(pos);
+ pf = GetItemAt(0);
}
else if (count > 1)
{
@@ -426,8 +425,7 @@
m_file2 = file1;
// Empty list
- while (!m_fileList.IsEmpty())
- m_fileList.RemoveTail();
+ m_fileList.clear();
// Add swapped files
files.lfile = file2;
@@ -439,9 +437,9 @@
* @brief Add patch item to internal list.
* @param [in] pf Patch item to add.
*/
-void CPatchDlg::AddItem(PATCHFILES pf)
+void CPatchDlg::AddItem(const PATCHFILES& pf)
{
- m_fileList.AddTail(pf);
+ m_fileList.push_back(pf);
}
/**
@@ -450,46 +448,25 @@
*/
int CPatchDlg::GetItemCount()
{
- return m_fileList.GetCount();
+ return m_fileList.size();
}
/**
- * @brief Return ref to first item in the internal list
- * @return POSITION of first item in the list.
- */
-POSITION CPatchDlg::GetFirstItem()
-{
- return m_fileList.GetHeadPosition();
-}
-
-/**
- * @brief Return next item in the internal list
- * @param [in, out] pos
- * - in POSITION for item to get
- * - out Next item's POSITION
+ * @brief Return item in the internal list at given position
+ * @param [in] position Zero-based index of item to get
* @return PATCHFILES from given position.
*/
-PATCHFILES CPatchDlg::GetNextItem(POSITION &pos)
+const PATCHFILES& CPatchDlg::GetItemAt(int position)
{
- return m_fileList.GetNext(pos);
+ return m_fileList.at(position);
}
/**
- * @brief Set files in given pos of internal list.
- * @param [in] pos POSITION of item to set.
- * @param [in] pf PATCHFILES to set in given position.
- */
-void CPatchDlg::SetItemAt(POSITION pos, PATCHFILES pf)
-{
- m_fileList.SetAt(pos, pf);
-}
-
-/**
* @brief Empties internal item list.
*/
void CPatchDlg::ClearItems()
{
- m_fileList.RemoveAll();
+ m_fileList.clear();
}
/**
Modified: trunk/Src/PatchDlg.h
===================================================================
--- trunk/Src/PatchDlg.h 2008-08-10 08:32:37 UTC (rev 5785)
+++ trunk/Src/PatchDlg.h 2008-08-11 03:28:03 UTC (rev 5786)
@@ -45,11 +45,9 @@
CPatchDlg(CWnd* pParent = NULL); // standard constructor
// Functions to add and get selected files (as PATCHFILEs)
- void AddItem(PATCHFILES pf);
+ void AddItem(const PATCHFILES& pf);
int GetItemCount();
- POSITION GetFirstItem();
- PATCHFILES GetNextItem(POSITION &pos);
- void SetItemAt(POSITION pos, PATCHFILES pf);
+ const PATCHFILES& GetItemAt(int position);
void ClearItems();
// Dialog Data
@@ -84,7 +82,7 @@
// Implementation
protected:
- CList<PATCHFILES, PATCHFILES&> m_fileList; /**< Source files to create patch from */
+ std::vector<PATCHFILES> m_fileList; /**< Source files to create patch from */
void ChangeFile(const CString &sFile, BOOL bLeft);
void UpdateSettings();
Modified: trunk/Src/PatchTool.cpp
===================================================================
--- trunk/Src/PatchTool.cpp 2008-08-10 08:32:37 UTC (rev 5785)
+++ trunk/Src/PatchTool.cpp 2008-08-11 03:28:03 UTC (rev 5786)
@@ -22,12 +22,12 @@
// ID line follows -- this is updated by SVN
// $Id$
-#include "stdafx.h"
+#include "StdAfx.h"
#include "UnicodeString.h"
#include "DiffWrapper.h"
-#include "patchtool.h"
+#include "PatchTool.h"
#include "PatchDlg.h"
-#include "Coretools.h"
+#include "coretools.h"
#include "paths.h"
#ifdef _DEBUG
@@ -64,7 +64,7 @@
files.rfile = file2;
// TODO: Read and add file's timestamps
- m_fileList.AddTail(files);
+ m_fileList.push_back(files);
}
/**
@@ -88,7 +88,7 @@
files.pathRight = altPath2;
// TODO: Read and add file's timestamps
- m_fileList.AddTail(files);
+ m_fileList.push_back(files);
}
/**
@@ -107,13 +107,9 @@
m_pDlgPatch = new CPatchDlg();
// If files already inserted, add them to dialog
- int count = m_fileList.GetCount();
- POSITION pos = m_fileList.GetHeadPosition();
-
- for (int i = 0; i < count; i++)
- {
- PATCHFILES files = m_fileList.GetNext(pos);
- m_pDlgPatch->AddItem(files);
+ for(std::vector<PATCHFILES>::iterator iter = m_fileList.begin(); iter != m_fileList.end(); ++iter)
+ {
+ m_pDlgPatch->AddItem(*iter);
}
if (ShowDialog())
@@ -132,11 +128,9 @@
m_diffWrapper.SetPrediffer(NULL);
int fileCount = m_pDlgPatch->GetItemCount();
- POSITION pos = m_pDlgPatch->GetFirstItem();
-
- for (int i = 0; i < fileCount; i++)
+ for (int index = 0; index < fileCount; index++)
{
- PATCHFILES files = m_pDlgPatch->GetNextItem(pos);
+ const PATCHFILES& files = m_pDlgPatch->GetItemAt(index);
// Set up DiffWrapper
m_diffWrapper.SetPaths(files.lfile, files.rfile, FALSE);
Modified: trunk/Src/PatchTool.h
===================================================================
--- trunk/Src/PatchTool.h 2008-08-10 08:32:37 UTC (rev 5785)
+++ trunk/Src/PatchTool.h 2008-08-11 03:28:03 UTC (rev 5786)
@@ -67,7 +67,7 @@
BOOL ShowDialog();
private:
- CList<PATCHFILES, PATCHFILES&> m_fileList; /**< List of files to patch. */
+ std::vector<PATCHFILES> m_fileList; /**< List of files to patch. */
CDiffWrapper m_diffWrapper; /**< DiffWrapper instance we use to create patch. */
CPatchDlg *m_pDlgPatch; /**< Dialog for selecting files and options. */
String m_sPatchFile; /**< Patch file path and filename. */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|