class Babeltrace2::BTFieldPath
Constants
- Scope
Public Class Methods
new(handle, retain: true, auto_release: true)
click to toggle source
Calls superclass method
# File lib/babeltrace2/trace-ir/field-path.rb, line 40 def initialize(handle, retain: true, auto_release: true) super(handle, retain: retain, auto_release: auto_release) end
path_from_s_to_h(str)
click to toggle source
# File lib/babeltrace2/trace-ir/field-path.rb, line 89 def self.path_from_s_to_h(str) str_orig = str m = str.match(/\A(PACKET_CONTEXT|EVENT_COMMON_CONTEXT|EVENT_SPECIFIC_CONTEXT|EVENT_PAYLOAD)/) raise "invalid path #{str}" if !m path = [(m[1].downcase << "_field_class").to_sym] str = str.sub(m[1], "") while !str.empty? case str when /\A\[(\d+)\]/ path.push :members, $1.to_i, :field_class str = str.sub("[#{$1}]", "") when /\A->/ path.push :element_field_class str = str.sub("->", "") when /\A=>/ path.push :field_class str = str.sub("=>", "") else raise "invalid path #{str_orig}" end end path end
Public Instance Methods
each() { |get_item_by_index(i)| ... }
click to toggle source
# File lib/babeltrace2/trace-ir/field-path.rb, line 63 def each if block_given? get_item_count.times { |i| yield get_item_by_index(i) } else to_enum(:each) end end
get_item_by_index(index)
click to toggle source
# File lib/babeltrace2/trace-ir/field-path.rb, line 55 def get_item_by_index(index) index = get_item_count + index if index < 0 return nil if index >= get_item_count || index < 0 BTFieldPathItem.new( Babeltrace2.bt_field_path_borrow_item_by_index_const(@handle, index)) end
Also aliased as: []
get_item_count()
click to toggle source
# File lib/babeltrace2/trace-ir/field-path.rb, line 49 def get_item_count @item_count ||= Babeltrace2.bt_field_path_get_item_count(@handle) end
Also aliased as: item_count, size
get_root_scope()
click to toggle source
# File lib/babeltrace2/trace-ir/field-path.rb, line 44 def get_root_scope Babeltrace2.bt_field_path_get_root_scope(@handle) end
Also aliased as: root_scope
to_s()
click to toggle source
# File lib/babeltrace2/trace-ir/field-path.rb, line 73 def to_s path = "" path << root_scope.to_s.sub("BT_FIELD_PATH_SCOPE_","") each { |e| case e.type when :BT_FIELD_PATH_ITEM_TYPE_INDEX path << "[#{e.index}]" when :BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT path << "->" when :BT_FIELD_PATH_ITEM_TYPE_CURRENT_OPTION_CONTENT path << "=>" end } path end