X3D libraries
The libraries to work with X3D dataset

libx3d io -- The I/O handling in the X3D libraries

Version 0.1

In order to handle any type of input and output (especially input though), the libx3d system comes with an I/O interface.

It is expected that several implementation be available to load virtually anything such as:

  • regular files (i.e. FILE * -- implemented, see the FileStream)
  • compressed files (i.e. filename.x3d.gz)
  • files on an HTTP server
  • files on an FTP server
  • files read over a network using some other protocol (i.e. local socket)
  • bufferized files (for network file to be saved in memory or a local cache)
The interface is written in such a way that it can be used to encapsulate other streams. For instance, the HTTP server could be sending us a JPEG image compressed using bz2 to save a few bytes. In such a case, opening the HTTP stream will automatically create a decompressor and return a stream pointer which can do both: read over the network and decompress the data.

In most cases, you will:

  • create a stream on your stack
  • call the x3dio::Stream::Open() function
  • call the x3dio::Stream::Read() function until it returns 0 or -1
  • return (which destroys the stream and thus closes the file, socket, etc.)
To write to a file, use the x3dio::Stream::Create(), x3dio::Stream::Update() or x3dio::Stream::Append() functions instead. Just like with x3dio::Stream::Open() the stream is automatically closed on destruction of the stream.

Note:
FileStream supports an additional function called x3dio::FileStream::Attach() used to attach an existing stream (such as stdin and stdout) to a stream.
Author:
Alexis Wilke
Version:
v0.1
License:
LGPL