From 5eb788bd9a41895585d4bb366a683437ddf63ad5 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 6 Jul 2012 23:18:09 +0300 Subject: [PATCH] Make FS::Path::Iterator assignable --- source/fs/path.cpp | 24 ++++++++++++------------ source/fs/path.h | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/source/fs/path.cpp b/source/fs/path.cpp index f12e274..b8b7c22 100644 --- a/source/fs/path.cpp +++ b/source/fs/path.cpp @@ -224,29 +224,29 @@ Path::Iterator Path::end() const Path::Iterator::Iterator(const Path &p): - path(p), + path(&p), start(0) { - if(path.path.empty()) + if(path->path.empty()) start = end = string::npos; - else if(path.path[0]==DIRSEP) + else if(path->path[0]==DIRSEP) end = 1; #ifdef WIN32 - else if(path.path.size()>2 && path.path[2]==DIRSEP && is_windows_drive(path.path.substr(0, 2))) + else if(path->path.size()>2 && path->path[2]==DIRSEP && is_windows_drive(path->path.substr(0, 2))) end = 2; #endif else - end = path.path.find(DIRSEP); + end = path->path.find(DIRSEP); } Path::Iterator &Path::Iterator::operator++() { start = end; - if(start>=path.path.size()) + if(start>=path->path.size()) return *this; - if(path.path[start]==DIRSEP) + if(path->path[start]==DIRSEP) ++start; - end = path.path.find(DIRSEP, start); + end = path->path.find(DIRSEP, start); return *this; } @@ -256,10 +256,10 @@ Path::Iterator &Path::Iterator::operator--() return *this; end = start; - if(end>1 && end1 && endpath.size() && path->path[end]!=DIRSEP) --end; - start = path.path.rfind(DIRSEP, end-1); + start = path->path.rfind(DIRSEP, end-1); if(start==string::npos) start = 0; else if(start=path.path.size()) + if(start>=path->path.size()) return string(); if(start==end) return string(); - return path.path.substr(start, end-start); + return path->path.substr(start, end-start); } } // namespace FS diff --git a/source/fs/path.h b/source/fs/path.h index c701e60..d515d78 100644 --- a/source/fs/path.h +++ b/source/fs/path.h @@ -29,7 +29,7 @@ public: friend class Path; private: - const Path &path; + const Path *path; std::string::size_type start, end; Iterator(const Path &); -- 2.45.2