Class: FFI::Clang::StringSet
- Inherits:
-
Object
- Object
- FFI::Clang::StringSet
- Includes:
- Enumerable
- Defined in:
- lib/ffi/clang/string_set.rb
Overview
Represents a set of strings returned by libclang.
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
-
#each(&block) ⇒ Object
Iterate over each string.
-
#initialize(string_set) ⇒ StringSet
constructor
Initialize a string set from a CXStringSet pointer.
Constructor Details
#initialize(string_set) ⇒ StringSet
Initialize a string set from a CXStringSet pointer.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ffi/clang/string_set.rb', line 20 def initialize(string_set) @strings = [] @size = 0 return if string_set.nil? string_set = Lib::CXStringSet.new(string_set) if string_set.is_a?(FFI::Pointer) return if string_set.pointer.null? begin @size = string_set[:count] strings = string_set[:strings] return if strings.null? @size.times do |i| @strings << Lib.get_string(Lib::CXString.new(strings + (i * Lib::CXString.size))) end ensure Lib.dispose_string_set(string_set) end end |
Instance Attribute Details
#size ⇒ Object (readonly)
Returns the value of attribute size.
16 17 18 |
# File 'lib/ffi/clang/string_set.rb', line 16 def size @size end |
Instance Method Details
#each(&block) ⇒ Object
Iterate over each string.
46 47 48 49 50 51 52 |
# File 'lib/ffi/clang/string_set.rb', line 46 def each(&block) return to_enum(__method__) unless block_given? @strings.each(&block) self end |