class CZMQ::FFI::Zconfig

work with config files written in rfc.zeromq.org/spec:4/ZPL. @note This class is 100% generated using zproject.

Public Class Methods

__new(name, parent)
Alias for: new
chunk_load(chunk) click to toggle source

Load a config tree from a memory chunk

@param chunk [Zchunk, #__ptr] @return [Zconfig]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 368
def self.chunk_load(chunk)
  chunk = chunk.__ptr if chunk
  result = ::CZMQ::FFI.zconfig_chunk_load(chunk)
  result = Zconfig.__new result, false
  result
end
create_finalizer_for(ptr) click to toggle source

@param ptr [::FFI::Pointer] @return [Proc]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 35
def self.create_finalizer_for(ptr)
  Proc.new do
    ptr_ptr = ::FFI::MemoryPointer.new :pointer
    ptr_ptr.write_pointer ptr
    ::CZMQ::FFI.zconfig_destroy ptr_ptr
  end
end
fct() { |self_, arg, level| ... } click to toggle source

Create a new callback of the following type:

typedef int (zconfig_fct) (
    zconfig_t *self, void *arg, int level);

@note WARNING: If your Ruby code doesn't retain a reference to the

FFI::Function object after passing it to a C function call,
it may be garbage collected while C still holds the pointer,
potentially resulting in a segmentation fault.
# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 85
def self.fct
  ::FFI::Function.new :int, [:pointer, :pointer, :int], blocking: true do |self_, arg, level|
    self_ = Zconfig.__new self_, false
    result = yield self_, arg, level
    result = Integer(result)
    result
  end
end
load(filename) click to toggle source

Load a config tree from a specified ZPL text file; returns a zconfig_t reference for the root, if the file exists and is readable. Returns NULL if the file does not exist. @param filename [String, to_s, nil] @return [CZMQ::Zconfig]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 109
def self.load(filename)
  ptr = ::CZMQ::FFI.zconfig_load(filename)
  __new ptr
end
loadf(format, *args) click to toggle source

Equivalent to zconfig_load, taking a format string instead of a fixed filename. @param format [String, to_s, nil] @param args [Array<Object>] @return [CZMQ::Zconfig]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 119
def self.loadf(format, *args)
  ptr = ::CZMQ::FFI.zconfig_loadf(format, *args)
  __new ptr
end
new(ptr, finalize = true) click to toggle source

Attaches the pointer ptr to this instance and defines a finalizer for it if necessary. @param ptr [::FFI::Pointer] @param finalize [Boolean]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.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
new(name, parent) click to toggle source

Create new config item @param name [String, to_s, nil] @param parent [Zconfig, #__ptr] @return [CZMQ::Zconfig]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 98
def self.new(name, parent)
  parent = parent.__ptr if parent
  ptr = ::CZMQ::FFI.zconfig_new(name, parent)
  __new ptr
end
Also aliased as: __new
reload(self_p) click to toggle source

Reload config tree from same file that it was previously loaded from. Returns 0 if OK, -1 if there was an error (and then does not change existing data).

@param self_p [#__ptr_give_ref] @return [Integer]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 358
def self.reload(self_p)
  self_p = self_p.__ptr_give_ref
  result = ::CZMQ::FFI.zconfig_reload(self_p)
  result
end
remove(self_p) click to toggle source

Destroy node and subtree (all children)

@param self_p [#__ptr_give_ref] @return [void]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 432
def self.remove(self_p)
  self_p = self_p.__ptr_give_ref
  result = ::CZMQ::FFI.zconfig_remove(self_p)
  result
end
str_load(string) click to toggle source

Load a config tree from a null-terminated string

@param string [String, to_s, nil] @return [Zconfig]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 390
def self.str_load(string)
  result = ::CZMQ::FFI.zconfig_str_load(string)
  result = Zconfig.__new result, true
  result
end
test(verbose) click to toggle source

Self test of this class

@param verbose [Boolean] @return [void]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 463
def self.test(verbose)
  verbose = !(0==verbose||!verbose) # boolean
  result = ::CZMQ::FFI.zconfig_test(verbose)
  result
end

Public Instance Methods

__ptr() click to toggle source

Return internal pointer @return [::FFI::Pointer]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 48
def __ptr
  raise DestroyedError unless @ptr
  @ptr
end
Also aliased as: to_ptr
__ptr_give_ref() click to toggle source

Nullify internal pointer and return pointer pointer. @note This detaches the current instance from the native object

and thus makes it unusable.

@return [::FFI::MemoryPointer] the pointer pointing to a pointer

pointing to the native object
# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 59
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_finalizer() click to toggle source

Undefines the finalizer for this object. @note Only use this if you need to and can guarantee that the native

object will be freed by other means.

@return [void]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 71
def __undef_finalizer
  ObjectSpace.undefine_finalizer self
  @finalizer = nil
end
at_depth(level) click to toggle source

Locate the last config item at a specified depth

@param level [Integer, to_int, to_i] @return [Zconfig]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 270
def at_depth(level)
  raise DestroyedError unless @ptr
  self_p = @ptr
  level = Integer(level)
  result = ::CZMQ::FFI.zconfig_at_depth(self_p, level)
  result = Zconfig.__new result, false
  result
end
child() click to toggle source

Find our first child, if any

@return [Zconfig]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 235
def child()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zconfig_child(self_p)
  result = Zconfig.__new result, false
  result
end
chunk_save() click to toggle source

Save a config tree to a new memory chunk

@return [Zchunk]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 378
def chunk_save()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zconfig_chunk_save(self_p)
  result = Zchunk.__new result, false
  result
end
comments() click to toggle source

Return comments of config item, as zlist.

@return [Zlist]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 309
def comments()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zconfig_comments(self_p)
  result = Zlist.__new result, false
  result
end
destroy() click to toggle source

Destroy a config item and all its children

@return [void]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 127
def destroy()
  return unless @ptr
  self_p = __ptr_give_ref
  result = ::CZMQ::FFI.zconfig_destroy(self_p)
  result
end
dup() click to toggle source

Create copy of zconfig, caller MUST free the value Create copy of config, as new zconfig object. Returns a fresh zconfig_t object. If config is null, or memory was exhausted, returns null.

@return [Zconfig]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 139
def dup()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zconfig_dup(self_p)
  result = Zconfig.__new result, true
  result
end
execute(handler, arg) click to toggle source

Execute a callback for each config item in the tree; returns zero if successful, else -1.

@param handler [::FFI::Pointer, to_ptr] @param arg [::FFI::Pointer, to_ptr] @return [Integer]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 285
def execute(handler, arg)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zconfig_execute(self_p, handler, arg)
  result
end
filename() click to toggle source

Report filename used during zconfig_load, or NULL if none

@return [String]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 345
def filename()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zconfig_filename(self_p)
  result
end
fprint(file) click to toggle source

Print the config file to open stream

@param file [::FFI::Pointer, to_ptr] @return [void]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 442
def fprint(file)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zconfig_fprint(self_p, file)
  result
end
get(path, default_value) click to toggle source

Get value for config item into a string value; leading slash is optional and ignored.

@param path [String, to_s, nil] @param default_value [String, to_s, nil] @return [::FFI::Pointer]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 199
def get(path, default_value)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zconfig_get(self_p, path, default_value)
  result
end
has_changed() click to toggle source

Return true if a configuration tree was loaded from a file and that file has changed in since the tree was loaded.

@return [Boolean]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 411
def has_changed()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zconfig_has_changed(self_p)
  result
end
locate(path) click to toggle source

Find a config item along a path; leading slash is optional and ignored.

@param path [String, to_s, nil] @return [Zconfig]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 258
def locate(path)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zconfig_locate(self_p, path)
  result = Zconfig.__new result, false
  result
end
name() click to toggle source

Return name of config item

@return [::FFI::Pointer]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 150
def name()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zconfig_name(self_p)
  result
end
next() click to toggle source

Find our first sibling, if any

@return [Zconfig]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 246
def next()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zconfig_next(self_p)
  result = Zconfig.__new result, false
  result
end
null?() click to toggle source

@return [Boolean]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 43
def null?
  !@ptr or @ptr.null?
end
print() click to toggle source

Print properties of object

@return [void]

put(path, value) click to toggle source

Insert or update configuration key with value

@param path [String, to_s, nil] @param value [String, to_s, nil] @return [void]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 172
def put(path, value)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zconfig_put(self_p, path, value)
  result
end
putf(path, format, *args) click to toggle source

Equivalent to zconfig_put, accepting a format specifier and variable argument list, instead of a single string value.

@param path [String, to_s, nil] @param format [String, to_s, nil] @param args [Array<Object>] see github.com/ffi/ffi/wiki/examples#using-varargs @return [void]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 186
def putf(path, format, *args)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zconfig_putf(self_p, path, format, *args)
  result
end
remove_subtree() click to toggle source

Destroy subtree (all children)

@return [void]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 421
def remove_subtree()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zconfig_remove_subtree(self_p)
  result
end
save(filename) click to toggle source

Save a config tree to a specified ZPL text file, where a filename “-” means dump to standard output.

@param filename [String, to_s, nil] @return [Integer]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 322
def save(filename)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zconfig_save(self_p, filename)
  result
end
savef(format, *args) click to toggle source

Equivalent to zconfig_save, taking a format string instead of a fixed filename.

@param format [String, to_s, nil] @param args [Array<Object>] see github.com/ffi/ffi/wiki/examples#using-varargs @return [Integer]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 335
def savef(format, *args)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zconfig_savef(self_p, format, *args)
  result
end
set_comment(format, *args) click to toggle source

Add comment to config item before saving to disk. You can add as many comment lines as you like. If you use a null format, all comments are deleted.

@param format [String, to_s, nil] @param args [Array<Object>] see github.com/ffi/ffi/wiki/examples#using-varargs @return [void]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 299
def set_comment(format, *args)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zconfig_set_comment(self_p, format, *args)
  result
end
set_name(name) click to toggle source

Set config item name, name may be NULL

@param name [String, to_s, nil] @return [void]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 210
def set_name(name)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zconfig_set_name(self_p, name)
  result
end
set_value(format, *args) click to toggle source

Set new value for config item. The new value may be a string, a printf format, or NULL. Note that if string may possibly contain '%', or if it comes from an insecure source, you must use '%s' as the format, followed by the string.

@param format [String, to_s, nil] @param args [Array<Object>] see github.com/ffi/ffi/wiki/examples#using-varargs @return [void]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 225
def set_value(format, *args)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zconfig_set_value(self_p, format, *args)
  result
end
str_save() click to toggle source

Save a config tree to a new null terminated string

@return [::FFI::AutoPointer]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 399
def str_save()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zconfig_str_save(self_p)
  result = ::FFI::AutoPointer.new(result, LibC.method(:free))
  result
end
to_ptr()

So external Libraries can just pass the Object to a FFI function which expects a :pointer

Alias for: __ptr
value() click to toggle source

Return value of config item

@return [::FFI::Pointer]

# File lib/czmq-ffi-gen/czmq/ffi/zconfig.rb, line 160
def value()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zconfig_value(self_p)
  result
end