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
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 53

def self.create_finalizer_for(ptr)
  Proc.new do
    ptr_ptr = ::FFI::MemoryPointer.new :pointer
    ptr_ptr.write_pointer ptr
    ::CZMQ::FFI.zarmour_destroy ptr_ptr
  end
end

.newCZMQ::Zarmour

Create a new zarmour

Returns:

  • (CZMQ::Zarmour)


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

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)


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

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:



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

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:



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

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.



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

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:



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

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



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

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:



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

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:



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

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:



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

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:



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

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:



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

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

#null?Boolean

Returns:

  • (Boolean)


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

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

#padBoolean

Return true if padding is turned on.

Returns:

  • (Boolean)

Raises:



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

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:



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

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:



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

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:



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

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:



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

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:



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

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:



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

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:



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

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