# 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 blob;

atom blob;

command tostr()   address BLOBtostr;
command fromstr() address BLOBfromstr;
command nequal()  address BLOBnequal;
command hash()    address BLOBhash;
command null()    address BLOBnull;
command read()    address BLOBread;
command write()   address BLOBwrite;
command put()     address BLOBput;
command del()     address BLOBdel;
command length()  address BLOBlength;
command heap()    address BLOBheap;

command blob(s:blob):blob
address BLOBblob_blob
comment "Noop routine.";

command blob(s:str):blob
address BLOBblob_fromstr;

# @+ string functions
# Manipulation functions to extract strings from blobs and vice versa.
# Not to be confused with blob parsing and printing.
command tostring(v:blob) :str
address BLOBfromblob
comment "get the bytes from blob as a string, till
	the first 0 byte or the end of the blob";
command tostring(v:blob, index:int ) :str
address BLOBfromidx
comment "get the bytes from blob as a string,
	 starting at byte 'index' till the first
	0 byte or the end of the blob.";
command toblob(v:str) :blob
address BLOBtoblob
comment "store a string as a blob.";
command nitems(b:blob):int
address BLOBnitems
comment " get the number of bytes in this blob.";

atom sqlblob:blob;

command tostr()   address SQLBLOBtostr;
command fromstr() address SQLBLOBfromstr;

command sqlblob(s:sqlblob):sqlblob
address BLOBblob_blob
comment "Noop routine.";

command sqlblob(s:str):sqlblob
address BLOBsqlblob_fromstr;

module blob;

command prelude() :void
address BLOBprelude;

blob.prelude();

module calc;

command blob(b:blob):blob address BLOBblob_blob;
command blob(s:str):blob address BLOBblob_fromstr;
command sqlblob(b:sqlblob):sqlblob address BLOBblob_blob;
command sqlblob(s:str):sqlblob address BLOBsqlblob_fromstr;
