December 2002
Intermediate to advanced
672 pages
16h 53m
English
You need tools to help debug your application. In particular, you want the ability to render binary messages in human-readable form.
When developing messaging applications, developers often hand-code pretty printers because they make debugging these applications considerably easier. However, this kind of code can be generated if you have a message repository. This solution shows how to reuse the message switch generator from Recipe 10.2:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xslt [ <!--Used to control code intenting --> <!ENTITY INDENT " "> <!ENTITY INDENT2 "&INDENT;&INDENT;"> <!ENTITY LS "<<"> ]> <xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- This pretty-printer generator needs a message switch so we --> <!-- reuse the one we already wrote. --> <xsl:import href="messageSwitch.xslt"/> <!--The directory to generate code --> <xsl:param name="generationDir" select=" 'src/' "/> <!--The C++ header file name --> <xsl:param name="prettyPrintHeader" select=" 'prettyPrint.h' "/> <!--The C++ source file name --> <xsl:param name="prettyPrintSource" select=" 'prettyPrint.C' "/> <!--Key to locate data types by name --> <xsl:key name="dataTypes" match="Structure" use="Name" /> <xsl:key name="dataTypes" match="Primitive" use="Name" /> <xsl:key name="dataTypes" match="Array" use="Name" /> <xsl:key name="dataTypes" match="Enumeration" use="Name" /> <xsl:template match="MessageRepository"> <xsl:document ...
Read now
Unlock full access