-- CharIO.Mesa  Edited by Sandman on June 30, 1980  9:23 AM 
-- Copyright  Xerox Corporation 1979, 1980

DIRECTORY
  StreamDefs USING [StreamHandle],
  String USING [SubString];

CharIO: DEFINITIONS =
  BEGIN

  Handle: TYPE = StreamDefs.StreamHandle;

  -- some control characters

  NUL: CHARACTER = 0C;
  BS: CHARACTER = 'H - 100B;
  TAB: CHARACTER = 'I - 100B;
  LF: CHARACTER = 'J - 100B;
  FF: CHARACTER = 'L - 100B;
  CR: CHARACTER = 'M - 100B;
  ControlZ: CHARACTER = 'Z - 100B;
  ESC: CHARACTER = 33C;
  SP: CHARACTER = ' ;
  DEL: CHARACTER = 177C;

  -- numerical output formatting

  NumberFormat: TYPE = RECORD [
    base: [2..36], zerofill, unsigned: BOOLEAN, columns: [0..255]];

  GetChar: PROCEDURE [in: Handle] RETURNS [CHARACTER] = INLINE
    BEGIN RETURN[in.get[in]] END;

  PutChar: PROCEDURE [out: Handle, c: CHARACTER] = INLINE
    BEGIN out.put[out, c] END;

  GetString: PROCEDURE [Handle, STRING, PROCEDURE [CHARACTER] RETURNS [BOOLEAN]];
  PutString: PROCEDURE [Handle, STRING];
  PutSubString: PROCEDURE [Handle, String.SubString];

  GetID, GetLine: PROCEDURE [Handle, STRING];
  PutLine: PROCEDURE [out: Handle, s: STRING] = INLINE
    BEGIN PutString[out, s]; PutChar[out, CR] END;

  GetNumber: PROCEDURE [in: Handle, radix: CARDINAL] RETURNS [UNSPECIFIED];
  PutNumber: PROCEDURE [Handle, UNSPECIFIED, NumberFormat];
  GetOctal: PROCEDURE [in: Handle] RETURNS [UNSPECIFIED] = INLINE
    BEGIN RETURN[GetNumber[in, 8]] END;

  PutOctal: PROCEDURE [Handle, UNSPECIFIED];
  GetDecimal: PROCEDURE [in: Handle] RETURNS [INTEGER] = INLINE
    BEGIN RETURN[GetNumber[in, 10]] END;

  PutDecimal: PROCEDURE [Handle, INTEGER];

  END.