Re: json
- Posted by ghaberek (admin) Aug 02, 2012
- 2816 views
mattlewis said...
Yes, this sounds like a good idea to me. You should totally code that up and contribute.
I suppose those could just be wrappers around regular getc() and seek() calls, no?
I've already started playing around with the concepts so I'll surely give it a whirl. At the very least, yes, they would be calls to the in-built file I/O routines, just with some "smart" buffering, etc. I would also like to be able to emulate file I/O in memory...
sequence my_data = {} -- obtain data atom ptr = allocate( length(my_data), 1 ) poke( ptr, my_data ) stream s = stream:open( ptr, STREAM_MEMORY ) -- perform I/O on this "stream" while buffers are moved -- and allocated to to accommodate the size of the data stream:close( s )
or just...
sequence my_data = {} -- obtain data stream s = stream:open( my_data, STREAM_MEMORY ) -- allocates data into memory with "cleanup" flag -- etc. stream:close( s )
-Greg