stabilize build system: depends, installer, boost/bdb fixes, cross targets groundwork
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
// boost/filesystem/v3/config.hpp ----------------------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes 2003
|
||||
|
||||
// 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
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
#ifndef BOOST_FILESYSTEM3_CONFIG_HPP
|
||||
#define BOOST_FILESYSTEM3_CONFIG_HPP
|
||||
|
||||
# if defined(BOOST_FILESYSTEM_VERSION) && BOOST_FILESYSTEM_VERSION != 3
|
||||
# error Compiling Filesystem version 3 file with BOOST_FILESYSTEM_VERSION defined != 3
|
||||
# endif
|
||||
|
||||
# if !defined(BOOST_FILESYSTEM_VERSION)
|
||||
# define BOOST_FILESYSTEM_VERSION 3
|
||||
# endif
|
||||
|
||||
#define BOOST_FILESYSTEM_I18N // aid users wishing to compile several versions
|
||||
|
||||
// This header implements separate compilation features as described in
|
||||
// http://www.boost.org/more/separate_compilation.html
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/system/api_config.hpp> // for BOOST_POSIX_API or BOOST_WINDOWS_API
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
// BOOST_FILESYSTEM_DEPRECATED needed for source compiles -----------------------------//
|
||||
|
||||
# ifdef BOOST_FILESYSTEM_SOURCE
|
||||
# define BOOST_FILESYSTEM_DEPRECATED
|
||||
# undef BOOST_FILESYSTEM_NO_DEPRECATED // fixes #9454, src bld fails if NO_DEP defined
|
||||
# endif
|
||||
|
||||
// throw an exception ----------------------------------------------------------------//
|
||||
//
|
||||
// Exceptions were originally thrown via boost::throw_exception().
|
||||
// As throw_exception() became more complex, it caused user error reporting
|
||||
// to be harder to interpret, since the exception reported became much more complex.
|
||||
// The immediate fix was to throw directly, wrapped in a macro to make any later change
|
||||
// easier.
|
||||
|
||||
#define BOOST_FILESYSTEM_THROW(EX) throw EX
|
||||
|
||||
# if defined( BOOST_NO_STD_WSTRING )
|
||||
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
||||
# endif
|
||||
|
||||
// This header implements separate compilation features as described in
|
||||
// http://www.boost.org/more/separate_compilation.html
|
||||
|
||||
// normalize macros ------------------------------------------------------------------//
|
||||
|
||||
#if !defined(BOOST_FILESYSTEM_DYN_LINK) && !defined(BOOST_FILESYSTEM_STATIC_LINK) \
|
||||
&& !defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_ALL_STATIC_LINK)
|
||||
# define BOOST_FILESYSTEM_STATIC_LINK
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_FILESYSTEM_DYN_LINK)
|
||||
# define BOOST_FILESYSTEM_DYN_LINK
|
||||
#elif defined(BOOST_ALL_STATIC_LINK) && !defined(BOOST_FILESYSTEM_STATIC_LINK)
|
||||
# define BOOST_FILESYSTEM_STATIC_LINK
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_FILESYSTEM_DYN_LINK) && defined(BOOST_FILESYSTEM_STATIC_LINK)
|
||||
# error Must not define both BOOST_FILESYSTEM_DYN_LINK and BOOST_FILESYSTEM_STATIC_LINK
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_ALL_NO_LIB) && !defined(BOOST_FILESYSTEM_NO_LIB)
|
||||
# define BOOST_FILESYSTEM_NO_LIB
|
||||
#endif
|
||||
|
||||
// enable dynamic linking ------------------------------------------------------------//
|
||||
|
||||
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_FILESYSTEM_DYN_LINK)
|
||||
# if defined(BOOST_FILESYSTEM_SOURCE)
|
||||
# define BOOST_FILESYSTEM_DECL BOOST_SYMBOL_EXPORT
|
||||
# else
|
||||
# define BOOST_FILESYSTEM_DECL BOOST_SYMBOL_IMPORT
|
||||
# endif
|
||||
#else
|
||||
# define BOOST_FILESYSTEM_DECL
|
||||
#endif
|
||||
|
||||
// enable automatic library variant selection ----------------------------------------//
|
||||
|
||||
#if !defined(BOOST_FILESYSTEM_SOURCE) && !defined(BOOST_ALL_NO_LIB) \
|
||||
&& !defined(BOOST_FILESYSTEM_NO_LIB)
|
||||
//
|
||||
// Set the name of our library, this will get undef'ed by auto_link.hpp
|
||||
// once it's done with it:
|
||||
//
|
||||
#define BOOST_LIB_NAME boost_filesystem
|
||||
//
|
||||
// If we're importing code from a dll, then tell auto_link.hpp about it:
|
||||
//
|
||||
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_FILESYSTEM_DYN_LINK)
|
||||
# define BOOST_DYN_LINK
|
||||
#endif
|
||||
//
|
||||
// And include the header that does the work:
|
||||
//
|
||||
#include <boost/config/auto_link.hpp>
|
||||
#endif // auto-linking disabled
|
||||
|
||||
#endif // BOOST_FILESYSTEM3_CONFIG_HPP
|
||||
@@ -0,0 +1,58 @@
|
||||
// boost/filesystem/convenience.hpp ----------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes, 2002-2005
|
||||
// Copyright Vladimir Prus, 2002
|
||||
// Use, modification, and distribution is subject to 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)
|
||||
|
||||
// See library home page at http://www.boost.org/libs/filesystem
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#ifndef BOOST_FILESYSTEM3_CONVENIENCE_HPP
|
||||
#define BOOST_FILESYSTEM3_CONVENIENCE_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
# if defined( BOOST_NO_STD_WSTRING )
|
||||
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
||||
# endif
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
|
||||
#include <boost/config/abi_prefix.hpp> // must be the last #include
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
|
||||
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
|
||||
|
||||
inline std::string extension(const path & p)
|
||||
{
|
||||
return p.extension().string();
|
||||
}
|
||||
|
||||
inline std::string basename(const path & p)
|
||||
{
|
||||
return p.stem().string();
|
||||
}
|
||||
|
||||
inline path change_extension( const path & p, const path & new_extension )
|
||||
{
|
||||
path new_p( p );
|
||||
new_p.replace_extension( new_extension );
|
||||
return new_p;
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
|
||||
} // namespace filesystem
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
||||
#endif // BOOST_FILESYSTEM3_CONVENIENCE_HPP
|
||||
@@ -0,0 +1,44 @@
|
||||
// boost/filesystem/detail/macro_value.hpp -------------------------------------------//
|
||||
|
||||
// (C) Copyright John Maddock 2001 - 2003
|
||||
// (C) Copyright Jens Maurer 2001
|
||||
// (C) Copyright Peter Dimov 2001
|
||||
// (C) Copyright Darin Adler 2001
|
||||
// (C) Copyright Beman Dawes 2002
|
||||
|
||||
// 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
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
#ifndef BOOST_FILESYSTEM_MACRO_VALUE_HPP
|
||||
#define BOOST_FILESYSTEM_MACRO_VALUE_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstdlib>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
inline const char* macro_value(const char* name, const char* value)
|
||||
{
|
||||
static const char* no_value = "[no value]";
|
||||
static const char* not_defined = "[not defined]";
|
||||
|
||||
BOOST_ASSERT_MSG(name, "name argument must not be a null pointer");
|
||||
BOOST_ASSERT_MSG(value, "value argument must not be a null pointer");
|
||||
|
||||
return strcmp(name, value + 1)
|
||||
? ((*value && *(value+1)) ? (value+1) : no_value)
|
||||
: not_defined; // name == value+1 so the macro is not defined
|
||||
}
|
||||
} // detail
|
||||
} // boost
|
||||
|
||||
#define BOOST_MACRO_VALUE(X) boost::detail::macro_value(#X, BOOST_STRINGIZE(=X))
|
||||
|
||||
#endif // BOOST_FILESYSTEM_MACRO_VALUE_HPP
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright (c) 2001 Ronald Garcia, Indiana University (garcia@osl.iu.edu)
|
||||
// Andrew Lumsdaine, Indiana University (lums@osl.iu.edu).
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_FILESYSTEM_UTF8_CODECVT_FACET_HPP
|
||||
#define BOOST_FILESYSTEM_UTF8_CODECVT_FACET_HPP
|
||||
|
||||
#include <boost/filesystem/config.hpp>
|
||||
|
||||
#define BOOST_UTF8_BEGIN_NAMESPACE \
|
||||
namespace boost { namespace filesystem { namespace detail {
|
||||
|
||||
#define BOOST_UTF8_END_NAMESPACE }}}
|
||||
#define BOOST_UTF8_DECL BOOST_FILESYSTEM_DECL
|
||||
|
||||
#include <boost/detail/utf8_codecvt_facet.hpp>
|
||||
|
||||
#undef BOOST_UTF8_BEGIN_NAMESPACE
|
||||
#undef BOOST_UTF8_END_NAMESPACE
|
||||
#undef BOOST_UTF8_DECL
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,9 @@
|
||||
// boost/filesystem/exception.hpp -----------------------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes 2003
|
||||
// Use, modification, and distribution is subject to 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)
|
||||
|
||||
// This header is no longer used. The contents have been moved to path.hpp.
|
||||
// It is provided so that user code #includes do not have to be changed.
|
||||
@@ -0,0 +1,182 @@
|
||||
// boost/filesystem/fstream.hpp ------------------------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes 2002
|
||||
|
||||
// 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
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
#ifndef BOOST_FILESYSTEM3_FSTREAM_HPP
|
||||
#define BOOST_FILESYSTEM3_FSTREAM_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
# if defined( BOOST_NO_STD_WSTRING )
|
||||
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
||||
# endif
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <iosfwd>
|
||||
#include <fstream>
|
||||
|
||||
#include <boost/config/abi_prefix.hpp> // must be the last #include
|
||||
|
||||
// on Windows, except for standard libaries known to have wchar_t overloads for
|
||||
// file stream I/O, use path::string() to get a narrow character c_str()
|
||||
#if defined(BOOST_WINDOWS_API) \
|
||||
&& (!defined(_CPPLIB_VER) || _CPPLIB_VER < 405 || defined(_STLPORT_VERSION))
|
||||
// !Dinkumware || early Dinkumware || STLPort masquerading as Dinkumware
|
||||
# define BOOST_FILESYSTEM_C_STR string().c_str() // use narrow, since wide not available
|
||||
#else // use the native c_str, which will be narrow on POSIX, wide on Windows
|
||||
# define BOOST_FILESYSTEM_C_STR c_str()
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
// basic_filebuf //
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
template < class charT, class traits = std::char_traits<charT> >
|
||||
class basic_filebuf : public std::basic_filebuf<charT,traits>
|
||||
{
|
||||
private: // disallow copying
|
||||
basic_filebuf(const basic_filebuf&);
|
||||
const basic_filebuf& operator=(const basic_filebuf&);
|
||||
|
||||
public:
|
||||
basic_filebuf() {}
|
||||
virtual ~basic_filebuf() {}
|
||||
|
||||
basic_filebuf<charT,traits>*
|
||||
open(const path& p, std::ios_base::openmode mode)
|
||||
{
|
||||
return std::basic_filebuf<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR, mode)
|
||||
? this : 0;
|
||||
}
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
// basic_ifstream //
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
template < class charT, class traits = std::char_traits<charT> >
|
||||
class basic_ifstream : public std::basic_ifstream<charT,traits>
|
||||
{
|
||||
private: // disallow copying
|
||||
basic_ifstream(const basic_ifstream&);
|
||||
const basic_ifstream& operator=(const basic_ifstream&);
|
||||
|
||||
public:
|
||||
basic_ifstream() {}
|
||||
|
||||
// use two signatures, rather than one signature with default second
|
||||
// argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
|
||||
|
||||
explicit basic_ifstream(const path& p)
|
||||
: std::basic_ifstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR, std::ios_base::in) {}
|
||||
|
||||
basic_ifstream(const path& p, std::ios_base::openmode mode)
|
||||
: std::basic_ifstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR, mode) {}
|
||||
|
||||
void open(const path& p)
|
||||
{ std::basic_ifstream<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR, std::ios_base::in); }
|
||||
|
||||
void open(const path& p, std::ios_base::openmode mode)
|
||||
{ std::basic_ifstream<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR, mode); }
|
||||
|
||||
virtual ~basic_ifstream() {}
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
// basic_ofstream //
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
template < class charT, class traits = std::char_traits<charT> >
|
||||
class basic_ofstream : public std::basic_ofstream<charT,traits>
|
||||
{
|
||||
private: // disallow copying
|
||||
basic_ofstream(const basic_ofstream&);
|
||||
const basic_ofstream& operator=(const basic_ofstream&);
|
||||
|
||||
public:
|
||||
basic_ofstream() {}
|
||||
|
||||
// use two signatures, rather than one signature with default second
|
||||
// argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
|
||||
|
||||
explicit basic_ofstream(const path& p)
|
||||
: std::basic_ofstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR, std::ios_base::out) {}
|
||||
|
||||
basic_ofstream(const path& p, std::ios_base::openmode mode)
|
||||
: std::basic_ofstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR, mode) {}
|
||||
|
||||
void open(const path& p)
|
||||
{ std::basic_ofstream<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR, std::ios_base::out); }
|
||||
|
||||
void open(const path& p, std::ios_base::openmode mode)
|
||||
{ std::basic_ofstream<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR, mode); }
|
||||
|
||||
virtual ~basic_ofstream() {}
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
// basic_fstream //
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
template < class charT, class traits = std::char_traits<charT> >
|
||||
class basic_fstream : public std::basic_fstream<charT,traits>
|
||||
{
|
||||
private: // disallow copying
|
||||
basic_fstream(const basic_fstream&);
|
||||
const basic_fstream & operator=(const basic_fstream&);
|
||||
|
||||
public:
|
||||
basic_fstream() {}
|
||||
|
||||
// use two signatures, rather than one signature with default second
|
||||
// argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
|
||||
|
||||
explicit basic_fstream(const path& p)
|
||||
: std::basic_fstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR,
|
||||
std::ios_base::in | std::ios_base::out) {}
|
||||
|
||||
basic_fstream(const path& p, std::ios_base::openmode mode)
|
||||
: std::basic_fstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR, mode) {}
|
||||
|
||||
void open(const path& p)
|
||||
{ std::basic_fstream<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR,
|
||||
std::ios_base::in | std::ios_base::out); }
|
||||
|
||||
void open(const path& p, std::ios_base::openmode mode)
|
||||
{ std::basic_fstream<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR, mode); }
|
||||
|
||||
virtual ~basic_fstream() {}
|
||||
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
// typedefs //
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
typedef basic_filebuf<char> filebuf;
|
||||
typedef basic_ifstream<char> ifstream;
|
||||
typedef basic_ofstream<char> ofstream;
|
||||
typedef basic_fstream<char> fstream;
|
||||
|
||||
typedef basic_filebuf<wchar_t> wfilebuf;
|
||||
typedef basic_ifstream<wchar_t> wifstream;
|
||||
typedef basic_ofstream<wchar_t> wofstream;
|
||||
typedef basic_fstream<wchar_t> wfstream;
|
||||
|
||||
} // namespace filesystem
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
||||
#endif // BOOST_FILESYSTEM3_FSTREAM_HPP
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,352 @@
|
||||
// filesystem path_traits.hpp --------------------------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes 2009
|
||||
|
||||
// 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
|
||||
|
||||
#ifndef BOOST_FILESYSTEM_PATH_TRAITS_HPP
|
||||
#define BOOST_FILESYSTEM_PATH_TRAITS_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
# if defined( BOOST_NO_STD_WSTRING )
|
||||
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
||||
# endif
|
||||
|
||||
#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 <cwchar> // for mbstate_t
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <iterator>
|
||||
#include <locale>
|
||||
#include <boost/assert.hpp>
|
||||
// #include <iostream> //**** comment me out ****
|
||||
|
||||
#include <boost/config/abi_prefix.hpp> // must be the last #include
|
||||
|
||||
namespace boost { namespace filesystem {
|
||||
|
||||
BOOST_FILESYSTEM_DECL const system::error_category& codecvt_error_category();
|
||||
// uses std::codecvt_base::result used for error codes:
|
||||
//
|
||||
// ok: Conversion successful.
|
||||
// partial: Not all source characters converted; one or more additional source
|
||||
// characters are needed to produce the final target character, or the
|
||||
// size of the target intermediate buffer was too small to hold the result.
|
||||
// error: A character in the source could not be converted to the target encoding.
|
||||
// noconv: The source and target characters have the same type and encoding, so no
|
||||
// conversion was necessary.
|
||||
|
||||
class directory_entry;
|
||||
|
||||
namespace path_traits {
|
||||
|
||||
typedef std::codecvt<wchar_t, char, std::mbstate_t> codecvt_type;
|
||||
|
||||
// is_pathable type trait; allows disabling over-agressive class path member templates
|
||||
|
||||
template <class T>
|
||||
struct is_pathable { static const bool value = false; };
|
||||
|
||||
template<> struct is_pathable<char*> { static const bool value = true; };
|
||||
template<> struct is_pathable<const char*> { static const bool value = true; };
|
||||
template<> struct is_pathable<wchar_t*> { static const bool value = true; };
|
||||
template<> struct is_pathable<const wchar_t*> { static const bool value = true; };
|
||||
template<> struct is_pathable<std::string> { static const bool value = true; };
|
||||
template<> struct is_pathable<std::wstring> { static const bool value = true; };
|
||||
template<> struct is_pathable<std::vector<char> > { static const bool value = true; };
|
||||
template<> struct is_pathable<std::vector<wchar_t> > { static const bool value = true; };
|
||||
template<> struct is_pathable<std::list<char> > { static const bool value = true; };
|
||||
template<> struct is_pathable<std::list<wchar_t> > { static const bool value = true; };
|
||||
template<> struct is_pathable<directory_entry> { static const bool value = true; };
|
||||
|
||||
// Pathable empty
|
||||
|
||||
template <class Container> inline
|
||||
// disable_if aids broken compilers (IBM, old GCC, etc.) and is harmless for
|
||||
// conforming compilers. Replace by plain "bool" at some future date (2012?)
|
||||
typename boost::disable_if<boost::is_array<Container>, bool>::type
|
||||
empty(const Container & c)
|
||||
{ return c.begin() == c.end(); }
|
||||
|
||||
template <class T> inline
|
||||
bool empty(T * const & c_str)
|
||||
{
|
||||
BOOST_ASSERT(c_str);
|
||||
return !*c_str;
|
||||
}
|
||||
|
||||
template <typename T, size_t N> inline
|
||||
bool empty(T (&x)[N])
|
||||
{ return !x[0]; }
|
||||
|
||||
// value types differ ---------------------------------------------------------------//
|
||||
//
|
||||
// A from_end argument of 0 is less efficient than a known end, so use only if needed
|
||||
|
||||
// with codecvt
|
||||
|
||||
BOOST_FILESYSTEM_DECL
|
||||
void convert(const char* from,
|
||||
const char* from_end, // 0 for null terminated MBCS
|
||||
std::wstring & to,
|
||||
const codecvt_type& cvt);
|
||||
|
||||
BOOST_FILESYSTEM_DECL
|
||||
void convert(const wchar_t* from,
|
||||
const wchar_t* from_end, // 0 for null terminated MBCS
|
||||
std::string & to,
|
||||
const codecvt_type& cvt);
|
||||
|
||||
inline
|
||||
void convert(const char* from,
|
||||
std::wstring & to,
|
||||
const codecvt_type& cvt)
|
||||
{
|
||||
BOOST_ASSERT(from);
|
||||
convert(from, 0, to, cvt);
|
||||
}
|
||||
|
||||
inline
|
||||
void convert(const wchar_t* from,
|
||||
std::string & to,
|
||||
const codecvt_type& cvt)
|
||||
{
|
||||
BOOST_ASSERT(from);
|
||||
convert(from, 0, to, cvt);
|
||||
}
|
||||
|
||||
// without codecvt
|
||||
|
||||
inline
|
||||
void convert(const char* from,
|
||||
const char* from_end, // 0 for null terminated MBCS
|
||||
std::wstring & to);
|
||||
|
||||
inline
|
||||
void convert(const wchar_t* from,
|
||||
const wchar_t* from_end, // 0 for null terminated MBCS
|
||||
std::string & to);
|
||||
|
||||
inline
|
||||
void convert(const char* from,
|
||||
std::wstring & to);
|
||||
|
||||
inline
|
||||
void convert(const wchar_t* from,
|
||||
std::string & to);
|
||||
|
||||
// value types same -----------------------------------------------------------------//
|
||||
|
||||
// char with codecvt
|
||||
|
||||
inline
|
||||
void convert(const char* from, const char* from_end, std::string & to,
|
||||
const codecvt_type&)
|
||||
{
|
||||
BOOST_ASSERT(from);
|
||||
BOOST_ASSERT(from_end);
|
||||
to.append(from, from_end);
|
||||
}
|
||||
|
||||
inline
|
||||
void convert(const char* from,
|
||||
std::string & to,
|
||||
const codecvt_type&)
|
||||
{
|
||||
BOOST_ASSERT(from);
|
||||
to += from;
|
||||
}
|
||||
|
||||
// wchar_t with codecvt
|
||||
|
||||
inline
|
||||
void convert(const wchar_t* from, const wchar_t* from_end, std::wstring & to,
|
||||
const codecvt_type&)
|
||||
{
|
||||
BOOST_ASSERT(from);
|
||||
BOOST_ASSERT(from_end);
|
||||
to.append(from, from_end);
|
||||
}
|
||||
|
||||
inline
|
||||
void convert(const wchar_t* from,
|
||||
std::wstring & to,
|
||||
const codecvt_type&)
|
||||
{
|
||||
BOOST_ASSERT(from);
|
||||
to += from;
|
||||
}
|
||||
|
||||
// char without codecvt
|
||||
|
||||
inline
|
||||
void convert(const char* from, const char* from_end, std::string & to)
|
||||
{
|
||||
BOOST_ASSERT(from);
|
||||
BOOST_ASSERT(from_end);
|
||||
to.append(from, from_end);
|
||||
}
|
||||
|
||||
inline
|
||||
void convert(const char* from, std::string & to)
|
||||
{
|
||||
BOOST_ASSERT(from);
|
||||
to += from;
|
||||
}
|
||||
|
||||
// wchar_t without codecvt
|
||||
|
||||
inline
|
||||
void convert(const wchar_t* from, const wchar_t* from_end, std::wstring & to)
|
||||
{
|
||||
BOOST_ASSERT(from);
|
||||
BOOST_ASSERT(from_end);
|
||||
to.append(from, from_end);
|
||||
}
|
||||
|
||||
inline
|
||||
void convert(const wchar_t* from, std::wstring & to)
|
||||
{
|
||||
BOOST_ASSERT(from);
|
||||
to += from;
|
||||
}
|
||||
|
||||
// Source dispatch -----------------------------------------------------------------//
|
||||
|
||||
// contiguous containers with codecvt
|
||||
template <class U> inline
|
||||
void dispatch(const std::string& c, U& to, const codecvt_type& cvt)
|
||||
{
|
||||
if (c.size())
|
||||
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
|
||||
}
|
||||
template <class U> inline
|
||||
void dispatch(const std::wstring& c, U& to, const codecvt_type& cvt)
|
||||
{
|
||||
if (c.size())
|
||||
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
|
||||
}
|
||||
template <class U> inline
|
||||
void dispatch(const std::vector<char>& c, U& to, const codecvt_type& cvt)
|
||||
{
|
||||
if (c.size())
|
||||
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
|
||||
}
|
||||
template <class U> inline
|
||||
void dispatch(const std::vector<wchar_t>& c, U& to, const codecvt_type& cvt)
|
||||
{
|
||||
if (c.size())
|
||||
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
|
||||
}
|
||||
|
||||
// contiguous containers without codecvt
|
||||
template <class U> inline
|
||||
void dispatch(const std::string& c, U& to)
|
||||
{
|
||||
if (c.size())
|
||||
convert(&*c.begin(), &*c.begin() + c.size(), to);
|
||||
}
|
||||
template <class U> inline
|
||||
void dispatch(const std::wstring& c, U& to)
|
||||
{
|
||||
if (c.size())
|
||||
convert(&*c.begin(), &*c.begin() + c.size(), to);
|
||||
}
|
||||
template <class U> inline
|
||||
void dispatch(const std::vector<char>& c, U& to)
|
||||
{
|
||||
if (c.size())
|
||||
convert(&*c.begin(), &*c.begin() + c.size(), to);
|
||||
}
|
||||
template <class U> inline
|
||||
void dispatch(const std::vector<wchar_t>& c, U& to)
|
||||
{
|
||||
if (c.size())
|
||||
convert(&*c.begin(), &*c.begin() + c.size(), to);
|
||||
}
|
||||
|
||||
// non-contiguous containers with codecvt
|
||||
template <class Container, class U> inline
|
||||
// disable_if aids broken compilers (IBM, old GCC, etc.) and is harmless for
|
||||
// conforming compilers. Replace by plain "void" at some future date (2012?)
|
||||
typename boost::disable_if<boost::is_array<Container>, void>::type
|
||||
dispatch(const Container & c, U& to, const codecvt_type& cvt)
|
||||
{
|
||||
if (c.size())
|
||||
{
|
||||
std::basic_string<typename Container::value_type> s(c.begin(), c.end());
|
||||
convert(s.c_str(), s.c_str()+s.size(), to, cvt);
|
||||
}
|
||||
}
|
||||
|
||||
// c_str
|
||||
template <class T, class U> inline
|
||||
void dispatch(T * const & c_str, U& to, const codecvt_type& cvt)
|
||||
{
|
||||
// std::cout << "dispatch() const T *\n";
|
||||
BOOST_ASSERT(c_str);
|
||||
convert(c_str, to, cvt);
|
||||
}
|
||||
|
||||
// Note: there is no dispatch on C-style arrays because the array may
|
||||
// contain a string smaller than the array size.
|
||||
|
||||
BOOST_FILESYSTEM_DECL
|
||||
void dispatch(const directory_entry & de,
|
||||
# ifdef BOOST_WINDOWS_API
|
||||
std::wstring & to,
|
||||
# else
|
||||
std::string & to,
|
||||
# endif
|
||||
const codecvt_type&);
|
||||
|
||||
// non-contiguous containers without codecvt
|
||||
template <class Container, class U> inline
|
||||
// disable_if aids broken compilers (IBM, old GCC, etc.) and is harmless for
|
||||
// conforming compilers. Replace by plain "void" at some future date (2012?)
|
||||
typename boost::disable_if<boost::is_array<Container>, void>::type
|
||||
dispatch(const Container & c, U& to)
|
||||
{
|
||||
if (c.size())
|
||||
{
|
||||
std::basic_string<typename Container::value_type> seq(c.begin(), c.end());
|
||||
convert(seq.c_str(), seq.c_str()+seq.size(), to);
|
||||
}
|
||||
}
|
||||
|
||||
// c_str
|
||||
template <class T, class U> inline
|
||||
void dispatch(T * const & c_str, U& to)
|
||||
{
|
||||
// std::cout << "dispatch() const T *\n";
|
||||
BOOST_ASSERT(c_str);
|
||||
convert(c_str, to);
|
||||
}
|
||||
|
||||
// Note: there is no dispatch on C-style arrays because the array may
|
||||
// contain a string smaller than the array size.
|
||||
|
||||
BOOST_FILESYSTEM_DECL
|
||||
void dispatch(const directory_entry & de,
|
||||
# ifdef BOOST_WINDOWS_API
|
||||
std::wstring & to
|
||||
# else
|
||||
std::string & to
|
||||
# endif
|
||||
);
|
||||
|
||||
|
||||
}}} // namespace boost::filesystem::path_traits
|
||||
|
||||
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
|
||||
|
||||
#endif // BOOST_FILESYSTEM_PATH_TRAITS_HPP
|
||||
@@ -0,0 +1,43 @@
|
||||
// filesystem/string_file.hpp --------------------------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes 2015
|
||||
|
||||
// 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
|
||||
|
||||
#ifndef BOOST_FILESYSTEM_STRING_FILE_HPP
|
||||
#define BOOST_FILESYSTEM_STRING_FILE_HPP
|
||||
|
||||
#include <string>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
inline
|
||||
void save_string_file(const path& p, const std::string& str)
|
||||
{
|
||||
ofstream file;
|
||||
file.exceptions(std::ofstream::failbit | std::ofstream::badbit);
|
||||
file.open(p, std::ios_base::binary);
|
||||
file.write(str.c_str(), str.size());
|
||||
}
|
||||
|
||||
inline
|
||||
void load_string_file(const path& p, std::string& str)
|
||||
{
|
||||
ifstream file;
|
||||
file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
|
||||
file.open(p, std::ios_base::binary);
|
||||
std::size_t sz = static_cast<std::size_t>(file_size(p));
|
||||
str.resize(sz, '\0');
|
||||
file.read(&str[0], sz);
|
||||
}
|
||||
} // namespace filesystem
|
||||
} // namespace boost
|
||||
|
||||
#endif // include guard
|
||||
Reference in New Issue
Block a user