Logo Search packages:      
Sourcecode: djvulibre version File versions

IFFByteStream Class Reference

#include <IFFByteStream.h>

Inheritance diagram for IFFByteStream:

ByteStream::Wrapper ByteStream GPEnabled

List of all members.


Detailed Description

ByteStream interface for an IFF file.

Class IFFByteStream# augments the ByteStream# interface with functions for navigating from chunk to chunk. It works in relation with a ByteStream specified at construction time.

{ Reading an IFF file} --- You can read an IFF file by constructing an IFFByteStream# object attached to the ByteStream containing the IFF file. Calling function {get_chunk} positions the file pointer at the beginning of the first chunk. You can then use {ByteStream::read} to access the chunk data. Function read# will return #0# if you attempt to read past the end of the chunk, just as if you were trying to read past the end of a file. You can at any time call function {close_chunk} to terminate reading data in this chunk. The following chunks can be accessed by calling get_chunk# and close_chunk# repeatedly until you reach the end of the file. Function read# is not very useful when accessing a composite chunk. You can instead make nested calls to functions get_chunk# and close_chunk# in order to access the chunks located inside the composite chunk.

{ Writing an IFF file} --- You can write an IFF file by constructing an IFFByteStream# object attached to the seekable ByteStream object that will contain the IFF file. Calling function {put_chunk} creates a first chunk header and positions the file pointer at the beginning of the chunk. You can then use {ByteStream::write} to store the chunk data. Calling function {close_chunk} terminates the current chunk. You can append more chunks by calling put_chunk# and close_chunk# repeatedly. Function write# is not very useful for writing a composite chunk. You can instead make nested calls to function put_chunk# and close_chunk# in order to create chunks located inside the composite chunk.

Writing an IFF file requires a seekable ByteStream (see {ByteStream::is_seekable}). This is not much of a problem because you can always create the IFF file into a {MemoryByteStream} and then use {ByteStream::copy} to transfer the IFF file into a non seekable ByteStream.

Definition at line 181 of file IFFByteStream.h.


Public Member Functions

void close_chunk ()
bool compare (IFFByteStream &iff)
int composite ()
size_t copy (ByteStream &bsfrom, size_t size=0)
virtual void flush (void)
void full_id (GUTF8String &chkid)
GP< ByteStreamget_bytestream (void)
int get_chunk (GUTF8String &chkid, int *rawoffsetptr=0, int *rawsizeptr=0)
void put_chunk (const char *chkid, int insertmagic=0)
virtual size_t read (void *buffer, size_t size)
int ready ()
void seek_close_chunk ()
void short_id (GUTF8String &chkid)
virtual long tell (void) const
virtual size_t write (const void *buffer, size_t size)

Static Public Member Functions

static int check_id (const char *id)
static GP< IFFByteStreamcreate (const GP< ByteStream > &bs)

Public Attributes

bool has_magic

Protected Types

enum  codepage_type { RAW, AUTO, NATIVE, UTF8 }

Protected Member Functions

int get_count (void) const
GNativeString getAsNative (void)
GUTF8String getAsUTF8 (void)
 IFFByteStream (const GP< ByteStream > &bs, const int pos)
ByteStreamoperator & ()
ByteStreamoperator & () const
virtual int seek (long offset, int whence=SEEK_SET, bool nothrow=false)
Utility Functions.
Class ByteStream# implements these functions using the virtual interface functions only. All subclasses of ByteStream# inherit these functions.

GP< ByteStreamduplicate (const size_t size=0) const
size_t format (const char *fmt,...)
 Allows printf() type operations to a bytestream.
void formatmessage (const char *fmt,...)
TArray< char > get_data (void)
 Use at your own risk, only guarenteed to work for ByteStream::Memorys.
virtual bool is_static (void) const
 Returns false, unless a subclass of ByteStream::Static.
unsigned int read16 ()
unsigned int read24 ()
unsigned int read32 ()
unsigned int read8 ()
size_t readall (void *buffer, size_t size)
virtual size_t readat (void *buffer, size_t sz, int pos)
int scanf (const char *fmt,...)
 Allows scanf() type operations on a bytestream.
virtual int size (void) const
size_t writall (const void *buffer, size_t size)
void write16 (unsigned int card16)
void write24 (unsigned int card24)
void write32 (unsigned int card32)
void write8 (unsigned int card8)
void writemessage (const char *message)
size_t writestring (const GNativeString &s)
size_t writestring (const GUTF8String &s)

Static Protected Member Functions

static GP< ByteStreamcreate (FILE *const f, char const *const mode, const bool closeme)
static GP< ByteStreamcreate (const int fd, char const *const mode, const bool closeme)
static GP< ByteStreamcreate (char const *const mode)
static GP< ByteStreamcreate (const GURL &url, char const *const mode)
static GP< ByteStreamcreate (void const *const buffer, const size_t size)
static GP< ByteStreamcreate (void)
static GP< ByteStreamcreate_static (void const *const buffer, const size_t size)
static GP< ByteStreamget_stderr (char const *const mode=0)
static GP< ByteStreamget_stdin (char const *const mode=0)
static GP< ByteStreamget_stdout (char const *const mode=0)

Protected Attributes

ByteStreambs
volatile int count
 The reference counter.
enum ByteStream::codepage_type cp
GP< ByteStreamgbs

Static Protected Attributes

static const char * EndOfFile = ERR_MSG("EOF")

Private Member Functions

 IFFByteStream (const IFFByteStream &)
IFFByteStreamoperator= (const IFFByteStream &)

Static Private Member Functions

static GP< IFFByteStreamcreate (ByteStream *bs)

Private Attributes

IFFContext * ctx
int dir
long offset
long seekto

Classes

struct  IFFContext

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index