| 1 | /* |
| 2 | * particle_blob.h |
| 3 | * |
| 4 | * Copyright (C) 2015 Aerospike, Inc. |
| 5 | * |
| 6 | * Portions may be licensed to Aerospike, Inc. under one or more contributor |
| 7 | * license agreements. |
| 8 | * |
| 9 | * This program is free software: you can redistribute it and/or modify it under |
| 10 | * the terms of the GNU Affero General Public License as published by the Free |
| 11 | * Software Foundation, either version 3 of the License, or (at your option) any |
| 12 | * later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 16 | * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
| 17 | * details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU Affero General Public License |
| 20 | * along with this program. If not, see http://www.gnu.org/licenses/ |
| 21 | */ |
| 22 | |
| 23 | #pragma once |
| 24 | |
| 25 | #include <stdint.h> |
| 26 | #include "aerospike/as_val.h" |
| 27 | #include "base/datamodel.h" |
| 28 | |
| 29 | // The BLOB particle interface function declarations are in this header file |
| 30 | // since BLOB functions are used by other particles derived from BLOB. |
| 31 | |
| 32 | // Destructor, etc. |
| 33 | void blob_destruct(as_particle* p); |
| 34 | uint32_t blob_size(const as_particle* p); |
| 35 | |
| 36 | // Handle "wire" format. |
| 37 | int32_t blob_concat_size_from_wire(as_particle_type wire_type, const uint8_t* wire_value, uint32_t value_size, as_particle** pp); |
| 38 | int blob_append_from_wire(as_particle_type wire_type, const uint8_t* wire_value, uint32_t value_size, as_particle** pp); |
| 39 | int blob_prepend_from_wire(as_particle_type wire_type, const uint8_t* wire_value, uint32_t value_size, as_particle** pp); |
| 40 | int blob_incr_from_wire(as_particle_type wire_type, const uint8_t* wire_value, uint32_t value_size, as_particle** pp); |
| 41 | int32_t blob_size_from_wire(const uint8_t* wire_value, uint32_t value_size); |
| 42 | int blob_from_wire(as_particle_type wire_type, const uint8_t* wire_value, uint32_t value_size, as_particle** pp); |
| 43 | int blob_compare_from_wire(const as_particle* p, as_particle_type wire_type, const uint8_t* wire_value, uint32_t value_size); |
| 44 | uint32_t blob_wire_size(const as_particle* p); |
| 45 | uint32_t blob_to_wire(const as_particle* p, uint8_t* wire); |
| 46 | |
| 47 | // Handle as_val translation. |
| 48 | uint32_t blob_size_from_asval(const as_val* val); |
| 49 | void blob_from_asval(const as_val* val, as_particle** pp); |
| 50 | as_val* blob_to_asval(const as_particle* p); |
| 51 | uint32_t blob_asval_wire_size(const as_val* val); |
| 52 | uint32_t blob_asval_to_wire(const as_val* val, uint8_t* wire); |
| 53 | |
| 54 | // Handle msgpack translation. |
| 55 | uint32_t blob_size_from_msgpack(const uint8_t* packed, uint32_t packed_size); |
| 56 | void blob_from_msgpack(const uint8_t* packed, uint32_t packed_size, as_particle** pp); |
| 57 | |
| 58 | // Handle on-device "flat" format. |
| 59 | const uint8_t* blob_skip_flat(const uint8_t* flat, const uint8_t* end); |
| 60 | const uint8_t* blob_cast_from_flat(const uint8_t* flat, const uint8_t* end, as_particle** pp); |
| 61 | const uint8_t* blob_from_flat(const uint8_t* flat, const uint8_t* end, as_particle** pp); |
| 62 | uint32_t blob_flat_size(const as_particle* p); |
| 63 | uint32_t blob_to_flat(const as_particle* p, uint8_t* flat); |
| 64 | |