Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:07

0001 // Copyright (c) 2016 Klemens D. Morgenstern
0002 //
0003 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0004 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 
0007 #ifndef BOOST_PROCESS_DETAIL_WINDOWS_ENV_INIT_HPP_
0008 #define BOOST_PROCESS_DETAIL_WINDOWS_ENV_INIT_HPP_
0009 
0010 #include <boost/winapi/error_codes.hpp>
0011 #include <boost/winapi/process.hpp>
0012 
0013 
0014 #include <boost/process/detail/config.hpp>
0015 #include <boost/process/detail/handler_base.hpp>
0016 #include <boost/process/environment.hpp>
0017 
0018 namespace boost { namespace process { namespace detail { namespace windows {
0019 
0020 template<typename Char>
0021 struct env_init : public ::boost::process::detail::handler_base
0022 {
0023     boost::process::basic_environment<Char> env;
0024 
0025     env_init(boost::process::basic_environment<Char> && env) : env(std::move(env)) {};
0026     env_init(const boost::process::basic_environment<Char> & env) : env(env) {};
0027 
0028     constexpr static ::boost::winapi::DWORD_ creation_flag(char)    {return 0u;}
0029     constexpr static ::boost::winapi::DWORD_ creation_flag(wchar_t)
0030     {
0031        return ::boost::winapi::CREATE_UNICODE_ENVIRONMENT_;
0032     }
0033 
0034     template <class WindowsExecutor>
0035     void on_setup(WindowsExecutor &exec) const
0036     {
0037         auto e = env.native_handle();
0038         if (*e == null_char<char>())
0039         {
0040             exec.set_error(std::error_code(::boost::winapi::ERROR_BAD_ENVIRONMENT_, std::system_category()),
0041                     "Empty Environment");
0042         }
0043 
0044         exec.env = e;
0045         exec.creation_flags |= creation_flag(Char());
0046     }
0047 
0048 };
0049 
0050 }}}}
0051 
0052 
0053 
0054 #endif /* BOOST_PROCESS_DETAIL_WINDOWS_ENV_INIT_HPP_ */