diff options
Diffstat (limited to '3rdParty/Boost/src/tools/bcp/copy_path.cpp')
-rw-r--r-- | 3rdParty/Boost/src/tools/bcp/copy_path.cpp | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/3rdParty/Boost/src/tools/bcp/copy_path.cpp b/3rdParty/Boost/src/tools/bcp/copy_path.cpp index 497dcd5..ded5d18 100644 --- a/3rdParty/Boost/src/tools/bcp/copy_path.cpp +++ b/3rdParty/Boost/src/tools/bcp/copy_path.cpp @@ -1,32 +1,33 @@ /* * * Copyright (c) 2003 Dr John Maddock - * Use, modification and distribution is subject to the - * Boost Software License, Version 1.0. (See accompanying file + * 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 file implements the following: * void bcp_implementation::copy_path(const fs::path& p) * void bcp_implementation::create_path(const fs::path& p) */ #include "bcp_imp.hpp" #include "fileview.hpp" #include <boost/filesystem/operations.hpp> +#include <boost/filesystem/fstream.hpp> #include <boost/regex.hpp> #include <fstream> #include <iterator> #include <algorithm> #include <iostream> struct get_new_library_name -{ +{ get_new_library_name(const std::string& n) : m_new_name(n) {} template <class I> std::string operator()(const boost::match_results<I>& what) { std::string s = what[0]; std::string::size_type n = s.find("boost"); if(n == std::string::npos) { s.insert(0, m_new_name); @@ -57,45 +58,45 @@ void bcp_implementation::copy_path(const fs::path& p) create_path(p.branch_path()); // // do text based copy if requested: // if(p.leaf() == "Jamroot") { static std::vector<char> v1, v2; v1.clear(); v2.clear(); - std::ifstream is((m_boost_path / p).c_str()); + boost::filesystem::ifstream is((m_boost_path / p)); std::copy(std::istreambuf_iterator<char>(is), std::istreambuf_iterator<char>(), std::back_inserter(v1)); static boost::regex libname_matcher; if(libname_matcher.empty()) { libname_matcher.assign("boost_"); } regex_replace(std::back_inserter(v2), v1.begin(), v1.end(), libname_matcher, m_namespace_name + "_"); std::swap(v1, v2); v2.clear(); - std::ofstream os; + boost::filesystem::ofstream os; if(m_unix_lines) - os.open((m_dest_path / p).c_str(), std::ios_base::binary | std::ios_base::out); + os.open((m_dest_path / p), std::ios_base::binary | std::ios_base::out); else - os.open((m_dest_path / p).c_str(), std::ios_base::out); + os.open((m_dest_path / p), std::ios_base::out); os.write(&*v1.begin(), v1.size()); os.close(); } else if(m_namespace_name.size() && m_lib_names.size() && is_jam_file(p)) { static std::vector<char> v1, v2; v1.clear(); v2.clear(); - std::ifstream is((m_boost_path / p).c_str()); + boost::filesystem::ifstream is((m_boost_path / p)); std::copy(std::istreambuf_iterator<char>(is), std::istreambuf_iterator<char>(), std::back_inserter(v1)); static boost::regex libname_matcher; if(libname_matcher.empty()) { std::string re = "\\<"; re += *m_lib_names.begin(); for(std::set<std::string>::const_iterator i = ++m_lib_names.begin(); i != m_lib_names.end(); ++i) { @@ -103,37 +104,37 @@ void bcp_implementation::copy_path(const fs::path& p) } re += "\\>"; libname_matcher.assign(re); } regex_replace(std::back_inserter(v2), v1.begin(), v1.end(), libname_matcher, get_new_library_name(m_namespace_name)); std::swap(v1, v2); v2.clear(); - std::ofstream os; + boost::filesystem::ofstream os; if(m_unix_lines) - os.open((m_dest_path / p).c_str(), std::ios_base::binary | std::ios_base::out); + os.open((m_dest_path / p), std::ios_base::binary | std::ios_base::out); else - os.open((m_dest_path / p).c_str(), std::ios_base::out); + os.open((m_dest_path / p), std::ios_base::out); os.write(&*v1.begin(), v1.size()); os.close(); } else if(m_namespace_name.size() && is_source_file(p)) { // // v1 hold the current content, v2 is temp buffer. - // Each time we do a search and replace the new content + // Each time we do a search and replace the new content // ends up in v2: we then swap v1 and v2, and clear v2. // static std::vector<char> v1, v2; v1.clear(); v2.clear(); - std::ifstream is((m_boost_path / p).c_str()); + boost::filesystem::ifstream is((m_boost_path / p)); std::copy(std::istreambuf_iterator<char>(is), std::istreambuf_iterator<char>(), std::back_inserter(v1)); static const boost::regex namespace_matcher( "(?|" "(namespace\\s+)boost(_\\w+)?(?:(\\s*::\\s*)phoenix)?" "|" "(namespace\\s+(?:detail::)?)(adstl|phoenix|rapidxml)\\>" "|" "()\\<boost((?:_(?!intrusive_tags)\\w+)?\\s*(?:::))(?:(\\s*)phoenix)?" @@ -164,19 +165,19 @@ void bcp_implementation::copy_path(const fs::path& p) regex_replace(std::back_inserter(v2), v1.begin(), v1.end(), namespace_matcher, "$1" + m_namespace_name + "$2(?3$3" + m_namespace_name + "phoenix?4$4)", boost::regex_constants::format_all); std::swap(v1, v2); v2.clear(); if(m_namespace_alias) { static const boost::regex namespace_alias( /* - "namespace\\s+" + m_namespace_name + + "namespace\\s+" + m_namespace_name + "\\s*" "(" "\\{" "(?:" "(?>[^\\{\\}/]+)" "(?>" "(?:" "(?1)" "|//[^\\n]+$" @@ -185,47 +186,47 @@ void bcp_implementation::copy_path(const fs::path& p) "(?:(?<=\\\\)\\n[^\\n]*)*)" ")" "[^\\{\\}]+" ")*" ")*" "\\}" ")" */ /* - "(namespace\\s+" + m_namespace_name + + "(namespace\\s+" + m_namespace_name + "\\s*\\{.*" "\\})([^\\{\\};]*)\\z" */ "(namespace)(\\s+)(" + m_namespace_name + ")" "(adstl|phoenix|rapidxml)?(\\s*\\{)" ); - regex_replace(std::back_inserter(v2), v1.begin(), v1.end(), namespace_alias, + regex_replace(std::back_inserter(v2), v1.begin(), v1.end(), namespace_alias, "$1 $3$4 {} $1 (?4$4:boost) = $3$4; $1$2$3$4$5", boost::regex_constants::format_all); std::swap(v1, v2); v2.clear(); } - std::ofstream os; + boost::filesystem::ofstream os; if(m_unix_lines) - os.open((m_dest_path / p).c_str(), std::ios_base::binary | std::ios_base::out); + os.open((m_dest_path / p), std::ios_base::binary | std::ios_base::out); else - os.open((m_dest_path / p).c_str(), std::ios_base::out); + os.open((m_dest_path / p), std::ios_base::out); if(v1.size()) os.write(&*v1.begin(), v1.size()); os.close(); } else if(m_unix_lines && !is_binary_file(p)) { - std::ifstream is((m_boost_path / p).c_str()); + boost::filesystem::ifstream is((m_boost_path / p)); std::istreambuf_iterator<char> isi(is); std::istreambuf_iterator<char> end; - std::ofstream os((m_dest_path / p).c_str(), std::ios_base::binary | std::ios_base::out); + boost::filesystem::ofstream os((m_dest_path / p), std::ios_base::binary | std::ios_base::out); std::ostreambuf_iterator<char> osi(os); std::copy(isi, end, osi); } else { // binary copy: fs::copy_file(m_boost_path / p, m_dest_path / p); } |