Class: CZMQ::FFI::Zarmour

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

Overview

Note:

This class is 100% generated using zproject.

armoured text encoding and decoding

Defined Under Namespace

Classes: DestroyedError

Constant Summary collapse

MODE_BASE64_STD =

Standard base 64

0
MODE_BASE64_URL =

URL and filename friendly base 64

1
MODE_BASE32_STD =

Standard base 32

2
MODE_BASE32_HEX =

Extended hex base 32

3
MODE_BASE16 =

Standard base 16

4
MODE_Z85 =

Z85 from ZeroMQ RFC 32

5

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ptr, finalize = true) ⇒ Zarmour

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

Parameters:

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


42
43
44
45
46
47
48
49
50
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 42

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



36
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 36

alias :__new :new

.create_finalizer_for(ptr) ⇒ Proc

Parameters:

  • ptr (::FFI::Pointer)

Returns:

  • (Proc)


53
54
55
56
57
58
59
60
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 53

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

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

.newCZMQ::Zarmour

Create a new zarmour

Returns:

  • (CZMQ::Zarmour)


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

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

.test(verbose) ⇒ void

This method returns an undefined value.

Self test of this class.

Parameters:

  • verbose (Boolean)


275
276
277
278
279
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 275

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

Instance Method Details

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

Return internal pointer

Returns:

  • (::FFI::Pointer)

Raises:



67
68
69
70
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 67

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:



78
79
80
81
82
83
84
85
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 78

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.



90
91
92
93
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 90

def __undef_finalizer
  ObjectSpace.undefine_finalizer self
  @finalizer = nil
end

#decode(data) ⇒ Zchunk

Decode an armoured string into a chunk. The decoded output is null-terminated, so it may be treated as a string, if that’s what it was prior to encoding.

Parameters:

  • data (String, #to_s, nil)

Returns:

Raises:



134
135
136
137
138
139
140
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 134

def decode(data)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zarmour_decode(self_p, data)
  result = Zchunk.__new result, true
  result
end

#destroyvoid

This method returns an undefined value.

Destroy the zarmour



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

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

#encode(data, size) ⇒ ::FFI::AutoPointer

Encode a stream of bytes into an armoured string. Returns the armoured string, or NULL if there was insufficient memory available to allocate a new string.

Parameters:

  • data (::FFI::Pointer, #to_ptr)
  • size (Integer, #to_int, #to_i)

Returns:

  • (::FFI::AutoPointer)

Raises:



119
120
121
122
123
124
125
126
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 119

def encode(data, size)
  raise DestroyedError unless @ptr
  self_p = @ptr
  size = Integer(size)
  result = ::CZMQ::FFI.zarmour_encode(self_p, data, size)
  result = ::FFI::AutoPointer.new(result, LibC.method(:free))
  result
end

#line_breaksBoolean

Return if splitting output into lines is turned on. Default is off.

Returns:

  • (Boolean)

Raises:



220
221
222
223
224
225
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 220

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

#line_lengthInteger

Get the line length used for splitting lines.

Returns:

  • (Integer)

Raises:



242
243
244
245
246
247
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 242

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

#modeInteger

Get the mode property.

Returns:

  • (Integer)

Raises:



145
146
147
148
149
150
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 145

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

#mode_strString

Get printable string for mode.

Returns:

  • (String)

Raises:



155
156
157
158
159
160
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 155

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

#null?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 62

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

#padBoolean

Return true if padding is turned on.

Returns:

  • (Boolean)

Raises:



177
178
179
180
181
182
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 177

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

#pad_char::FFI::Pointer

Get the padding character.

Returns:

  • (::FFI::Pointer)

Raises:



199
200
201
202
203
204
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 199

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

This method returns an undefined value.

Print properties of object

Raises:



264
265
266
267
268
269
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 264

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

#set_line_breaks(line_breaks) ⇒ void

This method returns an undefined value.

Turn splitting output into lines on or off.

Parameters:

  • line_breaks (Boolean)

Raises:



231
232
233
234
235
236
237
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 231

def set_line_breaks(line_breaks)
  raise DestroyedError unless @ptr
  self_p = @ptr
  line_breaks = !(0==line_breaks||!line_breaks) # boolean
  result = ::CZMQ::FFI.zarmour_set_line_breaks(self_p, line_breaks)
  result
end

#set_line_length(line_length) ⇒ void

This method returns an undefined value.

Set the line length used for splitting lines.

Parameters:

  • line_length (Integer, #to_int, #to_i)

Raises:



253
254
255
256
257
258
259
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 253

def set_line_length(line_length)
  raise DestroyedError unless @ptr
  self_p = @ptr
  line_length = Integer(line_length)
  result = ::CZMQ::FFI.zarmour_set_line_length(self_p, line_length)
  result
end

#set_mode(mode) ⇒ void

This method returns an undefined value.

Set the mode property.

Parameters:

  • mode (Integer, #to_int, #to_i)

Raises:



166
167
168
169
170
171
172
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 166

def set_mode(mode)
  raise DestroyedError unless @ptr
  self_p = @ptr
  mode = Integer(mode)
  result = ::CZMQ::FFI.zarmour_set_mode(self_p, mode)
  result
end

#set_pad(pad) ⇒ void

This method returns an undefined value.

Turn padding on or off. Default is on.

Parameters:

  • pad (Boolean)

Raises:



188
189
190
191
192
193
194
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 188

def set_pad(pad)
  raise DestroyedError unless @ptr
  self_p = @ptr
  pad = !(0==pad||!pad) # boolean
  result = ::CZMQ::FFI.zarmour_set_pad(self_p, pad)
  result
end

#set_pad_char(pad_char) ⇒ void

This method returns an undefined value.

Set the padding character.

Parameters:

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

Raises:



210
211
212
213
214
215
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 210

def set_pad_char(pad_char)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zarmour_set_pad_char(self_p, pad_char)
  result
end