]> git.tdb.fi Git - libs/core.git/commitdiff
Make FS::Path::Iterator assignable
authorMikko Rasa <tdb@tdb.fi>
Fri, 6 Jul 2012 20:18:09 +0000 (23:18 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 6 Jul 2012 20:18:09 +0000 (23:18 +0300)
source/fs/path.cpp
source/fs/path.h

index f12e27492709423f0875ecb046b0f6b2724dfd03..b8b7c223043786cf6bef748262f1e2d7cf495756 100644 (file)
@@ -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 && end<path.path.size() && path.path[end]!=DIRSEP)
+       if(end>1 && end<path->path.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<end-1)
@@ -270,11 +270,11 @@ Path::Iterator &Path::Iterator::operator--()
 
 string Path::Iterator::operator*() const
 {
-       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
index c701e60f7fb97dbf507cf0295ea13adefb32aec1..d515d7817031c1df3f98d0ad459c92a597b0dbcc 100644 (file)
@@ -29,7 +29,7 @@ public:
                friend class Path;
 
        private:
-               const Path &path;
+               const Path *path;
                std::string::size_type start, end;
 
                Iterator(const Path &);