Initial release of libkoralle, a simple Qt-based RIFF parser

There are Qt-based solutions for parsing tree-structured container formats like XML and JSON, but when a few days ago I came across a format based on the Resource Interchange File Format (RIFF) a quick search for a Qt-based parser yielded nothing for me… but a sigh and also the result of a mkdir command.

There is some nice documentation about RIFF on the English Wikipedia. This container format is as old as from 1991, and its ancestors even older. WAV and AVI formats are based on it, but also younger formats like Google’s WebP.

So to have other developers searching for a Qt-based RIFF parser yield something and to follow the release-often-and-early mantra, please find on the KDE ftp servers now (thanks again to the KDE admins for their less-in-a-day quick support!) what came after that mkdir command and what serves me quite well already in the parsing code of the format I deal with:

release 0.1.0 of libkoralle, a lib for parsing (and hopefully soon also writing) data in Resource Interchange File Format (RIFF) based formats.

How to use libkoralle:
Given a format based on RIFF with a structure like this:

RIFF id='XMPL'
  'VRSN'
  LIST id='DATT'
    'DATA'
    'DATA'

your code would, assuming the stream is well-formatted, be like this with version 0.1:

#include <Koralle0/RiffStreamReader>
...
Koralle0::RiffStreamReader reader(device);
reader.readNextChunkHeader();
// reader.chunkId(): Koralle0::FourCharCode('X','M','P','L')
// reader.isFileChunk(): true
// reader.isListChunk(): true
reader.openList(); // needs matching closeList();
  reader.readNextChunkHeader();
  // reader.chunkId(): Koralle0::FourCharCode('V','R','S','N')
  // reader.isFileChunk()/isListChunk(): false
  // reader.chunkData()/chunkSize(): data of the content
  reader.readNextChunkHeader();
  // reader.chunkId(): Koralle0::FourCharCode('D','A','T','T')
  // reader.isFileChunk(): false
  // reader.isListChunk(): true
  reader.openList();
  while(reader.readNextChunkHeader())
  {
    // reader.chunkId(): Koralle0::FourCharCode('D','A','T','A')
    // reader.isFileChunk()/isListChunk(): false
    // reader.chunkData()/chunkSize(): data of the content
  }
  reader.closeList();
reader.closeList();

Future version might have support for related container formats (IFF, RIFX, …) and allow passing of custom parsers for the data chunk content, to avoid the temporary QByteArray copy, as well as default parsers for standard chunk types like “INFO”.

See also Snorkel, a simple RIFF structure viewer I wrote using also libkoralle.

Contributors and feedback of course welcome! 🙂

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.