lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I wasn't concerned with buffers that could change length. If one can get
length changes more or less for free, then I'm all for that. If not, then
maybe what is needed is a memory buffer notion sitting on top of memory
blocks much the way that the stack-based string buffer currently sits on top
of strings but constructed in a way so that it was usable from Lua.

Mark

on 9/13/04 4:45 AM, Philippe Lhoste at PhiLho@GMX.net wrote:

> Mark Hamburg wrote:
> 
>> Are there any standard data buffer APIs (or implementations) for Lua? I'm
>> thinking about something much like strings but editable and not interned.
>> For example, if I'm reading a JPEG, turning the bytes into a string seems
>> like excessive work for the code to go through. Actually, there are a lot of
>> cases where this might be useful such as text file processing if the string
>> pattern match facilities were made to work on data buffers.
>> 
>> I can certainly implement something like this, but I'd favor a standard
>> API/implementation if one existed.
> 
> This looks like the string buffer I wished to have not so long ago...
> Of course, by "string", I mean data, ie. it can store whatever bytes you
> want to put there.
> 
> Such a string buffer should allow to read a range of bytes, apply all
> Lua string operations on a range, add data to the current end of the
> buffer (or at any position, overwriting or inserting), with definable
> behavior in case of overflow: either truncate written data, perhaps with
> a kind of exception rising, or growth the buffer to fit the additional
> data and more. Etc.
> 
> I really should work on it, unless somebody has done it (Tiago's
> lustring?) or write it before me...