IBM Support

How to use WriterTemplate introduced in Rhapsody 8.0.6 for advance code formatting

Technote (FAQ)


Question

How do you use WriterTemplate feature introduced in IBM Rational Rhapsody 8.0.6 in order to achieve advanced code formatting over multi-lining, spacing, indentation, positioning and more?

Cause

Information regarding WriterTemplate is limited in the Information Center for Rhapsody.

Answer

WriterTemplate was introduced in Rhapsody 8.0.6 to make the task of applying different formatting (e.g. multi-lining, spacing, indentation, positioning, etc) more flexible and customizable.

This feature is not provided to replace conventional formatting options already available in Rhapsody; however, it will allow you to do things exemplified below, which were not easy to achieve in old releases.

Review the General Formatting section in white paper 7039283: Customize code generation using Rational Rhapsody for C++ for details.

  • Example 1: Move comments inside the operation body (click to collapse or expand)
  • Example 2: Add 3 spaces in front of visibility keywords (click to collapse or expand)
  • Example 3: Align all lines at the beginning (click to collapse or expand)

You can also use this feature to insert special keywords, however, it won't be recommended because doing so in CPP_Roundtrip::General::RoundtripScheme=Respect (default) mode would make your code not understandable by Rhapsody, leading to various parsing errors described in technote 1640085: Rhapsody roundtrip reports parsing error if terminator is missing in macro statement inside of preserve code block

For more information, navigate to Properties tab in the Features dialog of each element, and look at properties defined under the WriterTemplate meta-class.

Notes:
  • Each WritetTemplate property contains “[[…]]”. Within those brackets there are Code Generation extractor keywords (those keywords will be substituted with proper code).
  • Adding code within these brackets will affect code, only if at least one of the contained keywords is substituted.

Related information

Purpose and Usage of Source Artifact
Further customization of code formatting

Document information

More support for: Rational Rhapsody
Documentation

Software version: 8.0.6

Operating system(s): Linux, Windows

Reference #: 1670578

Modified date: 17 April 2014