PostGIS  2.2.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  * Copyright (C) 2014 Sandro Santilli <strk@keybit.net>
7  * Copyright (C) 2013 Nicklas Avén
8  *
9  * This is free software; you can redistribute and/or modify it under
10  * the terms of the GNU General Public Licence. See the COPYING file.
11  *
12  **********************************************************************
13  *
14  * Handle varInt values, as described here:
15  * http://developers.google.com/protocol-buffers/docs/encoding#varints
16  *
17  **********************************************************************/
18 
19 #ifndef _LIBLWGEOM_VARINT_H
20 #define _LIBLWGEOM_VARINT_H 1
21 
22 #include <stdint.h>
23 #include <stdlib.h>
24 
25 
26 /* NEW SIGNATURES */
27 
28 size_t varint_u32_encode_buf(uint32_t val, uint8_t *buf);
29 size_t varint_s32_encode_buf(int32_t val, uint8_t *buf);
30 size_t varint_u64_encode_buf(uint64_t val, uint8_t *buf);
31 size_t varint_s64_encode_buf(int64_t val, uint8_t *buf);
32 int64_t varint_s64_decode(const uint8_t *the_start, const uint8_t *the_end, size_t *size);
33 uint64_t varint_u64_decode(const uint8_t *the_start, const uint8_t *the_end, size_t *size);
34 
35 size_t varint_size(const uint8_t *the_start, const uint8_t *the_end);
36 
37 /* Support from -INT{8,32,64}_MAX to INT{8,32,64}_MAX),
38  * e.g INT8_MIN is not supported in zigzag8 */
39 uint64_t zigzag64(int64_t val);
40 uint32_t zigzag32(int32_t val);
41 uint8_t zigzag8(int8_t val);
42 int64_t unzigzag64(uint64_t val);
43 int32_t unzigzag32(uint32_t val);
44 int8_t unzigzag8(uint8_t val);
45 
46 #endif /* !defined _LIBLWGEOM_VARINT_H */
47 
size_t varint_u32_encode_buf(uint32_t val, uint8_t *buf)
Definition: varint.c:75
int32_t unzigzag32(uint32_t val)
Definition: varint.c:188
size_t varint_size(const uint8_t *the_start, const uint8_t *the_end)
Definition: varint.c:139
int64_t varint_s64_decode(const uint8_t *the_start, const uint8_t *the_end, size_t *size)
Definition: varint.c:94
uint8_t zigzag8(int8_t val)
Definition: varint.c:174
uint64_t zigzag64(int64_t val)
Definition: varint.c:160
int64_t unzigzag64(uint64_t val)
Definition: varint.c:181
uint32_t zigzag32(int32_t val)
Definition: varint.c:167
size_t varint_s32_encode_buf(int32_t val, uint8_t *buf)
Definition: varint.c:87
uint64_t varint_u64_decode(const uint8_t *the_start, const uint8_t *the_end, size_t *size)
Definition: varint.c:101
size_t varint_u64_encode_buf(uint64_t val, uint8_t *buf)
Definition: varint.c:68
size_t varint_s64_encode_buf(int64_t val, uint8_t *buf)
Definition: varint.c:81
int8_t unzigzag8(uint8_t val)
Definition: varint.c:195