Changeset 9d4d5bcf994e…
Parent 44148c334a69…
by
Changes to 6 files · Browse files at 9d4d5bcf994e Showing diff from parent 44148c334a69 Diff from another changeset...
@@ -187,7 +187,7 @@
}
- myMenuIdMap.clear();
+ myMenuIdMap.RemoveAll();
}
@@ -553,10 +553,10 @@ {
UINT idCmd = LOWORD(lpcmi->lpVerb);
ATLTRACE("CShellExtCMenu::InvokeCommand: idCmd = %d\n", idCmd);
- MenuIdCmdMap::iterator iter = myMenuIdMap.find(idCmd);
- if (iter != myMenuIdMap.end())
+ const MenuIdCmdMap::CPair* p = myMenuIdMap.Lookup(idCmd);
+ if (p != NULL)
{
- RunDialog(iter->second.name);
+ RunDialog(p->m_value.name);
hr = S_OK;
}
else
@@ -601,21 +601,21 @@ ATLTRACE("CShellExtCMenu::GetCommandString: idCmd = %d, uFlags = %d (%s), "
"cchMax = %d\n", idCmd, uFlags, sflags, cchMax);
- MenuIdCmdMap::iterator iter = myMenuIdMap.find(static_cast<UINT>(idCmd));
- if (iter == myMenuIdMap.end())
+ const MenuIdCmdMap::CPair* p = myMenuIdMap.Lookup((UINT)idCmd);
+ if (p == NULL)
{
ATLTRACE("***** CShellExtCMenu::GetCommandString: idCmd not found\n");
}
else
{
- ATLTRACE("CShellExtCMenu::GetCommandString: name = '%s'\n", iter->second.name);
+ ATLTRACE("CShellExtCMenu::GetCommandString: name = '%s'\n", p->m_value.name);
if (uFlags == GCS_HELPTEXTW)
{
- pszw = iter->second.helpText;
+ pszw = p->m_value.helpText;
res = S_OK;
- size_t size = iter->second.helpText.GetLength();
+ size_t size = p->m_value.helpText.GetLength();
if (size >= 40)
{
ATLTRACE("***** CShellExtCMenu::GetCommandString: warning: "
|
@@ -1,10 +1,6 @@ #ifndef _CShellExtCMenu_h_
#define _CShellExtCMenu_h_
-#include <vector>
-#include <string>
-#include <map>
-
struct MenuDescription
{
CString name;
@@ -15,9 +11,7 @@};
typedef CAtlMap<CString, MenuDescription> MenuDescriptionMap;
-
-typedef std::map<UINT, MenuDescription> MenuIdCmdMap;
-
+typedef CAtlMap<UINT, MenuDescription> MenuIdCmdMap;
class CShellExtCMenuBase :
public CComObjectRootEx<CComMultiThreadModel>,
|
|
|
@@ -39,9 +39,10 @@
Directory::~Directory()
{
- for (DirsT::iterator i = subdirs_.begin(); i != subdirs_.end(); ++i)
+ POSITION position = subdirs_.GetHeadPosition();
+ while (position != NULL)
{
- delete *i;
+ delete subdirs_.GetNext(position);
}
}
@@ -88,16 +89,17 @@ if (base.IsEmpty())
{
e.name = n;
- cur->files_.push_back(e);
+ cur->files_.AddTail(e);
return 1;
}
Directory* d = 0;
- for (DirsT::iterator i = cur->subdirs_.begin();
- i != cur->subdirs_.end(); ++i)
+ POSITION position = cur->subdirs_.GetHeadPosition();
+ while (position != NULL)
{
- if ((*i)->name_ == base) {
- d = *i;
+ Directory* pItem = cur->subdirs_.GetNext(position);
+ if (pItem->name_ == base) {
+ d = pItem;
break;
}
}
@@ -105,7 +107,7 @@ if (!d)
{
d = new Directory(cur, base, cur->path());
- cur->subdirs_.push_back(d);
+ cur->subdirs_.AddTail(d);
}
n = rest;
@@ -134,21 +136,23 @@
if (base.IsEmpty())
{
- for (FilesT::const_iterator i = cur->files_.begin();
- i != cur->files_.end(); ++i)
+ POSITION position = cur->files_.GetHeadPosition();
+ while (position != NULL)
{
- if (i->name == n)
- return &(*i);
+ const Direntry& rItem = cur->files_.GetNext(position);
+ if (rItem.name == n)
+ return &rItem;
}
return 0;
}
- for (DirsT::const_iterator i = cur->subdirs_.begin();
- i != cur->subdirs_.end(); ++i)
+ POSITION position = cur->subdirs_.GetHeadPosition();
+ while (position != NULL)
{
- if ((*i)->name_ == base)
+ Directory* pItem = cur->subdirs_.GetNext(position);
+ if (pItem->name_ == base)
{
- cur = *i;
+ cur = pItem;
n = rest;
goto loopstart;
}
@@ -180,14 +184,15 @@ const bool leaf = base.IsEmpty();
const CString& searchstr = (leaf ? n : base);
- for (DirsT::const_iterator i = cur->subdirs_.begin();
- i != cur->subdirs_.end(); ++i)
+ POSITION position = cur->subdirs_.GetHeadPosition();
+ while (position != NULL)
{
- if ((*i)->name_ == searchstr)
+ Directory* pItem = cur->subdirs_.GetNext(position);
+ if (pItem->name_ == searchstr)
{
if (leaf)
- return *i;
- cur = *i;
+ return pItem;
+ cur = pItem;
n = rest;
goto loopstart;
}
@@ -200,9 +205,10 @@
void Directory::print() const
{
- for (DirsT::const_iterator i = subdirs_.begin(); i != subdirs_.end(); ++i)
+ POSITION position = subdirs_.GetHeadPosition();
+ while (position != NULL)
{
- const Directory* d = *i;
+ const Directory* d = subdirs_.GetNext(position);
if (!d)
{
ATLTRACE("Directory('%s')::print: error: d is 0\n", (LPCTSTR)path());
@@ -217,10 +223,12 @@ CString s;
char ctime_res[26];
- for (FilesT::const_iterator i = files_.begin(); i != files_.end(); ++i)
+ position = files_.GetHeadPosition();
+ while (position != NULL)
{
- CString p = (!base.IsEmpty() ? base + "/" + i->name : i->name);
- t = i->mtime;
+ const Direntry& rItem = files_.GetNext(position);
+ CString p = (!base.IsEmpty() ? base + "/" + rItem.name : rItem.name);
+ t = rItem.mtime;
errno_t err = ctime_s(ctime_res, 26, &t);
if (err == 0) {
s = ctime_res;
@@ -229,7 +237,7 @@ else {
s = "unset";
}
- printf("%c %6o %10u %-24s %s\n", i->state, i->mode, i->size,
+ printf("%c %6o %10u %-24s %s\n", rItem.state, rItem.mode, rItem.size,
(LPCTSTR)s, (LPCTSTR)p);
}
}
|
@@ -26,15 +26,12 @@
class Directory
{
- typedef std::vector<Directory*> DirsT;
- typedef std::vector<Direntry> FilesT;
-
Directory* const parent_;
const CString name_;
CString path_;
- DirsT subdirs_;
- FilesT files_;
+ CAtlList<Directory*> subdirs_;
+ CAtlList<Direntry> files_;
public:
Directory(Directory* p, const CString& n, const CString& basepath);
|
@@ -29,18 +29,18 @@
relpath += '/';
- for (V::const_iterator i = v_.begin(); i != v_.end(); ++i)
+ POSITION position = v_.GetHeadPosition();
+ while (position != NULL)
{
- const E& e = *i;
- if (relpath.IsEmpty() ||
- e.path_.compare(0, relpath.GetLength(), relpath) == 0)
+ const E& rEntry = v_.GetNext(position);
+ if (relpath.IsEmpty() || rEntry.path_.Left(relpath.GetLength()) == relpath)
{
- if (e.status_ == 'm' || e.status_ == 'r')
+ if (rEntry.status_ == 'm' || rEntry.status_ == 'r')
{
modified = true;
break;
}
- if (e.status_ == 'a')
+ if (rEntry.status_ == 'a')
added = true;
}
}
@@ -58,7 +58,7 @@
int DirectoryStatus::read(const CString& hgroot, const CString& cwd)
{
- v_.clear();
+ v_.RemoveAll();
noicons_ = false;
CString p = hgroot + "\\.hg\\thgstatus";
@@ -75,13 +75,13 @@ DirectoryStatus::E e;
int res = 1;
- const std::string noicons = "@@noicons";
+ const CString noicons = "@@noicons";
- std::vector<char> vline(200);
+ CString line;
for (;;)
{
- vline.clear();
+ line.Empty();
char t;
for (;;)
@@ -90,46 +90,42 @@ goto close;
if (t == '\n')
break;
- vline.push_back(t);
- if (vline.size() > 1000)
+ line.AppendChar(t);
+ if (line.GetLength() > 1000)
{
res = 0;
goto close;
}
}
- vline.push_back(0);
- std::string line = &vline[0];
-
- if (line.substr(0, noicons.size()) == noicons)
+ if (StartsWith(line, noicons))
{
noicons_ = true;
goto close;
}
- if (line.empty())
+ if (line.IsEmpty())
goto close;
e.status_ = line[0];
- std::string path;
- if (line.size() > 1)
+ CString path;
+ if (line.GetLength() > 1)
{
- path = line.c_str() + 1;
- ::CharLower(const_cast<char*>(path.c_str()));
+ path = line.Mid(1).MakeLower();
}
- path.push_back('/');
+ path.AppendChar('/');
e.path_ = path;
- v_.push_back(e);
+ v_.AddTail(e);
}
close:
fclose(f);
ATLTRACE("DirectoryStatus::read(%d): done. %d entries read. noicons_ = %d\n",
- v_.size(), noicons_);
+ v_.GetCount(), noicons_);
return res;
}
|
@@ -14,22 +14,17 @@ // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include <string>
-#include <vector>
-
-
class DirectoryStatus
{
struct E
{
- std::string path_;
+ CString path_;
char status_;
E(): status_(0) {}
};
- typedef std::vector<E> V;
- V v_;
+ CAtlList<E> v_;
bool noicons_;
public:
|
Loading...