File indexing completed on 2024-05-12 04:33:55
0001 // -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; c-brace-offset: 0; -*- 0002 /* This file is part of KDVI 0003 SPDX-FileCopyrightText: 2001 Stefan Kebekus (kebekus@kde.org) 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 /** 0008 * Byte reading routines which read big endian numbers from memory and 0009 * convert them to native integers. 0010 * 0011 * @author Stefan Kebekus (kebekus@kde.org) 0012 * 0013 **/ 0014 0015 #ifndef _bigEndianByteReader_H 0016 #define _bigEndianByteReader_H 0017 0018 #include <QGlobalStatic> 0019 0020 class bigEndianByteReader 0021 { 0022 public: 0023 /** Set this pointer to the location where the number resides which 0024 you want to read. */ 0025 quint8 *command_pointer; 0026 0027 /** This pointer marks the end of the memory area where bytes can be 0028 read. It should point to the first byte which CANNOT be 0029 read. The idea is to have a safety net which protects us against 0030 SEGFAULTs. This is also used in virtual fonts, where the macro 0031 does not have an EOP command at the end of the macro. */ 0032 quint8 *end_pointer; 0033 0034 /** If command_pointer >= end_pointer, this method return EOP (=140) 0035 and exists. Otherwise, the method returns the unsigned byte 0036 and increases the command_pointer by one. */ 0037 quint8 readUINT8(); 0038 0039 /** Similar to the method above, only that the method reads a big 0040 endian 2-byte word and increases the pointer by two. */ 0041 quint16 readUINT16(); 0042 0043 /** Similar to the method above, only that the method reads a big 0044 endian 4-byte word and increases the pointer by four. */ 0045 quint32 readUINT32(); 0046 0047 void writeUINT32(quint32 a); 0048 0049 /** Similar to the method above, only that the method reads a big 0050 endian number of length size, where 1 <= size <= 4. Note that 0051 the value 3 is allowed (and is actually used in DVI files)!!! */ 0052 quint32 readUINT(quint8 size); 0053 0054 /** Similar to the method above, only that the method reads a SIGNED 0055 number */ 0056 qint32 readINT(quint8); 0057 }; 0058 0059 #endif // ifndef _bigEndianByteReader_H