Listing 6
class MGT { %{ MGT(void) { for (size_t i = 0; i < 256; ++i) { tables[i] = 0; } for (size_t i = 0; i < 256; ++i) { descriptor[i] = 0; } } ~MGT(void) { for (size_t i = 0; table[i]; ++i) { delete(tables[i]); } for (size_t i = 0; descriptor[i]; ++i) { delete(descriptor[i]); } } %} const unsigned int(8) tableId = 0xc7; bit(1) sectionSyntaxIndicator; bit(1) privateIndicator; const bit(2) reserved2a = 0b11; bit(12) sectionLength; int(16) tableIdExtention; const bit(2) reserved2b = 0b11; bit(5) versionNumber; bit(1) currentNextIndicator; int(8) sectionNumber; int(8) lastSectionNumber; int(8) protocolVersion; int(16) tablesDefined; MgtDefinedTable tables[tablesDefined]; const bit(4) reserved4 = 0b1111; bit(12) descriptorsLength; { unsigned int parsedBytes; unsigned int i = 0; for (parsedBytes=0; parsedBytes < descriptorsLength; ) { SIDescriptor descriptor[[i]]; parsedBytes += lengthof(descriptor[i++]); } } }