1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<head> 4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5<title>Global args</title> 6<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css"> 7<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 8<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> 9<link rel="up" href="../../process/reference.html#header.boost.process.args_hpp" title="Header <boost/process/args.hpp>"> 10<link rel="prev" href="../../process/reference.html" title="Reference"> 11<link rel="next" href="argv.html" title="Global argv"> 12</head> 13<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 14<table cellpadding="2" width="100%"><tr> 15<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td> 16<td align="center"><a href="../../../../index.html">Home</a></td> 17<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td> 18<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 19<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 20<td align="center"><a href="../../../../more/index.htm">More</a></td> 21</tr></table> 22<hr> 23<div class="spirit-nav"> 24<a accesskey="p" href="../../process/reference.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../process/reference.html#header.boost.process.args_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="argv.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 25</div> 26<div class="refentry"> 27<a name="boost.process.args"></a><div class="titlepage"></div> 28<div class="refnamediv"> 29<h2><span class="refentrytitle">Global args</span></h2> 30<p>boost::process::args</p> 31</div> 32<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2> 33<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: <<a class="link" href="../../process/reference.html#header.boost.process.args_hpp" title="Header <boost/process/args.hpp>">boost/process/args.hpp</a>> 34 35</span><span class="emphasis"><em><span class="identifier">unspecified</span></em></span> args<span class="special">;</span></pre></div> 36<div class="refsect1"> 37<a name="id-1.3.30.9.2.4.4"></a><h2>Description</h2> 38<p>The <code class="computeroutput">args</code> property allows to explicitly set arguments for the execution. The name of the executable will always be the first element in the arg-vector.</p> 39<div class="sect1"> 40<div class="titlepage"><div><div><h2 class="title" style="clear: both"> 41<a name="namespaceboost_1_1process_1args_details"></a>Details</h2></div></div></div> 42<div class="toc"><dl class="toc"> 43<dt><span class="sect2"><a href="args.html#namespaceboost_1_1process_1args_operations">Operations</a></span></dt> 44<dt><span class="sect2"><a href="args.html#namespaceboost_1_1process_1args_example">Example</a></span></dt> 45</dl></div> 46<div class="sect2"> 47<div class="titlepage"><div><div><h3 class="title"> 48<a name="namespaceboost_1_1process_1args_operations"></a>Operations</h3></div></div></div> 49<div class="toc"><dl class="toc"> 50<dt><span class="sect3"><a href="args.html#namespaceboost_1_1process_1args_set_var">Setting values</a></span></dt> 51<dt><span class="sect3"><a href="args.html#namespaceboost_1_1process_1args_append_var">Appending values</a></span></dt> 52</dl></div> 53<div class="sect3"> 54<div class="titlepage"><div><div><h4 class="title"> 55<a name="namespaceboost_1_1process_1args_set_var"></a>Setting values</h4></div></div></div> 56<div class="toc"><dl class="toc"><dt><span class="sect4"><a href="args.html#namespaceboost_1_1process_1args_set_var_value">value</a></span></dt></dl></div> 57<p>To set a the argument vector the following syntax can be used.</p> 58<pre class="programlisting"><span class="identifier">args</span> <span class="special">=</span> <span class="identifier">value</span><span class="special">;</span> 59<span class="identifier">args</span><span class="special">(</span><span class="identifier">value</span><span class="special">)</span><span class="special">;</span> 60</pre> 61<p><code class="computeroutput">std::initializer_list</code> is among the allowed types, so the following syntax is also possible.</p> 62<pre class="programlisting"><span class="identifier">args</span> <span class="special">=</span> <span class="special">{</span><span class="identifier">value1</span><span class="special">,</span> <span class="identifier">value2</span><span class="special">}</span><span class="special">;</span> 63<span class="identifier">args</span><span class="special">(</span><span class="special">{</span><span class="identifier">value1</span><span class="special">,</span> <span class="identifier">value2</span><span class="special">}</span><span class="special">)</span><span class="special">;</span> 64</pre> 65<p>Below the possible types for <code class="computeroutput">value</code> are listed, with <code class="computeroutput">char_type</code> being either <code class="computeroutput">char</code> or <code class="computeroutput">wchar_t</code>.</p> 66<div class="sect4"> 67<div class="titlepage"><div><div><h5 class="title"> 68<a name="namespaceboost_1_1process_1args_set_var_value"></a>value</h5></div></div></div> 69<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 70<li class="listitem"><p><code class="computeroutput">std::basic_string<char_type></code></p></li> 71<li class="listitem"><p><code class="computeroutput">const char_type *</code></p></li> 72<li class="listitem"><p><code class="computeroutput">std::initializer_list<const char_type *></code></p></li> 73<li class="listitem"><p><code class="computeroutput">std::vector<std::basic_string<char_type>></code></p></li> 74</ul></div> 75<p> 76</p> 77<p>Additionally any range of <code class="computeroutput">std::basic_string<char_type></code> can be passed.</p> 78</div> 79</div> 80<div class="sect3"> 81<div class="titlepage"><div><div><h4 class="title"> 82<a name="namespaceboost_1_1process_1args_append_var"></a>Appending values</h4></div></div></div> 83<div class="toc"><dl class="toc"><dt><span class="sect4"><a href="args.html#namespaceboost_1_1process_1args_append_var_value">value</a></span></dt></dl></div> 84<p>To append a the argument vector the following syntax can be used.</p> 85<pre class="programlisting"><span class="identifier">args</span> <span class="special">+=</span> <span class="identifier">value</span><span class="special">;</span> 86</pre> 87<p><code class="computeroutput">std::initializer_list</code> is among the allowed types, so the following syntax is also possible.</p> 88<pre class="programlisting"><span class="identifier">args</span> <span class="special">+=</span> <span class="special">{</span><span class="identifier">value1</span><span class="special">,</span> <span class="identifier">value2</span><span class="special">}</span><span class="special">;</span> 89</pre> 90<p>Below the possible types for <code class="computeroutput">value</code> are listed, with <code class="computeroutput">char_type</code> being either <code class="computeroutput">char</code> or <code class="computeroutput">wchar_t</code>.</p> 91<div class="sect4"> 92<div class="titlepage"><div><div><h5 class="title"> 93<a name="namespaceboost_1_1process_1args_append_var_value"></a>value</h5></div></div></div> 94<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 95<li class="listitem"><p><code class="computeroutput">std::basic_string<char_type></code></p></li> 96<li class="listitem"><p><code class="computeroutput">const char_type *</code></p></li> 97<li class="listitem"><p><code class="computeroutput">std::initializer_list<const char_type *></code></p></li> 98<li class="listitem"><p><code class="computeroutput">std::vector<std::basic_string<char_type>></code></p></li> 99</ul></div> 100<p> 101</p> 102<p>Additionally any range of <code class="computeroutput">std::basic_string<char_type></code> can be passed.</p> 103</div> 104</div> 105</div> 106<div class="sect2"> 107<div class="titlepage"><div><div><h3 class="title"> 108<a name="namespaceboost_1_1process_1args_example"></a>Example</h3></div></div></div> 109<p>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:</p> 110<pre class="programlisting"><span class="identifier">spawn</span><span class="special">(</span><span class="string">"gcc"</span><span class="special">,</span> <span class="string">"--version"</span><span class="special">)</span><span class="special">;</span> 111<span class="identifier">spawn</span><span class="special">(</span><span class="string">"gcc"</span><span class="special">,</span> <span class="identifier">args</span> <span class="special">=</span><span class="string">"--version"</span><span class="special">)</span><span class="special">;</span> 112<span class="identifier">spawn</span><span class="special">(</span><span class="string">"gcc"</span><span class="special">,</span> <span class="identifier">args</span><span class="special">+=</span><span class="string">"--version"</span><span class="special">)</span><span class="special">;</span> 113<span class="identifier">spawn</span><span class="special">(</span><span class="string">"gcc"</span><span class="special">,</span> <span class="identifier">args</span> <span class="special">=</span><span class="special">{</span><span class="string">"--version"</span><span class="special">}</span><span class="special">)</span><span class="special">;</span> 114<span class="identifier">spawn</span><span class="special">(</span><span class="string">"gcc"</span><span class="special">,</span> <span class="identifier">args</span><span class="special">+=</span><span class="special">{</span><span class="string">"--version"</span><span class="special">}</span><span class="special">)</span><span class="special">;</span> 115</pre> 116<div class="note"><table border="0" summary="Note"> 117<tr> 118<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../doc/src/images/note.png"></td> 119<th align="left">Note</th> 120</tr> 121<tr><td align="left" valign="top"><p>A string will be parsed and set in quotes if it has none and contains spaces. </p></td></tr> 122</table></div> 123<p> 124</p> 125</div> 126</div> 127</div> 128</div> 129<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 130<td align="left"></td> 131<td align="right"><div class="copyright-footer">Copyright © 2006-2012 Julio M. Merino Vidal, Ilya Sokolov, 132 Felipe Tanus, Jeff Flinn, Boris Schaeling<br>Copyright © 2016 Klemens D. Morgenstern<p> 133 Distributed under the Boost Software License, Version 1.0. (See accompanying 134 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 135 </p> 136</div></td> 137</tr></table> 138<hr> 139<div class="spirit-nav"> 140<a accesskey="p" href="../../process/reference.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../process/reference.html#header.boost.process.args_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="argv.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 141</div> 142</body> 143</html> 144