<?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/topics/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://efnx.com</link>
	<description>code. blog.</description>
	<lastBuildDate>Tue, 15 May 2012 17:46:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</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>Formatting gcc, g++ Output Using PHP In TextMate</title>
		<link>http://efnx.com/formatting-gcc-g-output-using-php-in-textmate/</link>
		<comments>http://efnx.com/formatting-gcc-g-output-using-php-in-textmate/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 22:55:53 +0000</pubDate>
		<dc:creator>Schell</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[compiler]]></category>

		<guid isPermaLink="false">http://blog.efnx.com/?p=70</guid>
		<description><![CDATA[While at ZendCon08 I saw a lot of people sharing the same love for TextMate as myself. I fricken love TextMate. Some of my friends laughed at me, saying &#8220;Bah, TM&#8217;s not an IDE, why do you want to write shell scripts to try to make it one?&#8221; And I&#8217;d be like, &#8220;I&#8217;m an ActionScript [...]]]></description>
			<content:encoded><![CDATA[<p>While at ZendCon08 I saw a lot of people sharing the same love for TextMate as myself. I fricken love TextMate. Some of my friends laughed at me, saying &#8220;Bah, TM&#8217;s not an IDE, why do you want to write shell scripts to try to make it one?&#8221; And I&#8217;d be like, &#8220;I&#8217;m an ActionScript developer, there&#8217;s no point in using a sledge hammer to pound in nails.&#8221; This makes sense because my friends use Eclipse. I tried Eclipse but it&#8217;s so huge and the plugins are huge and the interface is cluttered and theming syntax-coloring is a pain. So when I got home from ZendCon, with my renewed love for PHP, and my continual quest to eventually be a good C programmer, I decided to write a gcc parser script that linked back into TextMate to go directly to my errors. I use a dark syntax theme, a slightly modded Amy, and the parser reflects that. Check out a picture of these gcc errors:<br />
<div id="attachment_71" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.efnx.com/wp-content/uploads/2008/09/phpgccparse.png" rel="lightbox"><img src="http://blog.efnx.com/wp-content/uploads/2008/09/phpgccparse.png" alt="Picture of colored gcc output." title="phpgccparser" width="300" height="187" class="size-medium wp-image-71" /></a><p class="wp-caption-text">Picture of colored gcc output.</p></div><br />
To do this you&#8217;ll need <a href="http://php.net">PHP</a> installed on your machine. After that, the first step is to create a new command in TextMate&#8217;s C Bundle. Call it &#8220;Build, Format With PHP,&#8221; or anything else. Set it to save all files in the project when run [from the pull down at the top] now enter this into the text area:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">FILE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">basename</span> <span style="color: #800000;">${TM_FILEPATH}</span><span style="color: #000000; font-weight: bold;">`</span><br />
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">DIR</span>=<span style="color: #800000;">${TM_PROJECT_DIRECTORY}</span><br />
~<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Application\ Support<span style="color: #000000; font-weight: bold;">/</span>TextMate<span style="color: #000000; font-weight: bold;">/</span>Support<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>make_format_gcc.sh</div></div>
<p>Next select Output as &#8220;Show as HTML&#8221; so we can see our output. Now create a file called &#8220;make_format_gcc.sh&#8221; in the folder ~/Library/Application Support/TextMate/Support/bin/<br />
Once you&#8217;ve created the file, use TM or vim to fill it with this:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #000000; font-weight: bold;">&amp;&gt;</span> <span style="color: #800000;">${FILE}</span>.mkout<br />
php <span style="color: #660033;">-f</span> ~<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Application\ Support<span style="color: #000000; font-weight: bold;">/</span>TextMate<span style="color: #000000; font-weight: bold;">/</span>Support<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gcc_format.php <span style="color: #800000;">${FILE}</span> <span style="color: #800000;">${DIR}</span></div></div>
<p>This bash script executes the make on the makefile and directs the standard and error output to the same file. Then the script calls php to parse and display the file. So now create a file named &#8220;gcc_format.php&#8221; in the same folder as make_format_gcc.sh and fill it with the meat of our parser:</p>
<div class="codecolorer-container php twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// get stdout and stderr then delete temp file</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$dir</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$argv</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$commandFile</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$argv</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.mkout'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$commands</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$commandFile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// break lines up by line ending</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$lines</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$commands</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// find errors and link them to pages and line number</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$errors</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lines</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$fnpos</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strpos"><span style="color: #990000;">strpos</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lines</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">':'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$filename</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lines</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$fnpos</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$lnpos</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strpos"><span style="color: #990000;">strpos</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lines</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">': error:'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$linestart</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$lnpos</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$fnpos</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$linestart</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$line</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lines</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$fnpos</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lnpos</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$fnpos</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$link</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;txmt://open/?url=file://<span style="color: #006699; font-weight: bold;">$dir</span>/<span style="color: #006699; font-weight: bold;">$filename</span>&amp;line=<span style="color: #006699; font-weight: bold;">$line</span>&amp;column=1&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$lines</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/substr_replace"><span style="color: #990000;">substr_replace</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$lines</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/a&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lnpos</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$lines</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$link</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$lines</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$errors</span><span style="color: #339933;">++;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;br /&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lines</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'<br />
&nbsp; &nbsp; &lt;html&gt;<br />
&nbsp; &nbsp; &lt;head&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;style type=&quot;text/css&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; body &nbsp; &nbsp;{background:#000000; color:#999999;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; #comment{width:100%; background: #230021; color:#6060BF;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; #fail &nbsp; {width:100%; background:#3E0018; color:#9918B8;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; #succ &nbsp; {width:100%; background:#230021; color:#B0FFF0;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; dslsh &nbsp; {color:#A96AA9;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; a:link &nbsp;{color:#008080;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; a:hover {color:#80A0FF;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/style&gt;<br />
&nbsp; &nbsp; &lt;/head&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;body&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div id=&quot;comment&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;dslsh&gt;//&lt;/dslsh&gt; '</span><span style="color: #339933;">.</span> <span style="color: #000088;">$argv</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'\'s build results:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt;'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$output</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$errors</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;div id=&quot;fail&quot;&gt;Build failed with '</span><span style="color: #339933;">.</span> <span style="color: #000088;">$errors</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">' errors.&lt;/div&gt;'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;div id=&quot;succ&quot;&gt;Build Succeeded!&lt;/div&gt;'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">echo</span><span style="color: #0000ff;">'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/body&gt;<br />
&nbsp; &nbsp; &lt;/html&gt;'</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></div>
<p>This example assumes that you are working in a directory with a makefile, but I&#8217;m sure it can be easily modded to work with any build script. The colors reflect my favorite theme, but they should also be easily modded with lines 32-38 of the php script. Happy coding, peoples!</p>
]]></content:encoded>
			<wfw:commentRss>http://efnx.com/formatting-gcc-g-output-using-php-in-textmate/feed/</wfw:commentRss>
		<slash:comments>3</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>

