diff options
author | Brad King <brad.king@kitware.com> | 2006-08-17 16:02:18 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2006-08-17 16:02:18 (GMT) |
commit | 3a44f2a47ed78e7806eb7cc0945b6fc2fd827a8b (patch) | |
tree | 136530c05cb13f5980edc64c20735cb4a42850bf | |
parent | 006b61be359c5cd6d7cf401bbb87b06dbcbe536d (diff) | |
download | CMake-3a44f2a47ed78e7806eb7cc0945b6fc2fd827a8b.zip CMake-3a44f2a47ed78e7806eb7cc0945b6fc2fd827a8b.tar.gz CMake-3a44f2a47ed78e7806eb7cc0945b6fc2fd827a8b.tar.bz2 |
ENH: Added JoinPath overload that accepts an iterator range.
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 28 | ||||
-rw-r--r-- | Source/kwsys/SystemTools.hxx.in | 3 |
2 files changed, 25 insertions, 6 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 7a7ae2c..85225ba 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -2813,20 +2813,36 @@ void SystemTools::SplitPath(const char* p, kwsys_stl::string SystemTools::JoinPath(const kwsys_stl::vector<kwsys_stl::string>& components) { + return SystemTools::JoinPath(components.begin(), components.end()); +} + +//---------------------------------------------------------------------------- +kwsys_stl::string +SystemTools +::JoinPath(kwsys_stl::vector<kwsys_stl::string>::const_iterator first, + kwsys_stl::vector<kwsys_stl::string>::const_iterator last) +{ + // Construct result in a single string. kwsys_stl::string result; - if(components.size() > 0) + + // The first two components do not add a slash. + if(first != last) { - result += components[0]; + result += *first++; } - if(components.size() > 1) + if(first != last) { - result += components[1]; + result += *first++; } - for(unsigned int i=2; i < components.size(); ++i) + + // All remaining components are always separated with a slash. + while(first != last) { result += "/"; - result += components[i]; + result += *first++; } + + // Return the concatenated result. return result; } diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index 0e44e58..5d7214d 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -364,6 +364,9 @@ public: */ static kwsys_stl::string JoinPath( const kwsys_stl::vector<kwsys_stl::string>& components); + static kwsys_stl::string JoinPath( + kwsys_stl::vector<kwsys_stl::string>::const_iterator first, + kwsys_stl::vector<kwsys_stl::string>::const_iterator last); /** * Compare a path or components of a path. |