home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2004 March / PCWELT_3_2004.ISO / pcwsoft / flaskmpeg_078_39_src.z.exe / flaskmpeg / Audio / RIFFFile.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-10-28  |  2.2 KB  |  83 lines

  1. /* rifffile.h - Copyright (c) 1996, 1998 by Timothy J. Weber */
  2.  
  3. #ifndef __RIFFFILE_H
  4. #define __RIFFFILE_H
  5.  
  6. /* Headers required to use this module */
  7. #include <stack>
  8. #include <string>
  9. #include <vector>
  10.  
  11. #include <stdio.h>
  12.  
  13. /***************************************************************************
  14.     macros, constants, and enums
  15. ***************************************************************************/
  16.  
  17. /***************************************************************************
  18.     typedefs, structs, classes
  19. ***************************************************************************/
  20.  
  21. class RiffFile;
  22. class RiffChunk {
  23. public:
  24.     char name[5];
  25.     unsigned long size;  // the length, read from the second chunk header entry
  26.     char subType[5];  // valid for RIFF and LIST chunks
  27.     long start;  // the file offset in bytes of the chunk contents
  28.     long after;  // the start of what comes after this chunk
  29.  
  30.     // initialize at the file's current read position, and mark the file as bad
  31.     // if there's an error.
  32.     RiffChunk()
  33.         {};
  34.     RiffChunk(RiffFile& file);
  35.  
  36.     bool operator < (const RiffChunk& other) const
  37.         { return start < other.start; };
  38.     bool operator == (const RiffChunk& other) const
  39.     { return strcmp(name, other.name) == 0
  40.         && size == other.size
  41.         && strcmp(subType, other.subType) == 0
  42.         && start == other.start; };
  43. };
  44.  
  45. class RiffFile {
  46.     FILE* fp;
  47.  
  48.     unsigned long formSize;
  49.  
  50.     std::stack<RiffChunk, std::vector<RiffChunk> > chunks;
  51.  
  52. public:
  53.     RiffFile(const char *name);
  54.     ~RiffFile();
  55.  
  56.     bool rewind();
  57.     bool push(const char* chunkType = 0);
  58.     bool pop();
  59.     long chunkSize() const;
  60.     const char* chunkName() const;
  61.     const char* subType() const;
  62.     bool getNextExtraItem(std::string& type, std::string& value);
  63.     FILE* filep()
  64.         { return fp; };
  65.  
  66. protected:
  67.     bool readExtraItem(std::string& type, std::string& value);
  68. };
  69.  
  70. /***************************************************************************
  71.     public variables
  72. ***************************************************************************/
  73.  
  74. #ifndef IN_RIFFFILE
  75. #endif
  76.  
  77. /***************************************************************************
  78.     function prototypes
  79. ***************************************************************************/
  80.  
  81. #endif
  82. /* __RIFFFILE_H */
  83.