inkscapestream.h revision 4cb9ed4c3d183554e888e636844f8e3c2e666c40
#ifndef __INKSCAPE_IO_INKSCAPESTREAM_H__
#define __INKSCAPE_IO_INKSCAPESTREAM_H__
/**
* Our base basic stream classes.
*
* Authors:
* Bob Jamison <rjamison@titan.com>
*
* Copyright (C) 2004 Inkscape.org
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include <cstdio>
#include <glibmm.h>
{
{
{
{ }
};
//#########################################################################
//# I N P U T S T R E A M
//#########################################################################
/**
* This interface is the base of all input stream classes. Users who wish
* to make an InputStream that is part of a chain should inherit from
* BasicInputStream. Inherit from this class to make a source endpoint,
* such as a URI or buffer.
*
*/
{
/**
* Constructor.
*/
InputStream() {}
/**
* Destructor
*/
virtual ~InputStream() {}
/**
* Return the number of bytes that are currently available
* to be read
*/
/**
* Do whatever it takes to 'close' this input stream
* The most likely implementation of this method will be
* for endpoints that use a resource for their data.
*/
/**
* Read one byte from this input stream. This is a blocking
* call. If no data is currently available, this call will
* not return until it exists. If the user does not want
* their code to block, then the usual solution is:
* if (available() > 0)
* myChar = get();
* This call returns -1 on end-of-file.
*/
}; // class InputStream
/**
* This is the class that most users should inherit, to provide
* their own streams.
*
*/
{
virtual ~BasicInputStream() {}
bool closed;
}; // class BasicInputStream
/**
* Convenience class for reading from standard input
*/
{
int available()
{ return 0; }
void close()
{ /* do nothing */ }
int get()
{ return getchar(); }
};
//#########################################################################
//# O U T P U T S T R E A M
//#########################################################################
/**
* This interface is the base of all input stream classes. Users who wish
* to make an OutputStream that is part of a chain should inherit from
* BasicOutputStream. Inherit from this class to make a destination endpoint,
* such as a URI or buffer.
*/
{
/**
* Constructor.
*/
OutputStream() {}
/**
* Destructor
*/
virtual ~OutputStream() {}
/**
* This call should
* 1. flush itself
* 2. close itself
* 3. close the destination stream
*/
/**
* This call should push any pending data it might have to
* the destination stream. It should NOT call flush() on
* the destination stream.
*/
/**
* Send one byte to the destination stream.
*/
}; // class OutputStream
/**
* This is the class that most users should inherit, to provide
* their own output streams.
*/
{
virtual ~BasicOutputStream() {}
bool closed;
}; // class BasicOutputStream
/**
* Convenience class for writing to standard output
*/
{
void close()
{ }
void flush()
{ }
};
//#########################################################################
//# R E A D E R
//#########################################################################
/**
* This interface and its descendants are for unicode character-oriented input
*
*/
{
/**
* Constructor.
*/
Reader() {}
/**
* Destructor
*/
/* Input formatting */
}; // interface Reader
/**
* This class and its descendants are for unicode character-oriented input
*
*/
{
virtual ~BasicReader() {}
/* Input formatting */
{ return readUnsignedShort(val); }
{ return readUnsignedInt(val); }
{ return readUnsignedLong(val); }
{ return readDouble(val); }
}; // class BasicReader
/**
* Class for placing a Reader on an open InputStream
*
*/
{
/*Overload these 3 for your implementation*/
};
/**
* Convenience class for reading formatted from standard input
*
*/
{
StdReader();
/*Overload these 3 for your implementation*/
};
//#########################################################################
//# W R I T E R
//#########################################################################
/**
* This interface and its descendants are for unicode character-oriented output
*
*/
{
/**
* Constructor.
*/
Writer() {}
/**
* Destructor
*/
/* Formatted output */
}; // interface Writer
/**
* This class and its descendants are for unicode character-oriented output
*
*/
{
virtual ~BasicWriter() {}
/*Overload these 3 for your implementation*/
/* Formatted output */
{ destination = NULL; }
}; // class BasicWriter
/**
* Class for placing a Writer on an open OutputStream
*
*/
{
/*Overload these 3 for your implementation*/
};
/**
* Convenience class for writing to standard output
*/
{
StdWriter();
};
//#########################################################################
//# U T I L I T Y
//#########################################################################
} // namespace IO
} // namespace Inkscape
#endif /* __INKSCAPE_IO_INKSCAPESTREAM_H__ */