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 // Copyright (c) 2016 Klemens D. Morgenstern
7 //
8 // Distributed under the Boost Software License, Version 1.0. (See accompanying
9 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10 
11 #ifndef BOOST_PROCESS_DETAIL_CMD_LINE_HPP
12 #define BOOST_PROCESS_DETAIL_CMD_LINE_HPP
13 
14 #include <boost/winapi/config.hpp>
15 #include <boost/process/detail/config.hpp>
16 #include <boost/process/detail/handler_base.hpp>
17 #include <boost/process/detail/traits/cmd_or_exe.hpp>
18 #include <boost/process/detail/traits/wchar_t.hpp>
19 
20 #if defined(BOOST_POSIX_API)
21 #include <boost/process/detail/posix/cmd.hpp>
22 #elif defined(BOOST_WINDOWS_API)
23 #include <boost/process/detail/windows/cmd.hpp>
24 #endif
25 
26 /** \file boost/process/cmd.hpp
27  *
28  *    This header provides the \xmlonly <globalname alt="boost::process::cmd">cmd</globalname>\endxmlonly property.
29  *
30 \xmlonly
31 <programlisting>
32 namespace boost {
33   namespace process {
34     <emphasis>unspecified</emphasis> <globalname alt="boost::process::cmd">cmd</globalname>;
35   }
36 }
37 </programlisting>
38 \endxmlonly
39 */
40 
41 namespace boost { namespace process { namespace detail {
42 
43 
44 struct cmd_
45 {
46     constexpr cmd_() = default;
47 
48     template<typename Char>
operator ()boost::process::detail::cmd_49     inline api::cmd_setter_<Char> operator()(const Char *s) const
50     {
51         return api::cmd_setter_<Char>(s);
52     }
53     template<typename Char>
operator =boost::process::detail::cmd_54     inline api::cmd_setter_<Char> operator= (const Char *s) const
55     {
56         return api::cmd_setter_<Char>(s);
57     }
58 
59     template<typename Char>
operator ()boost::process::detail::cmd_60     inline api::cmd_setter_<Char> operator()(const std::basic_string<Char> &s) const
61     {
62         return api::cmd_setter_<Char>(s);
63     }
64     template<typename Char>
operator =boost::process::detail::cmd_65     inline api::cmd_setter_<Char> operator= (const std::basic_string<Char> &s) const
66     {
67         return api::cmd_setter_<Char>(s);
68     }
69 };
70 
71 template<> struct is_wchar_t<api::cmd_setter_<wchar_t>> : std::true_type {};
72 
73 
74 
75 template<>
76 struct char_converter<char, api::cmd_setter_<wchar_t>>
77 {
convboost::process::detail::char_converter78     static api::cmd_setter_<char> conv(const api::cmd_setter_<wchar_t> & in)
79     {
80         return { ::boost::process::detail::convert(in.str()) };
81     }
82 };
83 
84 template<>
85 struct char_converter<wchar_t, api::cmd_setter_<char>>
86 {
convboost::process::detail::char_converter87     static api::cmd_setter_<wchar_t> conv(const api::cmd_setter_<char> & in)
88     {
89         return { ::boost::process::detail::convert(in.str()) };
90     }
91 };
92 
93 
94 
95 
96 
97 
98 }
99 
100 
101 /** The cmd property allows to explicitly set commands for the execution.
102 
103 The overload form applies when only one string is passed to a launching function.
104 The string will be internally parsed and split at spaces.
105 
106 The following expressions are valid, with `value` being either a C-String or
107 a `std::basic_string` with `char` or `wchar_t`.
108 
109 \code{.cpp}
110 cmd="value";
111 cmd(value);
112 \endcode
113 
114 The property can only be used for assignments.
115 
116 
117  */
118 constexpr static ::boost::process::detail::cmd_ cmd;
119 
120 }}
121 
122 #endif
123