Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59483 - in sandbox/filesystem-v3: boost boost/filesystem libs/filesystem/doc libs/filesystem/example libs/filesystem/example/test libs/filesystem/test libs/filesystem/test/msvc
From: bdawes_at_[hidden]
Date: 2010-02-04 17:23:13


Author: bemandawes
Date: 2010-02-04 17:23:11 EST (Thu, 04 Feb 2010)
New Revision: 59483
URL: http://svn.boost.org/trac/boost/changeset/59483

Log:
Change path ContiguousIterator to InputIterator, plus tutorial work in progress
Added:
   sandbox/filesystem-v3/libs/filesystem/example/tut5.cpp (contents, props changed)
Text files modified:
   sandbox/filesystem-v3/boost/filesystem.hpp | 5 +++--
   sandbox/filesystem-v3/boost/filesystem/path.hpp | 37 ++++++++++++++++++++++---------------
   sandbox/filesystem-v3/libs/filesystem/doc/do_list.html | 2 +-
   sandbox/filesystem-v3/libs/filesystem/doc/reference.html | 37 +++++++++++++++++--------------------
   sandbox/filesystem-v3/libs/filesystem/doc/tutorial.html | 6 +++---
   sandbox/filesystem-v3/libs/filesystem/example/Jamfile.v2 | 1 +
   sandbox/filesystem-v3/libs/filesystem/example/test/Jamfile.v2 | 2 ++
   sandbox/filesystem-v3/libs/filesystem/example/test/setup.bat | 1 +
   sandbox/filesystem-v3/libs/filesystem/example/test/setup.sh | 2 ++
   sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem-v3-sandbox.sln | 10 ++++++++++
   sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp | 30 ++++++++++++++++++++++++------
   11 files changed, 86 insertions(+), 47 deletions(-)

Modified: sandbox/filesystem-v3/boost/filesystem.hpp
==============================================================================
--- sandbox/filesystem-v3/boost/filesystem.hpp (original)
+++ sandbox/filesystem-v3/boost/filesystem.hpp 2010-02-04 17:23:11 EST (Thu, 04 Feb 2010)
@@ -14,8 +14,9 @@
 #define BOOST_FILESYSTEM_FILESYSTEM_HPP
 
 #include <boost/filesystem/config.hpp>
-#include <boost/filesystem/operations.hpp> // includes path.hpp
+#include <boost/filesystem/path.hpp>
+#include <boost/filesystem/operations.hpp>
 #include <boost/filesystem/convenience.hpp>
-
+#include <boost/filesystem/fstream.hpp>
 #endif
 

Modified: sandbox/filesystem-v3/boost/filesystem/path.hpp
==============================================================================
--- sandbox/filesystem-v3/boost/filesystem/path.hpp (original)
+++ sandbox/filesystem-v3/boost/filesystem/path.hpp 2010-02-04 17:23:11 EST (Thu, 04 Feb 2010)
@@ -24,6 +24,7 @@
 #include <boost/shared_ptr.hpp>
 #include <boost/static_assert.hpp>
 #include <string>
+#include <iterator>
 #include <cstring>
 #include <iosfwd> // needed by basic_path inserter and extractor
 #include <stdexcept>
@@ -144,12 +145,15 @@
 
     path(const path& p) : m_pathname(p.m_pathname) {}
 
- template <class ContiguousIterator>
- path(ContiguousIterator begin, ContiguousIterator end)
+ template <class InputIterator>
+ path(InputIterator begin, InputIterator end)
     {
       if (begin != end)
- path_traits::convert(&*begin, &*begin+std::distance(begin, end),
- m_pathname, codecvt());
+ {
+ std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
+ s(begin, end);
+ path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, codecvt());
+ }
     }
 
     template <class Source>
@@ -166,13 +170,16 @@
       return *this;
     }
 
- template <class ContiguousIterator>
- path& assign(ContiguousIterator begin, ContiguousIterator end)
+ template <class InputIterator>
+ path& assign(InputIterator begin, InputIterator end)
     {
       m_pathname.clear();
       if (begin != end)
- path_traits::convert(&*begin, &*begin+std::distance(begin, end),
- m_pathname, codecvt());
+ {
+ std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
+ s(begin, end);
+ path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, codecvt());
+ }
       return *this;
     }
 
@@ -191,8 +198,8 @@
 
     path& operator/=(const path& p);
 
- template <class ContiguousIterator>
- path& append(ContiguousIterator begin, ContiguousIterator end);
+ template <class InputIterator>
+ path& append(InputIterator begin, InputIterator end);
 
     template <class Source>
     path& operator/=(Source const& source);
@@ -578,15 +585,15 @@
 // class path member template implementation //
 //--------------------------------------------------------------------------------------//
 
- template <class ContiguousIterator>
- path& path::append(ContiguousIterator begin, ContiguousIterator end)
+ template <class InputIterator>
+ path& path::append(InputIterator begin, InputIterator end)
   {
     if (begin == end)
       return *this;
     string_type::size_type sep_pos(m_append_separator_if_needed());
- if (begin != end)
- path_traits::convert(&*begin, &*begin+std::distance(begin, end),
- m_pathname, codecvt());
+ std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
+ s(begin, end);
+ path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, codecvt());
     if (sep_pos)
       m_erase_redundant_separator(sep_pos);
     return *this;

Modified: sandbox/filesystem-v3/libs/filesystem/doc/do_list.html
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/doc/do_list.html (original)
+++ sandbox/filesystem-v3/libs/filesystem/doc/do_list.html 2010-02-04 17:23:11 EST (Thu, 04 Feb 2010)
@@ -88,7 +88,7 @@
 <p>Distributed under the Boost Software License, Version 1.0. See
 <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>
 <p>Revised
-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->18 January 2010<!--webbot bot="Timestamp" endspan i-checksum="32149" --></p>
+<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->04 February 2010<!--webbot bot="Timestamp" endspan i-checksum="40545" --></p>
 
 <p>&nbsp;</p>
 

Modified: sandbox/filesystem-v3/libs/filesystem/doc/reference.html
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/doc/reference.html (original)
+++ sandbox/filesystem-v3/libs/filesystem/doc/reference.html 2010-02-04 17:23:11 EST (Thu, 04 Feb 2010)
@@ -496,8 +496,8 @@
         path();
         path(const path&amp; p);
 
- template &lt;class ContiguousIterator&gt;
- path(ContiguousIterator begin, ContiguousIterator end);
+ template &lt;class InputIterator&gt;
+ path(InputIterator begin, InputIterator end);
 
         template &lt;class Source&gt;
           path(Source const&amp; source);
@@ -507,8 +507,8 @@
         // assignments
         path&amp; operator=(const path&amp; p);
 
- template &lt;class ContiguousIterator&gt;
- path&amp; assign(ContiguousIterator begin, ContiguousIterator end);
+ template &lt;class InputIterator&gt;
+ path&amp; assign(InputIterator begin, InputIterator end);
 
         template &lt;class Source&gt;
           path&amp; operator=(Source const&amp; source);
@@ -516,8 +516,8 @@
         // appends
         path&amp; operator/=(const path&amp; p);
 
- template &lt;class ContiguousIterator&gt;
- path&amp; append(ContiguousIterator begin, ContiguousIterator end);
+ template &lt;class InputIterator&gt;
+ path&amp; append(InputIterator begin, InputIterator end);
 
         template &lt;class Source&gt;
           path&amp; operator/=(Source const&amp; source);
@@ -615,9 +615,9 @@
 implementation. <i>--
 end note</i>]</p>
 </blockquote>
-<p><code><a name="ContiguousIterator">ContiguousIterator</a></code> is required be a standard library <code>RandomIterator</code>
-compliant iterator
-pointing to contiguous storage. The iterator's value type is required to be <code>char</code>, <code>
+<p><code><a name="InputIterator">InputIterator</a></code> is required meet the
+requirements for a C++ standard library <code>RandomIterator</code>
+compliant iterator. The iterator's value type is required to be <code>char</code>, <code>
   wchar_t</code>, <code>char16_t</code>, or <code>char32_t</code>.</p>
 <p><code><a name="Source">Source</a></code> is required to be one of:</p>
 <ul>
@@ -630,9 +630,6 @@
   wchar_t</code>, <code>char16_t</code>, or <code>char32_t</code>.</li>
   <li>A <code>boost::filesystem::directory_entry</code>.</li>
 </ul>
-<p>Iteration over <code>ContiguousIterator</code>
-and <code>Source</code> arguments shall result in generic pathname format or
-native pathname format strings.</p>
 <p>The specifications for certain <code>path</code> functions require that
 arguments in the generic pathname format be converted to native pathname format
 as they are stored in <code>pathname</code>. If the native format requires
@@ -679,8 +676,8 @@
 <blockquote>
   <p><i>Postconditions:</i> <code>empty()</code>.</p>
   </blockquote>
-<pre>template &lt;class ContiguousIterator&gt;
- path(ContiguousIterator begin, ContiguousIterator end);</pre>
+<pre>template &lt;class InputIterator&gt;
+ path(InputIterator begin, InputIterator end);</pre>
 <pre>template &lt;class Source&gt;
   path(Source const&amp; source);</pre>
 <blockquote>
@@ -697,8 +694,8 @@
 </blockquote>
 <h3> <a name="path-assignments"> <code>
 <font size="4">path</font></code> assignments</a></h3>
-<pre>template &lt;class ContiguousIterator&gt;
- path&amp; assign(ContiguousIterator begin, ContiguousIterator end);</pre>
+<pre>template &lt;class InputIterator&gt;
+ path&amp; assign(InputIterator begin, InputIterator end);</pre>
 <pre>template &lt;class Source&gt;
   path&amp; operator=(Source const&amp; source);</pre>
 <blockquote>
@@ -744,8 +741,8 @@
   </blockquote>
   <p><i>Returns: </i><code>*this</code></p>
 </blockquote>
-<pre>template &lt;class ContiguousIterator&gt;
- path&amp; append(ContiguousIterator begin, ContiguousIterator end);</pre>
+<pre>template &lt;class InputIterator&gt;
+ path&amp; append(InputIterator begin, InputIterator end);</pre>
 <pre>template &lt;class Source&gt;
   path&amp; operator/=(Source const &amp; source);</pre>
 <blockquote>
@@ -3181,11 +3178,11 @@
   </tr>
 </table>
 <hr>
-<p>© Copyright Beman Dawes, 2002, 2006, 2007, 2009</p>
+<p>� Copyright Beman Dawes, 2002, 2006, 2007, 2009</p>
 <p>Distributed under the Boost Software License, Version 1.0. See
 <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>
 <p>Revised
-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->03 February 2010<!--webbot bot="Timestamp" endspan i-checksum="40543" --></p>
+<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->04 February 2010<!--webbot bot="Timestamp" endspan i-checksum="40545" --></p>
 
 </body>
 

Modified: sandbox/filesystem-v3/libs/filesystem/doc/tutorial.html
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/doc/tutorial.html (original)
+++ sandbox/filesystem-v3/libs/filesystem/doc/tutorial.html 2010-02-04 17:23:11 EST (Thu, 04 Feb 2010)
@@ -633,8 +633,8 @@
 <blockquote style="font-size: 10pt">
   <pre>template &lt;class Source&gt;
   path(Source const&amp; source);</pre>
- <pre>template &lt;class ContiguousIterator&gt;
- path(ContiguousIterator begin, ContiguousIterator end);</pre>
+ <pre>template &lt;class InputIterator&gt;
+ path(InputIterator begin, InputIterator end);</pre>
 </blockquote>
 <p>&nbsp;</p>
 <p>In addition to handling a variety of types, class path function templates
@@ -953,7 +953,7 @@
 <p>Distributed under the Boost Software License, Version 1.0. See
 <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>
 <p>Revised
-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->03 February 2010<!--webbot bot="Timestamp" endspan i-checksum="40543" --></p>
+<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->04 February 2010<!--webbot bot="Timestamp" endspan i-checksum="40545" --></p>
 
 </body>
 

Modified: sandbox/filesystem-v3/libs/filesystem/example/Jamfile.v2
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/example/Jamfile.v2 (original)
+++ sandbox/filesystem-v3/libs/filesystem/example/Jamfile.v2 2010-02-04 17:23:11 EST (Thu, 04 Feb 2010)
@@ -20,4 +20,5 @@
 exe tut2 : tut2.cpp ;
 exe tut3 : tut3.cpp ;
 exe tut4 : tut4.cpp ;
+exe tut5 : tut5.cpp ;
 exe path_info : path_info.cpp ;

Modified: sandbox/filesystem-v3/libs/filesystem/example/test/Jamfile.v2
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/example/test/Jamfile.v2 (original)
+++ sandbox/filesystem-v3/libs/filesystem/example/test/Jamfile.v2 2010-02-04 17:23:11 EST (Thu, 04 Feb 2010)
@@ -19,11 +19,13 @@
 exe tut2 : tut2.cpp ;
 exe tut3 : tut3.cpp ;
 exe tut4 : tut4.cpp ;
+exe tut5 : tut5.cpp ;
 exe path_info : path_info.cpp ;
 
 install tut1-copy : tut1 : <location>. ;
 install tut2-copy : tut2 : <location>. ;
 install tut3-copy : tut3 : <location>. ;
 install tut4-copy : tut4 : <location>. ;
+install tut5-copy : tut5 : <location>. ;
 install path_info-copy : path_info : <location>. ;
   

Modified: sandbox/filesystem-v3/libs/filesystem/example/test/setup.bat
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/example/test/setup.bat (original)
+++ sandbox/filesystem-v3/libs/filesystem/example/test/setup.bat 2010-02-04 17:23:11 EST (Thu, 04 Feb 2010)
@@ -7,6 +7,7 @@
 copy /y ..\tut2.cpp >nul
 copy /y ..\tut3.cpp >nul
 copy /y ..\tut4.cpp >nul
+copy /y ..\tut5.cpp >nul
 copy /y ..\path_info.cpp >nul
 del *.exe 2>nul
 del *.pdb 2>nul

Modified: sandbox/filesystem-v3/libs/filesystem/example/test/setup.sh
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/example/test/setup.sh (original)
+++ sandbox/filesystem-v3/libs/filesystem/example/test/setup.sh 2010-02-04 17:23:11 EST (Thu, 04 Feb 2010)
@@ -8,10 +8,12 @@
 cp ../tut2.cpp .
 cp ../tut3.cpp .
 cp ../tut4.cpp .
+cp ../tut5.cpp .
 cp ../path_info.cpp .
 rm tut1 2>/dev/nul
 rm tut2 2>/dev/nul
 rm tut3 2>/dev/nul
 rm tut4 2>/dev/nul
+rm tut5 2>/dev/nul
 rm path_info 2>/dev/nul
 

Added: sandbox/filesystem-v3/libs/filesystem/example/tut5.cpp
==============================================================================
--- (empty file)
+++ sandbox/filesystem-v3/libs/filesystem/example/tut5.cpp 2010-02-04 17:23:11 EST (Thu, 04 Feb 2010)
@@ -0,0 +1,47 @@
+// filesystem tut5.cpp ---------------------------------------------------------------//
+
+// Copyright Beman Dawes 2010
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Library home page: http://www.boost.org/libs/filesystem
+
+#include <boost/filesystem.hpp>
+#include <string>
+#include <list>
+namespace fs = boost::filesystem;
+
+int main()
+{
+ // \u263A is "Unicode WHITE SMILING FACE = have a nice day!"
+ std::string narrow_string ("smile2");
+ std::wstring wide_string (L"smile2\u263A");
+ std::list<char> narrow_list;
+ narrow_list.push_back('s');
+ narrow_list.push_back('m');
+ narrow_list.push_back('i');
+ narrow_list.push_back('l');
+ narrow_list.push_back('e');
+ narrow_list.push_back('3');
+ std::list<wchar_t> wide_list;
+ wide_list.push_back(L's');
+ wide_list.push_back(L'm');
+ wide_list.push_back(L'i');
+ wide_list.push_back(L'l');
+ wide_list.push_back(L'e');
+ wide_list.push_back(L'3');
+ wide_list.push_back(L'\u263A');
+
+ { fs::ofstream f("smile"); }
+ { fs::ofstream f(L"smile\u263A"); }
+ { fs::ofstream f(narrow_string); }
+ { fs::ofstream f(wide_string); }
+ { fs::ofstream f(fs::path(narrow_list.begin(), narrow_list.end())); }
+ { fs::ofstream f(fs::path(wide_list.begin(), wide_list.end())); }
+
+ { fs::ofstream f("../test/smile-generic"); }
+ { fs::ofstream f("..\\test\\smile-windows"); }
+
+ return 0;
+}

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 2010-02-04 17:23:11 EST (Thu, 04 Feb 2010)
@@ -94,6 +94,12 @@
                 {FFD738F7-96F0-445C-81EA-551665EF53D1} = {FFD738F7-96F0-445C-81EA-551665EF53D1}
         EndProjectSection
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tut5", "tut5\tut5.vcproj", "{9D7703A1-F076-4362-BE31-A1C5893D05DF}"
+ ProjectSection(ProjectDependencies) = postProject
+ {F94CCADD-A90B-480C-A304-C19D015D36B1} = {F94CCADD-A90B-480C-A304-C19D015D36B1}
+ {FFD738F7-96F0-445C-81EA-551665EF53D1} = {FFD738F7-96F0-445C-81EA-551665EF53D1}
+ EndProjectSection
+EndProject
 Global
         GlobalSection(SolutionConfigurationPlatforms) = preSolution
                 Debug|Win32 = Debug|Win32
@@ -183,6 +189,10 @@
                 {1AEABC96-F4D5-4B15-B246-3AA34A1827CB}.Debug|Win32.Build.0 = Debug|Win32
                 {1AEABC96-F4D5-4B15-B246-3AA34A1827CB}.Release|Win32.ActiveCfg = Release|Win32
                 {1AEABC96-F4D5-4B15-B246-3AA34A1827CB}.Release|Win32.Build.0 = Release|Win32
+ {9D7703A1-F076-4362-BE31-A1C5893D05DF}.Debug|Win32.ActiveCfg = Debug|Win32
+ {9D7703A1-F076-4362-BE31-A1C5893D05DF}.Debug|Win32.Build.0 = Debug|Win32
+ {9D7703A1-F076-4362-BE31-A1C5893D05DF}.Release|Win32.ActiveCfg = Release|Win32
+ {9D7703A1-F076-4362-BE31-A1C5893D05DF}.Release|Win32.Build.0 = Release|Win32
         EndGlobalSection
         GlobalSection(SolutionProperties) = preSolution
                 HideSolutionNode = FALSE

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 2010-02-04 17:23:11 EST (Thu, 04 Feb 2010)
@@ -27,6 +27,7 @@
 #include <sstream>
 #include <string>
 #include <locale>
+#include <list>
 
 namespace fs = boost::filesystem;
 namespace bs = boost::system;
@@ -93,6 +94,8 @@
 
   string s("string");
   wstring ws(L"wstring");
+ std::list<char> l; // see main() for initialization to s, t, r, i, n, g
+ std::list<wchar_t> wl; // see main() for initialization to w, s, t, r, i, n, g
 
   // test_constructors ---------------------------------------------------------------//
 
@@ -104,7 +107,7 @@
     PATH_IS(x0, L"");
     BOOST_TEST_EQ(x0.native().size(), 0U);
 
- path x1(s.begin(), s.end()); // iterator range char
+ path x1(l.begin(), l.end()); // iterator range char
     PATH_IS(x1, L"string");
     BOOST_TEST_EQ(x1.native().size(), 6U);
 
@@ -112,7 +115,7 @@
     PATH_IS(x2, L"string");
     BOOST_TEST_EQ(x2.native().size(), 6U);
 
- path x3(ws.begin(), ws.end()); // iterator range wchar_t
+ path x3(wl.begin(), wl.end()); // iterator range wchar_t
     PATH_IS(x3, L"wstring");
     BOOST_TEST_EQ(x3.native().size(), 7U);
 
@@ -158,10 +161,10 @@
     PATH_IS(x, L"yet another path");
     BOOST_TEST_EQ(x.native().size(), 16U);
 
- x.assign(s.begin(), s.end()); // iterator range char
+ x.assign(l.begin(), l.end()); // iterator range char
     PATH_IS(x, L"string");
 
- x.assign(ws.begin(), ws.end()); // iterator range wchar_t
+ x.assign(wl.begin(), wl.end()); // iterator range wchar_t
     PATH_IS(x, L"wstring");
 
     x = string("std::string"); // container char
@@ -216,11 +219,11 @@
     PATH_IS(x, BOOST_FS_FOO L"yet another path");
 
     x = "/foo";
- x.append(s.begin(), s.end()); // iterator range char
+ x.append(l.begin(), l.end()); // iterator range char
     PATH_IS(x, BOOST_FS_FOO L"string");
 
     x = "/foo";
- x.append(ws.begin(), ws.end()); // iterator range wchar_t
+ x.append(wl.begin(), wl.end()); // iterator range wchar_t
     PATH_IS(x, BOOST_FS_FOO L"wstring");
 
     x = "/foo";
@@ -806,6 +809,21 @@
   cout << "BOOST_WINDOWS_PATH\n";
 #endif
 
+ l.push_back('s');
+ l.push_back('t');
+ l.push_back('r');
+ l.push_back('i');
+ l.push_back('n');
+ l.push_back('g');
+
+ wl.push_back(L'w');
+ wl.push_back(L's');
+ wl.push_back(L't');
+ wl.push_back(L'r');
+ wl.push_back(L'i');
+ wl.push_back(L'n');
+ wl.push_back(L'g');
+
   test_overloads();
   test_constructors();
   test_assignments();


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