// Copyright (c) 2006, 2007 Julio M. Merino Vidal
// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
// Copyright (c) 2009 Boris Schaeling
// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
// Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
// Copyright (c) 2016 Klemens D. Morgenstern
//
// Distributed under 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)
#ifndef BOOST_PROCESS_ARGS_HPP
#define BOOST_PROCESS_ARGS_HPP
/** \file boost/process/args.hpp
*
* This header provides the \xmlonly args\endxmlonly property. It also provides the
* alternative name \xmlonly argv\endxmlonly .
*
*
\xmlonly
namespace boost {
namespace process {
unspecified args;
unspecified argv;
}
}
\endxmlonly
*/
#include
#include
namespace boost { namespace process { namespace detail {
struct args_
{
template
using remove_reference_t = typename std::remove_reference::type;
template
using value_type = typename remove_reference_t::value_type;
template
using vvalue_type = value_type>;
template
arg_setter_, true> operator()(Range &&range) const
{
return arg_setter_, true>(std::forward(range));
}
template
arg_setter_, true> operator+=(Range &&range) const
{
return arg_setter_, true>(std::forward(range));
}
template
arg_setter_, false> operator= (Range &&range) const
{
return arg_setter_, false>(std::forward(range));
}
template
arg_setter_ operator()(std::basic_string && str) const
{
return arg_setter_ (str);
}
template
arg_setter_ operator+=(std::basic_string && str) const
{
return arg_setter_ (str);
}
template
arg_setter_ operator= (std::basic_string && str) const
{
return arg_setter_(str);
}
template
arg_setter_ operator()(const std::basic_string & str) const
{
return arg_setter_ (str);
}
template
arg_setter_ operator+=(const std::basic_string & str) const
{
return arg_setter_ (str);
}
template
arg_setter_ operator= (const std::basic_string & str) const
{
return arg_setter_(str);
}
template
arg_setter_ operator()(std::basic_string & str) const
{
return arg_setter_ (str);
}
template
arg_setter_ operator+=(std::basic_string & str) const
{
return arg_setter_ (str);
}
template
arg_setter_ operator= (std::basic_string & str) const
{
return arg_setter_(str);
}
template
arg_setter_ operator()(const Char* str) const
{
return arg_setter_ (str);
}
template
arg_setter_ operator+=(const Char* str) const
{
return arg_setter_ (str);
}
template
arg_setter_ operator= (const Char* str) const
{
return arg_setter_(str);
}
// template
// arg_setter_ operator()(const Char (&str) [Size]) const
// {
// return arg_setter_ (str);
// }
// template
// arg_setter_ operator+=(const Char (&str) [Size]) const
// {
// return arg_setter_ (str);
// }
// template
// arg_setter_ operator= (const Char (&str) [Size]) const
// {
// return arg_setter_(str);
// }
arg_setter_ operator()(std::initializer_list &&range) const
{
return arg_setter_(range.begin(), range.end());
}
arg_setter_ operator+=(std::initializer_list &&range) const
{
return arg_setter_(range.begin(), range.end());
}
arg_setter_ operator= (std::initializer_list &&range) const
{
return arg_setter_(range.begin(), range.end());
}
arg_setter_ operator()(std::initializer_list &&range) const
{
return arg_setter_(range.begin(), range.end());
}
arg_setter_ operator+=(std::initializer_list &&range) const
{
return arg_setter_(range.begin(), range.end());
}
arg_setter_ operator= (std::initializer_list &&range) const
{
return arg_setter_(range.begin(), range.end());
}
arg_setter_ operator()(std::initializer_list &&range) const
{
return arg_setter_(range.begin(), range.end());
}
arg_setter_ operator+=(std::initializer_list &&range) const
{
return arg_setter_(range.begin(), range.end());
}
arg_setter_ operator= (std::initializer_list &&range) const
{
return arg_setter_(range.begin(), range.end());
}
arg_setter_ operator()(std::initializer_list &&range) const
{
return arg_setter_(range.begin(), range.end());
}
arg_setter_ operator+=(std::initializer_list &&range) const
{
return arg_setter_(range.begin(), range.end());
}
arg_setter_ operator= (std::initializer_list &&range) const
{
return arg_setter_(range.begin(), range.end());
}
};
}
/**
The `args` property allows to explicitly set arguments for the execution. The
name of the executable will always be the first element in the arg-vector.
\section args_details Details
\subsection args_operations Operations
\subsubsection args_set_var Setting values
To set a the argument vector the following syntax can be used.
\code{.cpp}
args = value;
args(value);
\endcode
`std::initializer_list` is among the allowed types, so the following syntax is also possible.
\code{.cpp}
args = {value1, value2};
args({value1, value2});
\endcode
Below the possible types for `value` are listed, with `char_type` being either `char` or `wchar_t`.
\paragraph args_set_var_value value
- `std::basic_string`
- `const char_type * `
- `std::initializer_list`
- `std::vector>`
Additionally any range of `std::basic_string` can be passed.
\subsubsection args_append_var Appending values
To append a the argument vector the following syntax can be used.
\code{.cpp}
args += value;
\endcode
`std::initializer_list` is among the allowed types, so the following syntax is also possible.
\code{.cpp}
args += {value1, value2};
\endcode
Below the possible types for `value` are listed, with `char_type` being either `char` or `wchar_t`.
\paragraph args_append_var_value value
- `std::basic_string`
- `const char_type * `
- `std::initializer_list`
- `std::vector>`
Additionally any range of `std::basic_string` can be passed.
\subsection args_example Example
The overload form is used when more than one string is passed, from the second one forward.
I.e. the following expressions have the same results:
\code{.cpp}
spawn("gcc", "--version");
spawn("gcc", args ="--version");
spawn("gcc", args+="--version");
spawn("gcc", args ={"--version"});
spawn("gcc", args+={"--version"});
\endcode
\note A string will be parsed and set in quotes if it has none and contains spaces.
*/
constexpr boost::process::detail::args_ args{};
///Alias for \xmlonly args \endxmlonly .
constexpr boost::process::detail::args_ argv{};
}}
#endif