Class: Babeltrace2::BTValue
- Inherits:
-
BTSharedObject
show all
- Defined in:
- lib/babeltrace2/value.rb,
lib/babeltrace2/value.rb,
lib/babeltrace2/value.rb,
lib/babeltrace2/value.rb,
lib/babeltrace2/value.rb,
lib/babeltrace2/value.rb
Defined Under Namespace
Classes: Array, Bool, Integer, Map, Null, Real, String
Constant Summary
collapse
- TYPE_MAP =
{}
- IntegerUnsigned =
BTValue::Integer::Unsigned
- IntegerSigned =
BTValue::Integer::Signed
- StringSetStatus =
BTValueStringSetStatus
- ArrayAppendElementStatus =
BTValueArrayAppendElementStatus
- ArraySetElementByIndexStatus =
BTValueArraySetElementByIndexStatus
- MapForeachEntryFuncStatus =
BTValueMapForeachEntryFuncStatus
- MapForeachEntryStatus =
BTValueMapForeachEntryStatus
- MapForeachEntryConstFuncStatus =
BTValueMapForeachEntryConstFuncStatus
- MapForeachEntryConstStatus =
BTValueMapForeachEntryConstStatus
- MapExtendStatus =
BTValueMapExtendStatus
Instance Attribute Summary
Attributes inherited from BTObject
#handle
Class Method Summary
collapse
Instance Method Summary
collapse
inherited, #initialize
Methods inherited from BTObject
#initialize, #to_ptr
Class Method Details
.from_handle(handle, retain: true, auto_release: true) ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/babeltrace2/value.rb', line 62
def self.from_handle(handle, retain: true, auto_release: true)
type = Babeltrace2.bt_value_get_type(handle)
if type == :BT_VALUE_TYPE_NULL
return BTValueNull.instance
else
clss = TYPE_MAP[type]
raise "unsupported value type" unless clss
handle = clss[0].new(handle)
clss[1].new(handle, retain: retain, auto_release: auto_release)
end
end
|
.from_value(value) ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/babeltrace2/value.rb', line 74
def self.from_value(value)
case value
when BTValue
value
when nil
return BTValueNull.instance
when false
Bool.new(value: false)
when true
Bool.new(value: true)
when ::Integer
if value > (1<<63) - 1
BTValueIntegerUnsigned.new(value: value)
else
BTValueIntegerSigned.new(value: value)
end
when ::Float
BTValueReal.new(value: value)
when ::String
BTValueString.new(value: value)
when ::Array
arr = BTValueArray.new
value.each { |v|
arr.push(v)
}
arr
when ::Hash
map = BTValueMap.new
value.each { |k, v|
map.insert_entry(k, v)
}
map
else
raise TypeError, "unsupported value type"
end
end
|
Instance Method Details
#get_type ⇒ Object
Also known as:
type
57
58
59
|
# File 'lib/babeltrace2/value.rb', line 57
def get_type
Babeltrace2.bt_value_get_type(@handle)
end
|
#is_equal(other) ⇒ Object
Also known as:
==
#to_s ⇒ Object
111
112
113
|
# File 'lib/babeltrace2/value.rb', line 111
def to_s
value.to_s
end
|