# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0.  If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.

module io;
pattern stdin():bstream
address io_stdin
comment "return the input stream to the database client";
pattern stderr():streams
address io_stderr
comment "return the error stream for the database console";
pattern stdout():streams
address io_stdout
comment "return the output stream for the database client";

pattern print(val:any_1,lst:any...):void 
address IOprint_val
comment "Print a MAL value tuple .";

pattern print(b1:bat[:any]...):void 
address IOtable
comment "BATs are printed with '#' for legend 
	lines, and the BUNs on seperate lines 
	between brackets, containing each to 
	comma separated values (head and tail). 
	If multiple BATs are passed for printing, 
	print() performs an implicit natural 
	join on the void head, producing a multi attribute table.";

pattern print(val:any_1):void 
address IOprint_val
comment "Print a MAL value.";
pattern print(val:bat[:any_1]):void 
address IOprint_val
comment "Print a MAL value column .";

pattern printf(fmt:str,val:any...):void 
address IOprintf
comment "Select default format ";
pattern printf(fmt:str):void 
address IOprintf
comment "Select default format ";

pattern printf(filep:streams,fmt:str,val:any...):void 
address IOprintfStream
comment "Select default format ";
pattern printf(filep:streams,fmt:str):void 
address IOprintfStream
comment "Select default format ";

command export(b:bat[:any_2], filepath:str)  
address IOexport
comment "Export a BAT as ASCII to a file. If the 'filepath' is not absolute, it
 is put into the $DBPATH directory. Success of failure is indicated.";

command import(b:bat[:any_2], filepath:str)
address IOimport
comment "Import a BAT from an ASCII dump. The tuples are appended to the
 first argument. Its signature must match the dump,
 else parsing errors will occur as an exception.";

# used for testing malloc failures
command setmemorylimit(nbytes:lng):void
address IOsetmemorylimit
comment "Set memory limit for testing";
