class GLib::Strv

Extra methods for GLib::Strv. The bulk is defined in `gir_ffi-base/glib/strv.rb`

Represents a null-terminated array of strings. GLib uses this construction, but does not provide any actual functions for this class.

Constants

POINTER_SIZE

Public Class Methods

from(it) click to toggle source
# File lib/ffi-glib/strv.rb, line 8
def self.from it
  case it
  when nil
    nil
  when FFI::Pointer
    wrap it
  when self
    it
  else
    from_enumerable it
  end
end
from_enumerable(enum) click to toggle source
# File lib/ffi-glib/strv.rb, line 21
def self.from_enumerable enum
  self.wrap GirFFI::InPointer.from_array :utf8, enum
end
new(ptr) click to toggle source
# File lib/gir_ffi-base/glib/strv.rb, line 11
def initialize ptr
  @ptr = ptr
end
wrap(ptr) click to toggle source
# File lib/gir_ffi-base/glib/strv.rb, line 26
def self.wrap ptr
  self.new ptr
end

Public Instance Methods

==(other) click to toggle source
# File lib/ffi-glib/strv.rb, line 4
def ==(other)
  self.to_a == other.to_a
end
each() { |read_string| ... } click to toggle source
# File lib/gir_ffi-base/glib/strv.rb, line 19
def each
  reset_iterator or return
  while (ptr = next_ptr)
    yield ptr.read_string
  end
end
to_ptr() click to toggle source
# File lib/gir_ffi-base/glib/strv.rb, line 15
def to_ptr
  @ptr
end

Private Instance Methods

next_ptr() click to toggle source
# File lib/gir_ffi-base/glib/strv.rb, line 37
def next_ptr
  ptr = @ptr.get_pointer @offset
  @offset += POINTER_SIZE
  ptr unless ptr.null?
end
reset_iterator() click to toggle source
# File lib/gir_ffi-base/glib/strv.rb, line 32
def reset_iterator
  return if @ptr.null?
  @offset = 0
end