c++: how to break (not parse) a string into command line arguments?
<p>I am using <code>boost::program_options</code> to parse my command line. Now, I am adding support for batch execution, by means of a <code>--script</code> argument denoting a file, containing command line options on every line, for instance:</p>

<pre><code>--src="\"z:\dev\veds\sqlexpress\Run 1.ved\"" --src-kind=bla --yz
--src=z:\dev\veds\sqlexpress\db.ebf
--src=z:\dev\veds\sqlexpress\db2.mdf
--src=db3
--src="\"z:\dev\veds\sqlite\Run 41 (Run 23).ved\""
--src=z:\dev\veds\sqlite\ws_results_db_2012_01_15_18_37_03.db3
--src=z:\dev\veds\mysql\10.ved
--src=z:\dev\veds\mysql\db
</code></pre>

<p>Each line in the file denotes a single execution of my tool and lists the command line options for this particular execution.</p>

<p>The problem is that reading the script file yields complete lines, which are not broken into individual command line options. But, one has to have <code>argc</code> and <code>argv</code> in order to use <code>boost::program_options</code>, i.e. it depends on someone to break the command line into different options.</p>

<p>I cannot simply break by spaces, because some values contain spaces and hence they are enclosed with double quotes, even nested double quotes.</p>

<p>On the other hand, I do not want to run the tool from the OS command prompt for each set of command line options, because of the expensive bootstrap - the reason why I am introducing the script feature in the first place.</p>

<p>Is there a simple way to break the lines into the command line arguments in the same way the OS does it? </p>

<p>Thanks.</p>
