virtual QByteArray GetByteArray() const { int size = m_data.MinEncodedSize(); QByteArray byte_array(size, 0); m_data.Encode(reinterpret_cast<byte *>(byte_array.data()), size); return byte_array; }
virtual void GenerateByteArray() { int size = _integer.MinEncodedSize(); QByteArray byte_array(size, 0); _integer.Encode(reinterpret_cast<byte *>(byte_array.data()), size); SetByteArray(byte_array); }
const QByteArray imageToByteArray(const QImage & image) { QByteArray byte_array(image.byteCount(), 0); QBuffer buf(&byte_array); buf.open(QIODevice::WriteOnly); image.save(&buf, "png"); buf.close(); return byte_array; }
byte_array dsa160_key::public_key() const { assert(type() != invalid); byte_array data; { byte_array_owrap<flurry::oarchive> write(data); // Write the public part of the key write.archive() << dsa_->p << dsa_->q << dsa_->g << dsa_->pub_key << byte_array(); } return data; }
/* Allocates memory */ void growable_byte_array::append_byte_array(cell byte_array_) { data_root<byte_array> byte_array(byte_array_, elements.parent); cell len = array_capacity(byte_array.untagged()); cell new_size = count + len; factor_vm* parent = elements.parent; if (new_size >= array_capacity(elements.untagged())) elements = parent->reallot_array(elements.untagged(), new_size * 2); memcpy(&elements->data<uint8_t>()[count], byte_array->data<uint8_t>(), len); count += len; }
void growable_byte_array::append_byte_array(cell byte_array_) { gc_root<byte_array> byte_array(byte_array_,elements.myvm); cell len = array_capacity(byte_array.untagged()); cell new_size = count + len; factorvm *myvm = elements.myvm; if(new_size >= array_capacity(elements.untagged())) elements = myvm->reallot_array(elements.untagged(),new_size * 2); memcpy(&elements->data<u8>()[count],byte_array->data<u8>(),len); count += len; }
ReturnOop InstanceClass::package_name(JVM_SINGLE_ARG_TRAPS) { UsingFastOops fast_oops; Symbol::Fast symbol_class_name = original_name(); int len = symbol_class_name().strrchr('/'); if (len <= 0) { len = symbol_class_name().length(); } TypeArray::Fast byte_array = Universe::new_byte_array(len JVM_CHECK_0); for (int i = 0; i < len; i++) { byte_array().byte_at_put(i, symbol_class_name().byte_at(i)); } GUARANTEE(SymbolTable::current()->not_null(), "JavaClass::package_name() requires SymbolTable"); return SymbolTable::symbol_for(&byte_array JVM_NO_CHECK_AT_BOTTOM_0); }
VALUE unserialize(VALUE self, VALUE string) { Check_Type(string, T_STRING); QByteArray byte_array(RSTRING_PTR(string), RSTRING_LEN(string)); QDataStream data_stream(byte_array); QVariant variant; data_stream >> variant; // FIXME return a Ruby object for the variant instead of its qDebug QString output; QDebug debug(&output); debug << variant; VALUE result = rb_str_new2(output.toUtf8().data()); rb_enc_associate_index(string, rb_enc_find_index("UTF-8")); return result; }
// Target address must be routable to in order to send. // Find the destination host in the "routing table" (a simple list of neighbors). bool sim_socket::send(uia::comm::endpoint const& ep, const char* data, size_t size) { assert(port_ > 0); uia::comm::endpoint src; src.port(port_); sim_host_ptr dest_host = host_->neighbor_at(ep, src); if (!dest_host) { logger::warning() << "Unknown or non-adjacent target host " << ep; return false; } sim_connection_ptr pipe(host_->connection_at(src)); assert(pipe); make_shared<sim_packet>(host_, src, pipe, ep, byte_array(data, size))->send(); return true; }
ReturnOop SymbolTable::slashified_symbol_for(utf8 s, int len JVM_TRAPS) { UsingFastOops fast_oops; TypeArray::Fast byte_array = Universe::new_byte_array(len JVM_CHECK_0); utf8 p = (utf8)byte_array().base_address(); jvm_memcpy(p, s, len); for (int i = 0; i < len; i++) { if (p[i] == '/') { // This makes external class names which already contain '/' instead // of '.' fail resolution p[i] = '.'; } else if (p[i] == '.') { p[i] = '/'; } } return symbol_for(&byte_array JVM_NO_CHECK_AT_BOTTOM_0); }
byte_array byte_array::left(size_t new_size) const { new_size = std::min(new_size, size()); return byte_array(const_data(), new_size); }
/// Returns the size of this OSC message. /// /// @return Size of the OSC message in bytes. /// @see byte_array /// @see data size_t size() const { return byte_array().size(); }
/// Returns a complete byte array of this OSC message as a char /// pointer. This call is convenient for actually sending this OSC messager. /// /// @return The OSC message as an char*. /// @see byte_array /// @see size /// /// <pre> /// int sockfd; // initialize a socket... /// tnyosc::Message* msg; // create a OSC message... /// send_to(sockfd, msg->data(), msg->size(), 0); /// </pre> /// const char* data() const { return get_pointer(byte_array()); }
byte_array byte_array::mid(int pos, size_t new_size) const { new_size = std::min(new_size, size() - pos); return byte_array(const_data() + pos, new_size); }
byte_array byte_array::wrap(const char* data, size_t size) { return byte_array(data, size); }
byte_array byte_array::right(size_t new_size) const { new_size = std::min(new_size, size()); return byte_array(const_data() + size() - new_size, new_size); }
byte_array async_file::read(ssize_t max_size) { return byte_array(); }