mirror of
https://github.com/boostorg/filesystem.git
synced 2026-01-29 19:42:08 +00:00
is_iterator dispatch working. Unstable work-in-progress.
This commit is contained in:
@@ -12,6 +12,10 @@
|
||||
#ifndef BOOST_FILESYSTEM3_CONFIG_HPP
|
||||
#define BOOST_FILESYSTEM3_CONFIG_HPP
|
||||
|
||||
// during initial development on a branch, defining BOOST_FILESYSTEM_TS here is fast and easy
|
||||
#define BOOST_FILESYSTEM_TS
|
||||
|
||||
|
||||
# if defined(BOOST_FILESYSTEM_VERSION) && BOOST_FILESYSTEM_VERSION != 3
|
||||
# error Compiling Filesystem version 3 file with BOOST_FILESYSTEM_VERSION defined != 3
|
||||
# endif
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/* TODO:
|
||||
|
||||
* What was the purpose of is_pathable? Is it still needed? If so, it needs to be generalized.
|
||||
If Source is an iterator or container with a value_type of one of the encoded character types
|
||||
then it is OK. See C:\boost\trunk-ex\libs\interop\include\boost\interop\detail\iterator_value.hpp
|
||||
for workarounds for some issues.
|
||||
|
||||
*/
|
||||
// filesystem path.hpp ---------------------------------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes 2002-2005, 2009
|
||||
@@ -31,6 +39,7 @@
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/functional/hash_fwd.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/type_traits/decay.hpp>
|
||||
#include <string>
|
||||
#include <iterator>
|
||||
#include <cstring>
|
||||
@@ -40,6 +49,8 @@
|
||||
#include <locale>
|
||||
#include <algorithm>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/config/abi_prefix.hpp> // must be the last #include
|
||||
|
||||
namespace boost
|
||||
@@ -131,11 +142,15 @@ namespace filesystem
|
||||
|
||||
path(const path& p) : m_pathname(p.m_pathname) {}
|
||||
|
||||
#ifndef BOOST_FILESYSTEM_TS
|
||||
// --- traditional signatures --
|
||||
|
||||
template <class Source>
|
||||
path(Source const& source,
|
||||
typename boost::enable_if<path_traits::is_pathable<
|
||||
typename boost::decay<Source>::type> >::type* =0)
|
||||
{
|
||||
|
||||
path_traits::dispatch(source, m_pathname, codecvt());
|
||||
}
|
||||
|
||||
@@ -180,7 +195,23 @@ namespace filesystem
|
||||
path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, cvt);
|
||||
}
|
||||
}
|
||||
#else
|
||||
// --- ISO Technical Specification signatures --
|
||||
|
||||
template <class Source>
|
||||
path(const Source& source)
|
||||
{
|
||||
detail::append(source, m_pathname,
|
||||
typename path_traits::source_tag<typename boost::decay<Source>::type>::type());
|
||||
}
|
||||
|
||||
template <class InputIterator>
|
||||
path(InputIterator first, InputIterator last)
|
||||
{
|
||||
detail::append(first, last, m_pathname);
|
||||
}
|
||||
|
||||
#endif
|
||||
// ----- assignments -----
|
||||
|
||||
path& operator=(const path& p)
|
||||
@@ -757,6 +788,33 @@ namespace filesystem
|
||||
std::wstring path::generic_string<std::wstring>(const codecvt_type& cvt) const
|
||||
{ return generic_wstring(cvt); }
|
||||
|
||||
#ifdef BOOST_FILESYSTEM_TS
|
||||
namespace detail
|
||||
{
|
||||
template <class Source>
|
||||
void append(const Source& from, path::string_type& to, path_traits::iterator_source_tag)
|
||||
{
|
||||
std::cout << "*** append from iterator" << std::endl;
|
||||
}
|
||||
|
||||
template <class Source>
|
||||
void append(const Source& from, path::string_type& to, path_traits::container_source_tag)
|
||||
{
|
||||
std::cout << "***" << boost::is_iterator<Source>::value << std::endl;
|
||||
std::cout << "*** append from container" << std::endl;
|
||||
}
|
||||
|
||||
template <class InputIterator>
|
||||
void append(InputIterator first, InputIterator last, path::string_type& to)
|
||||
{
|
||||
std::cout << "***" << boost::is_iterator<Source>::value << std::endl;
|
||||
std::cout << "*** append from range" << std::endl;
|
||||
}
|
||||
|
||||
} // namesapce detail
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace filesystem
|
||||
} // namespace boost
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
#include <boost/filesystem/config.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_array.hpp>
|
||||
#include <boost/type_traits/decay.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/filesystem/detail/is_iterator.hpp>
|
||||
#include <cwchar> // for mbstate_t
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -227,6 +227,25 @@ namespace path_traits {
|
||||
# endif
|
||||
const codecvt_type&);
|
||||
|
||||
//------------------------------------ TS helpers -------------------------------------//
|
||||
|
||||
#ifdef BOOST_FILESYSTEM_TS
|
||||
|
||||
struct iterator_source_tag {};
|
||||
struct container_source_tag {};
|
||||
|
||||
template <class TorF>
|
||||
struct source_tag_helper;
|
||||
template<> struct source_tag_helper<boost::true_type> { typedef iterator_source_tag type; };
|
||||
template<> struct source_tag_helper<boost::false_type> { typedef container_source_tag type; };
|
||||
|
||||
template <class Source>
|
||||
struct source_tag
|
||||
{
|
||||
typedef typename source_tag_helper<typename boost::is_iterator<Source>::type>::type type;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
}}} // namespace boost::filesystem::path_traits
|
||||
|
||||
|
||||
@@ -16,10 +16,8 @@
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
#include <boost/config/warning_disable.hpp>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/detail/lightweight_main.hpp>
|
||||
|
||||
@@ -33,6 +31,9 @@ int cpp_main(int argc, char* argv[])
|
||||
{
|
||||
cout << "Hello, filesystem world" << endl;
|
||||
|
||||
const char* p = ".";
|
||||
|
||||
BOOST_TEST(fs::exists(p));
|
||||
BOOST_TEST(fs::exists("."));
|
||||
|
||||
return ::boost::report_errors();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user