<?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>Fragmented Code &#187; C/C++</title>
	<atom:link href="http://www.fragmentedcode.com/topics/cpp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fragmentedcode.com</link>
	<description>Snippets, Blocks and Infinite Loops</description>
	<lastBuildDate>Sun, 24 Oct 2010 03:10:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Where I spend my day &#8230;</title>
		<link>http://www.fragmentedcode.com/2009/03/23/spend-day/</link>
		<comments>http://www.fragmentedcode.com/2009/03/23/spend-day/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 15:47:13 +0000</pubDate>
		<dc:creator>zoul</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Google App Engine]]></category>
		<category><![CDATA[Google Chrome]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[desk]]></category>
		<category><![CDATA[hdtv]]></category>

		<guid isPermaLink="false">http://www.fragmentedcode.com/?p=122</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<div id="attachment_124" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.fragmentedcode.com/wp-content/uploads/2009/03/dsc_9588_s-copy.jpg"><img class="size-full wp-image-124" title="my desk" src="http://www.fragmentedcode.com/wp-content/uploads/2009/03/dsc_9588_s-copy.jpg" alt="my desk, where I spend all my time." width="500" height="410" /></a><p class="wp-caption-text">my desk, where I spend all my time.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.fragmentedcode.com/2009/03/23/spend-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XMLObject v1.0 Beta Release</title>
		<link>http://www.fragmentedcode.com/2006/12/25/xmlobject-v10-beta-release/</link>
		<comments>http://www.fragmentedcode.com/2006/12/25/xmlobject-v10-beta-release/#comments</comments>
		<pubDate>Mon, 25 Dec 2006 17:54:33 +0000</pubDate>
		<dc:creator>zoul</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Game Development]]></category>
		<category><![CDATA[GarageGames]]></category>
		<category><![CDATA[Releases]]></category>
		<category><![CDATA[Torque Game Builder]]></category>
		<category><![CDATA[Torque Game Engine]]></category>
		<category><![CDATA[TorqueScript]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.fragmentedcode.com/?p=23</guid>
		<description><![CDATA[I have released the existing XMLObject code as a v1.0 Beta, and the details can be found in this GG .plan. The current object supports the majority of the expat libraries standard callbacks, with the exception of it&#8217;s Schema/DTD callbacks, as well as the ability to parse both a full file and a string (obtained [...]]]></description>
			<content:encoded><![CDATA[<p>I have released the existing XMLObject code as a v1.0 Beta, and the details can be found in <a href="http://garagegames.com/blogs/73953/11955">this GG .plan</a>.</p>
<p>The current object supports the majority of the expat libraries standard callbacks, with the exception of it&#8217;s Schema/DTD callbacks, as well as the ability to parse both a full file and a string (obtained from network resources such as SOAP and XML-RPC requests).</p>
<p>Additional features, demos and examples of use for the XMLObject will be released in time, these examples include integrating my existing HighScores object as an XML document, as well as retrieving the HighScores object from a network resource.</p>
<p>For more details, and a download link, please drop by and read the GG .plan.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fragmentedcode.com/2006/12/25/xmlobject-v10-beta-release/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XMLObject Updates</title>
		<link>http://www.fragmentedcode.com/2006/12/21/xmlobject-updates/</link>
		<comments>http://www.fragmentedcode.com/2006/12/21/xmlobject-updates/#comments</comments>
		<pubDate>Thu, 21 Dec 2006 10:36:24 +0000</pubDate>
		<dc:creator>zoul</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Game Development]]></category>
		<category><![CDATA[GarageGames]]></category>
		<category><![CDATA[Torque Game Builder]]></category>
		<category><![CDATA[Torque Game Engine]]></category>
		<category><![CDATA[TorqueScript]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.fragmentedcode.com/?p=24</guid>
		<description><![CDATA[Ok, I&#8217;ve finished some more of the XMLObject code, and now have the following SAX methods implemented as TorqueScript callbacks: onElementStart(%this, %name, %attributes) onElementEnd(%this, %name) onCharacterData(%this, %name, %data) // %name is a reference to the last element started onProcessingInstruction(%this, %target, %data) onComment(%this, %data) onCdataSectionStart(%this) onCdataSectionEnd(%this) onDefault(%this, %data, %len) Not all of the callbacks have been [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, I&#8217;ve finished some more of the XMLObject code, and now have the following SAX methods implemented as TorqueScript callbacks:</p>
<ul>
<li>onElementStart(%this, %name, %attributes)</li>
<li>onElementEnd(%this, %name)</li>
<li>onCharacterData(%this, %name, %data) // %name is a reference to the last element started</li>
<li>onProcessingInstruction(%this, %target, %data)</li>
<li>onComment(%this, %data)</li>
<li>onCdataSectionStart(%this)</li>
<li>onCdataSectionEnd(%this)</li>
<li>onDefault(%this, %data, %len)</li>
</ul>
<p>Not all of the callbacks have been thoroughly tested, but the following callbacks have been tested and found to be in full working order so far;</p>
<p>OnElementStart, onElementEnd, onCharacterData and onComment.</p>
<p>It looks like I&#8217;m getting nearer and nearer to having my saveXml() and loadXml() methods fully functioning, and as seen in my previous post, I&#8217;ve already got the makings of a TorqueScript-based object/level loader.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fragmentedcode.com/2006/12/21/xmlobject-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TorqueScript XML Object Loads</title>
		<link>http://www.fragmentedcode.com/2006/12/20/torquescript-xml-object-loads/</link>
		<comments>http://www.fragmentedcode.com/2006/12/20/torquescript-xml-object-loads/#comments</comments>
		<pubDate>Thu, 21 Dec 2006 01:34:40 +0000</pubDate>
		<dc:creator>zoul</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Game Development]]></category>
		<category><![CDATA[GarageGames]]></category>
		<category><![CDATA[Torque Game Builder]]></category>
		<category><![CDATA[Torque Game Engine]]></category>
		<category><![CDATA[TorqueScript]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.fragmentedcode.com/?p=25</guid>
		<description><![CDATA[I&#8217;ve managed to get the XMLObject to a fairly useable point, so far, the following script, is useable: [js] function sceneObjectParser::onElementStart(%this, %name, %atts) { switch$(%name) { case &#8220;objects&#8221;: %this.objectBlock = true; default: if(%this.objectBlock) { %obj = new (%name)() { class = getAttribute(%atts, &#8220;class&#8221;); superClass = getAttribute(%atts, &#8220;superClass&#8221;); }; %obj.dump(); } } } function sceneObjectParser::onElementEnd(%this, %name) [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve managed to get the XMLObject to a fairly useable point, so far, the following script, is useable:</p>
<p>[js]<br />
function sceneObjectParser::onElementStart(%this, %name, %atts)<br />
{<br />
   switch$(%name)<br />
   {<br />
      case &#8220;objects&#8221;: %this.objectBlock = true;<br />
      default:<br />
         if(%this.objectBlock)<br />
         {<br />
            %obj = new (%name)()<br />
            {<br />
               class = getAttribute(%atts, &#8220;class&#8221;);<br />
               superClass = getAttribute(%atts, &#8220;superClass&#8221;);<br />
            };<br />
            %obj.dump();<br />
         }<br />
   }<br />
}</p>
<p>function sceneObjectParser::onElementEnd(%this, %name)<br />
{<br />
    switch$(%name)<br />
    {<br />
       case &#8220;objects&#8221;: %this.objectBlock = false;<br />
    }<br />
}</p>
<p>function sceneObjectParser::onCharacterData(%this, %name, %data, %len)<br />
{<br />
   echo(&#8220;CDATA: &#8212;&#8221; @ %name @ &#8221; &#8211; &#8221; @ %data @ &#8220;&#8212;&#8221;);<br />
}</p>
<p>function getAttribute(%atts, %name)<br />
{<br />
   for(%x = 0; %x < %atts.getCount(); %x++)<br />
   {<br />
      if(%atts.getObject(%x).AttributeName $= %name) return %atts.getObject(%x).AttributeValue;<br />
   }<br />
   return "";<br />
}</p>
<p>$xml = new XMLObject() { class = "sceneObjectParser"; objectBlock = false; };<br />
$xml.parseDocument("XMLTestFile.xml");<br />
[/js]</p>
<p>This will actually create instances of the objects identified by the xml elements inside of an "objects" node, for example, the following XML document was parsed for testing;<br />
[xml]<br />
<level name="xmlLevel"><br />
    <objects><br />
        <t2dsceneobject class="mySceneObject" superClass="mySuperClass" /><br />
        <t2dstaticsprite class="myStaticSprite" /><br />
        <scriptobject class="myScriptObject" superClass="mySuperClass2" /><br />
    </objects></p>
<p>[/xml]</p>
<p>I&#8217;ve not yet thoroughly tested it, but once I find a useful and reusable XML format for Objects and Levels, I&#8217;ll start working on the saveXml and loadXml functions respectively, and add them as either ConsoleFunctions which take in any SimObject, or add them as addon functions to the base SimObject within the XMLObject.cc itself (little to no engine code should need to be updated for this resource to work effectively)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fragmentedcode.com/2006/12/20/torquescript-xml-object-loads/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TorqueScript XMLObject</title>
		<link>http://www.fragmentedcode.com/2006/12/20/torquescript-xmlobject/</link>
		<comments>http://www.fragmentedcode.com/2006/12/20/torquescript-xmlobject/#comments</comments>
		<pubDate>Wed, 20 Dec 2006 19:36:12 +0000</pubDate>
		<dc:creator>zoul</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Game Development]]></category>
		<category><![CDATA[GarageGames]]></category>
		<category><![CDATA[Torque Game Builder]]></category>
		<category><![CDATA[Torque Game Engine]]></category>
		<category><![CDATA[TorqueScript]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.fragmentedcode.com/?p=26</guid>
		<description><![CDATA[I have started working on an implementation of Expat (the Gnome XML Parser) library into TGB, and expect that a large portion of the code should work with TGE as well, as it&#8217;s just a simple Console Object being added to the system. So far, I&#8217;ve managed to create and expose the XMLObject class to [...]]]></description>
			<content:encoded><![CDATA[<p>I have started working on an implementation of Expat (the Gnome XML Parser) library into TGB, and expect that a large portion of the code should work with TGE as well, as it&#8217;s just a simple Console Object being added to the system.</p>
<p>So far, I&#8217;ve managed to create and expose the XMLObject class to TorqueScript, as well as added a &#8216;parseDocument&#8217; method to the object, which is exposed to TorqueScript and takes in a Filename as it&#8217;s only parameter.  This then makes numerous calls to the startElement and endElement C++ methods (there&#8217;s a static and non-static version of each, something to do with the function pointers that expat uses since its written in C).  These C++ methods then call there TorqueScript equivalents, onStartElement and onEndElement, which allows a script developer to very simply use the SAX parser functionality of Expat within TorqueScript by doing the following:</p>
<p>[js]<br />
function MySax::onStartElement(%this, %name, %atts)<br />
{<br />
  echo(&#8220;ElementStart: &#8221; @ %name);<br />
  for(%x = 0; %x &lt; %atts.getCount(); %x++)<br />
  {<br />
    echo(&#8221;  Name:  &#8221; @ %atts.getObject(%x).AttributeName);<br />
    echo(&#8221;  Value: &#8221; @ %atts.getObject(%x).AttributeValue);<br />
  }<br />
}</p>
<p>function MySax::onElementEnd(%this, %name)<br />
{<br />
  echo(&#8220;TS ElementEnd: &#8221; @ %name);<br />
}</p>
<p>%sax = new XMLObject()<br />
{<br />
  class = &#8220;MySax&#8221;;<br />
};</p>
<p>%sax.parseDocument(&#8220;XMLFile.xml&#8221;);<br />
[/js]</p>
<p>I am intending to release the XMLObject code, along with any other TGB engine hacks I make that use the code, as a resource on GG&#8217;s site.  I&#8217;ll post my progress here, and when I get a more completed version, I&#8217;ll post a .plan on GG&#8217;s site.</p>
<p>So far, all I&#8217;ve managed to cover is the Start and End element handlers, and the CDATA handler for the XML, my plans include to add the following:</p>
<ol>
<li>SimObject.saveXml() &#8212; save SimObjects as XML Files rather then TorqueScript</li>
<li>SimObject.loadXml() &#8212; load SimObjects from XML Files, rather then exec()ing the TorqueScript</li>
<li>Full list of SAX Methods, as made available through Expat</li>
<li>Possibility of adding a DOM to the Code (Adding a DOM may require using yet another library, other then SAX, or a replacement to SAX that supports DOM &#8212; but I&#8217;m going to take a look at implementing a very simple DOM using my own code, and my own XPath implementation &#8212; just cause I wanna see how hard it&#8217;ll be to do ;p)</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.fragmentedcode.com/2006/12/20/torquescript-xmlobject/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

