Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55582 - in sandbox/filesystem-v3: boost/filesystem libs/filesystem/src libs/filesystem/test
From: bdawes_at_[hidden]
Date: 2009-08-14 10:44:56


Author: bemandawes
Date: 2009-08-14 10:44:56 EDT (Fri, 14 Aug 2009)
New Revision: 55582
URL: http://svn.boost.org/trac/boost/changeset/55582

Log:
rename path::native() -> preferred(), source() -> rep()
Text files modified:
   sandbox/filesystem-v3/boost/filesystem/operations.hpp | 13 ----------
   sandbox/filesystem-v3/boost/filesystem/path.hpp | 48 ++++++++++++++++++++-------------------
   sandbox/filesystem-v3/libs/filesystem/src/operations.cpp | 4 +-
   sandbox/filesystem-v3/libs/filesystem/src/path.cpp | 2
   sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp | 28 +++++++++++-----------
   5 files changed, 42 insertions(+), 53 deletions(-)

Modified: sandbox/filesystem-v3/boost/filesystem/operations.hpp
==============================================================================
--- sandbox/filesystem-v3/boost/filesystem/operations.hpp (original)
+++ sandbox/filesystem-v3/boost/filesystem/operations.hpp 2009-08-14 10:44:56 EDT (Fri, 14 Aug 2009)
@@ -345,19 +345,6 @@
 
 }; // directory_entry
 
-//// dispatch directory_entry supplied here rather than in
-//// <boost/filesystem/path_traits.hpp>, thus avoiding header circularity.
-//// test cases are in operations_unit_test.cpp
-//
-//namespace path_traits
-//{
-// template <class U> inline
-// void dispatch( const directory_entry & de, U & to, const codecvt_type & )
-// {
-// to = de.path().source();
-// }
-//} // namespace path_traits
-
 //--------------------------------------------------------------------------------------//
 // //
 // directory_iterator helpers //

Modified: sandbox/filesystem-v3/boost/filesystem/path.hpp
==============================================================================
--- sandbox/filesystem-v3/boost/filesystem/path.hpp (original)
+++ sandbox/filesystem-v3/boost/filesystem/path.hpp 2009-08-14 10:44:56 EDT (Fri, 14 Aug 2009)
@@ -32,13 +32,13 @@
      whether a '/' or '\' is appended.
    * path.cpp: locale and detail append/convert need error handling.
    * Provide the name check functions for more character types? Templatize?
- * Why do native() and generic() return paths rather than const strings/string refs?
+ * Why do preferred() and generic() return paths rather than const strings/string refs?
      Either change or document rationale.
    * Use BOOST_DELETED, BOOST_DEFAULTED, where appropriate.
    * imbue/codecvt too complex. Move to path_traits? Refactor?
    * path_unit_test, x /= x test failing, commented out. Fix. See test_appends.
- * The name source() is obscure. Come up with a more explicit name.
    * Add test for scoped_path_locale.
+ * Should there be a public "preferered_separator" const?
      
                          Design Questions
 
@@ -132,7 +132,7 @@
       const String & source_ )
         : path_error( what_, ec_ ), m_source( source_ ) {}
 
- const String & source() const { return m_source; }
+ const String & rep() const { return m_source; }
 
   private:
     String m_source;
@@ -323,24 +323,23 @@
     // Implementations are permitted to return const values or const references.
 
     // The string or path returned by an observer will be described as being formatted
- // as "native", "generic", or "source".
+ // as "native", "generic", or "internal".
     //
     // For POSIX, these are all the same format; slashes and backslashes are not modified.
     //
- // For Windows, native: slashes are converted to backslashes
- // generic: backslashes are converted to slashes
- // source: slashes and backslashes are not modified
+ // For Windows, native: slashes are converted to backslashes
+ // generic: backslashes are converted to slashes
+ // internal: slashes and backslashes are not modified
 
 // template< class T >
-// T string( system::error_code & ec = boost::throws() ) const // source (i.e. original) format
+// T string( system::error_code & ec = boost::throws() ) const // internal (i.e. original) format
 // {
 // return path_traits::convert<T>( m_path, ec );
 // }
 
 # ifdef BOOST_WINDOWS_API
 
- // source format
- const std::string string() const
+ const std::string string() const // internal format
     {
       std::string tmp;
       if ( !m_path.empty() )
@@ -352,7 +351,6 @@
 
 # else // BOOST_POSIX_API
 
- // source format
     const std::string & string() const { return m_path; }
     const std::wstring wstring() const
     {
@@ -364,24 +362,28 @@
     }
 
 # endif
-
     
 # ifdef BOOST_WINDOWS_PATH
 
- const path native() const; // native format
- const path generic() const; // generic format
+ const path preferred() const; // preferred format
+ const path generic() const; // generic format
 
 # else // BOOST_POSIX_PATH
 
- const path native() const { return m_path; }
- const path generic() const { return m_path; }
+ const path preferred() const { return m_path; }
+ const path generic() const { return m_path; }
 
 # endif
 
- const string_type & source() const { return m_path; } // source format
+ // ----- internals observers -----
+ //
+ // access to the internal string is efficient and often convenient, but may result in
+ // less than fully portable code.
+
+ const string_type & rep() const { return m_path; } // internal format
 
     // c_str() returns a C string suitable for calls to the operating system API.
- // On POSIX and Windows that's source format, on some OS's it may be native format.
+ // On POSIX and Windows that's internal format, on some OS's it may be native format.
     const value_type * c_str() const { return m_path.c_str(); }
 
     // ----- decomposition -----
@@ -566,11 +568,11 @@
   inline bool operator==( const path::string_type & lhs, const path & rhs ) { return rhs == lhs; }
   inline bool operator==( const path::value_type * lhs, const path & rhs ) { return rhs == lhs; }
 # else // BOOST_POSIX_API
- inline bool operator==( const path & lhs, const path & rhs ) { return lhs.source() == rhs.source(); }
- inline bool operator==( const path & lhs, const path::string_type & rhs ) { return lhs.source() == rhs; }
- inline bool operator==( const path & lhs, const path::value_type * rhs ) { return lhs.source() == rhs; }
- inline bool operator==( const path::string_type & lhs, const path & rhs ) { return lhs == rhs.source(); }
- inline bool operator==( const path::value_type * lhs, const path & rhs ) { return lhs == rhs.source(); }
+ inline bool operator==( const path & lhs, const path & rhs ) { return lhs.rep() == rhs.rep(); }
+ inline bool operator==( const path & lhs, const path::string_type & rhs ) { return lhs.rep() == rhs; }
+ inline bool operator==( const path & lhs, const path::value_type * rhs ) { return lhs.rep() == rhs; }
+ inline bool operator==( const path::string_type & lhs, const path & rhs ) { return lhs == rhs.rep(); }
+ inline bool operator==( const path::value_type * lhs, const path & rhs ) { return lhs == rhs.rep(); }
 # endif
 
 

Modified: sandbox/filesystem-v3/libs/filesystem/src/operations.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/src/operations.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/src/operations.cpp 2009-08-14 10:44:56 EDT (Fri, 14 Aug 2009)
@@ -1439,14 +1439,14 @@
 
     void dispatch( const directory_entry & de, std::wstring & to, const codecvt_type & )
     {
- to = de.path().source();
+ to = de.path().rep();
     }
 
 # else
 
     void dispatch( const directory_entry & de, std::string & to, const codecvt_type & )
     {
- to = de.path().source();
+ to = de.path().rep();
     }
 
 # endif

Modified: sandbox/filesystem-v3/libs/filesystem/src/path.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/src/path.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/src/path.cpp 2009-08-14 10:44:56 EDT (Fri, 14 Aug 2009)
@@ -147,7 +147,7 @@
   
   // native ---------------------------------------------------------------//
 
- const path path::native() const
+ const path path::preferred() const
   {
     path tmp;
 

Modified: sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp 2009-08-14 10:44:56 EDT (Fri, 14 Aug 2009)
@@ -237,7 +237,7 @@
 
     path p0( "abc" );
 
- CHECK( p0.source().size() == 3 );
+ CHECK( p0.rep().size() == 3 );
     CHECK( p0.string() == "abc" );
     CHECK( p0.string().size() == 3 );
     CHECK( p0.wstring() == L"abc" );
@@ -255,8 +255,8 @@
     CHECK( p.generic().string() == "abc/def/ghi" );
     CHECK( p.generic().wstring() == L"abc/def/ghi" );
 
- CHECK( p.native().string() == "abc\\def\\ghi" );
- CHECK( p.native().wstring() == L"abc\\def\\ghi" );
+ CHECK( p.preferred().string() == "abc\\def\\ghi" );
+ CHECK( p.preferred().wstring() == L"abc\\def\\ghi" );
 
 # else // BOOST_POSIX_PATH
 
@@ -270,8 +270,8 @@
     CHECK( p.generic().string() == "abc\\def/ghi" );
     CHECK( p.generic().wstring() == L"abc\\def/ghi" );
 
- CHECK( p.native().string() == "abc\\def/ghi" );
- CHECK( p.native().wstring() == L"abc\\def/ghi" );
+ CHECK( p.preferred().string() == "abc\\def/ghi" );
+ CHECK( p.preferred().wstring() == L"abc\\def/ghi" );
 
 # endif
   }
@@ -359,15 +359,15 @@
 
     // operator /
 
- CHECK( p1 / p2 == path( "foo/bar" ).native() );
- CHECK( "foo" / p2 == path( "foo/bar" ).native() );
- CHECK( L"foo" / p2 == path( "foo/bar" ).native() );
- CHECK( string( "foo" ) / p2 == path( "foo/bar" ).native() );
- CHECK( wstring( L"foo" ) / p2 == path( "foo/bar" ).native() );
- CHECK( p1 / "bar" == path( "foo/bar" ).native() );
- CHECK( p1 / L"bar" == path( "foo/bar" ).native() );
- CHECK( p1 / string( "bar" ) == path( "foo/bar" ).native() );
- CHECK( p1 / wstring( L"bar" ) == path( "foo/bar" ).native() );
+ CHECK( p1 / p2 == path( "foo/bar" ).preferred() );
+ CHECK( "foo" / p2 == path( "foo/bar" ).preferred() );
+ CHECK( L"foo" / p2 == path( "foo/bar" ).preferred() );
+ CHECK( string( "foo" ) / p2 == path( "foo/bar" ).preferred() );
+ CHECK( wstring( L"foo" ) / p2 == path( "foo/bar" ).preferred() );
+ CHECK( p1 / "bar" == path( "foo/bar" ).preferred() );
+ CHECK( p1 / L"bar" == path( "foo/bar" ).preferred() );
+ CHECK( p1 / string( "bar" ) == path( "foo/bar" ).preferred() );
+ CHECK( p1 / wstring( L"bar" ) == path( "foo/bar" ).preferred() );
 
     swap( p1, p2 );
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk