Setting Variable Formats

You can change the way the Variables view displays data. For example, you can add labels to variable data so that those labels appear in the Variables view and clarify the displayed data.

For example, suppose you have the structure defined in Listing 1.

Listing 1 Sample structure definition

struct Rect {
short top;
short left;
short bottom;
short right;
};

The Variables view might show an instance of the Rect structure like this:

myRect 0x000DCEA8

You can create an XML file that defines a new way to display the structure, as shown in Listing 2.

Listing 2 Sample variable format definition

<variableformats>
<variableformat>
<osname>osWin32</osname>
<runtimename>runtimeWin32</runtimename>
<typename>Rect</typename>
<expression>
"{T: " + ^var.top +
" L: " + ^var.left +
" B: " + ^var.bottom +
" R: " + ^var.right +
"}{H: " + (^var.bottom - ^var.top) +
" W: " + (^var.right - ^var.left) + "}"
</expression>
</variableformat>
</variableformats>

Given this new variable format definition, the Variables view now shows the same myRect instance like this:

myRect {T: 30 L: 30 B: 120 R: 120}{H: 90 W: 90}

To manipulate variable formats, you place an XML file that defines the new format inside the VariableFormats directory at

<CARBIDE>\plugins\com.nokia.carbide.cpp.support_2.0.0.xxx\Debugger\Plugins\Support\VariableFormats

where Carbide is the path to your Carbide installation.

The IDE reads the XML files in this directory to determine how to display variable data. Table 1 explains the main XML tags that the IDE recognizes.

Table 1 Variable formats—XML tags
Tag Explanation
variableformats A group of variable format records.
variableformat An individual variable format record.
osname The operating system that defines the scope of this record.
runtimename The runtime that defines the scope of this record.
typename The name of the Type that this record will format.
expression The expression that reformats the variable display. The IDE evaluates this expression to determine the format that it applies to the variable. The IDE replaces all occurrences of the ^var placeholder with the name of the variable.
Related references