• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2006, 2007 Julio M. Merino Vidal
2 // Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
3 // Copyright (c) 2009 Boris Schaeling
4 // Copyright (c) 2010 Felipe Tanus, Boris Schaeling
5 // Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
6 //
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 
10 #ifndef BOOST_PROCESS_START_IN_DIR_HPP
11 #define BOOST_PROCESS_START_IN_DIR_HPP
12 
13 #include <boost/process/detail/config.hpp>
14 #include <boost/process/detail/handler.hpp>
15 #include <boost/process/locale.hpp>
16 #include <boost/process/detail/traits/wchar_t.hpp>
17 
18 #if defined (BOOST_POSIX_API)
19 #include <boost/process/detail/posix/start_dir.hpp>
20 #elif defined (BOOST_WINDOWS_API)
21 #include <boost/process/detail/windows/start_dir.hpp>
22 #endif
23 
24 #include <boost/process/detail/config.hpp>
25 #include <string>
26 #include <boost/filesystem/path.hpp>
27 
28 /** \file boost/process/start_dir.hpp
29  *
30 Header which provides the start_dir property, which allows to set the directory
31 the process shall be started in.
32 \xmlonly
33 <programlisting>
34 namespace boost {
35   namespace process {
36     <emphasis>unspecified</emphasis> <globalname alt="boost::process::start_dir">start_dir</globalname>;
37   }
38 }
39 </programlisting>
40 \endxmlonly
41 
42  */
43 
44 namespace boost { namespace process { namespace detail {
45 
46 struct start_dir_
47 {
start_dir_boost::process::detail::start_dir_48     constexpr start_dir_() {};
49 
50     template<typename Char>
operator ()boost::process::detail::start_dir_51     api::start_dir_init<Char> operator()(const std::basic_string<Char> & st) const {return {st}; }
52     template<typename Char>
operator ()boost::process::detail::start_dir_53     api::start_dir_init<Char> operator()(std::basic_string<Char> && s) const {return {std::move(s)}; }
54     template<typename Char>
operator ()boost::process::detail::start_dir_55     api::start_dir_init<Char> operator()(const Char* s)                const {return {s}; }
56     api::start_dir_init<typename boost::filesystem::path::value_type>
operator ()boost::process::detail::start_dir_57                               operator()(const boost::filesystem::path & st) const {return {st.native()}; }
58 
59     template<typename Char>
operator =boost::process::detail::start_dir_60     api::start_dir_init<Char> operator= (const std::basic_string<Char> & st) const {return {st}; }
61     template<typename Char>
operator =boost::process::detail::start_dir_62     api::start_dir_init<Char> operator= (std::basic_string<Char> && s) const {return {std::move(s)}; }
63     template<typename Char>
operator =boost::process::detail::start_dir_64     api::start_dir_init<Char> operator= (const Char* s)                const {return {s}; }
65     api::start_dir_init<typename boost::filesystem::path::value_type>
operator =boost::process::detail::start_dir_66                               operator= (const boost::filesystem::path & st) const {return {st.native()}; }
67 
68 };
69 
70 template<> struct is_wchar_t<api::start_dir_init<wchar_t>> : std::true_type {};
71 
72 template<>
73 struct char_converter<char, api::start_dir_init<wchar_t>>
74 {
convboost::process::detail::char_converter75     static api::start_dir_init<char> conv(const api::start_dir_init<wchar_t> & in)
76     {
77         return api::start_dir_init<char>{::boost::process::detail::convert(in.str())};
78     }
79 };
80 
81 template<>
82 struct char_converter<wchar_t, api::start_dir_init<char>>
83 {
convboost::process::detail::char_converter84     static api::start_dir_init<wchar_t> conv(const api::start_dir_init<char> & in)
85     {
86         return api::start_dir_init<wchar_t>{::boost::process::detail::convert(in.str())};
87     }
88 };
89 
90 }
91 
92 /**
93 
94 To set the start dir, the `start_dir` property is provided.
95 
96 The valid operations are the following:
97 
98 \code{.cpp}
99 start_dir=path
100 start_dir(path)
101 \endcode
102 
103 It can be used with `std::string`, `std::wstring` and `boost::filesystem::path`.
104 
105 
106  */
107 constexpr ::boost::process::detail::start_dir_ start_dir;
108 
109 }}
110 
111 #endif
112