ElCel Technology Home|Company|Software|Services|MyAccount|Shopping Cart
SOFTWARE
OpenTop
XML Tools
User Comments
Support

OpenTop C++
Features
Core Services
Unicode
Input/Output
Networking
XML
Secure Sockets
Web Services
Platforms
Licensing
Purchasing
Documentation
Release Notes
FAQ

OpenTop Input/Output Facilities


OpenTop contains classes for managing both files and streams of data.

Possibly the most admired feature of the Java™ and .NET™ input/output models is their explicit separation of byte and Unicode character streams and the flexible way in which these streams can be filtered, extended and combined.

OpenTop offers an alternative to standard C++ streams, providing a rich set of classes inspired by the Java API. Of course OpenTop applications are not obliged to use the OpenTop I/O streams, but their flexibility, power and ease of use often makes them an ideal choice over the standard alternative.


Byte Streams

For applications that need to read/write bytes of data, OpenTop provides the abstract InputStream and OutputStream interfaces. These interfaces define the minimum set of operations (such as read(), write(), close() and so on) which all byte streams implement.

OpenTop supplies concrete implementations of these interfaces for writing to and reading from data files, the console, network sockets, in-memory buffers and more. These classes perform a similar role to the standard C++ streambuf class but, because they are only concerned with the specific task of reading or writing bytes and don't concern themselves with ancillary tasks such as buffering or encoding, they are considerably easier to understand and implement.

Filter Streams

So far we have only discussed streams which connect to a tangible store of bytes. However, one of the most elegant features of OpenTop streams is that they can be wrapped by other streams. This process is called filtering and the streams which perform this task are called filter streams.

A filter stream implements the InputStream or OutputStream interface and also contains a reference to another InputStream or OutputStream which is the filtered stream. The filter delegates read and write requests to the contained stream, but performs some additional function such as buffering the data to improve efficiency.

The BufferedInputStream class is an example of a filter stream which aids performance by placing a buffer between the reader and the data store. The elegance of this design is demonstrated here because any input stream can now take advantage of efficient buffering simply by being wrapped by a BufferedInputStream, thereby removing the need for individual streams to perform this task themselves.

By combining streams with one or more filters, the application is able to create a virtual pipeline through which data travels on its journey to or from the data store. In some ways the OpenTop streams mirror the UNIX command filter paradigm; where each filter stream performs one specific, identifiable task, and multiple filters can be built-up into a pipeline to perform more complex tasks.

Unicode Character Streams (Readers and Writers)

In addition to the byte streams described above, OpenTop contains streams for reading and writing Unicode characters. The Unicode character stream equivalent to InputStream and OutputStream are Reader and Writer respectively.

Unicode characters are often serialized to an external data source as an encoded stream of bytes. OpenTop provides the InputStreamReader and OutputStreamWriter classes which can decode or encode Unicode characters using any of the wide range of supplied Unicode encodings.

Just like their byte stream equivalents, Readers and Writers support the filter paradigm as exemplified by the BufferedReader class. Additionally, streams are provided which buffer their characters in memory or store them in string objects.

Platform-independent File System Access

Even though the C++ standard defines the fstream class for performing file i/o, one of the perennial frustrations for cross-platform developers is the lack of a standard facility to navigate the file system, e.g. listing directories or determining a file's attributes.

OpenTop provides the File class which gives application developers a portable method of accessing file and directory information.


Networking