1/*
2 * particle_integer.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 INTEGER particle interface function declarations are in this header file
30// since INTEGER functions are used by other particles derived from INTEGER.
31
32// Destructor, etc.
33void integer_destruct(as_particle *p);
34uint32_t integer_size(const as_particle *p);
35
36// Handle "wire" format.
37int32_t integer_concat_size_from_wire(as_particle_type wire_type, const uint8_t *wire_value, uint32_t value_size, as_particle **pp);
38int integer_append_from_wire(as_particle_type wire_type, const uint8_t *wire_value, uint32_t value_size, as_particle **pp);
39int integer_prepend_from_wire(as_particle_type wire_type, const uint8_t *wire_value, uint32_t value_size, as_particle **pp);
40int integer_incr_from_wire(as_particle_type wire_type, const uint8_t *wire_value, uint32_t value_size, as_particle **pp);
41int32_t integer_size_from_wire(const uint8_t *wire_value, uint32_t value_size);
42int integer_from_wire(as_particle_type wire_type, const uint8_t *wire_value, uint32_t value_size, as_particle **pp);
43int integer_compare_from_wire(const as_particle *p, as_particle_type wire_type, const uint8_t *wire_value, uint32_t value_size);
44uint32_t integer_wire_size(const as_particle *p);
45uint32_t integer_to_wire(const as_particle *p, uint8_t *wire);
46
47// Handle as_val translation.
48uint32_t integer_size_from_asval(const as_val *val);
49void integer_from_asval(const as_val *val, as_particle **pp);
50as_val *integer_to_asval(const as_particle *p);
51uint32_t integer_asval_wire_size(const as_val *val);
52uint32_t integer_asval_to_wire(const as_val *val, uint8_t *wire);
53
54// Handle msgpack translation.
55uint32_t integer_size_from_msgpack(const uint8_t *packed, uint32_t packed_size);
56void integer_from_msgpack(const uint8_t *packed, uint32_t packed_size, as_particle **pp);
57