Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50408 - in sandbox/filesystem-v3: boost/filesystem libs/filesystem/src libs/filesystem/test libs/filesystem/test/msvc libs/filesystem/test/msvc/filesystem_dll libs/filesystem/test/msvc/path_test libs/filesystem/test/msvc/system_dll
From: bdawes_at_[hidden]
Date: 2008-12-29 17:10:37


Author: bemandawes
Date: 2008-12-29 17:10:37 EST (Mon, 29 Dec 2008)
New Revision: 50408
URL: http://svn.boost.org/trac/boost/changeset/50408

Log:
filesystem.v3: user supplied path_traits working; see path_unit_test.cpp
Text files modified:
   sandbox/filesystem-v3/boost/filesystem/path.hpp | 88 ++++++++++++++++++-----------------
   sandbox/filesystem-v3/libs/filesystem/src/path.cpp | 3
   sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem-v3-sandbox.sln | 42 +++++++----------
   sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem_dll/filesystem_dll.vcproj | 2
   sandbox/filesystem-v3/libs/filesystem/test/msvc/path_test/path_test.vcproj | 2
   sandbox/filesystem-v3/libs/filesystem/test/msvc/system_dll/system_dll.vcproj | 2
   sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp | 97 +++++++++++++++++++++++----------------
   7 files changed, 125 insertions(+), 111 deletions(-)

Modified: sandbox/filesystem-v3/boost/filesystem/path.hpp
==============================================================================
--- sandbox/filesystem-v3/boost/filesystem/path.hpp (original)
+++ sandbox/filesystem-v3/boost/filesystem/path.hpp 2008-12-29 17:10:37 EST (Mon, 29 Dec 2008)
@@ -91,6 +91,7 @@
 {
 namespace filesystem
 {
+
   // exception classes -----------------------------------------------------//
 
   // filesystem_error is not used because errors are sometimes thrown during
@@ -140,17 +141,12 @@
 
 # ifdef BOOST_WINDOWS_API
 
- typedef std::wstring string_type;
- typedef string_type::value_type value_type;
- typedef string_type::size_type size_type;
-
     BOOST_FILESYSTEM_DECL
     void append( const char * begin,
- const char * end, // 0 for null terminated MBCS
- std::wstring & target,
- system::error_code & ec );
+ const char * end, // 0 for null terminated MBCS
+ std::wstring & target, system::error_code & ec );
 
- // ----- convert ----
+ // ----- convert -----
 
     BOOST_FILESYSTEM_DECL
     std::string convert_to_string( const std::wstring & src, system::error_code & ec );
@@ -219,22 +215,29 @@
 namespace path_traits
 {
 
+ // path representation type
+#ifdef BOOST_WINDOWS_API
+ typedef std::wstring string_type;
+#else
+ typedef std::string string_type;
+#endif
+
   template< class I > struct is_iterator { static const bool value = false; };
   template< class C > struct is_container { static const bool value = false; };
 
   template< class charT > // specialization optional
   inline void append( const charT * begin, // requires: null termination
- detail::string_type & target, system::error_code & ec )
+ string_type & target, system::error_code & ec )
   {
- append( begin, 0, target, ec );
+ path_traits::append<charT>( begin, 0, target, ec );
   }
 
   template< class charT > // specialization required
   void append( const charT * begin, const charT * end,
- detail::string_type & target, system::error_code & ec );
+ string_type & target, system::error_code & ec );
 
- //template< class S > // specialization required
- //S convert( const detail::string_type & source, system::error_code & ec );
+ template< class String > // specialization required
+ String convert( const string_type & source, system::error_code & ec );
 
   //------------------------------------------------------------------------------------//
   // specializations //
@@ -252,6 +255,28 @@
   template<> struct is_iterator<std::wstring::const_iterator> { static const bool value = true; };
   template<> struct is_container<std::wstring> { static const bool value = true; };
 
+ template<>
+ inline void append<string_type::value_type>( const string_type::value_type * begin,
+ const string_type::value_type * end, string_type & target, system::error_code & ec )
+ {
+ ec.clear();
+ target.assign( begin, end ); // but what if throws bad_alloc?
+ }
+
+ template<>
+ inline void append<string_type::value_type>( const string_type::value_type * begin,
+ string_type & target, system::error_code & ec )
+ {
+ ec.clear();
+ target += begin; // but what if throws bad_alloc?
+ }
+
+ template<>
+ inline string_type convert<string_type>( const string_type & s, system::error_code & ec )
+ {
+ return s;
+ }
+
 # ifdef BOOST_WINDOWS_API
 
   template<>
@@ -269,35 +294,12 @@
   }
 
   template<>
- inline void append<wchar_t>( const wchar_t * begin, const wchar_t * end,
- std::wstring & target, system::error_code & ec )
- {
- ec.clear();
- target.assign( begin, end ); // but what if throws bad_alloc?
- }
-
- template<>
- inline void append<wchar_t>( const wchar_t * begin, std::wstring & target,
+ inline std::string convert<std::string>( const std::wstring & s,
     system::error_code & ec )
   {
- ec.clear();
- target += begin; // but what if throws bad_alloc?
+ return detail::convert_to_string( s, ec );
   }
 
- //template<>
- //inline std::string convert<std::string>( const std::wstring & s,
- // system::error_code & ec )
- //{
- // return detail::convert_to_string( s, ec );
- //}
-
- //template<>
- //inline std::wstring convert<std::wstring>( const std::wstring & s,
- // system::error_code & ec )
- //{
- // return s;
- //}
-
 # endif
 
 # ifdef BOOST_FILESYSTEM_CPP0X_CHAR_TYPES
@@ -322,9 +324,9 @@
     // Thus string_type is std::string for POSIX and std::wstring for Windows.
     // value_type is char for POSIX and wchar_t for Windows.
 
- typedef detail::string_type string_type;
- typedef string_type::value_type value_type;
- typedef string_type::size_type size_type;
+ typedef path_traits::string_type string_type;
+ typedef string_type::value_type value_type;
+ typedef string_type::size_type size_type;
 
     // ----- character encoding conversions -----
 
@@ -576,7 +578,9 @@
 
     template< class T >
     T string( system::error_code & ec = system::throws ) const
- { return convert<T>( m_path, ec ); }
+ {
+ return path_traits::convert<T>( m_path, ec );
+ }
 
 # ifdef BOOST_WINDOWS_API
 

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 2008-12-29 17:10:37 EST (Mon, 29 Dec 2008)
@@ -364,7 +364,6 @@
   // sets pos and len of first element, excluding extra separators
   // if src.empty(), sets pos,len, to 0,0.
 
- BOOST_FILESYSTEM_DECL
   void first_element(
       const string_type & src,
       size_type & element_pos,
@@ -444,7 +443,7 @@
   {
     iterator itr;
     itr.m_path_ptr = this;
- detail::size_type element_size;
+ path::size_type element_size;
     first_element( m_path, itr.m_pos, element_size );
     itr.m_element = m_path.substr( itr.m_pos, element_size );
     if ( itr.m_element.m_path == preferred_separator_string )

Modified: sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem-v3-sandbox.sln
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem-v3-sandbox.sln (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem-v3-sandbox.sln 2008-12-29 17:10:37 EST (Mon, 29 Dec 2008)
@@ -16,8 +16,6 @@
                 {F94CCADD-A90B-480C-A304-C19D015D36B1} = {F94CCADD-A90B-480C-A304-C19D015D36B1}
         EndProjectSection
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tchar_example", "tchar_example\tchar_example.vcproj", "{2D4CD761-6DF6-40AC-B4A5-F169D5F93226}"
-EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "convenience_test", "convenience_test\convenience_test.vcproj", "{08986FB5-0C83-4BC4-92DF-05E12E1C03C1}"
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "path_test_dynamic_link", "path_test_dynamic_link\path_test_dynamic_linkl.vcproj", "{54347DE3-6AA2-4466-A2EC-7176E0EC1110}"
@@ -38,46 +36,40 @@
                 Release|Win32 = Release|Win32
         EndGlobalSection
         GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {3C77F610-2E31-4087-9DF2-7CD45198A02D}.Debug|Win32.ActiveCfg = Debug|Win32
- {3C77F610-2E31-4087-9DF2-7CD45198A02D}.Debug|Win32.Build.0 = Debug|Win32
+ {3C77F610-2E31-4087-9DF2-7CD45198A02D}.Debug|Win32.ActiveCfg = Release|Win32
+ {3C77F610-2E31-4087-9DF2-7CD45198A02D}.Debug|Win32.Build.0 = Release|Win32
                 {3C77F610-2E31-4087-9DF2-7CD45198A02D}.Release|Win32.ActiveCfg = Release|Win32
                 {3C77F610-2E31-4087-9DF2-7CD45198A02D}.Release|Win32.Build.0 = Release|Win32
- {5DAF595A-4640-4F86-8A5F-E54E3E4CE7D0}.Debug|Win32.ActiveCfg = Debug|Win32
- {5DAF595A-4640-4F86-8A5F-E54E3E4CE7D0}.Debug|Win32.Build.0 = Debug|Win32
+ {5DAF595A-4640-4F86-8A5F-E54E3E4CE7D0}.Debug|Win32.ActiveCfg = Release|Win32
+ {5DAF595A-4640-4F86-8A5F-E54E3E4CE7D0}.Debug|Win32.Build.0 = Release|Win32
                 {5DAF595A-4640-4F86-8A5F-E54E3E4CE7D0}.Release|Win32.ActiveCfg = Release|Win32
                 {5DAF595A-4640-4F86-8A5F-E54E3E4CE7D0}.Release|Win32.Build.0 = Release|Win32
- {8BB7E604-46EF-42BE-ABB5-D7044B3E8A40}.Debug|Win32.ActiveCfg = Debug|Win32
- {8BB7E604-46EF-42BE-ABB5-D7044B3E8A40}.Debug|Win32.Build.0 = Debug|Win32
+ {8BB7E604-46EF-42BE-ABB5-D7044B3E8A40}.Debug|Win32.ActiveCfg = Release|Win32
+ {8BB7E604-46EF-42BE-ABB5-D7044B3E8A40}.Debug|Win32.Build.0 = Release|Win32
                 {8BB7E604-46EF-42BE-ABB5-D7044B3E8A40}.Release|Win32.ActiveCfg = Release|Win32
                 {8BB7E604-46EF-42BE-ABB5-D7044B3E8A40}.Release|Win32.Build.0 = Release|Win32
- {F3D230C4-9185-4C2B-AB0E-0F0D28D8268C}.Debug|Win32.ActiveCfg = Debug|Win32
- {F3D230C4-9185-4C2B-AB0E-0F0D28D8268C}.Debug|Win32.Build.0 = Debug|Win32
+ {F3D230C4-9185-4C2B-AB0E-0F0D28D8268C}.Debug|Win32.ActiveCfg = Release|Win32
+ {F3D230C4-9185-4C2B-AB0E-0F0D28D8268C}.Debug|Win32.Build.0 = Release|Win32
                 {F3D230C4-9185-4C2B-AB0E-0F0D28D8268C}.Release|Win32.ActiveCfg = Release|Win32
                 {F3D230C4-9185-4C2B-AB0E-0F0D28D8268C}.Release|Win32.Build.0 = Release|Win32
- {F94CCADD-A90B-480C-A304-C19D015D36B1}.Debug|Win32.ActiveCfg = Debug|Win32
- {F94CCADD-A90B-480C-A304-C19D015D36B1}.Debug|Win32.Build.0 = Debug|Win32
+ {F94CCADD-A90B-480C-A304-C19D015D36B1}.Debug|Win32.ActiveCfg = Release|Win32
+ {F94CCADD-A90B-480C-A304-C19D015D36B1}.Debug|Win32.Build.0 = Release|Win32
                 {F94CCADD-A90B-480C-A304-C19D015D36B1}.Release|Win32.ActiveCfg = Release|Win32
                 {F94CCADD-A90B-480C-A304-C19D015D36B1}.Release|Win32.Build.0 = Release|Win32
- {FFD738F7-96F0-445C-81EA-551665EF53D1}.Debug|Win32.ActiveCfg = Debug|Win32
- {FFD738F7-96F0-445C-81EA-551665EF53D1}.Debug|Win32.Build.0 = Debug|Win32
+ {FFD738F7-96F0-445C-81EA-551665EF53D1}.Debug|Win32.ActiveCfg = Release|Win32
+ {FFD738F7-96F0-445C-81EA-551665EF53D1}.Debug|Win32.Build.0 = Release|Win32
                 {FFD738F7-96F0-445C-81EA-551665EF53D1}.Release|Win32.ActiveCfg = Release|Win32
                 {FFD738F7-96F0-445C-81EA-551665EF53D1}.Release|Win32.Build.0 = Release|Win32
- {2D4CD761-6DF6-40AC-B4A5-F169D5F93226}.Debug|Win32.ActiveCfg = Debug|Win32
- {2D4CD761-6DF6-40AC-B4A5-F169D5F93226}.Debug|Win32.Build.0 = Debug|Win32
- {2D4CD761-6DF6-40AC-B4A5-F169D5F93226}.Release|Win32.ActiveCfg = Release|Win32
- {2D4CD761-6DF6-40AC-B4A5-F169D5F93226}.Release|Win32.Build.0 = Release|Win32
- {08986FB5-0C83-4BC4-92DF-05E12E1C03C1}.Debug|Win32.ActiveCfg = Debug|Win32
- {08986FB5-0C83-4BC4-92DF-05E12E1C03C1}.Debug|Win32.Build.0 = Debug|Win32
+ {08986FB5-0C83-4BC4-92DF-05E12E1C03C1}.Debug|Win32.ActiveCfg = Release|Win32
+ {08986FB5-0C83-4BC4-92DF-05E12E1C03C1}.Debug|Win32.Build.0 = Release|Win32
                 {08986FB5-0C83-4BC4-92DF-05E12E1C03C1}.Release|Win32.ActiveCfg = Release|Win32
                 {08986FB5-0C83-4BC4-92DF-05E12E1C03C1}.Release|Win32.Build.0 = Release|Win32
- {54347DE3-6AA2-4466-A2EC-7176E0EC1110}.Debug|Win32.ActiveCfg = Debug|Win32
- {54347DE3-6AA2-4466-A2EC-7176E0EC1110}.Debug|Win32.Build.0 = Debug|Win32
+ {54347DE3-6AA2-4466-A2EC-7176E0EC1110}.Debug|Win32.ActiveCfg = Release|Win32
+ {54347DE3-6AA2-4466-A2EC-7176E0EC1110}.Debug|Win32.Build.0 = Release|Win32
                 {54347DE3-6AA2-4466-A2EC-7176E0EC1110}.Release|Win32.ActiveCfg = Release|Win32
                 {54347DE3-6AA2-4466-A2EC-7176E0EC1110}.Release|Win32.Build.0 = Release|Win32
- {DE12E87D-87C1-4FF3-AF16-85097F2A5184}.Debug|Win32.ActiveCfg = Debug|Win32
- {DE12E87D-87C1-4FF3-AF16-85097F2A5184}.Debug|Win32.Build.0 = Debug|Win32
+ {DE12E87D-87C1-4FF3-AF16-85097F2A5184}.Debug|Win32.ActiveCfg = Release|Win32
                 {DE12E87D-87C1-4FF3-AF16-85097F2A5184}.Release|Win32.ActiveCfg = Release|Win32
- {DE12E87D-87C1-4FF3-AF16-85097F2A5184}.Release|Win32.Build.0 = Release|Win32
         EndGlobalSection
         GlobalSection(SolutionProperties) = preSolution
                 HideSolutionNode = FALSE

Modified: sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem_dll/filesystem_dll.vcproj
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem_dll/filesystem_dll.vcproj (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem_dll/filesystem_dll.vcproj 2008-12-29 17:10:37 EST (Mon, 29 Dec 2008)
@@ -44,6 +44,7 @@
                                 AdditionalIncludeDirectories="..\..\..\..\.."
                                 PreprocessorDefinitions="BOOST_ALL_NO_LIB;BOOST_ALL_DYN_LINK;WIN32;_DEBUG;_WINDOWS;_USRDLL;FILESYSTEM_DLL_EXPORTS"
                                 MinimalRebuild="true"
+ ExceptionHandling="2"
                                 BasicRuntimeChecks="3"
                                 RuntimeLibrary="3"
                                 UsePrecompiledHeader="0"
@@ -117,6 +118,7 @@
                                 EnableIntrinsicFunctions="true"
                                 AdditionalIncludeDirectories="..\..\..\..\.."
                                 PreprocessorDefinitions="BOOST_ALL_NO_LIB;BOOST_ALL_DYN_LINK;WIN32;NDEBUG;_WINDOWS;_USRDLL;FILESYSTEM_DLL_EXPORTS"
+ ExceptionHandling="2"
                                 RuntimeLibrary="2"
                                 EnableFunctionLevelLinking="true"
                                 UsePrecompiledHeader="0"

Modified: sandbox/filesystem-v3/libs/filesystem/test/msvc/path_test/path_test.vcproj
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/msvc/path_test/path_test.vcproj (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/msvc/path_test/path_test.vcproj 2008-12-29 17:10:37 EST (Mon, 29 Dec 2008)
@@ -42,7 +42,6 @@
                                 Optimization="0"
                                 PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
                                 MinimalRebuild="true"
- ExceptionHandling="1"
                                 BasicRuntimeChecks="3"
                                 RuntimeLibrary="3"
                                 UsePrecompiledHeader="0"
@@ -116,7 +115,6 @@
                                 Optimization="2"
                                 EnableIntrinsicFunctions="true"
                                 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
- ExceptionHandling="1"
                                 RuntimeLibrary="2"
                                 EnableFunctionLevelLinking="true"
                                 UsePrecompiledHeader="0"

Modified: sandbox/filesystem-v3/libs/filesystem/test/msvc/system_dll/system_dll.vcproj
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/msvc/system_dll/system_dll.vcproj (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/msvc/system_dll/system_dll.vcproj 2008-12-29 17:10:37 EST (Mon, 29 Dec 2008)
@@ -44,6 +44,7 @@
                                 AdditionalIncludeDirectories="..\..\..\..\.."
                                 PreprocessorDefinitions="BOOST_ALL_NO_LIB;BOOST_ALL_DYN_LINK;WIN32;_DEBUG;_WINDOWS;_USRDLL;SYSTEM_DLL_EXPORTS"
                                 MinimalRebuild="true"
+ ExceptionHandling="2"
                                 BasicRuntimeChecks="3"
                                 RuntimeLibrary="3"
                                 UsePrecompiledHeader="0"
@@ -117,6 +118,7 @@
                                 EnableIntrinsicFunctions="true"
                                 AdditionalIncludeDirectories="..\..\..\..\.."
                                 PreprocessorDefinitions="BOOST_ALL_NO_LIB;BOOST_ALL_DYN_LINK;WIN32;NDEBUG;_WINDOWS;_USRDLL;SYSTEM_DLL_EXPORTS"
+ ExceptionHandling="2"
                                 RuntimeLibrary="2"
                                 EnableFunctionLevelLinking="true"
                                 UsePrecompiledHeader="0"

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 2008-12-29 17:10:37 EST (Mon, 29 Dec 2008)
@@ -519,45 +519,62 @@
 //
 // }
 
-// // test_user_supplied_type ---------------------------------------------------------//
-//
-// typedef std::basic_string<long long> llstring;
-//
-//} // unnamed namespace
-//
-//namespace boost
-//{
-// namespace filesystem
-// {
-// template<> struct pathable_iterator<const long long *> { static const bool value = true; };
-// template<> struct pathable_iterator<long long *> { static const bool value = true; };
-// template<> struct pathable_iterator<llstring::iterator> { static const bool value = true; };
-// template<> struct pathable_iterator<llstring::const_iterator> { static const bool value = true; };
-// template<> struct pathable_container<llstring> { static const bool value = true; };
-// }
-//}
-//
-//namespace
-//{
-//
-// void test_user_supplied_type()
-// {
-// std::cout << "testing user supplied type..." << std::endl;
-//
-// long long ll_c_str[] = { 'a', 'b', 'c', 0 };
-// llstring ll_str( ll_c_str );
-//
-// path p1( ll_c_str );
-// CHECK( p1 == path("abc") );
-// CHECK( p1 == "abc" );
-// llstring t1( p1.string<llstring>() );
-// CHECK( t1 == ll_str );
-//
-// //path p2( ll_str );
-//
-//
-// //path p3( ll_str.begin(), ll_str.end() );
-// }
+ // test_user_supplied_type ---------------------------------------------------------//
+
+ typedef std::basic_string<int> user_string;
+
+} // unnamed namespace
+
+namespace boost
+{
+namespace filesystem
+{
+ namespace path_traits
+ {
+ template<> struct is_iterator<const user_string::value_type *> { static const bool value = true; };
+ template<> struct is_iterator<user_string::value_type *> { static const bool value = true; };
+ template<> struct is_iterator<user_string::iterator> { static const bool value = true; };
+ template<> struct is_iterator<user_string::const_iterator> { static const bool value = true; };
+ template<> struct is_container<user_string> { static const bool value = true; };
+
+ template<>
+ void append<user_string::value_type>( const user_string::value_type * begin,
+ const user_string::value_type * end, string_type & target, system::error_code & ec )
+ {
+ for ( ; begin != end && *begin; ++begin )
+ target += *begin + 1; // change so that results distinguishable from char cvts
+ }
+
+ template<>
+ user_string convert<user_string>( const string_type & source,
+ system::error_code & ec )
+ {
+ user_string temp;
+ for ( string_type::const_iterator it = source.begin();
+ it != source.end(); ++it )
+ temp += *it - 1;
+ return temp;
+ }
+ } // namespace path_traits
+} // namespace filesystem
+} // namespace boost
+
+namespace
+{
+
+ void test_user_supplied_type()
+ {
+ std::cout << "testing user supplied type..." << std::endl;
+
+ user_string::value_type usr_c_str[] = { 'a', 'b', 'c', 0 };
+ user_string usr( usr_c_str );
+
+ path p1( usr_c_str );
+ CHECK( p1 == path("bcd") );
+ CHECK( p1 == "bcd" );
+ user_string s1( p1.string<user_string>() );
+ CHECK( s1 == usr );
+ }
 
 } // unnamed namespace
 
@@ -582,7 +599,7 @@
   test_decompositions();
   test_queries();
   ////test_locales();
- //test_user_supplied_type();
+ test_user_supplied_type();
  
   cout << errors << " errors detected\n";
   


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