Skip to content

Commit

Permalink
Add experimental path::generic() function returning generic formatted…
Browse files Browse the repository at this point in the history
… (i.e. separators are forward slashes). Motivation: may be simpler than having a family of generic_*string functions.
  • Loading branch information
Beman committed Aug 8, 2015
1 parent 5b8b9db commit 6e92c9a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions include/boost/filesystem/path.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,21 @@ namespace filesystem

// ----- generic format observers -----

// Experimental generic function returning generic formatted path (i.e. separators
// are forward slashes). Motivation: simpler than a family of generic_*string
// functions.
path generic() const
{
# ifdef BOOST_WINDOWS_API
path tmp;
std::replace_copy(m_pathname.begin(), m_pathname.end(),
std::back_inserter(tmp.m_pathname), L'\\', L'/');
return tmp;
# else
return path(*this);
# endif
}

template <class String>
String generic_string() const;

Expand Down
2 changes: 2 additions & 0 deletions test/path_unit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ namespace
CHECK(p.string() == "abc\\def/ghi");
CHECK(p.wstring() == L"abc\\def/ghi");

CHECK(p.generic().string() == "abc/def/ghi");
CHECK(p.generic_string() == "abc/def/ghi");
CHECK(p.generic_wstring() == L"abc/def/ghi");

Expand All @@ -450,6 +451,7 @@ namespace
CHECK(p.string() == "abc\\def/ghi");
CHECK(p.wstring() == L"abc\\def/ghi");

CHECK(p.generic().string() == "abc\\def/ghi");
CHECK(p.generic_string() == "abc\\def/ghi");
CHECK(p.generic_wstring() == L"abc\\def/ghi");

Expand Down

0 comments on commit 6e92c9a

Please sign in to comment.