Array field describes an array of some data type. Array is a sequence of several values of the same type.
Syntax:
[[noindex]] type-id var-id[expression];
Expression
may be constant expression or dynamic expression. If it evaluates to 0, the field is removed from the output.
Device Monitoring Studio automatically distinguishes between a simple array and an ordinary array. An array of elements of integer and floating-point built-in types is considered a simple array. Simple arrays do not impose a limit on a number of items and are extremely cheap to bind and consume no memory at all. Ordinary arrays (that is, arrays of user-defined types, or string types) have a hard-coded limit on array item count (about 2 million items) and require a corresponding amount of free RAM. A noindex attribute
may precede the array field declaration if you do not use an Array Indexing Operator in any of the expressions to refer to elements of this array.
This will save the memory and structure binding time.
Example of array fields:
struct B
{
// …
};
struct A
{
int a[5]; // static array, considered as simple array
B b[a[0]]; // dynamic array (a number of elements is taken from the first element of a). Not a simple array
};
Any array of elements of integer or floating-point built-in types is called a simple array. Array of elements of other types is called an ordinary array.
The following table briefly describes the difference between two array types:
Property | Simple Array | Ordinary Array |
---|---|---|
User-defined element type supported | No | Yes |
Consumes more memory as array's size increases | No | Yes |
Consumes more time as array's size increases | No | Yes |
Has upper array size limit | No | Yes |
Supports [noindex] attribute | No, ignored if used | Yes, consumes less memory and time if used on an array |
You are allowed to declare an array of “infinite” size when declaring an array. The following syntax is used:
type-id var-id[*];
type-id
must be a user-defined type that must contain at least one $break_array directive that will specify the last element of the “infinite” array.
This is very useful if array size is not known at the array declaration point. For example, the following code snippet is capable of parsing a C-style null-terminated string:
struct StringCharacter
{
char c;
if (c == 0)
$break_array(true);
};
struct NullTerminatedString
{
StringCharacter chars[*];
};
// Display the class usage
struct FileStructure
{
NullTerminatedString FileName;
NullTerminatedString Location;
// …
};
When Device Monitoring Studio visualizes an array, it optionally visualizes its first several values in-line. Other values are displayed when you expand the array item. Character arrays (arrays of elements of char and wchar_t types) are visualized as ANSI or UNICODE strings respectively.