Written by Mike D Sutton
EDais@mvps.org

Http://EDais.mvps.org/

- 05.02.2006 -

Introduction:

If you have ever developed support for an external file format or otherwise had to read in data from a file, you may also have come across the case where you have to parse the file contents from a memory buffer instead. In this case either a new routine needs to be written to read the file contents from a memory block or the entire thing is written down to disk and the original file load method can be invoked.
Both of these techniques leave something to be desired however and these are not the only two cases where input data source differs; for instance you may be reading from a VB file handle or an API file handle, an HTTP site or FTP server, and in each of these cases the methods used to read the data differ.
The ideal solution to this problem would be if there were a way of reading or writing data regardless of the method used to accomplish it, and this is what we’re going to achieve in this article.

The method we’re going to use to accomplish this is to create a number of different data streams which cope with each of the different data sources, however they will all communicate through a common interface. You’ll find streams used in many other development languages so you may have already come across the concept before.
If you’re not particularly familiar with classes and interfaces then you may want to have a quick read up on those first.

Chapter index:

Move on to chapter 1
Back to tutorials