Class: CZMQ::FFI::Zuuid

Inherits:
Object
  • Object
show all
Defined in:
lib/czmq-ffi-gen/czmq/ffi/zuuid.rb

Overview

Note:

This class is 100% generated using zproject.

UUID support class

Defined Under Namespace

Classes: DestroyedError

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ptr, finalize = true) ⇒ Zuuid

Attaches the pointer ptr to this instance and defines a finalizer for it if necessary.

Parameters:

  • ptr (::FFI::Pointer)
  • finalize (Boolean) (defaults to: true)


24
25
26
27
28
29
30
31
32
# File 'lib/czmq-ffi-gen/czmq/ffi/zuuid.rb', line 24

def initialize(ptr, finalize = true)
  @ptr = ptr
  if @ptr.null?
    @ptr = nil # Remove null pointers so we don't have to test for them.
  elsif finalize
    @finalizer = self.class.create_finalizer_for @ptr
    ObjectSpace.define_finalizer self, @finalizer
  end
end

Class Method Details

.__newObject



18
# File 'lib/czmq-ffi-gen/czmq/ffi/zuuid.rb', line 18

alias :__new :new

.create_finalizer_for(ptr) ⇒ Proc

Parameters:

  • ptr (::FFI::Pointer)

Returns:

  • (Proc)


35
36
37
38
39
40
41
42
# File 'lib/czmq-ffi-gen/czmq/ffi/zuuid.rb', line 35

def self.create_finalizer_for(ptr)
  ptr_ptr = ::FFI::MemoryPointer.new :pointer

  Proc.new do
    ptr_ptr.write_pointer ptr
    ::CZMQ::FFI.zuuid_destroy ptr_ptr
  end
end

.newCZMQ::Zuuid

Create a new UUID object.

Returns:

  • (CZMQ::Zuuid)


79
80
81
82
# File 'lib/czmq-ffi-gen/czmq/ffi/zuuid.rb', line 79

def self.new()
  ptr = ::CZMQ::FFI.zuuid_new()
  __new ptr
end

.new_from(source) ⇒ CZMQ::Zuuid

Create UUID object from supplied ZUUID_LEN-octet value.

Parameters:

  • source (::FFI::Pointer, #to_ptr)

Returns:

  • (CZMQ::Zuuid)


87
88
89
90
# File 'lib/czmq-ffi-gen/czmq/ffi/zuuid.rb', line 87

def self.new_from(source)
  ptr = ::CZMQ::FFI.zuuid_new_from(source)
  __new ptr
end

.test(verbose) ⇒ void

This method returns an undefined value.

Self test of this class.

Parameters:

  • verbose (Boolean)


216
217
218
219
220
# File 'lib/czmq-ffi-gen/czmq/ffi/zuuid.rb', line 216

def self.test(verbose)
  verbose = !(0==verbose||!verbose) # boolean
  result = ::CZMQ::FFI.zuuid_test(verbose)
  result
end

Instance Method Details

#__ptr::FFI::Pointer Also known as: to_ptr

Return internal pointer

Returns:

  • (::FFI::Pointer)

Raises:



49
50
51
52
# File 'lib/czmq-ffi-gen/czmq/ffi/zuuid.rb', line 49

def __ptr
  raise DestroyedError unless @ptr
  @ptr
end

#__ptr_give_ref::FFI::MemoryPointer

Note:

This detaches the current instance from the native object and thus makes it unusable.

Nullify internal pointer and return pointer pointer.

Returns:

  • (::FFI::MemoryPointer)

    the pointer pointing to a pointer pointing to the native object

Raises:



60
61
62
63
64
65
66
67
# File 'lib/czmq-ffi-gen/czmq/ffi/zuuid.rb', line 60

def __ptr_give_ref
  raise DestroyedError unless @ptr
  ptr_ptr = ::FFI::MemoryPointer.new :pointer
  ptr_ptr.write_pointer @ptr
  __undef_finalizer if @finalizer
  @ptr = nil
  ptr_ptr
end

#__undef_finalizervoid

Note:

Only use this if you need to and can guarantee that the native object will be freed by other means.

This method returns an undefined value.

Undefines the finalizer for this object.



72
73
74
75
# File 'lib/czmq-ffi-gen/czmq/ffi/zuuid.rb', line 72

def __undef_finalizer
  ObjectSpace.undefine_finalizer self
  @finalizer = nil
end

#data::FFI::Pointer

Return UUID binary data.

Returns:

  • (::FFI::Pointer)

Raises:



128
129
130
131
132
133
# File 'lib/czmq-ffi-gen/czmq/ffi/zuuid.rb', line 128

def data()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zuuid_data(self_p)
  result
end

#destroyvoid

This method returns an undefined value.

Destroy a specified UUID object.



95
96
97
98
99
100
# File 'lib/czmq-ffi-gen/czmq/ffi/zuuid.rb', line 95

def destroy()
  return unless @ptr
  self_p = __ptr_give_ref
  result = ::CZMQ::FFI.zuuid_destroy(self_p)
  result
end

#dupZuuid

Make copy of UUID object; if uuid is null, or memory was exhausted, returns null.

Returns:

Raises:



204
205
206
207
208
209
210
# File 'lib/czmq-ffi-gen/czmq/ffi/zuuid.rb', line 204

def dup()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zuuid_dup(self_p)
  result = Zuuid.__new result, false
  result
end

#eq(compare) ⇒ Boolean

Check if UUID is same as supplied value

Parameters:

  • compare (::FFI::Pointer, #to_ptr)

Returns:

  • (Boolean)

Raises:



182
183
184
185
186
187
# File 'lib/czmq-ffi-gen/czmq/ffi/zuuid.rb', line 182

def eq(compare)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zuuid_eq(self_p, compare)
  result
end

#export(target) ⇒ void

This method returns an undefined value.

Store UUID blob in target array

Parameters:

  • target (::FFI::Pointer, #to_ptr)

Raises:



171
172
173
174
175
176
# File 'lib/czmq-ffi-gen/czmq/ffi/zuuid.rb', line 171

def export(target)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zuuid_export(self_p, target)
  result
end

#neq(compare) ⇒ Boolean

Check if UUID is different from supplied value

Parameters:

  • compare (::FFI::Pointer, #to_ptr)

Returns:

  • (Boolean)

Raises:



193
194
195
196
197
198
# File 'lib/czmq-ffi-gen/czmq/ffi/zuuid.rb', line 193

def neq(compare)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zuuid_neq(self_p, compare)
  result
end

#null?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/czmq-ffi-gen/czmq/ffi/zuuid.rb', line 44

def null?
  !@ptr or @ptr.null?
end

#set(source) ⇒ void

This method returns an undefined value.

Set UUID to new supplied ZUUID_LEN-octet value.

Parameters:

  • source (::FFI::Pointer, #to_ptr)

Raises:



106
107
108
109
110
111
# File 'lib/czmq-ffi-gen/czmq/ffi/zuuid.rb', line 106

def set(source)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zuuid_set(self_p, source)
  result
end

#set_str(source) ⇒ Integer

Set UUID to new supplied string value skipping ‘-’ and ‘‘’ optional delimiters. Return 0 if OK, else returns -1.

Parameters:

  • source (String, #to_s, nil)

Returns:

  • (Integer)

Raises:



118
119
120
121
122
123
# File 'lib/czmq-ffi-gen/czmq/ffi/zuuid.rb', line 118

def set_str(source)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zuuid_set_str(self_p, source)
  result
end

#sizeInteger

Return UUID binary size

Returns:

  • (Integer)

Raises:



138
139
140
141
142
143
# File 'lib/czmq-ffi-gen/czmq/ffi/zuuid.rb', line 138

def size()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zuuid_size(self_p)
  result
end

#strString

Returns UUID as string

Returns:

  • (String)

Raises:



148
149
150
151
152
153
# File 'lib/czmq-ffi-gen/czmq/ffi/zuuid.rb', line 148

def str()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zuuid_str(self_p)
  result
end

#str_canonicalString

Return UUID in the canonical string format: 8-4-4-4-12, in lower case. Caller does not modify or free returned value. See en.wikipedia.org/wiki/Universally_unique_identifier

Returns:

  • (String)

Raises:



160
161
162
163
164
165
# File 'lib/czmq-ffi-gen/czmq/ffi/zuuid.rb', line 160

def str_canonical()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zuuid_str_canonical(self_p)
  result
end