From ceac394c2133d44e81db2eb633ff54a9ad6ce7c5 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 10 Nov 2005 05:52:11 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r3865, which included commits to RCS files with non-trunk default branches. svn path=/trunk/extensions/gripd/; revision=3866 --- src/midiio/include/FileIO.h | 148 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 src/midiio/include/FileIO.h (limited to 'src/midiio/include/FileIO.h') diff --git a/src/midiio/include/FileIO.h b/src/midiio/include/FileIO.h new file mode 100644 index 0000000..fdec5de --- /dev/null +++ b/src/midiio/include/FileIO.h @@ -0,0 +1,148 @@ +// +// Copyright 1997 by Craig Stuart Sapp, All Rights Reserved. +// Programmer: Craig Stuart Sapp +// Creation Date: Fri May 9 22:30:32 PDT 1997 +// Last Modified: Sun Dec 14 05:26:16 GMT-0800 1997 +// Filename: ...sig/maint/code/base/FileIO/FileIO.h +// Web Address: http://sig.sapp.org/include/sigBase/FileIO.h +// Documentation: http://sig.sapp.org/doc/classes/FileIO +// Syntax: C++ +// +// Description: Derived from the fstream class, this class has +// functions which allow writing binary files in +// both little and big endian formats. Useful for +// writing files such as soundfiles and MIDI files +// which require numbers to be stored in a particular +// endian format. +// + +#ifndef _FILEIO_H_INCLUDED +#define _FILEIO_H_INCLUDED + + +#include + +typedef unsigned char uchar; +typedef unsigned short ushort; +typedef unsigned long ulong; +typedef unsigned int uint; + +// templates would be nice to use here, but they don't seem +// to work intuitively... + +class FileIO : public std::fstream { + public: + FileIO (void); + FileIO (const char* filename, std::ios::openmode state); + ~FileIO (); + + void readBigEndian (char& aNumber); + void readBigEndian (uchar& aNumber); + void readBigEndian (short& aNumber); + void readBigEndian (ushort& aNumber); + void readBigEndian (long& aNumber); + void readBigEndian (ulong& aNumber); + void readBigEndian (int& aNumber); + void readBigEndian (uint& aNumber); + void readBigEndian (float& aNumber); + void readBigEndian (double& aNumber); + + void readLittleEndian (char& aNumber); + void readLittleEndian (uchar& aNumber); + void readLittleEndian (short& aNumber); + void readLittleEndian (ushort& aNumber); + void readLittleEndian (long& aNumber); + void readLittleEndian (ulong& aNumber); + void readLittleEndian (int& aNumber); + void readLittleEndian (uint& aNumber); + void readLittleEndian (float& aNumber); + void readLittleEndian (double& aNumber); + + void readMachineEndian (char& aNumber); + void readMachineEndian (uchar& aNumber); + void readMachineEndian (short& aNumber); + void readMachineEndian (ushort& aNumber); + void readMachineEndian (long& aNumber); + void readMachineEndian (ulong& aNumber); + void readMachineEndian (int& aNumber); + void readMachineEndian (uint& aNumber); + void readMachineEndian (float& aNumber); + void readMachineEndian (double& aNumber); + + void readNotMachineEndian (char& aNumber); + void readNotMachineEndian (uchar& aNumber); + void readNotMachineEndian (short& aNumber); + void readNotMachineEndian (ushort& aNumber); + void readNotMachineEndian (long& aNumber); + void readNotMachineEndian (ulong& aNumber); + void readNotMachineEndian (int& aNumber); + void readNotMachineEndian (uint& aNumber); + void readNotMachineEndian (float& aNumber); + void readNotMachineEndian (double& aNumber); + + void writeBigEndian (char aNumber); + void writeBigEndian (uchar aNumber); + void writeBigEndian (short aNumber); + void writeBigEndian (ushort aNumber); + void writeBigEndian (long aNumber); + void writeBigEndian (ulong aNumber); + void writeBigEndian (int aNumber); + void writeBigEndian (uint aNumber); + void writeBigEndian (float aNumber); + void writeBigEndian (double aNumber); + + void writeLittleEndian (char aNumber); + void writeLittleEndian (uchar aNumber); + void writeLittleEndian (short aNumber); + void writeLittleEndian (ushort aNumber); + void writeLittleEndian (long aNumber); + void writeLittleEndian (ulong aNumber); + void writeLittleEndian (int aNumber); + void writeLittleEndian (uint aNumber); + void writeLittleEndian (float aNumber); + void writeLittleEndian (double aNumber); + + void writeMachineEndian (char aNumber); + void writeMachineEndian (uchar aNumber); + void writeMachineEndian (short aNumber); + void writeMachineEndian (ushort aNumber); + void writeMachineEndian (long aNumber); + void writeMachineEndian (ulong aNumber); + void writeMachineEndian (int aNumber); + void writeMachineEndian (uint aNumber); + void writeMachineEndian (float aNumber); + void writeMachineEndian (double aNumber); + + void writeNotMachineEndian (char aNumber); + void writeNotMachineEndian (uchar aNumber); + void writeNotMachineEndian (short aNumber); + void writeNotMachineEndian (ushort aNumber); + void writeNotMachineEndian (long aNumber); + void writeNotMachineEndian (ulong aNumber); + void writeNotMachineEndian (int aNumber); + void writeNotMachineEndian (uint aNumber); + void writeNotMachineEndian (float aNumber); + void writeNotMachineEndian (double aNumber); + + protected: + + char flipBytes (char aNumber); + uchar flipBytes (uchar aNumber); + short flipBytes (short aNumber); + ushort flipBytes (ushort aNumber); + long flipBytes (long aNumber); + ulong flipBytes (ulong aNumber); + int flipBytes (int aNumber); + uint flipBytes (uint aNumber); + float flipBytes (float aNumber); + double flipBytes (double aNumber); + +}; + + + +#endif /* _FILEIO_H_INCLUDED */ + + + +// md5sum: 0a146ebe5c6bd0850be973f612827d20 - FileIO.h =css= 20030102 -- cgit v1.2.1