<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The efnx code blog. &#187; C++</title>
	<atom:link href="http://efnx.com/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://efnx.com</link>
	<description>code. blog.</description>
	<lastBuildDate>Wed, 18 Jan 2012 20:48:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>DIY Webserver Using PureMVC++</title>
		<link>http://efnx.com/diy-webserver-using-puremvc/</link>
		<comments>http://efnx.com/diy-webserver-using-puremvc/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 22:33:13 +0000</pubDate>
		<dc:creator>Schell</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[mvc]]></category>

		<guid isPermaLink="false">http://blog.efnx.com/diy-webserver-using-puremvc/</guid>
		<description><![CDATA[To test out my newly ported PureMVC++ implementation I decided to write an example webserver. I&#8217;ve always wanted to write one, and I didn&#8217;t realize just how easy it is (to make a VERY rudimentary version). The server parses your http request and then spits it back out at you, with some nice html. That&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>To test out my newly ported PureMVC++ implementation I decided to write an example webserver. I&#8217;ve always wanted to write one, and I didn&#8217;t realize just how easy it is (to make a VERY rudimentary version). </p>
<p>The server parses your http request and then spits it back out at you, with some nice html.<br />
<a href="http://blog.efnx.com/wp-content/uploads/2009/12/Screen-shot-2009-12-22-at-2.35.47-PM.png" rel="lightbox"><img src="http://blog.efnx.com/wp-content/uploads/2009/12/Screen-shot-2009-12-22-at-2.35.47-PM-300x229.png" alt="Screen shot 2009-12-22 at 2.35.47 PM" title="Screen shot 2009-12-22 at 2.35.47 PM" width="300" height="229" class="size-medium wp-image-273" /></a><br />
That&#8217;s it! Source code is here:<br />
<a href="http://github.com/schell/PureMVC-Plus-Plus/tree/master/example/httpserver/">http://github.com/schell/PureMVC-Plus-Plus/tree/master/example/httpserver/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://efnx.com/diy-webserver-using-puremvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PureMVC++ – A  C++ MVC framework (ported from AS3)</title>
		<link>http://efnx.com/puremvc-a-c-mvc-framework-ported-from-as3/</link>
		<comments>http://efnx.com/puremvc-a-c-mvc-framework-ported-from-as3/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 23:26:54 +0000</pubDate>
		<dc:creator>Schell</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[mvc]]></category>

		<guid isPermaLink="false">http://blog.efnx.com/?p=229</guid>
		<description><![CDATA[I had some time over the past month to port the popular PureMVC application architecture from AS3, to C++. I learned a ton about C++ and it turned out to be a rather smooth process. The code is up on github. Differences in the C++ version Notification names and types are ints! At first I [...]]]></description>
			<content:encoded><![CDATA[<p>I had some time over the past month to port the popular <a href="http://puremvc.org">PureMVC</a> application architecture from AS3, to C++. I learned a ton about C++ and it turned out to be a rather smooth process. The code is up on <a href="http://wiki.github.com/schell/PureMVC-Plus-Plus" title="PureMVC at github">github</a>.</p>
<h3>Differences in the C++ version</h3>
<dl>
<dt>Notification names and types are ints!</dt>
<dd>At first I used strings for notification names and types, just like in other ports. I did this until I was writing the first sample application. At that moment I realize in C++ you can&#8217;t switch on strings! There&#8217;s no support for writing a switch statement on the type std::string. I simply didn&#8217;t know that. So code like this just won&#8217;t compile:</p>
<div class="codecolorer-container actionscript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #b1b100;">switch</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;somestring&quot;</span><span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;notthisone&quot;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;not gonna happen&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;northisone&quot;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;also not gonna happen&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;somestring&quot;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;this one gets evaluated&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">default</span>:<br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p>C++ only allows you to switch on ints, so to save us from having to write something like this:</p>
<div class="codecolorer-container cpp twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>note<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>getName<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">==</span> <span style="color: #FF0000;">&quot;notthisstring&quot;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;not gonna happen&quot;</span><span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>note<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>getName<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">==</span> <span style="color: #FF0000;">&quot;northisstring&quot;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;also not going to happen&quot;</span><span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span>...</div></div>
<p>I decided to make note names and types ints. This way we can enumerate our notification names and types like so:</p>
<div class="codecolorer-container cpp twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">class</span> n_name<br />
<span style="color: #008000;">&#123;</span><br />
<span style="color: #0000ff;">public</span><span style="color: #008080;">:</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">enum</span> name<br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; NIL,<br />
&nbsp; &nbsp; &nbsp; &nbsp; STARTUP, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666;">// triggers the app startup sequence</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; SET,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// sets something</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; GET,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// makes a request to get something</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; DISPLAY,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// display something</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; QUIT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666;">// quit the app</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>and then handle the notification with ints:</p>
<div class="codecolorer-container cpp twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">int</span> name <span style="color: #000080;">=</span> note<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>getName<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<span style="color: #0000ff;">switch</span><span style="color: #008000;">&#40;</span>name<span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">case</span> n_name<span style="color: #008080;">::</span><span style="color: #007788;">STARTUP</span><span style="color: #008080;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Startup the app!&quot;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">case</span> n_name<span style="color: #008080;">::</span><span style="color: #007788;">QUIT</span><span style="color: #008080;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Shutdown...&quot;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">default</span><span style="color: #008080;">:</span><br />
<span style="color: #008000;">&#125;</span></div></div>
</dd>
<p></p>
<dt>IFacade no longer contains a <span class="code">registerCommand</span> method</dt>
<dd>I tried my best to figure out a way to implement <a href="http://en.wikipedia.org/wiki/State_(computer_science)">stateless</a> commands in C++. The way the AS3 version accomplishes this is by passing around references to classes. In that port handling references to classes in an abstract way is easy because AS3 has built in <a href="http://en.wikipedia.org/wiki/Type_introspection">type introspection</a>. In order to do the same thing in C++ we&#8217;d have to depend on something from the boost library. That&#8217;s not an option. Instead I gave Facade a templated method to replace IFacade&#8217;s <span class="code">registerCommand</span> (conveniently called <span class="code">registerCommand</span>). So instead of calling <span class="code">registerCommand(noteName, CommandClassName)</span>, one makes a call like this: <span class="code">registerCommand&lt;CommandClassName&gt;(noteName)</span>. This calls a special template function created by the compiler that adds <span class="code">CommandClassName</span> to a templated Observer, which is added to the View&#8217;s observer list.</dd>
</dl>
<p>That covers it for now. In the coming weeks I&#8217;ll probably be adding example code to this post, as well as example applications to the repo. If you&#8217;re interested in the project, keep up to date with the repo at <a href="http://wiki.github.com/schell/PureMVC-Plus-Plus" title="PureMVC at github">github</a> and soon we&#8217;ll have a repo at PureMVC.org. I&#8217;ve added some temporary <a href="http://civiliansoftware.com/pmvcpp" title"PureMVC++ documentation">documentation</a> for you to use as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://efnx.com/puremvc-a-c-mvc-framework-ported-from-as3/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>I updated my gcc formatting php script.</title>
		<link>http://efnx.com/i-updated-my-gcc-format-php-script/</link>
		<comments>http://efnx.com/i-updated-my-gcc-format-php-script/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 17:03:10 +0000</pubDate>
		<dc:creator>Schell</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[g++]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[TextMate]]></category>

		<guid isPermaLink="false">http://blog.efnx.com/i-updated-my-gcc-format-php-script/</guid>
		<description><![CDATA[A while ago I wrote a script that formats gcc output to link errors back into TM. I updated that script with support for warnings and added some cool looking construction theme colors for the errors and warnings. Have a look see. Formatting gcc and g++ output for TextMate.]]></description>
			<content:encoded><![CDATA[<p>A while ago I wrote a script that formats gcc output to link errors back into TM. I updated that script with support for warnings and added some cool looking construction theme colors for the errors and warnings. Have a look see.</p>
<p><a href="http://blog.efnx.com/formatting-gcc-g-output-using-php-in-textmate/">Formatting gcc and g++ output for TextMate.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://efnx.com/i-updated-my-gcc-format-php-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quake for Flash (C/C++ to AS3)</title>
		<link>http://efnx.com/quake-for-flash-cc-to-as3/</link>
		<comments>http://efnx.com/quake-for-flash-cc-to-as3/#comments</comments>
		<pubDate>Tue, 27 Nov 2007 19:41:26 +0000</pubDate>
		<dc:creator>Schell</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Quake]]></category>
		<category><![CDATA[Scott Peterson]]></category>

		<guid isPermaLink="false">http://blog.efnx.com/?p=34</guid>
		<description><![CDATA[Scott Peterson has created a tool for porting C/C++ code to AS3. What the shit. That rocks. This demo was shown at the 2007 Adobe MAX conference, in the sneak peeks section, so keep in mind it may never see the light of day. But how cool is this? Adobe better jump on this.]]></description>
			<content:encoded><![CDATA[<p>Scott Peterson has created a tool for porting C/C++ code to AS3. What the shit. That rocks. This demo was shown at the 2007 Adobe MAX conference, in the sneak peeks section, so keep in mind it may never see the light of day. But how cool is this? Adobe better jump on this.<br />
<object type="application/x-shockwave-flash" data="http://blip.tv/scripts/flash/showplayer.swf?enablejs=true&#038;file=http%3A//blip.tv/rss/flash/413376&#038;feedurl=http%3A//skipintro.blip.tv/rss/&#038;autostart=false&#038;brandname=skipintro&#038;brandlink=http%3A//skipintro.blip.tv/" width="400" height="255" allowfullscreen="true" id="showplayer"><param name="movie" value="http://blip.tv/scripts/flash/showplayer.swf?enablejs=true&#038;file=http%3A//blip.tv/rss/flash/413376&#038;feedurl=http%3A//skipintro.blip.tv/rss/&#038;autostart=false&#038;brandname=skipintro&#038;brandlink=http%3A//skipintro.blip.tv/" /><param name="quality" value="best" /></object></p>
]]></content:encoded>
			<wfw:commentRss>http://efnx.com/quake-for-flash-cc-to-as3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

