Listing 5
class Mgt { private: const unsigned char * data; mutable size_t tables_index_x; mutable size_t tables_byte_offset_x; mutable size_t tables_num_bits_x; mutable size_t descriptors_index_x; mutable size_t descriptors_byte_offset_x; mutable size_t descriptors_num_elts_x; public: Mgt (const unsigned char *_data): data (_data), tables_index_x (0), tables_byte_offset_x (0), tables_num_bits_x (0), descriptors_index_x (0), descriptors_byte_offset_x (0), descriptors_num_elts_x (0) { }; size_t tableId (void) const { const size_t bitOffset = 0; const size_t num_bits = 8; unsigned long retval = extract_bits (data, bitOffset, num_bits); return retval; }; size_t sectionSyntaxIndicator (void) const { const size_t bitOffset = 0 + 8; const size_t num_bits = 1; unsigned long retval = extract_bits (data, bitOffset, num_bits); return retval; }; ... ... size_t descriptors_num_elts (void) const { if (descriptors_num_elts_x == 0 && descriptors_num_bytes () != 0) { size_t byteOffset = (0 + 8 + 1 + 1 + 2 + 12 + 16 + 2 + 5 + 1 + 8 + 8 + 8 + 16 + tables_num_bits () + 4 + 12) / 8; size_t total_bytes = descriptors_num_bytes (); for (size_t num_bytes = 0; num_bytes < total_bytes; ++descriptors_num_elts_x) { SIDescriptor x (data + byteOffset + num_bytes); num_bytes += x.num_bits () / 8; } } return descriptors_num_elts_x; }; }