#ifndef IOSTREAM_H
#define IOSTREAM_H

typedef unsigned long streamsize_type;

context ostream( dtype ostype )
{
  ostype *write( ostype *, const char *, streamsize_type );
  int fail( ostype * );
};

context writeable( type T )
{
  forall( dtype ostype | ostream( ostype ) ) ostype * ?<<?( ostype *, T );
};

// implement writable for some intrinsic types

forall( dtype ostype | ostream( ostype ) ) ostype * ?<<?( ostype *, char );

forall( dtype ostype | ostream( ostype ) ) ostype * ?<<?( ostype *, int );

forall( dtype ostype | ostream( ostype ) ) ostype * ?<<?( ostype *, const char * );


context istream( dtype istype )
{
  istype *read( istype *, char *, streamsize_type );
  istype *unread( istype *, char );
  int fail( istype * );
  int eof( istype * );
};

context readable( type T )
{
  forall( dtype istype | istream( istype ) ) istype * ?<<?( istype *, T );
};

forall( dtype istype | istream( istype ) )
istype * ?>>?( istype *, char* );

forall( dtype istype | istream( istype ) )
istype * ?>>?( istype *, int* );

#endif /* #ifndef IOSTREAM_H */
