stasis-aries-wal/lang/ruby/stasis/string_iterator.rb

31 lines
923 B
Ruby
Raw Normal View History

2010-09-20 16:09:44 +00:00
require 'stasis/raw'
module Stasis
class StringIterator
def StringIterator.value(xid, it)
objptrptr = FFI::MemoryPointer.new :pointer
len = Raw.Titerator_value(xid, it, objptrptr)
if(len == -1) then return nil end
objptr = objptrptr.get_pointer(0)
# The slice is for bounds checking.
str = objptr.null? ? nil : objptr.slice(0, len).get_string(0)
# The iterator frees objptr during tupleDone.
objptrptr.free
return str
end
def StringIterator.key(xid, it)
objptrptr = FFI::MemoryPointer.new :pointer
len = Raw.Titerator_key(xid, it, objptrptr)
if(len == -1) then return nil end
objptr = objptrptr.get_pointer(0)
# The slice is for bounds checking.
str = objptr.null? ? nil : objptr.slice(0, len).get_string(0)
# The iterator frees objptr during tupleDone.
objptrptr.free
return str
end
end
end