qpid_proton 0.18.1 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/ext/cproton/cproton.c +863 -75
  3. data/lib/codec/data.rb +589 -815
  4. data/lib/codec/mapping.rb +142 -126
  5. data/lib/core/condition.rb +89 -0
  6. data/lib/core/connection.rb +188 -228
  7. data/lib/core/connection_driver.rb +202 -0
  8. data/lib/core/container.rb +366 -0
  9. data/lib/core/delivery.rb +76 -251
  10. data/lib/core/disposition.rb +21 -35
  11. data/lib/core/endpoint.rb +21 -53
  12. data/lib/core/event.rb +156 -0
  13. data/lib/core/exceptions.rb +109 -106
  14. data/lib/core/link.rb +24 -49
  15. data/lib/core/listener.rb +82 -0
  16. data/lib/core/message.rb +59 -155
  17. data/lib/core/messaging_handler.rb +190 -0
  18. data/lib/core/receiver.rb +38 -7
  19. data/lib/core/sasl.rb +43 -46
  20. data/lib/core/sender.rb +55 -32
  21. data/lib/core/session.rb +58 -58
  22. data/lib/core/ssl.rb +5 -13
  23. data/lib/core/ssl_details.rb +1 -2
  24. data/lib/core/ssl_domain.rb +5 -8
  25. data/lib/core/terminus.rb +62 -30
  26. data/lib/core/tracker.rb +45 -0
  27. data/lib/core/transfer.rb +121 -0
  28. data/lib/core/transport.rb +62 -97
  29. data/lib/core/uri.rb +73 -0
  30. data/lib/core/url.rb +11 -7
  31. data/lib/handler/adapter.rb +78 -0
  32. data/lib/handler/messaging_adapter.rb +127 -0
  33. data/lib/handler/messaging_handler.rb +128 -178
  34. data/lib/handler/reactor_messaging_adapter.rb +158 -0
  35. data/lib/messenger/messenger.rb +9 -8
  36. data/lib/messenger/subscription.rb +1 -2
  37. data/lib/messenger/tracker.rb +1 -2
  38. data/lib/messenger/tracker_status.rb +1 -2
  39. data/lib/qpid_proton.rb +36 -66
  40. data/lib/reactor/container.rb +40 -234
  41. data/lib/types/array.rb +73 -130
  42. data/lib/types/described.rb +2 -44
  43. data/lib/types/hash.rb +19 -56
  44. data/lib/types/strings.rb +1 -2
  45. data/lib/types/type.rb +68 -0
  46. data/lib/util/{handler.rb → deprecation.rb} +22 -15
  47. data/lib/util/error_handler.rb +4 -25
  48. data/lib/util/timeout.rb +1 -2
  49. data/lib/util/version.rb +1 -2
  50. data/lib/util/wrapper.rb +58 -38
  51. metadata +16 -33
  52. data/lib/core/base_handler.rb +0 -31
  53. data/lib/core/selectable.rb +0 -130
  54. data/lib/event/collector.rb +0 -148
  55. data/lib/event/event.rb +0 -318
  56. data/lib/event/event_base.rb +0 -91
  57. data/lib/event/event_type.rb +0 -71
  58. data/lib/handler/acking.rb +0 -70
  59. data/lib/handler/c_adaptor.rb +0 -47
  60. data/lib/handler/c_flow_controller.rb +0 -33
  61. data/lib/handler/endpoint_state_handler.rb +0 -217
  62. data/lib/handler/incoming_message_handler.rb +0 -74
  63. data/lib/handler/outgoing_message_handler.rb +0 -100
  64. data/lib/handler/wrapped_handler.rb +0 -76
  65. data/lib/reactor/acceptor.rb +0 -41
  66. data/lib/reactor/backoff.rb +0 -41
  67. data/lib/reactor/connector.rb +0 -115
  68. data/lib/reactor/global_overrides.rb +0 -44
  69. data/lib/reactor/link_option.rb +0 -90
  70. data/lib/reactor/reactor.rb +0 -196
  71. data/lib/reactor/session_per_connection.rb +0 -45
  72. data/lib/reactor/ssl_config.rb +0 -41
  73. data/lib/reactor/task.rb +0 -39
  74. data/lib/reactor/urls.rb +0 -45
  75. data/lib/util/class_wrapper.rb +0 -54
  76. data/lib/util/condition.rb +0 -47
  77. data/lib/util/constants.rb +0 -85
  78. data/lib/util/engine.rb +0 -82
  79. data/lib/util/reactor.rb +0 -32
  80. data/lib/util/swig_helper.rb +0 -114
  81. data/lib/util/uuid.rb +0 -32
data/lib/codec/data.rb CHANGED
@@ -1,4 +1,3 @@
1
- #--
2
1
  # Licensed to the Apache Software Foundation (ASF) under one
3
2
  # or more contributor license agreements. See the NOTICE file
4
3
  # distributed with this work for additional information
@@ -15,894 +14,669 @@
15
14
  # KIND, either express or implied. See the License for the
16
15
  # specific language governing permissions and limitations
17
16
  # under the License.
18
- #++
19
-
20
- module Qpid::Proton::Codec
21
-
22
- # +DataError+ is raised when an error occurs while encoding
23
- # or decoding data.
24
- class DataError < Exception; end
25
-
26
- # The +Data+ class provides an interface for decoding, extracting,
27
- # creating, and encoding arbitrary AMQP data. A +Data+ object
28
- # contains a tree of AMQP values. Leaf nodes in this tree correspond
29
- # to scalars in the AMQP type system such as INT or STRING. Interior
30
- # nodes in this tree correspond to compound values in the AMQP type
31
- # system such as *LIST*,*MAP*, *ARRAY*, or *DESCRIBED*. The root node
32
- # of the tree is the +Data+ object itself and can have an arbitrary
33
- # number of children.
34
- #
35
- # A +Data+ object maintains the notion of the current sibling node
36
- # and a current parent node. Siblings are ordered within their parent.
37
- # Values are accessed and/or added by using the #next, #prev,
38
- # #enter, and #exit methods to navigate to the desired location in
39
- # the tree and using the supplied variety of mutator and accessor
40
- # methods to access or add a value of the desired type.
41
- #
42
- # The mutator methods will always add a value _after_ the current node
43
- # in the tree. If the current node has a next sibling the mutator method
44
- # will overwrite the value on this node. If there is no current node
45
- # or the current node has no next sibling then one will be added. The
46
- # accessor methods always set the added/modified node to the current
47
- # node. The accessor methods read the value of the current node and do
48
- # not change which node is current.
49
- #
50
- # The following types of scalar values are supported:
51
- #
52
- # * NULL
53
- # * BOOL
54
- # * UBYTE
55
- # * BYTE
56
- # * USHORT
57
- # * SHORT
58
- # * UINT
59
- # * INT
60
- # * CHAR
61
- # * ULONG
62
- # * LONG
63
- # * TIMESTAMP
64
- # * FLOAT
65
- # * DOUBLE
66
- # * DECIMAL32
67
- # * DECIMAL64
68
- # * DECIMAL128
69
- # * UUID
70
- # * BINARY
71
- # * STRING
72
- # * SYMBOL
73
- #
74
- # The following types of compound values are supported:
75
- #
76
- # * DESCRIBED
77
- # * ARRAY
78
- # * LIST
79
- # * MAP
80
- #
81
- class Data
82
-
83
- # Creates a new instance with the specified capacity.
84
- #
85
- # @param capacity [Integer, Object] The initial capacity or content.
86
- #
87
- def initialize(capacity = 16)
88
- # TODO aconway 2017-08-11: error prone, confusion between capacity and Integer content.
89
- if capacity.is_a?(Integer)
90
- @data = Cproton.pn_data(capacity.to_i)
91
- @free = true
92
- else
93
- @data = capacity
94
- @free = false
95
- end
96
-
97
- # destructor
98
- ObjectSpace.define_finalizer(self, self.class.finalize!(@data, @free))
99
- end
100
17
 
101
- # @private
102
- def self.finalize!(data, free)
103
- proc {
104
- Cproton.pn_data_free(data) if free
105
- }
106
- end
18
+ module Qpid::Proton
19
+ # @private
20
+ module Codec
21
+
22
+ DataError = ::TypeError
23
+
24
+ # @private wrapper for pn_data_t*
25
+ # Raises TypeError for invalid conversions
26
+ class Data
27
+
28
+ # @private
29
+ PROTON_METHOD_PREFIX = "pn_data"
30
+ # @private
31
+ include Util::Wrapper
32
+
33
+ # @private
34
+ # Convert a pn_data_t* containing a single value to a ruby object.
35
+ # @return [Object, nil] The ruby value extracted from +impl+ or nil if impl is empty
36
+ def self.to_object(impl)
37
+ if (Cproton.pn_data_size(impl) > 0)
38
+ d = Data.new(impl)
39
+ d.rewind
40
+ d.next_object
41
+ end
42
+ end
107
43
 
108
- # @private
109
- def to_s
110
- tmp = Cproton.pn_string("")
111
- Cproton.pn_inspect(@data, tmp)
112
- result = Cproton.pn_string_get(tmp)
113
- Cproton.pn_free(tmp)
114
- return result
115
- end
44
+ # @private
45
+ # Clear a pn_data_t* and convert a ruby object into it. If x==nil leave it empty.
46
+ def self.from_object(impl, x)
47
+ d = Data.new(impl)
48
+ d.clear
49
+ d.object = x if x
50
+ nil
51
+ end
116
52
 
117
- # Clears the object.
118
- #
119
- def clear
120
- Cproton.pn_data_clear(@data)
121
- end
53
+ # @overload initialize(capacity)
54
+ # @param capacity [Integer] capacity for the new data instance.
55
+ # @overload instance(impl)
56
+ # @param impl [SWIG::pn_data_t*] wrap the C impl pointer.
57
+ def initialize(capacity = 16)
58
+ if capacity.is_a?(Integer)
59
+ @impl = Cproton.pn_data(capacity.to_i)
60
+ @free = true
61
+ else
62
+ # Assume non-integer capacity is a SWIG::pn_data_t*
63
+ @impl = capacity
64
+ @free = false
65
+ end
122
66
 
123
- # Clears the current node and sets the parent to the root node.
124
- #
125
- # Clearing the current node sets it *before* the first node, calling
126
- # #next will advance to the first node.
127
- #
128
- def rewind
129
- Cproton.pn_data_rewind(@data)
130
- end
67
+ # destructor
68
+ ObjectSpace.define_finalizer(self, self.class.finalize!(@impl, @free))
69
+ end
131
70
 
132
- # Advances the current node to its next sibling and returns its types.
133
- #
134
- # If there is no next sibling the current node remains unchanged
135
- # and nil is returned.
136
- #
137
- def next
138
- Cproton.pn_data_next(@data)
139
- end
71
+ # @private
72
+ def self.finalize!(impl, free)
73
+ proc {
74
+ Cproton.pn_data_free(impl) if free
75
+ }
76
+ end
140
77
 
141
- # Advances the current node to its previous sibling and returns its type.
142
- #
143
- # If there is no previous sibling then the current node remains unchanged
144
- # and nil is return.
145
- #
146
- def prev
147
- return Cproton.pn_data_prev(@data) ? type : nil
148
- end
78
+ proton_caller :clear, :rewind, :next, :prev, :enter, :exit
149
79
 
150
- # Sets the parent node to the current node and clears the current node.
151
- #
152
- # Clearing the current node sets it _before_ the first child.
153
- #
154
- def enter
155
- Cproton.pn_data_enter(@data)
156
- end
80
+ def enter_exit()
81
+ enter
82
+ yield self
83
+ ensure
84
+ exit
85
+ end
157
86
 
158
- # Sets the current node to the parent node and the parent node to its own
159
- # parent.
160
- #
161
- def exit
162
- Cproton.pn_data_exit(@data)
163
- end
87
+ def code() Cproton.pn_data_type(@impl); end
88
+
89
+ def type() Mapping.for_code(Cproton.pn_data_type(@impl)); end
90
+
91
+ # Returns a representation of the data encoded in AMQP format.
92
+ def encode
93
+ buffer = "\0"*1024
94
+ loop do
95
+ cd = Cproton.pn_data_encode(@impl, buffer, buffer.length)
96
+ if cd == Cproton::PN_OVERFLOW
97
+ buffer *= 2
98
+ elsif cd >= 0
99
+ return buffer[0...cd]
100
+ else
101
+ check(cd)
102
+ end
103
+ end
104
+ end
164
105
 
165
- # Returns the numeric type code of the current node.
166
- #
167
- # @return [Integer] The current node type.
168
- # @return [nil] If there is no current node.
169
- #
170
- def type_code
171
- dtype = Cproton.pn_data_type(@data)
172
- return (dtype == -1) ? nil : dtype
173
- end
106
+ # Decodes the first value from supplied AMQP data and returns the number
107
+ # of bytes consumed.
108
+ #
109
+ # @param encoded [String] The encoded data.
110
+ def decode(encoded)
111
+ check(Cproton.pn_data_decode(@impl, encoded, encoded.length))
112
+ end
174
113
 
175
- # @return [Integer] The type object for the current node.
176
- # @see #type_code
177
- #
178
- def type
179
- Mapping.for_code(type_code)
180
- end
114
+ proton_is :described, :array_described
115
+ proton_caller :put_described
116
+ proton_caller :put_list, :get_list, :put_map, :get_map
117
+ proton_get :array_type
118
+ proton_caller :put_array
119
+ def get_array() [Cproton.pn_data_get_array(@impl), array_described?, array_type]; end
181
120
 
182
- # Returns a representation of the data encoded in AMQP format.
183
- #
184
- # @return [String] The context of the Data as an AMQP data string.
185
- #
186
- # @example
187
- #
188
- # @data.string = "This is a test."
189
- # @encoded = @data.encode
190
- #
191
- # # @encoded now contains the text "This is a test." encoded for
192
- # # AMQP transport.
193
- #
194
- def encode
195
- buffer = "\0"*1024
196
- loop do
197
- cd = Cproton.pn_data_encode(@data, buffer, buffer.length)
198
- if cd == Cproton::PN_OVERFLOW
199
- buffer *= 2
200
- elsif cd >= 0
201
- return buffer[0...cd]
202
- else
203
- check(cd)
121
+ def expect(code)
122
+ unless code == self.code
123
+ raise TypeError, "expected #{Cproton.pn_type_name(code)}, got #{Cproton.pn_type_name(self.code)}"
204
124
  end
205
125
  end
206
- end
207
-
208
- # Decodes the first value from supplied AMQP data and returns the number
209
- # of bytes consumed.
210
- #
211
- # @param encoded [String] The encoded data.
212
- #
213
- # @example
214
- #
215
- # # SCENARIO: A string of encoded data, @encoded, contains the text
216
- # # of "This is a test." and is passed to an instance of Data
217
- # # for decoding.
218
- #
219
- # @data.decode(@encoded)
220
- # @data.string #=> "This is a test."
221
- #
222
- def decode(encoded)
223
- check(Cproton.pn_data_decode(@data, encoded, encoded.length))
224
- end
225
-
226
- # Puts a list value.
227
- #
228
- # Elements may be filled by entering the list node and putting element
229
- # values.
230
- #
231
- # @example
232
- #
233
- # data = Qpid::Proton::Codec::Data.new
234
- # data.put_list
235
- # data.enter
236
- # data.int = 1
237
- # data.int = 2
238
- # data.int = 3
239
- # data.exit
240
- #
241
- def put_list
242
- check(Cproton.pn_data_put_list(@data))
243
- end
244
126
 
245
- # If the current node is a list, this returns the number of elements.
246
- # Otherwise, it returns zero.
247
- #
248
- # List elements can be accessed by entering the list.
249
- #
250
- # @example
251
- #
252
- # count = @data.list
253
- # @data.enter
254
- # (0...count).each
255
- # type = @data.next
256
- # puts "Value: #{@data.string}" if type == STRING
257
- # # ... process other node types
258
- # end
259
- def list
260
- Cproton.pn_data_get_list(@data)
261
- end
127
+ def described
128
+ expect Cproton::PN_DESCRIBED
129
+ enter_exit { Types::Described.new(self.next_object, self.next_object) }
130
+ end
262
131
 
263
- # Puts a map value.
264
- #
265
- # Elements may be filled by entering the map node and putting alternating
266
- # key/value pairs.
267
- #
268
- # @example
269
- #
270
- # data = Qpid::Proton::Codec::Data.new
271
- # data.put_map
272
- # data.enter
273
- # data.string = "key"
274
- # data.string = "value"
275
- # data.exit
276
- #
277
- def put_map
278
- check(Cproton.pn_data_put_map(@data))
279
- end
132
+ def described= d
133
+ put_described
134
+ enter_exit { self << d.descriptor << d.value }
135
+ end
280
136
 
281
- # If the current node is a map, this returns the number of child
282
- # elements. Otherwise, it returns zero.
283
- #
284
- # Key/value pairs can be accessed by entering the map.
285
- #
286
- # @example
287
- #
288
- # count = @data.map
289
- # @data.enter
290
- # (0...count).each do
291
- # type = @data.next
292
- # puts "Key=#{@data.string}" if type == STRING
293
- # # ... process other key types
294
- # type = @data.next
295
- # puts "Value=#{@data.string}" if type == STRING
296
- # # ... process other value types
297
- # end
298
- # @data.exit
299
- def map
300
- Cproton.pn_data_get_map(@data)
301
- end
137
+ def fill(a, count, what)
138
+ a << self.object while self.next
139
+ raise TypeError, "#{what} expected #{count} elements, got #{a.size}" unless a.size == count
140
+ a
141
+ end
302
142
 
303
- # @private
304
- def get_map
305
- ::Hash.proton_data_get(self)
306
- end
143
+ def list
144
+ return array if code == Cproton::PN_ARRAY
145
+ expect Cproton::PN_LIST
146
+ count = get_list
147
+ a = []
148
+ enter_exit { fill(a, count, __method__) }
149
+ end
307
150
 
308
- # Puts an array value.
309
- #
310
- # Elements may be filled by entering the array node and putting the
311
- # element values. The values must all be of the specified array element
312
- # type.
313
- #
314
- # If an array is *described* then the first child value of the array
315
- # is the descriptor and may be of any type.
316
- #
317
- # @param described [Boolean] True if the array is described.
318
- # @param element_type [Integer] The AMQP type for each element of the array.
319
- #
320
- # @example
321
- #
322
- # # create an array of integer values
323
- # data = Qpid::Proton::Codec::Data.new
324
- # data.put_array(false, INT)
325
- # data.enter
326
- # data.int = 1
327
- # data.int = 2
328
- # data.int = 3
329
- # data.exit
330
- #
331
- # # create a described array of double values
332
- # data.put_array(true, DOUBLE)
333
- # data.enter
334
- # data.symbol = "array-descriptor"
335
- # data.double = 1.1
336
- # data.double = 1.2
337
- # data.double = 1.3
338
- # data.exit
339
- #
340
- def put_array(described, element_type)
341
- check(Cproton.pn_data_put_array(@data, described, element_type.code))
342
- end
151
+ def list=(a)
152
+ put_list
153
+ enter_exit { a.each { |x| self << x } }
154
+ end
343
155
 
344
- # If the current node is an array, returns a tuple of the element count, a
345
- # boolean indicating whether the array is described, and the type of each
346
- # element. Otherwise it returns +(0, false, nil).
347
- #
348
- # Array data can be accessed by entering the array.
349
- #
350
- # @example
351
- #
352
- # # get the details of thecurrent array
353
- # count, described, array_type = @data.array
354
- #
355
- # # enter the node
356
- # data.enter
357
- #
358
- # # get the next node
359
- # data.next
360
- # puts "Descriptor: #{data.symbol}" if described
361
- # (0...count).each do
362
- # @data.next
363
- # puts "Element: #{@data.string}"
364
- # end
365
- def array
366
- count = Cproton.pn_data_get_array(@data)
367
- described = Cproton.pn_data_is_array_described(@data)
368
- array_type = Cproton.pn_data_get_array_type(@data)
369
- return nil if array_type == -1
370
- [count, described, Mapping.for_code(array_type) ]
371
- end
156
+ def array
157
+ return list if code == Cproton::PN_LIST
158
+ expect Cproton::PN_ARRAY
159
+ count, d, t = get_array
160
+ enter_exit do
161
+ desc = next_object if d
162
+ a = Types::UniformArray.new(t, nil, desc)
163
+ fill(a, count, "array")
164
+ end
165
+ end
372
166
 
373
- # @private
374
- def get_array
375
- ::Array.proton_get(self)
376
- end
167
+ def array=(a)
168
+ t = a.type if a.respond_to? :type
169
+ d = a.descriptor if a.respond_to? :descriptor
170
+ if (h = a.instance_variable_get(:@proton_array_header))
171
+ t ||= h.type
172
+ d ||= h.descriptor
173
+ end
174
+ raise TypeError, "no type when converting #{a.class} to an array" unless t
175
+ put_array(!d.nil?, t.code)
176
+ m = Mapping[t]
177
+ enter_exit do
178
+ self << d unless d.nil?
179
+ a.each { |e| m.put(self, e); }
180
+ end
181
+ end
377
182
 
378
- # Puts a described value.
379
- #
380
- # A described node has two children, the descriptor and the value.
381
- # These are specified by entering the node and putting the
382
- # desired values.
383
- #
384
- # @example
385
- #
386
- # data = Qpid::Proton::Codec::Data.new
387
- # data.put_described
388
- # data.enter
389
- # data.symbol = "value-descriptor"
390
- # data.string = "the value"
391
- # data.exit
392
- #
393
- def put_described
394
- check(Cproton.pn_data_put_described(@data))
395
- end
183
+ def map
184
+ expect Cproton::PN_MAP
185
+ count = self.get_map
186
+ raise TypeError, "invalid map, total of keys and values is odd" if count.odd?
187
+ enter_exit do
188
+ m = {}
189
+ m[object] = next_object while self.next
190
+ raise TypeError, "map expected #{count/2} entries, got #{m.size}" unless m.size == count/2
191
+ m
192
+ end
193
+ end
396
194
 
397
- # @private
398
- def get_described
399
- raise TypeError, "not a described type" unless self.described?
400
- self.enter
401
- self.next
402
- type = self.type
403
- descriptor = type.get(self)
404
- self.next
405
- type = self.type
406
- value = type.get(self)
407
- self.exit
408
- Qpid::Proton::Types::Described.new(descriptor, value)
409
- end
195
+ def map= m
196
+ put_map
197
+ enter_exit { m.each_pair { |k,v| self << k << v } }
198
+ end
410
199
 
411
- # Checks if the current node is a described value.
412
- #
413
- # The described and value may be accessed by entering the described value.
414
- #
415
- # @example
416
- #
417
- # if @data.described?
418
- # @data.enter
419
- # puts "The symbol is #{@data.symbol}"
420
- # puts "The value is #{@data.string}"
421
- # end
422
- def described?
423
- Cproton.pn_data_is_described(@data)
424
- end
200
+ # Return nil if vallue is null, raise exception otherwise.
201
+ def null() raise TypeError, "expected null, got #{type || 'empty'}" unless null?; end
202
+
203
+ # Set the current value to null
204
+ def null=(dummy=nil) check(Cproton.pn_data_put_null(@impl)); end
205
+
206
+ # Puts an arbitrary object type.
207
+ #
208
+ # The Data instance will determine which AMQP type is appropriate and will
209
+ # use that to encode the object.
210
+ #
211
+ # @param object [Object] The value.
212
+ #
213
+ def object=(object)
214
+ Mapping.for_class(object.class).put(self, object)
215
+ object
216
+ end
425
217
 
426
- # Puts a null value.
427
- #
428
- def null
429
- check(Cproton.pn_data_put_null(@data))
430
- end
218
+ # Add an arbitrary data value using object=, return self
219
+ def <<(x) self.object=x; self; end
431
220
 
432
- # Utility method for Qpid::Proton::Codec::Mapping
433
- #
434
- # @private
435
- #
436
- def null=(value)
437
- null
438
- end
221
+ # Move forward to the next value and return it
222
+ def next_object
223
+ self.next or raise TypeError, "not enough data"
224
+ self.object
225
+ end
439
226
 
440
- # Puts an arbitrary object type.
441
- #
442
- # The Data instance will determine which AMQP type is appropriate and will
443
- # use that to encode the object.
444
- #
445
- # @param object [Object] The value.
446
- #
447
- def object=(object)
448
- Mapping.for_class(object.class).put(self, object)
449
- end
227
+ # Gets the current node, based on how it was encoded.
228
+ #
229
+ # @return [Object] The current node.
230
+ #
231
+ def object
232
+ self.type.get(self) if self.type
233
+ end
450
234
 
451
- # Gets the current node, based on how it was encoded.
452
- #
453
- # @return [Object] The current node.
454
- #
455
- def object
456
- type = self.type
457
- return nil if type.nil?
458
- type.get(data)
459
- end
235
+ # Checks if the current node is null.
236
+ #
237
+ # @return [Boolean] True if the node is null.
238
+ #
239
+ def null?
240
+ Cproton.pn_data_is_null(@impl)
241
+ end
460
242
 
461
- # Checks if the current node is null.
462
- #
463
- # @return [Boolean] True if the node is null.
464
- #
465
- def null?
466
- Cproton.pn_data_is_null(@data)
467
- end
243
+ # Puts a boolean value.
244
+ #
245
+ # @param value [Boolean] The boolean value.
246
+ #
247
+ def bool=(value)
248
+ check(Cproton.pn_data_put_bool(@impl, value))
249
+ end
468
250
 
469
- # Puts a boolean value.
470
- #
471
- # @param value [Boolean] The boolean value.
472
- #
473
- def bool=(value)
474
- check(Cproton.pn_data_put_bool(@data, value))
475
- end
251
+ # If the current node is a boolean, then it returns the value. Otherwise,
252
+ # it returns false.
253
+ #
254
+ # @return [Boolean] The boolean value.
255
+ #
256
+ def bool
257
+ Cproton.pn_data_get_bool(@impl)
258
+ end
476
259
 
477
- # If the current node is a boolean, then it returns the value. Otherwise,
478
- # it returns false.
479
- #
480
- # @return [Boolean] The boolean value.
481
- #
482
- def bool
483
- Cproton.pn_data_get_bool(@data)
484
- end
260
+ # Puts an unsigned byte value.
261
+ #
262
+ # @param value [Integer] The unsigned byte value.
263
+ #
264
+ def ubyte=(value)
265
+ check(Cproton.pn_data_put_ubyte(@impl, value))
266
+ end
485
267
 
486
- # Puts an unsigned byte value.
487
- #
488
- # @param value [Integer] The unsigned byte value.
489
- #
490
- def ubyte=(value)
491
- check(Cproton.pn_data_put_ubyte(@data, value))
492
- end
268
+ # If the current node is an unsigned byte, returns its value. Otherwise,
269
+ # it returns 0.
270
+ #
271
+ # @return [Integer] The unsigned byte value.
272
+ #
273
+ def ubyte
274
+ Cproton.pn_data_get_ubyte(@impl)
275
+ end
493
276
 
494
- # If the current node is an unsigned byte, returns its value. Otherwise,
495
- # it returns 0.
496
- #
497
- # @return [Integer] The unsigned byte value.
498
- #
499
- def ubyte
500
- Cproton.pn_data_get_ubyte(@data)
501
- end
277
+ # Puts a byte value.
278
+ #
279
+ # @param value [Integer] The byte value.
280
+ #
281
+ def byte=(value)
282
+ check(Cproton.pn_data_put_byte(@impl, value))
283
+ end
502
284
 
503
- # Puts a byte value.
504
- #
505
- # @param value [Integer] The byte value.
506
- #
507
- def byte=(value)
508
- check(Cproton.pn_data_put_byte(@data, value))
509
- end
285
+ # If the current node is an byte, returns its value. Otherwise,
286
+ # it returns 0.
287
+ #
288
+ # @return [Integer] The byte value.
289
+ #
290
+ def byte
291
+ Cproton.pn_data_get_byte(@impl)
292
+ end
510
293
 
511
- # If the current node is an byte, returns its value. Otherwise,
512
- # it returns 0.
513
- #
514
- # @return [Integer] The byte value.
515
- #
516
- def byte
517
- Cproton.pn_data_get_byte(@data)
518
- end
294
+ # Puts an unsigned short value.
295
+ #
296
+ # @param value [Integer] The unsigned short value
297
+ #
298
+ def ushort=(value)
299
+ check(Cproton.pn_data_put_ushort(@impl, value))
300
+ end
519
301
 
520
- # Puts an unsigned short value.
521
- #
522
- # @param value [Integer] The unsigned short value
523
- #
524
- def ushort=(value)
525
- check(Cproton.pn_data_put_ushort(@data, value))
526
- end
302
+ # If the current node is an unsigned short, returns its value. Otherwise,
303
+ # it returns 0.
304
+ #
305
+ # @return [Integer] The unsigned short value.
306
+ #
307
+ def ushort
308
+ Cproton.pn_data_get_ushort(@impl)
309
+ end
527
310
 
528
- # If the current node is an unsigned short, returns its value. Otherwise,
529
- # it returns 0.
530
- #
531
- # @return [Integer] The unsigned short value.
532
- #
533
- def ushort
534
- Cproton.pn_data_get_ushort(@data)
535
- end
311
+ # Puts a short value.
312
+ #
313
+ # @param value [Integer] The short value.
314
+ #
315
+ def short=(value)
316
+ check(Cproton.pn_data_put_short(@impl, value))
317
+ end
536
318
 
537
- # Puts a short value.
538
- #
539
- # @param value [Integer] The short value.
540
- #
541
- def short=(value)
542
- check(Cproton.pn_data_put_short(@data, value))
543
- end
319
+ # If the current node is a short, returns its value. Otherwise,
320
+ # returns a 0.
321
+ #
322
+ # @return [Integer] The short value.
323
+ #
324
+ def short
325
+ Cproton.pn_data_get_short(@impl)
326
+ end
544
327
 
545
- # If the current node is a short, returns its value. Otherwise,
546
- # returns a 0.
547
- #
548
- # @return [Integer] The short value.
549
- #
550
- def short
551
- Cproton.pn_data_get_short(@data)
552
- end
328
+ # Puts an unsigned integer value.
329
+ #
330
+ # @param value [Integer] the unsigned integer value
331
+ #
332
+ def uint=(value)
333
+ raise TypeError if value.nil?
334
+ raise RangeError, "invalid uint: #{value}" if value < 0
335
+ check(Cproton.pn_data_put_uint(@impl, value))
336
+ end
553
337
 
554
- # Puts an unsigned integer value.
555
- #
556
- # @param value [Integer] the unsigned integer value
557
- #
558
- def uint=(value)
559
- raise TypeError if value.nil?
560
- raise RangeError, "invalid uint: #{value}" if value < 0
561
- check(Cproton.pn_data_put_uint(@data, value))
562
- end
338
+ # If the current node is an unsigned int, returns its value. Otherwise,
339
+ # returns 0.
340
+ #
341
+ # @return [Integer] The unsigned integer value.
342
+ #
343
+ def uint
344
+ Cproton.pn_data_get_uint(@impl)
345
+ end
563
346
 
564
- # If the current node is an unsigned int, returns its value. Otherwise,
565
- # returns 0.
566
- #
567
- # @return [Integer] The unsigned integer value.
568
- #
569
- def uint
570
- Cproton.pn_data_get_uint(@data)
571
- end
347
+ # Puts an integer value.
348
+ #
349
+ # ==== Options
350
+ #
351
+ # * value - the integer value
352
+ def int=(value)
353
+ check(Cproton.pn_data_put_int(@impl, value))
354
+ end
572
355
 
573
- # Puts an integer value.
574
- #
575
- # ==== Options
576
- #
577
- # * value - the integer value
578
- def int=(value)
579
- check(Cproton.pn_data_put_int(@data, value))
580
- end
356
+ # If the current node is an integer, returns its value. Otherwise,
357
+ # returns 0.
358
+ #
359
+ # @return [Integer] The integer value.
360
+ #
361
+ def int
362
+ Cproton.pn_data_get_int(@impl)
363
+ end
581
364
 
582
- # If the current node is an integer, returns its value. Otherwise,
583
- # returns 0.
584
- #
585
- # @return [Integer] The integer value.
586
- #
587
- def int
588
- Cproton.pn_data_get_int(@data)
589
- end
365
+ # Puts a character value.
366
+ #
367
+ # @param value [Integer] The character value.
368
+ #
369
+ def char=(value)
370
+ check(Cproton.pn_data_put_char(@impl, value))
371
+ end
590
372
 
591
- # Puts a character value.
592
- #
593
- # @param value [Integer] The character value.
594
- #
595
- def char=(value)
596
- check(Cproton.pn_data_put_char(@data, value))
597
- end
373
+ # If the current node is a character, returns its value. Otherwise,
374
+ # returns 0.
375
+ #
376
+ # @return [Integer] The character value.
377
+ #
378
+ def char
379
+ Cproton.pn_data_get_char(@impl)
380
+ end
598
381
 
599
- # If the current node is a character, returns its value. Otherwise,
600
- # returns 0.
601
- #
602
- # @return [Integer] The character value.
603
- #
604
- def char
605
- Cproton.pn_data_get_char(@data)
606
- end
382
+ # Puts an unsigned long value.
383
+ #
384
+ # @param value [Integer] The unsigned long value.
385
+ #
386
+ def ulong=(value)
387
+ raise TypeError if value.nil?
388
+ raise RangeError, "invalid ulong: #{value}" if value < 0
389
+ check(Cproton.pn_data_put_ulong(@impl, value))
390
+ end
607
391
 
608
- # Puts an unsigned long value.
609
- #
610
- # @param value [Integer] The unsigned long value.
611
- #
612
- def ulong=(value)
613
- raise TypeError if value.nil?
614
- raise RangeError, "invalid ulong: #{value}" if value < 0
615
- check(Cproton.pn_data_put_ulong(@data, value))
616
- end
392
+ # If the current node is an unsigned long, returns its value. Otherwise,
393
+ # returns 0.
394
+ #
395
+ # @return [Integer] The unsigned long value.
396
+ #
397
+ def ulong
398
+ Cproton.pn_data_get_ulong(@impl)
399
+ end
617
400
 
618
- # If the current node is an unsigned long, returns its value. Otherwise,
619
- # returns 0.
620
- #
621
- # @return [Integer] The unsigned long value.
622
- #
623
- def ulong
624
- Cproton.pn_data_get_ulong(@data)
625
- end
401
+ # Puts a long value.
402
+ #
403
+ # @param value [Integer] The long value.
404
+ #
405
+ def long=(value)
406
+ check(Cproton.pn_data_put_long(@impl, value))
407
+ end
626
408
 
627
- # Puts a long value.
628
- #
629
- # @param value [Integer] The long value.
630
- #
631
- def long=(value)
632
- check(Cproton.pn_data_put_long(@data, value))
633
- end
409
+ # If the current node is a long, returns its value. Otherwise, returns 0.
410
+ #
411
+ # @return [Integer] The long value.
412
+ def long
413
+ Cproton.pn_data_get_long(@impl)
414
+ end
634
415
 
635
- # If the current node is a long, returns its value. Otherwise, returns 0.
636
- #
637
- # @return [Integer] The long value.
638
- def long
639
- Cproton.pn_data_get_long(@data)
640
- end
416
+ # Puts a timestamp value.
417
+ #
418
+ # @param value [Integer] The timestamp value.
419
+ #
420
+ def timestamp=(value)
421
+ value = value.to_i if (!value.nil? && value.is_a?(Time))
422
+ check(Cproton.pn_data_put_timestamp(@impl, value))
423
+ end
641
424
 
642
- # Puts a timestamp value.
643
- #
644
- # @param value [Integer] The timestamp value.
645
- #
646
- def timestamp=(value)
647
- value = value.to_i if (!value.nil? && value.is_a?(Time))
648
- check(Cproton.pn_data_put_timestamp(@data, value))
649
- end
425
+ # If the current node is a timestamp, returns its value. Otherwise,
426
+ # returns 0.
427
+ #
428
+ # @return [Integer] The timestamp value.
429
+ #
430
+ def timestamp
431
+ Cproton.pn_data_get_timestamp(@impl)
432
+ end
650
433
 
651
- # If the current node is a timestamp, returns its value. Otherwise,
652
- # returns 0.
653
- #
654
- # @return [Integer] The timestamp value.
655
- #
656
- def timestamp
657
- Cproton.pn_data_get_timestamp(@data)
658
- end
434
+ # Puts a float value.
435
+ #
436
+ # @param value [Float] The floating point value.
437
+ #
438
+ def float=(value)
439
+ check(Cproton.pn_data_put_float(@impl, value))
440
+ end
659
441
 
660
- # Puts a float value.
661
- #
662
- # @param value [Float] The floating point value.
663
- #
664
- def float=(value)
665
- check(Cproton.pn_data_put_float(@data, value))
666
- end
442
+ # If the current node is a float, returns its value. Otherwise,
443
+ # returns 0.
444
+ #
445
+ # @return [Float] The floating point value.
446
+ #
447
+ def float
448
+ Cproton.pn_data_get_float(@impl)
449
+ end
667
450
 
668
- # If the current node is a float, returns its value. Otherwise,
669
- # returns 0.
670
- #
671
- # @return [Float] The floating point value.
672
- #
673
- def float
674
- Cproton.pn_data_get_float(@data)
675
- end
451
+ # Puts a double value.
452
+ #
453
+ # @param value [Float] The double precision floating point value.
454
+ #
455
+ def double=(value)
456
+ check(Cproton.pn_data_put_double(@impl, value))
457
+ end
676
458
 
677
- # Puts a double value.
678
- #
679
- # @param value [Float] The double precision floating point value.
680
- #
681
- def double=(value)
682
- check(Cproton.pn_data_put_double(@data, value))
683
- end
459
+ # If the current node is a double, returns its value. Otherwise,
460
+ # returns 0.
461
+ #
462
+ # @return [Float] The double precision floating point value.
463
+ #
464
+ def double
465
+ Cproton.pn_data_get_double(@impl)
466
+ end
684
467
 
685
- # If the current node is a double, returns its value. Otherwise,
686
- # returns 0.
687
- #
688
- # @return [Float] The double precision floating point value.
689
- #
690
- def double
691
- Cproton.pn_data_get_double(@data)
692
- end
468
+ # Puts a decimal32 value.
469
+ #
470
+ # @param value [Integer] The decimal32 value.
471
+ #
472
+ def decimal32=(value)
473
+ check(Cproton.pn_data_put_decimal32(@impl, value))
474
+ end
693
475
 
694
- # Puts a decimal32 value.
695
- #
696
- # @param value [Integer] The decimal32 value.
697
- #
698
- def decimal32=(value)
699
- check(Cproton.pn_data_put_decimal32(@data, value))
700
- end
476
+ # If the current node is a decimal32, returns its value. Otherwise,
477
+ # returns 0.
478
+ #
479
+ # @return [Integer] The decimal32 value.
480
+ #
481
+ def decimal32
482
+ Cproton.pn_data_get_decimal32(@impl)
483
+ end
701
484
 
702
- # If the current node is a decimal32, returns its value. Otherwise,
703
- # returns 0.
704
- #
705
- # @return [Integer] The decimal32 value.
706
- #
707
- def decimal32
708
- Cproton.pn_data_get_decimal32(@data)
709
- end
485
+ # Puts a decimal64 value.
486
+ #
487
+ # @param value [Integer] The decimal64 value.
488
+ #
489
+ def decimal64=(value)
490
+ check(Cproton.pn_data_put_decimal64(@impl, value))
491
+ end
710
492
 
711
- # Puts a decimal64 value.
712
- #
713
- # @param value [Integer] The decimal64 value.
714
- #
715
- def decimal64=(value)
716
- check(Cproton.pn_data_put_decimal64(@data, value))
717
- end
493
+ # If the current node is a decimal64, returns its value. Otherwise,
494
+ # it returns 0.
495
+ #
496
+ # @return [Integer] The decimal64 value.
497
+ #
498
+ def decimal64
499
+ Cproton.pn_data_get_decimal64(@impl)
500
+ end
718
501
 
719
- # If the current node is a decimal64, returns its value. Otherwise,
720
- # it returns 0.
721
- #
722
- # @return [Integer] The decimal64 value.
723
- #
724
- def decimal64
725
- Cproton.pn_data_get_decimal64(@data)
726
- end
502
+ # Puts a decimal128 value.
503
+ #
504
+ # @param value [Integer] The decimal128 value.
505
+ #
506
+ def decimal128=(value)
507
+ raise TypeError, "invalid decimal128 value: #{value}" if value.nil?
508
+ value = value.to_s(16).rjust(32, "0")
509
+ bytes = []
510
+ value.scan(/(..)/) {|v| bytes << v[0].to_i(16)}
511
+ check(Cproton.pn_data_put_decimal128(@impl, bytes))
512
+ end
727
513
 
728
- # Puts a decimal128 value.
729
- #
730
- # @param value [Integer] The decimal128 value.
731
- #
732
- def decimal128=(value)
733
- raise TypeError, "invalid decimal128 value: #{value}" if value.nil?
734
- value = value.to_s(16).rjust(32, "0")
735
- bytes = []
736
- value.scan(/(..)/) {|v| bytes << v[0].to_i(16)}
737
- check(Cproton.pn_data_put_decimal128(@data, bytes))
738
- end
514
+ # If the current node is a decimal128, returns its value. Otherwise,
515
+ # returns 0.
516
+ #
517
+ # @return [Integer] The decimal128 value.
518
+ #
519
+ def decimal128
520
+ value = ""
521
+ Cproton.pn_data_get_decimal128(@impl).each{|val| value += ("%02x" % val)}
522
+ value.to_i(16)
523
+ end
739
524
 
740
- # If the current node is a decimal128, returns its value. Otherwise,
741
- # returns 0.
742
- #
743
- # @return [Integer] The decimal128 value.
744
- #
745
- def decimal128
746
- value = ""
747
- Cproton.pn_data_get_decimal128(@data).each{|val| value += ("%02x" % val)}
748
- value.to_i(16)
749
- end
525
+ # Puts a +UUID+ value.
526
+ #
527
+ # The UUID is expected to be in the format of a string or else a 128-bit
528
+ # integer value.
529
+ #
530
+ # @param value [String, Numeric] A string or numeric representation of the UUID.
531
+ #
532
+ # @example
533
+ #
534
+ # # set a uuid value from a string value
535
+ # require 'securerandom'
536
+ # @impl.uuid = SecureRandom.uuid
537
+ #
538
+ # # or
539
+ # @impl.uuid = "fd0289a5-8eec-4a08-9283-81d02c9d2fff"
540
+ #
541
+ # # set a uuid value from a 128-bit value
542
+ # @impl.uuid = 0 # sets to 00000000-0000-0000-0000-000000000000
543
+ #
544
+ def uuid=(value)
545
+ raise ::ArgumentError, "invalid uuid: #{value}" if value.nil?
546
+
547
+ # if the uuid that was submitted was numeric value, then translated
548
+ # it into a hex string, otherwise assume it was a string represtation
549
+ # and attempt to decode it
550
+ if value.is_a? Numeric
551
+ value = "%032x" % value
552
+ else
553
+ raise ::ArgumentError, "invalid uuid: #{value}" if !valid_uuid?(value)
750
554
 
751
- # Puts a +UUID+ value.
752
- #
753
- # The UUID is expected to be in the format of a string or else a 128-bit
754
- # integer value.
755
- #
756
- # @param value [String, Numeric] A string or numeric representation of the UUID.
757
- #
758
- # @example
759
- #
760
- # # set a uuid value from a string value
761
- # require 'securerandom'
762
- # @data.uuid = SecureRandom.uuid
763
- #
764
- # # or
765
- # @data.uuid = "fd0289a5-8eec-4a08-9283-81d02c9d2fff"
766
- #
767
- # # set a uuid value from a 128-bit value
768
- # @data.uuid = 0 # sets to 00000000-0000-0000-0000-000000000000
769
- #
770
- def uuid=(value)
771
- raise ::ArgumentError, "invalid uuid: #{value}" if value.nil?
772
-
773
- # if the uuid that was submitted was numeric value, then translated
774
- # it into a hex string, otherwise assume it was a string represtation
775
- # and attempt to decode it
776
- if value.is_a? Numeric
777
- value = "%032x" % value
778
- else
779
- raise ::ArgumentError, "invalid uuid: #{value}" if !valid_uuid?(value)
780
-
781
- value = (value[0, 8] +
782
- value[9, 4] +
783
- value[14, 4] +
784
- value[19, 4] +
785
- value[24, 12])
786
- end
787
- bytes = []
788
- value.scan(/(..)/) {|v| bytes << v[0].to_i(16)}
789
- check(Cproton.pn_data_put_uuid(@data, bytes))
790
- end
555
+ value = (value[0, 8] +
556
+ value[9, 4] +
557
+ value[14, 4] +
558
+ value[19, 4] +
559
+ value[24, 12])
560
+ end
561
+ bytes = []
562
+ value.scan(/(..)/) {|v| bytes << v[0].to_i(16)}
563
+ check(Cproton.pn_data_put_uuid(@impl, bytes))
564
+ end
791
565
 
792
- # If the current value is a +UUID+, returns its value. Otherwise,
793
- # it returns nil.
794
- #
795
- # @return [String] The string representation of the UUID.
796
- #
797
- def uuid
798
- value = ""
799
- Cproton.pn_data_get_uuid(@data).each{|val| value += ("%02x" % val)}
800
- value.insert(8, "-").insert(13, "-").insert(18, "-").insert(23, "-")
801
- end
566
+ # If the current value is a +UUID+, returns its value. Otherwise,
567
+ # it returns nil.
568
+ #
569
+ # @return [String] The string representation of the UUID.
570
+ #
571
+ def uuid
572
+ value = ""
573
+ Cproton.pn_data_get_uuid(@impl).each{|val| value += ("%02x" % val)}
574
+ value.insert(8, "-").insert(13, "-").insert(18, "-").insert(23, "-")
575
+ end
802
576
 
803
- # Puts a binary value.
804
- #
805
- # A binary string is encoded as an ASCII 8-bit string value. This is in
806
- # contranst to other strings, which are treated as UTF-8 encoded.
807
- #
808
- # @param value [String] An arbitrary string value.
809
- #
810
- # @see #string=
811
- #
812
- def binary=(value)
813
- check(Cproton.pn_data_put_binary(@data, value))
814
- end
577
+ # Puts a binary value.
578
+ #
579
+ # A binary string is encoded as an ASCII 8-bit string value. This is in
580
+ # contranst to other strings, which are treated as UTF-8 encoded.
581
+ #
582
+ # @param value [String] An arbitrary string value.
583
+ #
584
+ # @see #string=
585
+ #
586
+ def binary=(value)
587
+ check(Cproton.pn_data_put_binary(@impl, value))
588
+ end
815
589
 
816
- # If the current node is binary, returns its value. Otherwise, it returns
817
- # an empty string ("").
818
- #
819
- # @return [String] The binary string.
820
- #
821
- # @see #string
822
- #
823
- def binary
824
- Qpid::Proton::Types::BinaryString.new(Cproton.pn_data_get_binary(@data))
825
- end
590
+ # If the current node is binary, returns its value. Otherwise, it returns
591
+ # an empty string ("").
592
+ #
593
+ # @return [String] The binary string.
594
+ #
595
+ # @see #string
596
+ #
597
+ def binary
598
+ Qpid::Proton::Types::BinaryString.new(Cproton.pn_data_get_binary(@impl))
599
+ end
826
600
 
827
- # Puts a UTF-8 encoded string value.
828
- #
829
- # *NOTE:* A nil value is stored as an empty string rather than as a nil.
830
- #
831
- # @param value [String] The UTF-8 encoded string value.
832
- #
833
- # @see #binary=
834
- #
835
- def string=(value)
836
- check(Cproton.pn_data_put_string(@data, value))
837
- end
601
+ # Puts a UTF-8 encoded string value.
602
+ #
603
+ # *NOTE:* A nil value is stored as an empty string rather than as a nil.
604
+ #
605
+ # @param value [String] The UTF-8 encoded string value.
606
+ #
607
+ # @see #binary=
608
+ #
609
+ def string=(value)
610
+ check(Cproton.pn_data_put_string(@impl, value))
611
+ end
838
612
 
839
- # If the current node is a string, returns its value. Otherwise, it
840
- # returns an empty string ("").
841
- #
842
- # @return [String] The UTF-8 encoded string.
843
- #
844
- # @see #binary
845
- #
846
- def string
847
- Qpid::Proton::Types::UTFString.new(Cproton.pn_data_get_string(@data))
848
- end
613
+ # If the current node is a string, returns its value. Otherwise, it
614
+ # returns an empty string ("").
615
+ #
616
+ # @return [String] The UTF-8 encoded string.
617
+ #
618
+ # @see #binary
619
+ #
620
+ def string
621
+ Qpid::Proton::Types::UTFString.new(Cproton.pn_data_get_string(@impl))
622
+ end
849
623
 
850
- # Puts a symbolic value.
851
- #
852
- # @param value [String] The symbolic string value.
853
- #
854
- def symbol=(value)
855
- check(Cproton.pn_data_put_symbol(@data, value))
856
- end
624
+ # Puts a symbolic value.
625
+ #
626
+ # @param value [String|Symbol] The symbolic string value.
627
+ #
628
+ def symbol=(value)
629
+ check(Cproton.pn_data_put_symbol(@impl, value.to_s))
630
+ end
857
631
 
858
- # If the current node is a symbol, returns its value. Otherwise, it
859
- # returns an empty string ("").
860
- #
861
- # @return [String] The symbolic string value.
862
- #
863
- def symbol
864
- Cproton.pn_data_get_symbol(@data)
865
- end
632
+ # If the current node is a symbol, returns its value. Otherwise, it
633
+ # returns an empty string ("").
634
+ #
635
+ # @return [Symbol] The symbol value.
636
+ #
637
+ def symbol
638
+ Cproton.pn_data_get_symbol(@impl).to_sym
639
+ end
866
640
 
867
- # Get the current value as a single object.
868
- #
869
- # @return [Object] The current node's object.
870
- #
871
- # @see #type_code
872
- # @see #type
873
- #
874
- def get
875
- type.get(self);
876
- end
641
+ # Get the current value as a single object.
642
+ #
643
+ # @return [Object] The current node's object.
644
+ #
645
+ # @see #type_code
646
+ # @see #type
647
+ #
648
+ def get
649
+ type.get(self);
650
+ end
877
651
 
878
- # Puts a new value with the given type into the current node.
879
- #
880
- # @param value [Object] The value.
881
- # @param type_code [Mapping] The value's type.
882
- #
883
- # @private
884
- #
885
- def put(value, type_code);
886
- type_code.put(self, value);
887
- end
652
+ # Puts a new value with the given type into the current node.
653
+ #
654
+ # @param value [Object] The value.
655
+ # @param type_code [Mapping] The value's type.
656
+ #
657
+ # @private
658
+ #
659
+ def put(value, type_code);
660
+ type_code.put(self, value);
661
+ end
888
662
 
889
- private
663
+ private
890
664
 
891
- def valid_uuid?(value)
892
- # ensure that the UUID is in the right format
893
- # xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
894
- value =~ /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/
895
- end
665
+ def valid_uuid?(value)
666
+ # ensure that the UUID is in the right format
667
+ # xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
668
+ value =~ /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/
669
+ end
896
670
 
897
- # @private
898
- def check(err)
899
- if err < 0
900
- raise DataError, "[#{err}]: #{Cproton.pn_data_error(@data)}"
901
- else
902
- return err
671
+ # @private
672
+ def check(err)
673
+ if err < 0
674
+ raise TypeError, "[#{err}]: #{Cproton.pn_data_error(@impl)}"
675
+ else
676
+ return err
677
+ end
903
678
  end
904
- end
905
679
 
680
+ end
906
681
  end
907
-
908
682
  end