<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>C/C++ cross platform command line parser</title>
		<link>http://www.allegro.cc/forums/view/612582</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Wed, 15 May 2013 11:07:05 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m looking for a <i>good</i> cross platform cli parser for a little project I&#39;m working on. It absolutely has to work in C++ (using C++11 for the project), and at least support linux and windows (via mingw and potentially msvc, if I can&#39;t get the code to properly work in mingw, since I&#39;m using std::thread, it <i>may</i> not work in mingw.. we&#39;ll see).</p><p>append: Boost is a last resort.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Tue, 14 May 2013 19:18:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Write your own in perl / python or faster yacc / flex / bison ?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GullRaDriel)</author>
		<pubDate>Tue, 14 May 2013 21:56:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It&#39;s just for parsing command line arguments/options. writing it in a scripting language would be, odd to say the least. And I suppose I could write a full parser for it, but thats a bit overkill. I can whip something up with some basic string parsing, but I&#39;d prefer to use something that&#39;s already proven.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Tue, 14 May 2013 21:59:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>What&#39;s so hard with parsing command line options manually? First off, this is done fine with default library. And they&#39;re all already fit in a bunch of strings for you in <span class="source-code"><span class="k1">char</span> <span class="k3">*</span><span class="k3">*</span> argv</span>, one per string, quotes already handled. Just <span class="source-code"><a href="http://www.delorie.com/djgpp/doc/libc/libc_670.html" target="_blank">scanf</a></span> your strings for values. You may preselect strigns to process as keys if second letter would be dash and otherwise preselect strings to <span class="source-code"><a href="http://www.delorie.com/djgpp/doc/libc/libc_670.html" target="_blank">scanf</a></span> with <span class="source-code"><a href="http://www.delorie.com/djgpp/doc/libc/libc_768.html" target="_blank">strncmp</a></span> including trailing equals sign if <span class="source-code"><a href="http://www.delorie.com/djgpp/doc/libc/libc_670.html" target="_blank">scanf</a></span> -ing every string against every possible key would take too long.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Raidho36)</author>
		<pubDate>Wed, 15 May 2013 03:29:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes, I could. But there are a few features that I&#39;d like to have, that are less than trivial to support. Why code my own flexible option parser when one already exists?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Wed, 15 May 2013 03:32:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Because that&#39;s a good practice and you&#39;d spend more time looking for it than actually implementing it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Raidho36)</author>
		<pubDate>Wed, 15 May 2013 03:35:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It&#39;s also incredibly tedious <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /> and reinventing the wheel for no good reason.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Wed, 15 May 2013 03:49:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Is <a href="http://en.wikipedia.org/wiki/Getopt">getopt</a> what you are looking for? The PHP version works great, which I assume is just a wrapper over this C function.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Wed, 15 May 2013 05:02:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes, <i>getopt</i> is what you&#39;re looking for. Whether or not it&#39;s ported to MinGW or not, I don&#39;t know, but I don&#39;t see why not. It&#39;s not doing anything exceptional. The Wikipedia article that ML linked to seems to have a link to a Windows port for Visual C++ even (not necessarily GNU-compatible, but good enough, I imagine).</p><p>For the n00bs among us, I&#39;m sure what TF is looking for is things like: <tt>-gnu</tt> to be the same as <tt>-g -n -u</tt>, and for <tt>-- -gnu</tt> to be received as no options and <span class="source-code"><span class="s">"-gnu"</span></span> literally in <span class="source-code">argv</span>. These are conventions that a UNIX user becomes accustomed to, and rightly so. Windows is so weak in this regard. I&#39;ve rolled my own a few times, but it&#39;s still a lot of work to support all of these features gracefully (particularly in a low-level language like C or C++), and it&#39;s so much easier using <i>getopt</i>.</p><p>Protip: In Perl, there&#39;s Getopt::Long.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bamccaig)</author>
		<pubDate>Wed, 15 May 2013 07:54:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>getopt isn&#39;t really what I was looking for. It doesn&#39;t do gnu style options.</p><p>bam is mostly right. I&#39;d also like for --option to be a single option, rather than a group of options.</p><p>believe it or not I know about getopt <img src="http://www.allegro.cc/forums/smileys/shocked.gif" alt=":o" /></p><p>that said, the project that the wiki links to, actually seems to support getopt_long. It&#39;ll do.</p><p>append: well it <i>might</i> do. It&#39;s LGPL, not sure I like the license for this project.<br />append2: I may just end up doing my own due to the license, and requirements. I was hoping there were more options available.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Wed, 15 May 2013 11:07:05 +0000</pubDate>
	</item>
</rss>
