MobilityDB  1.0
timetypes.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * This MobilityDB code is provided under The PostgreSQL License.
4  *
5  * Copyright (c) 2016-2021, Université libre de Bruxelles and MobilityDB
6  * contributors
7  *
8  * MobilityDB includes portions of PostGIS version 3 source code released
9  * under the GNU General Public License (GPLv2 or later).
10  * Copyright (c) 2001-2021, PostGIS contributors
11  *
12  * Permission to use, copy, modify, and distribute this software and its
13  * documentation for any purpose, without fee, and without a written
14  * agreement is hereby granted, provided that the above copyright notice and
15  * this paragraph and the following two paragraphs appear in all copies.
16  *
17  * IN NO EVENT SHALL UNIVERSITE LIBRE DE BRUXELLES BE LIABLE TO ANY PARTY FOR
18  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
19  * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
20  * EVEN IF UNIVERSITE LIBRE DE BRUXELLES HAS BEEN ADVISED OF THE POSSIBILITY
21  * OF SUCH DAMAGE.
22  *
23  * UNIVERSITE LIBRE DE BRUXELLES SPECIFICALLY DISCLAIMS ANY WARRANTIES,
24  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25  * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON
26  * AN "AS IS" BASIS, AND UNIVERSITE LIBRE DE BRUXELLES HAS NO OBLIGATIONS TO
27  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 
28  *
29  *****************************************************************************/
30 
42 #ifndef __TIMETYPES_H__
43 #define __TIMETYPES_H__
44 
45 #include <postgres.h>
46 #include <access/stratnum.h>
47 #include <utils/timestamp.h>
48 
52 typedef struct
53 {
54  TimestampTz lower;
55  TimestampTz upper;
56  bool lower_inc;
57  bool upper_inc;
58 } Period;
59 
63 typedef struct
64 {
65  TimestampTz t;
66  bool inclusive;
67  bool lower;
68 } PeriodBound;
69 
73 typedef struct
74 {
75  int32 vl_len_;
76  int32 count;
78  TimestampTz elems[1];
79 } TimestampSet;
80 
84 typedef struct
85 {
86  int32 vl_len_;
87  int32 count;
89  Period elems[1];
90 } PeriodSet;
91 
92 /*
93  * fmgr macros for time types
94  */
95 
96 #define DatumGetTimestampSet(X) ((TimestampSet *) DatumGetPointer(X))
97 #define TimestampSetGetDatum(X) PointerGetDatum(X)
98 #define PG_GETARG_TIMESTAMPSET(X) DatumGetTimestampSet(PG_GETARG_POINTER(X))
99 #define PG_RETURN_TIMESTAMPSET(X) PG_RETURN_POINTER(X)
100 
101 #define DatumGetPeriod(X) ((Period *) DatumGetPointer(X))
102 #define PeriodGetDatum(X) PointerGetDatum(X)
103 #define PG_GETARG_PERIOD(X) DatumGetPeriod(PG_GETARG_POINTER(X))
104 #define PG_RETURN_PERIOD(X) PG_RETURN_POINTER(X)
105 
106 #define DatumGetPeriodSet(X) ((PeriodSet *) DatumGetPointer(X))
107 #define PeriodSetGetDatum(X) PointerGetDatum(X)
108 #define PG_GETARG_PERIODSET(X) DatumGetPeriodSet(PG_GETARG_POINTER(X))
109 #define PG_RETURN_PERIODSET(X) PG_RETURN_POINTER(X)
110 
111 /*****************************************************************************/
112 
113 #endif
Structure to represent periods.
Definition: timetypes.h:52
TimestampTz upper
upper bound value
Definition: timetypes.h:55
Internal representation of either bound of a period (not what&#39;s on disk)
Definition: timetypes.h:63
int32 count
number of TimestampTz elements
Definition: timetypes.h:76
bool lower_inc
lower bound is inclusive (vs exclusive)
Definition: timetypes.h:56
Period period
bounding period
Definition: timetypes.h:88
int32 count
number of Period elements
Definition: timetypes.h:87
int32 vl_len_
varlena header (do not touch directly!)
Definition: timetypes.h:86
Period period
bounding period
Definition: timetypes.h:77
int32 vl_len_
varlena header (do not touch directly!)
Definition: timetypes.h:75
Structure to represent period sets.
Definition: timetypes.h:84
TimestampTz t
bound value
Definition: timetypes.h:65
TimestampTz lower
lower bound value
Definition: timetypes.h:54
Structure to represent timestamp sets.
Definition: timetypes.h:73
bool lower
this is the lower (vs upper) bound
Definition: timetypes.h:67
bool inclusive
bound is inclusive (vs exclusive)
Definition: timetypes.h:66
bool upper_inc
upper bound is inclusive (vs exclusive)
Definition: timetypes.h:57