14.1 Binarystream Interface

ORIGIN '~beta/basiclib/betaenv';
LIB_DEF 'sysutilsbinstream' '../lib';
(*
 * COPYRIGHT
 *   Copyright Mjolner Informatics, 1995-98
 *   All rights reserved.
 * 
 * For constructing an in-memory byte stream in a repetition
 * that can be saved and/or restored on a file.
 * Used by the compiler and valhalla for generating
 * and reading '.db' files.
 *)
BODY 'private/binarystreambody';

---LIB:attributes---

BinaryStream:
  (# put: @
       (# ch: @char 
       enter ch 
       ... 
       #);
     putShort: @
       (# V: @integer 
       enter V 
       ... 
       #);
     putLong: @
       (# V: @integer 
       enter V 
       ... 
       #);
     putText: @
       (# T: ^text
       enter T[] 
       ... 
       #);
     get: @ 
       (# ch: @char 
       ... 
       exit ch 
       #);
     getShort:  @
       (# V: @integer 
       ... 
       exit V 
       #);
     getLong: @
       (# V: @integer 
       ... 
       exit V 
       #);
     getText: @
       (# T: ^text
       ... 
       exit T[] 
       #);
     save:
       (# openFailed:< Exception;
          FN: ^text
       enter FN[] 
       do ...
       #);
     restore:
       (# notFound:< Exception;
          FN: ^text 
       enter FN[]
       do ...
       #);
     fragRestore:
       (# notFound:< Exception;
          FN: ^text 
       enter FN[]
       do ...
       #);
     (* The folowing exceptions may not be sufficient;
      * the exception model is clumsy since the current version 
      * is a quick merge of the two binarystream versions used by
      * the compiler and valhalla. The compiler uses the exceptions below
      * but they are not used by valhalla; continue is therefore 
      * set to true. Valhalla uses the openFailed/notFound execptions
      * in save,restore and fragRestore
      *)
     AccessError:< 
       Exception(# FN: ^text enter FN[] do true -> continue; INNER #);
     NoSpaceError:< 
       Exception(# FN: ^text enter FN[] do true -> continue; INNER #);
     WriteError:< 
       Exception(# FN: ^text enter FN[] do true -> continue; INNER #);

     rep: @ ...            
  #)


14.1 Binarystream Interface
© 1994-2002 Mjølner Informatics
[Modified: Tuesday January 11th 2000 at 16:32]