Memory-Based Streams

Support for reading and writing on memory buffers, and therefore, on text.

This code is used by open_51 "open/3" and similar routines.

Define:

1. _GNU_SOURCE:

Functions:

1. Term Yap_memStreamToTerm(int output_stream, Functor f, Term inp):

1. char * Yap_StrPrefix(const char *buf, size_t n):

1. int fill_pads(int sno, int sno0, int total, format_info *fg USES_REGS):

1. bool Yap_set_stream_to_buf(StreamDesc st, const char buf, size_t nchars USES_REGS):

1. int Yap_open_buf_read_stream(void spt, const char buf, size_t nchars, encoding_t *encp, memBufSource src, Atom fname, Term uname):

1. static Int open_mem_read_stream(USES_REGS1): : "open_mem_read_stream(+Text, -Stream" )

@class open_mem_read_stream_2

open a term with text (atom, string, list of codes, list_of_atoms) as a text buffer .

1. int Yap_open_buf_write_stream(int sno, encoding_t enc):

1. static Int open_mem_write_stream(USES_REGS1): : "open_mem_write_stream(-Stream" )

@class open_mem_write_stream_1

open a system-allocated buffer for writing.

1. char * Yap_MemExportStreamPtr(int sno): : Yap_PeekMemwriteStream() shows the current buffer for a memory stream.

sno thein-memory stream return:
temporary buffer, discarded by close and may be moved away by other writes..

1. static Int peek_mem_write_stream(USES_REGS1): : "peek_mem_write_stream(+Stream, -InpText, -FinalText" )

@class peek_mem_write_stream_3

convert the buffer used by the memory-based stream to a difference of list of codes.

1. void Yap_MemOps(StreamDesc *st):

1. int format_synch(int sno, int sno0, format_info *fg):

1. bool Yap_CloseMemoryStream(int sno):

1. void Yap_InitMems(void):