Sha256: a2d537bc3d2c38af958426baf08a1ef37da0ebc08f906f82a04bb17123afb9f6

Contents?: true

Size: 694 Bytes

Versions: 5

Compression:

Stored size: 694 Bytes

Contents

#include "or-hash.h"
#include "or-variable.h"

OR_Hash::~OR_Hash() {}

octave_value OR_Hash::to_octave()
{
  int i;
  VALUE names = rb_funcall(ruby_val, rb_intern("keys"), 0);
  int number_of_keys = RARRAY(names)->len;

  string_vector keys = string_vector();
  for (i = 0; i < number_of_keys; i++) {
    keys.append(std::string(RSTRING(RARRAY(names)->ptr[i])->ptr));
  }

  Octave_map struct_matrix = Octave_map(dim_vector(0, 1), Cell(keys));
  for (i = 0; i < number_of_keys; i++) {
    struct_matrix.contents(std::string(RSTRING(RARRAY(names)->ptr[i])->ptr)) = OR_Variable(rb_hash_aref(ruby_val, rb_str_new2(RSTRING(RARRAY(names)->ptr[i])->ptr))).to_octave();
  }

  return struct_matrix;
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
octave-ruby-1.0.3 ext/octave_api/or-hash.cpp
octave-ruby-1.0.5 ext/octave_api/or-hash.cpp
octave-ruby-1.0.7 ext/octave_api/or-hash.cpp
octave-ruby-1.0.4 ext/octave_api/or-hash.cpp
octave-ruby-1.0.6 ext/octave_api/or-hash.cpp