|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r60129 - sandbox/filesystem-v3/libs/filesystem/example
From: bdawes_at_[hidden]
Date: 2010-03-03 13:59:50
Author: bemandawes
Date: 2010-03-03 13:59:49 EST (Wed, 03 Mar 2010)
New Revision: 60129
URL: http://svn.boost.org/trac/boost/changeset/60129
Log:
Upgrade to V3
Text files modified:
sandbox/filesystem-v3/libs/filesystem/example/Jamfile.v2 | 1
sandbox/filesystem-v3/libs/filesystem/example/path_table.cpp | 157 +++++++++++++--------------------------
2 files changed, 53 insertions(+), 105 deletions(-)
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-03-03 13:59:49 EST (Wed, 03 Mar 2010)
@@ -22,3 +22,4 @@
exe tut4 : tut4.cpp ;
exe tut5 : tut5.cpp ;
exe path_info : path_info.cpp ;
+exe path_table : path_table.cpp ;
Modified: sandbox/filesystem-v3/libs/filesystem/example/path_table.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/example/path_table.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/example/path_table.cpp 2010-03-03 13:59:49 EST (Wed, 03 Mar 2010)
@@ -1,28 +1,19 @@
-// Generate an HTML table showing path decomposition -----------------------//
+// Generate an HTML table showing path decomposition ---------------------------------//
-// Copyright Beman Dawes 2005. Distributed under the Boost
-// Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+// Copyright Beman Dawes 2005.
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
// See http://www.boost.org/libs/filesystem for documentation.
// For purposes of generating the table, support both POSIX and Windows paths
-#define BOOST_FILESYSTEM_NAMESPACE posix
-#define BOOST_POSIX_PATH
-#include "boost/filesystem/path.hpp"
-
-#undef BOOST_FILESYSTEM_PATH_HPP
-#undef BOOST_FILESYSTEM_NAMESPACE
-#define BOOST_FILESYSTEM_NAMESPACE windows
-#define BOOST_WINDOWS_PATH
-#include "boost/filesystem/path.hpp"
-
-namespace pos = boost::posix;
-namespace win = boost::windows;
+#include "boost/filesystem.hpp"
#include <iostream>
#include <fstream>
+using boost::filesystem::path;
using std::string;
using std::cout;
@@ -33,145 +24,100 @@
const string empty_string;
- struct column_abc
+ struct column_base
{
virtual string heading() const = 0;
- virtual string cell_value( const pos::path & p ) const = 0;
- virtual string cell_value( const win::path & p ) const = 0;
+ virtual string cell_value( const path & p ) const = 0;
};
- struct c0 : public column_abc
+ struct c0 : public column_base
{
string heading() const { return string("<code>string()</code>"); }
- string cell_value( const pos::path & p ) const
- {
- return p.string();
- }
- string cell_value( const win::path & p ) const
- {
- return p.string();
- }
+ string cell_value( const path & p ) const { return p.string(); }
} o0;
- struct c1 : public column_abc
+ struct c1 : public column_base
{
- string heading() const { return string("<code>file_<br>string()"); }
- string cell_value( const pos::path & p ) const { return p.file_string(); }
- string cell_value( const win::path & p ) const { return p.file_string(); }
+ string heading() const { return string("<code>generic_<br>string()</code>"); }
+ string cell_value( const path & p ) const { return p.generic_string(); }
} o1;
- struct c2 : public column_abc
+ struct c2 : public column_base
{
- string heading() const { return string("Elements found<br>by iteration"); }
- string cell_value( const pos::path & p ) const
+ string heading() const { return string("Iteration<br>over<br>Elements"); }
+ string cell_value( const path & p ) const
{
string s;
- for( pos::path::iterator i(p.begin()); i != p.end(); ++i )
+ for( path::iterator i(p.begin()); i != p.end(); ++i )
{
if ( i != p.begin() ) s += ',';
- s += '\"';
- s += *i;
- s += '\"';
+ s += (*i).string();
}
- if ( s.empty() ) s += "\"\"";
- return s;
- }
- string cell_value( const win::path & p ) const
- {
- string s;
- for( win::path::iterator i(p.begin()); i != p.end(); ++i )
- {
- if ( i != p.begin() ) s += ',';
- s += '\"';
- s += *i;
- s += '\"';
- }
- if ( s.empty() ) s += "\"\"";
return s;
}
} o2;
- struct c3 : public column_abc
+ struct c3 : public column_base
{
- string heading() const { return string("<code>root_<br>path()<br>.string()</code>"); }
- string cell_value( const pos::path & p ) const { return p.root_path().string(); }
- string cell_value( const win::path & p ) const { return p.root_path().string(); }
+ string heading() const { return string("<code>root_<br>path()</code>"); }
+ string cell_value( const path & p ) const { return p.root_path().string(); }
} o3;
- struct c4 : public column_abc
+ struct c4 : public column_base
{
string heading() const { return string("<code>root_<br>name()</code>"); }
- string cell_value( const pos::path & p ) const { return p.root_name(); }
- string cell_value( const win::path & p ) const { return p.root_name(); }
+ string cell_value( const path & p ) const { return p.root_name().string(); }
} o4;
- struct c5 : public column_abc
+ struct c5 : public column_base
{
string heading() const { return string("<code>root_<br>directory()</code>"); }
- string cell_value( const pos::path & p ) const { return p.root_directory(); }
- string cell_value( const win::path & p ) const { return p.root_directory(); }
+ string cell_value( const path & p ) const { return p.root_directory().string(); }
} o5;
- struct c6 : public column_abc
+ struct c6 : public column_base
{
- string heading() const { return string("<code>relative_<br>path()<br>.string()</code>"); }
- string cell_value( const pos::path & p ) const { return p.relative_path().string(); }
- string cell_value( const win::path & p ) const { return p.relative_path().string(); }
+ string heading() const { return string("<code>relative_<br>path()</code>"); }
+ string cell_value( const path & p ) const { return p.relative_path().string(); }
} o6;
- struct c7 : public column_abc
+ struct c7 : public column_base
{
- string heading() const { return string("<code>branch_<br>path()<br>.string()</code>"); }
- string cell_value( const pos::path & p ) const { return p.branch_path().string(); }
- string cell_value( const win::path & p ) const { return p.branch_path().string(); }
+ string heading() const { return string("<code>parent_<br>path(</code>"); }
+ string cell_value( const path & p ) const { return p.parent_path().string(); }
} o7;
- struct c8 : public column_abc
+ struct c8 : public column_base
{
- string heading() const { return string("<code>leaf()</code>"); }
- string cell_value( const pos::path & p ) const { return p.leaf(); }
- string cell_value( const win::path & p ) const { return p.leaf(); }
+ string heading() const { return string("<code>filename()</code>"); }
+ string cell_value( const path & p ) const { return p.filename().string(); }
} o8;
- const column_abc * column[] = { &o2, &o0, &o1, &o3, &o4, &o5, &o6, &o7, &o8 };
+ const column_base * column[] = { &o2, &o0, &o1, &o3, &o4, &o5, &o6, &o7, &o8 };
// do_cell ---------------------------------------------------------------//
void do_cell( const string & test_case, int i )
{
-
- string posix_result( column[i]->cell_value( pos::path(test_case) ) );
- string windows_result( column[i]->cell_value( win::path(test_case) ) );
-
- outfile <<
- (posix_result != windows_result
- ? "<td bgcolor=\"#CCFF99\"><code>"
- : "<td><code>");
-
- if ( posix_result.empty() || posix_result[0] != '\"' )
- outfile << '\"' << posix_result << '\"';
+ string value = column[i]->cell_value(path(test_case));
+ if (value.empty())
+ outfile << "<td><font size=\"-1\"><i>empty</i></font></td>\n";
else
- outfile << posix_result;
-
- if ( posix_result != windows_result )
- {
- outfile << "<br>";
- if ( windows_result.empty() || windows_result[0] != '\"' )
- outfile << '\"' << windows_result << '\"';
- else
- outfile << windows_result;
- }
-
- outfile << "</code></td>\n";
+ outfile << "<td><code>" << value << "</code></td>\n";
}
// do_row ------------------------------------------------------------------//
void do_row( const string & test_case )
{
- outfile << "<tr>\n<td><code>\"" << test_case << "\"</code></td>\n";
+ outfile << "<tr>\n";
- for ( int i = 0; i < sizeof(column)/sizeof(column_abc&); ++i )
+ if (test_case.empty())
+ outfile << "<td><font size=\"-1\"><i>empty</i></font></td>\n";
+ else
+ outfile << "<td><code>" << test_case << "</code></td>\n";
+
+ for ( int i = 0; i < sizeof(column)/sizeof(column_base&); ++i )
{
do_cell( test_case, i );
}
@@ -184,7 +130,7 @@
void do_table()
{
outfile <<
- "<h1>Path Decomposition Table for <i>POSIX</i> and <i>Windows</i></h1>\n"
+ "<h1>Path Decomposition Table</h1>\n"
"<p>Shaded entries indicate cases where <i>POSIX</i> and <i>Windows</i>\n"
"implementations yield different results. The top value is the\n"
"<i>POSIX</i> result and the bottom value is the <i>Windows</i> result.\n"
@@ -196,7 +142,7 @@
outfile << "<tr><td><b>Constructor<br>argument</b></td>\n";
- for ( int i = 0; i < sizeof(column)/sizeof(column_abc&); ++i )
+ for ( int i = 0; i < sizeof(column)/sizeof(column_base&); ++i )
{
outfile << "<td><b>" << column[i]->heading() << "</b></td>\n";
}
@@ -208,7 +154,8 @@
string test_case;
while ( std::getline( infile, test_case ) )
{
- do_row( test_case );
+ if (test_case.empty() || test_case[0] != '#')
+ do_row( test_case );
}
outfile << "</table>\n";
@@ -216,7 +163,7 @@
} // unnamed namespace
-// main --------------------------------------------------------------------//
+// main ------------------------------------------------------------------------------//
#define BOOST_NO_CPP_MAIN_SUCCESS_MESSAGE
#include <boost/test/included/prg_exec_monitor.hpp>
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