mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-03 04:21:13 +00:00
[Lua] manipulate byte array as string (#6624)
* [Lua] manipulate byte array as string Sometimes it would be more effective than reading byte by byte * change according to the review * update
This commit is contained in:
@@ -76,6 +76,17 @@ function mt:Vector(off)
|
||||
return off + self:Get(N.UOffsetT, off) + 4
|
||||
end
|
||||
|
||||
function mt:VectorAsString(off, start, stop)
|
||||
local o = self:Offset(off)
|
||||
if o ~= 0 then
|
||||
start = start or 1
|
||||
stop = stop or self:VectorLen(o)
|
||||
local a = self:Vector(o) + start - 1
|
||||
return self.bytes:Slice(a, a + stop - start + 1)
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function mt:Union(t2, off)
|
||||
assert(getmetatable(t2) == mt_name)
|
||||
enforceOffset(off)
|
||||
|
||||
Reference in New Issue
Block a user