Sha256: f6b0884450cc11ad33de891cdc2cdbb8f235632981609f999b64718d4820af60

Contents?: true

Size: 1.48 KB

Versions: 4

Compression:

Stored size: 1.48 KB

Contents

#pragma once

#include <rice/Array.hpp>

using Rice::Array;
using Rice::Object;

template<>
inline
Object to_ruby<std::vector<tomoto::Float>>(std::vector<tomoto::Float> const & x)
{
  Array res;
  for (auto const& v : x) {
    res.push(v);
  }
  return res;
}

template<>
inline
Object to_ruby<std::vector<uint32_t>>(std::vector<uint32_t> const & x)
{
  Array res;
  for (auto const& v : x) {
    res.push(v);
  }
  return res;
}

template<>
inline
Object to_ruby<std::vector<uint64_t>>(std::vector<uint64_t> const & x)
{
  Array res;
  for (auto const& v : x) {
    res.push(v);
  }
  return res;
}

template<>
inline
std::vector<std::string> from_ruby<std::vector<std::string>>(Object x)
{
  Array a = Array(x);
  std::vector<std::string> res;
  res.reserve(a.size());
  for (auto const& v : a) {
    res.push_back(from_ruby<std::string>(v));
  }
  return res;
}

template<>
inline
std::vector<tomoto::Float> from_ruby<std::vector<tomoto::Float>>(Object x)
{
  Array a = Array(x);
  std::vector<tomoto::Float> res;
  res.reserve(a.size());
  for (auto const& v : a) {
    res.push_back(from_ruby<tomoto::Float>(v));
  }
  return res;
}

template<>
inline
std::vector<uint64_t> from_ruby<std::vector<uint64_t>>(Object x)
{
  Array a = Array(x);
  std::vector<uint64_t> res;
  res.reserve(a.size());
  for (auto const& v : a) {
    res.push_back(from_ruby<uint64_t>(v));
  }
  return res;
}

inline tomoto::RawDoc buildDoc(std::vector<std::string>& words) {
  tomoto::RawDoc doc;
  doc.rawWords = words;
  return doc;
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tomoto-0.2.2 ext/tomoto/utils.h
tomoto-0.2.1 ext/tomoto/utils.h
tomoto-0.2.0 ext/tomoto/utils.h
tomoto-0.1.4 ext/tomoto/utils.h