PostGIS  2.5.7dev-r@@SVN_REVISION@@
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 
36 size_t varint_u32_encode_buf(uint32_t val, uint8_t *buf);
37 size_t varint_s32_encode_buf(int32_t val, uint8_t *buf);
38 size_t varint_u64_encode_buf(uint64_t val, uint8_t *buf);
39 size_t varint_s64_encode_buf(int64_t val, uint8_t *buf);
40 int64_t varint_s64_decode(const uint8_t *the_start, const uint8_t *the_end, size_t *size);
41 uint64_t varint_u64_decode(const uint8_t *the_start, const uint8_t *the_end, size_t *size);
42 
43 size_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 */
47 uint64_t zigzag64(int64_t val);
48 uint32_t zigzag32(int32_t val);
49 uint8_t zigzag8(int8_t val);
50 int64_t unzigzag64(uint64_t val);
51 int32_t unzigzag32(uint32_t val);
52 int8_t unzigzag8(uint8_t val);
53 
54 #endif /* !defined _LIBLWGEOM_VARINT_H */
55 
unsigned int uint32_t
Definition: uthash.h:78
unsigned char uint8_t
Definition: uthash.h:79
int64_t unzigzag64(uint64_t val)
Definition: varint.c:189
int32_t unzigzag32(uint32_t val)
Definition: varint.c:196
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:147
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:203
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:168
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:175
uint8_t zigzag8(int8_t val)
Definition: varint.c:182
size_t varint_u32_encode_buf(uint32_t val, uint8_t *buf)
Definition: varint.c:83