MobilityDB 1.3
Loading...
Searching...
No Matches
type_inout.h
Go to the documentation of this file.
1/*****************************************************************************
2 *
3 * This MobilityDB code is provided under The PostgreSQL License.
4 * Copyright (c) 2016-2025, Université libre de Bruxelles and MobilityDB
5 * contributors
6 *
7 * MobilityDB includes portions of PostGIS version 3 source code released
8 * under the GNU General Public License (GPLv2 or later).
9 * Copyright (c) 2001-2025, PostGIS contributors
10 *
11 * Permission to use, copy, modify, and distribute this software and its
12 * documentation for any purpose, without fee, and without a written
13 * agreement is hereby granted, provided that the above copyright notice and
14 * this paragraph and the following two paragraphs appear in all copies.
15 *
16 * IN NO EVENT SHALL UNIVERSITE LIBRE DE BRUXELLES BE LIABLE TO ANY PARTY FOR
17 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
18 * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
19 * EVEN IF UNIVERSITE LIBRE DE BRUXELLES HAS BEEN ADVISED OF THE POSSIBILITY
20 * OF SUCH DAMAGE.
21 *
22 * UNIVERSITE LIBRE DE BRUXELLES SPECIFICALLY DISCLAIMS ANY WARRANTIES,
23 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON
25 * AN "AS IS" BASIS, AND UNIVERSITE LIBRE DE BRUXELLES HAS NO OBLIGATIONS TO
26 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
27 *
28 *****************************************************************************/
29
35#ifndef __TYPE_INOUT_H__
36#define __TYPE_INOUT_H__
37
38/* PostgreSQL */
39#include <postgres.h>
40/* MEOS */
41#include "temporal/meos_catalog.h"
42
43/*****************************************************************************
44 * Definitions taken from the file liblwgeom_internal.h
45 *****************************************************************************/
46
47/* Any (absolute) values outside this range will be printed in scientific
48 * notation */
49#define OUT_MIN_DOUBLE 1E-8
50#define OUT_MAX_DOUBLE 1E15
51#define OUT_DEFAULT_DECIMAL_DIGITS 15
52
53/* 17 digits are sufficient for round-tripping
54 * Then we might add up to 8 (from OUT_MIN_DOUBLE) max leading zeroes (or
55 * 2 digits for "e+") */
56#define OUT_MAX_DIGITS 17 + 8
57
58/* Limit for the max amount of characters that a double can use, including dot
59 * and sign */
60#define OUT_MAX_BYTES_DOUBLE (1 /* Sign */ + 2 /* 0.x */ + OUT_MAX_DIGITS)
61#define OUT_DOUBLE_BUFFER_SIZE OUT_MAX_BYTES_DOUBLE + 1 /* +1 including NULL */
62
63/*****************************************************************************/
64
65extern uint8_t *datum_as_wkb(Datum value, meosType type, uint8_t variant,
66 size_t *size_out);
67extern char *datum_as_hexwkb(Datum value, meosType type, uint8_t variant,
68 size_t *size);
69
70extern Datum type_from_wkb(const uint8_t *wkb, size_t size, meosType type);
71extern Datum type_from_hexwkb(const char *hexwkb, size_t size, meosType type);
72
73/*****************************************************************************/
74
75#endif /* __TYPE_INOUT_H__ */
meosType
Enumeration that defines the built-in and temporal types used in MobilityDB.
Definition: meos_catalog.h:55
uintptr_t Datum
Definition: postgres_ext_defs.in.h:7
uint8_t * datum_as_wkb(Datum value, meosType type, uint8_t variant, size_t *size_out)
Return the WKB representation of a datum value.
Definition: type_out.c:2253
Datum type_from_hexwkb(const char *hexwkb, size_t size, meosType type)
Return a value from its HexEWKB representation.
Definition: type_in.c:2159
char * datum_as_hexwkb(Datum value, meosType type, uint8_t variant, size_t *size)
Return the HexWKB representation of a datum value.
Definition: type_out.c:2327
Datum type_from_wkb(const uint8_t *wkb, size_t size, meosType type)
Return a value from its Well-Known Binary (WKB) representation.
Definition: type_in.c:2092