PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches
varint.h
Go to the documentation of this file.
1/**********************************************************************
2 *
3 * PostGIS - Spatial Types for PostgreSQL
4 * http://postgis.net
5 *
6 * PostGIS is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * PostGIS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with PostGIS. If not, see <http://www.gnu.org/licenses/>.
18 *
19 **********************************************************************
20 *
21 * Copyright (C) 2014 Sandro Santilli <strk@kbt.io>
22 * Copyright (C) 2013 Nicklas Avén
23 *
24 **********************************************************************/
25
26
27#ifndef _LIBLWGEOM_VARINT_H
28#define _LIBLWGEOM_VARINT_H 1
29
30#include <stdint.h>
31#include <stdlib.h>
32
33
34/* NEW SIGNATURES */
35
36size_t varint_u32_encode_buf(uint32_t val, uint8_t *buf);
37size_t varint_s32_encode_buf(int32_t val, uint8_t *buf);
38size_t varint_u64_encode_buf(uint64_t val, uint8_t *buf);
39size_t varint_s64_encode_buf(int64_t val, uint8_t *buf);
40int64_t varint_s64_decode(const uint8_t *the_start, const uint8_t *the_end, size_t *size);
41uint64_t varint_u64_decode(const uint8_t *the_start, const uint8_t *the_end, size_t *size);
42
43size_t varint_size(const uint8_t *the_start, const uint8_t *the_end);
44
45/* Support from -INT{8,32,64}_MAX to INT{8,32,64}_MAX),
46 * e.g INT8_MIN is not supported in zigzag8 */
47uint64_t zigzag64(int64_t val);
48uint32_t zigzag32(int32_t val);
49uint8_t zigzag8(int8_t val);
50int64_t unzigzag64(uint64_t val);
51int32_t unzigzag32(uint32_t val);
52int8_t unzigzag8(uint8_t val);
53
54#endif /* !defined _LIBLWGEOM_VARINT_H */
55
int64_t unzigzag64(uint64_t val)
Definition varint.c:190
int32_t unzigzag32(uint32_t val)
Definition varint.c:197
size_t varint_s32_encode_buf(int32_t val, uint8_t *buf)
Definition varint.c:95
size_t varint_size(const uint8_t *the_start, const uint8_t *the_end)
Definition varint.c:148
size_t varint_s64_encode_buf(int64_t val, uint8_t *buf)
Definition varint.c:89
int8_t unzigzag8(uint8_t val)
Definition varint.c:204
size_t varint_u64_encode_buf(uint64_t val, uint8_t *buf)
Definition varint.c:76
int64_t varint_s64_decode(const uint8_t *the_start, const uint8_t *the_end, size_t *size)
Definition varint.c:102
uint64_t zigzag64(int64_t val)
Definition varint.c:169
uint64_t varint_u64_decode(const uint8_t *the_start, const uint8_t *the_end, size_t *size)
Definition varint.c:109
uint32_t zigzag32(int32_t val)
Definition varint.c:176
uint8_t zigzag8(int8_t val)
Definition varint.c:183
size_t varint_u32_encode_buf(uint32_t val, uint8_t *buf)
Definition varint.c:83