annotate main/database/src/converters.cc @ 11697:9e624fa135a1 octave-forge

Added converters for geometric types.
author i7tiol
date Sun, 12 May 2013 10:19:34 +0000
parents abd563353849
children b3cbebad8a26
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
1 /*
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
2
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
3 Copyright (C) 2012, 2013 Olaf Till <i7tiol@t-online.de>
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
4
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
5 This program is free software; you can redistribute it and/or modify
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
7 the Free Software Foundation; either version 3 of the License, or
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
8 (at your option) any later version.
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
9
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
13 GNU General Public License for more details.
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
14
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
16 along with this program; If not, see <http://www.gnu.org/licenses/>.
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
17
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
18 */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
19
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
20 #include <octave/oct.h>
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
21 #include <octave/ov-struct.h>
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
22 #include <octave/ov-float.h>
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
23 #include <octave/ov-uint8.h>
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
24 #include <octave/Cell.h>
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
25
11553
35e9e4b6ab34 Fix configuration of postgresql include directories.
i7tiol
parents: 11480
diff changeset
26 #include <libpq-fe.h>
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
27
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
28 #include "converters.h"
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
29 #include "pq_connection.h"
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
30
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
31 // remember to adjust OCT_PQ_NUM_CONVERTERS in converters.h
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
32
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
33 // helper function for debugging
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
34 void print_conv (oct_pq_conv_t *c)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
35 {
11474
4fd39d36eff5 Retrieve element information of composite types already at connection time. Exclude negative element numbers (system columns) of composite types corresponding to tables.
i7tiol
parents: 11429
diff changeset
36 printf ("oid: %u, aoid: %u, c: %i, e: %i, nc: %i, n: %s, to_s: %i, to_b: %i, fr_s: %i, fr_b: %i,",
4fd39d36eff5 Retrieve element information of composite types already at connection time. Exclude negative element numbers (system columns) of composite types corresponding to tables.
i7tiol
parents: 11429
diff changeset
37 c->oid, c->aoid, c->is_composite, c->is_enum, c->is_not_constant, c->name.c_str (), c->to_octave_str ? 1 : 0, c->to_octave_bin ? 1 : 0, c->from_octave_str ? 1 : 0, c->from_octave_bin ? 1 : 0);
4fd39d36eff5 Retrieve element information of composite types already at connection time. Exclude negative element numbers (system columns) of composite types corresponding to tables.
i7tiol
parents: 11429
diff changeset
38
4fd39d36eff5 Retrieve element information of composite types already at connection time. Exclude negative element numbers (system columns) of composite types corresponding to tables.
i7tiol
parents: 11429
diff changeset
39 printf (", el_oids:");
11645
bd5a8f1bdfb8 Clean out harmless warnings and one unnecessarily returned column.
i7tiol
parents: 11553
diff changeset
40 for (size_t i = 0; i < c->el_oids.size (); i++)
11474
4fd39d36eff5 Retrieve element information of composite types already at connection time. Exclude negative element numbers (system columns) of composite types corresponding to tables.
i7tiol
parents: 11429
diff changeset
41 printf (" %u", c->el_oids[i]);
4fd39d36eff5 Retrieve element information of composite types already at connection time. Exclude negative element numbers (system columns) of composite types corresponding to tables.
i7tiol
parents: 11429
diff changeset
42
4fd39d36eff5 Retrieve element information of composite types already at connection time. Exclude negative element numbers (system columns) of composite types corresponding to tables.
i7tiol
parents: 11429
diff changeset
43 printf ("\n");
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
44 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
45
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
46 /* type bool */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
47
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
48 int to_octave_str_bool (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
49 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
50 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
51 bool tp = (*c == 't' ? true : false);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
52
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
53 ov = octave_value (tp);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
54
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
55 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
56 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
57
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
58 int to_octave_bin_bool (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
59 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
60 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
61 ov = octave_value (bool (*c));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
62
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
63 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
64 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
65
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
66 int from_octave_str_bool (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
67 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
68 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
69 bool b = ov.bool_value ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
70
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
71 if (error_state)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
72 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
73 error ("can not convert octave_value to bool value");
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
74 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
75 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
76
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
77 val.push_back (b ? '1' : '0');
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
78 val.push_back ('\0');
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
79
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
80 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
81 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
82
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
83 int from_octave_bin_bool (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
84 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
85 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
86 bool b = ov.bool_value ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
87
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
88 if (error_state)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
89 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
90 error ("can not convert octave_value to bool value");
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
91 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
92 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
93
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
94 val.push_back (char (b));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
95
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
96 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
97 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
98
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
99 oct_pq_conv_t conv_bool = {0, // 16
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
100 0, // 1000
11474
4fd39d36eff5 Retrieve element information of composite types already at connection time. Exclude negative element numbers (system columns) of composite types corresponding to tables.
i7tiol
parents: 11429
diff changeset
101 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
102 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
103 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
104 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
105 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
106 "bool",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
107 &to_octave_str_bool,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
108 &to_octave_bin_bool,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
109 &from_octave_str_bool,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
110 &from_octave_bin_bool};
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
111
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
112 /* end type bool */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
113
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
114 /* type oid */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
115
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
116 int to_octave_str_oid (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
117 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
118 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
119 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
120 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
121
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
122 int to_octave_bin_oid (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
123 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
124 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
125 ov = octave_value (octave_uint32 (be32toh (*((uint32_t *) c))));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
126
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
127 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
128 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
129
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
130 int from_octave_str_oid (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
131 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
132 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
133 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
134 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
135
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
136 int from_octave_bin_oid (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
137 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
138 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
139 uint32_t oid = ov.uint_value ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
140
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
141 if (error_state)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
142 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
143 error ("can not convert octave_value to oid value");
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
144 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
145 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
146
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
147 OCT_PQ_PUT(val, uint32_t, htobe32 (oid))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
148
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
149 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
150 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
151
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
152 oct_pq_conv_t conv_oid = {0, // 26
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
153 0,
11474
4fd39d36eff5 Retrieve element information of composite types already at connection time. Exclude negative element numbers (system columns) of composite types corresponding to tables.
i7tiol
parents: 11429
diff changeset
154 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
155 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
156 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
157 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
158 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
159 "oid",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
160 &to_octave_str_oid,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
161 &to_octave_bin_oid,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
162 &from_octave_str_oid,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
163 &from_octave_bin_oid};
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
164
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
165 /* end type oid */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
166
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
167 /* type float8 */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
168
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
169 int to_octave_str_float8 (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
170 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
171 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
172 // not implemented
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
173
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
174 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
175 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
176
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
177 int to_octave_bin_float8 (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
178 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
179 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
180 union
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
181 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
182 double d;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
183 int64_t i;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
184 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
185 swap;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
186
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
187 swap.i = be64toh (*((int64_t *) c));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
188
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
189 ov = octave_value (swap.d);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
190
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
191 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
192 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
193
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
194 int from_octave_str_float8 (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
195 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
196 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
197 // not implemented
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
198
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
199 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
200 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
201
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
202 int from_octave_bin_float8 (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
203 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
204 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
205 union
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
206 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
207 double d;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
208 int64_t i;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
209 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
210 swap;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
211
11655
6bbb1584d933 More efficient code order in float converters (probably useless with -O0).
i7tiol
parents: 11645
diff changeset
212 swap.d = ov.double_value ();
6bbb1584d933 More efficient code order in float converters (probably useless with -O0).
i7tiol
parents: 11645
diff changeset
213
6bbb1584d933 More efficient code order in float converters (probably useless with -O0).
i7tiol
parents: 11645
diff changeset
214 if (error_state)
6bbb1584d933 More efficient code order in float converters (probably useless with -O0).
i7tiol
parents: 11645
diff changeset
215 {
6bbb1584d933 More efficient code order in float converters (probably useless with -O0).
i7tiol
parents: 11645
diff changeset
216 error ("can not convert octave_value to float8 value");
6bbb1584d933 More efficient code order in float converters (probably useless with -O0).
i7tiol
parents: 11645
diff changeset
217 return 1;
6bbb1584d933 More efficient code order in float converters (probably useless with -O0).
i7tiol
parents: 11645
diff changeset
218 }
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
219
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
220 OCT_PQ_PUT(val, int64_t, htobe64 (swap.i))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
221
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
222 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
223 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
224
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
225 oct_pq_conv_t conv_float8 = {0, // 701
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
226 0, // 1022
11474
4fd39d36eff5 Retrieve element information of composite types already at connection time. Exclude negative element numbers (system columns) of composite types corresponding to tables.
i7tiol
parents: 11429
diff changeset
227 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
228 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
229 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
230 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
231 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
232 "float8",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
233 &to_octave_str_float8,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
234 &to_octave_bin_float8,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
235 &from_octave_str_float8,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
236 &from_octave_bin_float8};
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
237
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
238 /* end type float8 */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
239
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
240 /* type float4 */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
241
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
242 int to_octave_str_float4 (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
243 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
244 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
245 // not implemented
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
246
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
247 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
248 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
249
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
250 int to_octave_bin_float4 (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
251 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
252 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
253 union
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
254 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
255 float f;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
256 int32_t i;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
257 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
258 swap;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
259
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
260 swap.i = be32toh (*((int32_t *) c));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
261
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
262 ov = octave_value (swap.f);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
263
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
264 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
265 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
266
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
267 int from_octave_str_float4 (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
268 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
269 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
270 // not implemented
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
271
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
272 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
273 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
274
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
275 int from_octave_bin_float4 (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
276 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
277 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
278 union
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
279 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
280 float f;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
281 int32_t i;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
282 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
283 swap;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
284
11655
6bbb1584d933 More efficient code order in float converters (probably useless with -O0).
i7tiol
parents: 11645
diff changeset
285 swap.f = ov.float_value ();
6bbb1584d933 More efficient code order in float converters (probably useless with -O0).
i7tiol
parents: 11645
diff changeset
286
6bbb1584d933 More efficient code order in float converters (probably useless with -O0).
i7tiol
parents: 11645
diff changeset
287 if (error_state)
6bbb1584d933 More efficient code order in float converters (probably useless with -O0).
i7tiol
parents: 11645
diff changeset
288 {
6bbb1584d933 More efficient code order in float converters (probably useless with -O0).
i7tiol
parents: 11645
diff changeset
289 error ("can not convert octave_value to float4 value");
6bbb1584d933 More efficient code order in float converters (probably useless with -O0).
i7tiol
parents: 11645
diff changeset
290 return 1;
6bbb1584d933 More efficient code order in float converters (probably useless with -O0).
i7tiol
parents: 11645
diff changeset
291 }
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
292
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
293 OCT_PQ_PUT(val, int32_t, htobe32 (swap.i))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
294
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
295 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
296 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
297
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
298 oct_pq_conv_t conv_float4 = {0,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
299 0,
11474
4fd39d36eff5 Retrieve element information of composite types already at connection time. Exclude negative element numbers (system columns) of composite types corresponding to tables.
i7tiol
parents: 11429
diff changeset
300 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
301 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
302 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
303 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
304 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
305 "float4",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
306 &to_octave_str_float4,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
307 &to_octave_bin_float4,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
308 &from_octave_str_float4,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
309 &from_octave_bin_float4};
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
310
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
311 /* end type float4 */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
312
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
313 /* type bytea */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
314
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
315 int to_octave_str_bytea (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
316 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
317 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
318 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
319 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
320
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
321 int to_octave_bin_bytea (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
322 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
323 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
324 uint8NDArray m (dim_vector (nb, 1));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
325
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
326 uint8_t *p = (uint8_t *) m.fortran_vec ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
327 for (octave_idx_type i = 0; i < nb; i++)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
328 *(p++) = uint8_t (*(c++));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
329
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
330 ov = octave_value (m);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
331
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
332 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
333 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
334
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
335 int from_octave_str_bytea (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
336 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
337 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
338 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
339 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
340
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
341 int from_octave_bin_bytea (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
342 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
343 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
344 uint8NDArray b = ov.uint8_array_value ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
345
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
346 if (! error_state)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
347 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
348 dim_vector dv = b.dims ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
349 if (dv.length () > 2 || (dv(0) > 1 && dv(1) > 1))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
350 error ("bytea representation must be one-dimensional");
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
351 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
352
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
353 if (error_state)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
354 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
355 error ("can not convert octave_value to bytea representation");
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
356 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
357 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
358
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
359 octave_idx_type nl = b.numel ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
360
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
361 for (int i = 0; i < nl; i++)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
362 val.push_back (b(i).value ());
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
363
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
364 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
365 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
366
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
367 oct_pq_conv_t conv_bytea = {0,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
368 0,
11474
4fd39d36eff5 Retrieve element information of composite types already at connection time. Exclude negative element numbers (system columns) of composite types corresponding to tables.
i7tiol
parents: 11429
diff changeset
369 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
370 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
371 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
372 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
373 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
374 "bytea",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
375 &to_octave_str_bytea,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
376 &to_octave_bin_bytea,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
377 &from_octave_str_bytea,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
378 &from_octave_bin_bytea};
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
379
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
380 /* end type bytea */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
381
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
382 /* type text */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
383
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
384 int to_octave_str_text (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
385 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
386 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
387 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
388 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
389
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
390 int to_octave_bin_text (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
391 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
392 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
393 std::string s (c, nb);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
395 ov = octave_value (s);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
396
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
397 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
398 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
399
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
400 int from_octave_str_text (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
401 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
402 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
403 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
404 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
405
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
406 int from_octave_bin_text (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
407 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
408 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
409 std::string s = ov.string_value ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
410
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
411 if (error_state)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
412 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
413 error ("can not convert octave_value to string");
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
414 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
415 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
416
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
417 octave_idx_type l = s.size ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
418
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
419 for (int i = 0; i < l; i++)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
420 val.push_back (s[i]);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
421
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
422 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
423 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
424
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
425 oct_pq_conv_t conv_text = {0,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
426 0,
11474
4fd39d36eff5 Retrieve element information of composite types already at connection time. Exclude negative element numbers (system columns) of composite types corresponding to tables.
i7tiol
parents: 11429
diff changeset
427 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
428 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
429 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
430 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
431 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
432 "text",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
433 &to_octave_str_text,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
434 &to_octave_bin_text,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
435 &from_octave_str_text,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
436 &from_octave_bin_text};
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
437
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
438 /* end type text */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
439
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
440 /* type varchar */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
441
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
442 oct_pq_conv_t conv_varchar = {0,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
443 0,
11474
4fd39d36eff5 Retrieve element information of composite types already at connection time. Exclude negative element numbers (system columns) of composite types corresponding to tables.
i7tiol
parents: 11429
diff changeset
444 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
445 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
446 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
447 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
448 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
449 "varchar",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
450 &to_octave_str_text,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
451 &to_octave_bin_text,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
452 &from_octave_str_text,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
453 &from_octave_bin_text};
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
454
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
455 /* end type varchar */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
456
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
457 /* type bpchar */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
458
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
459 oct_pq_conv_t conv_bpchar = {0,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
460 0,
11474
4fd39d36eff5 Retrieve element information of composite types already at connection time. Exclude negative element numbers (system columns) of composite types corresponding to tables.
i7tiol
parents: 11429
diff changeset
461 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
462 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
463 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
464 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
465 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
466 "bpchar",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
467 &to_octave_str_text,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
468 &to_octave_bin_text,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
469 &from_octave_str_text,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
470 &from_octave_bin_text};
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
471
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
472 /* end type bpchar */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
473
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
474 /* type name */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
475
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
476 oct_pq_conv_t conv_name = {0,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
477 0,
11474
4fd39d36eff5 Retrieve element information of composite types already at connection time. Exclude negative element numbers (system columns) of composite types corresponding to tables.
i7tiol
parents: 11429
diff changeset
478 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
479 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
480 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
481 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
482 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
483 "name",
11658
f9f1af45e49a Some cleanup in 'name' converters.
i7tiol
parents: 11657
diff changeset
484 &to_octave_str_text,
f9f1af45e49a Some cleanup in 'name' converters.
i7tiol
parents: 11657
diff changeset
485 &to_octave_bin_text,
f9f1af45e49a Some cleanup in 'name' converters.
i7tiol
parents: 11657
diff changeset
486 &from_octave_str_text,
f9f1af45e49a Some cleanup in 'name' converters.
i7tiol
parents: 11657
diff changeset
487 &from_octave_bin_text};
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
488
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
489 /* end type name */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
490
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
491 /* type int2 */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
492
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
493 int to_octave_str_int2 (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
494 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
495 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
496 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
497 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
498
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
499 int to_octave_bin_int2 (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
500 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
501 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
502 ov = octave_value (octave_int16 (int16_t (be16toh (*((int16_t *) c)))));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
503
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
504 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
505 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
506
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
507 int from_octave_str_int2 (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
508 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
509 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
510 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
511 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
512
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
513 int from_octave_bin_int2 (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
514 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
515 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
516 int16_t i2 = ov.int_value ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
517
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
518 if (error_state)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
519 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
520 error ("can not convert octave_value to int2 value");
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
521 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
522 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
523
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
524 OCT_PQ_PUT(val, int16_t, htobe16 (i2))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
525
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
526 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
527 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
528
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
529 oct_pq_conv_t conv_int2 = {0, // 26
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
530 0,
11474
4fd39d36eff5 Retrieve element information of composite types already at connection time. Exclude negative element numbers (system columns) of composite types corresponding to tables.
i7tiol
parents: 11429
diff changeset
531 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
532 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
533 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
534 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
535 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
536 "int2",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
537 &to_octave_str_int2,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
538 &to_octave_bin_int2,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
539 &from_octave_str_int2,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
540 &from_octave_bin_int2};
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
541
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
542
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
543 /* end type int2 */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
544
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
545 /* type int4 */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
546
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
547 int to_octave_str_int4 (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
548 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
549 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
550 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
551 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
552
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
553 int to_octave_bin_int4 (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
554 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
555 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
556 ov = octave_value (octave_int32 (int32_t (be32toh (*((int32_t *) c)))));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
557
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
558 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
559 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
560
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
561 int from_octave_str_int4 (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
562 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
563 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
564 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
565 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
566
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
567 int from_octave_bin_int4 (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
568 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
569 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
570 int32_t i4 = ov.int_value ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
571
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
572 if (error_state)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
573 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
574 error ("can not convert octave_value to int4 value");
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
575 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
576 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
577
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
578 OCT_PQ_PUT(val, int32_t, htobe32 (i4))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
579
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
580 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
581 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
582
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
583 oct_pq_conv_t conv_int4 = {0,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
584 0,
11474
4fd39d36eff5 Retrieve element information of composite types already at connection time. Exclude negative element numbers (system columns) of composite types corresponding to tables.
i7tiol
parents: 11429
diff changeset
585 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
586 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
587 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
588 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
589 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
590 "int4",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
591 &to_octave_str_int4,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
592 &to_octave_bin_int4,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
593 &from_octave_str_int4,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
594 &from_octave_bin_int4};
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
595
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
596
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
597 /* end type int4 */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
598
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
599 /* type int8 */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
600
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
601 int to_octave_str_int8 (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
602 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
603 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
604 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
605 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
606
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
607 int to_octave_bin_int8 (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
608 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
609 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
610 ov = octave_value (octave_int64 (int64_t (be64toh (*((int64_t *) c)))));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
611
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
612 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
613 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
614
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
615 int from_octave_str_int8 (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
616 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
617 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
618 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
619 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
620
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
621 int from_octave_bin_int8 (const octave_pq_connection &conn,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
622 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
623 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
624 int64_t i8 = ov.int64_scalar_value ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
625
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
626 if (error_state)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
627 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
628 error ("can not convert octave_value to int8 value");
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
629 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
630 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
631
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
632 OCT_PQ_PUT(val, int64_t, htobe64 (i8))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
633
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
634 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
635 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
636
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
637 oct_pq_conv_t conv_int8 = {0,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
638 0,
11474
4fd39d36eff5 Retrieve element information of composite types already at connection time. Exclude negative element numbers (system columns) of composite types corresponding to tables.
i7tiol
parents: 11429
diff changeset
639 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
640 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
641 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
642 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
643 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
644 "int8",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
645 &to_octave_str_int8,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
646 &to_octave_bin_int8,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
647 &from_octave_str_int8,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
648 &from_octave_bin_int8};
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
649
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
650
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
651 /* end type int8 */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
652
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
653 /* type money */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
654
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
655 oct_pq_conv_t conv_money = {0,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
656 0,
11474
4fd39d36eff5 Retrieve element information of composite types already at connection time. Exclude negative element numbers (system columns) of composite types corresponding to tables.
i7tiol
parents: 11429
diff changeset
657 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
658 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
659 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
660 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
661 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
662 "money",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
663 &to_octave_str_int8,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
664 &to_octave_bin_int8,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
665 &from_octave_str_int8,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
666 &from_octave_bin_int8};
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
667
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
668 /* end type money */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
669
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
670 // helpers for time types
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
671
11667
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
672 static inline octave_value time_8byte_to_octave (const char *c,
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
673 const bool &int_dt)
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
674 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
675 if (int_dt)
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
676 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
677 return octave_value (octave_int64 (int64_t (be64toh (*((int64_t *) c)))));
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
678 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
679 else
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
680 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
681 union
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
682 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
683 double d;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
684 int64_t i;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
685 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
686 swap;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
687
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
688 swap.i = be64toh (*((int64_t *) c));
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
689
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
690 return octave_value (swap.d);
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
691 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
692 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
693
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
694 static inline int time_8byte_from_octave (const octave_value &ov,
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
695 oct_pq_dynvec_t &val,
11667
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
696 const bool &int_dt)
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
697 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
698 if (int_dt)
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
699 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
700 // don't convert automatically because of possible overflow
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
701 if (ov.is_float_type ())
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
702 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
703 error ("floating point octave_value provided for 8-byte time value, but postgresql is configured for int64");
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
704 return 1;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
705 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
706
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
707 int64_t i8 = ov.int64_scalar_value ();
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
708
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
709 if (error_state)
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
710 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
711 error ("can not convert octave_value to int64 time value");
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
712 return 1;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
713 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
714
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
715 OCT_PQ_PUT(val, int64_t, htobe64 (i8))
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
716
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
717 return 0;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
718 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
719 else
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
720 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
721 // don't convert automatically because of possible loss of accuracy
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
722 if (ov.is_integer_type ())
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
723 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
724 error ("integer type octave_value provided for 8-byte time value, but postgresql is configured for double");
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
725 return 1;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
726 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
727
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
728 union
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
729 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
730 double d;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
731 int64_t i;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
732 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
733 swap;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
734
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
735 swap.d = ov.double_value ();
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
736
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
737 if (error_state)
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
738 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
739 error ("can not convert octave_value to double time value");
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
740 return 1;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
741 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
742
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
743 OCT_PQ_PUT(val, int64_t, htobe64 (swap.i))
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
744
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
745 return 0;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
746 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
747 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
748
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
749 // end helpers for time types
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
750
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
751 /* type timestamp */
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
752
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
753 int to_octave_str_timestamp (const octave_pq_connection &conn,
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
754 const char *c, octave_value &ov, int nb)
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
755 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
756 return 1;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
757 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
758
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
759 int to_octave_bin_timestamp (const octave_pq_connection &conn,
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
760 const char *c, octave_value &ov, int nb)
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
761 {
11667
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
762 ov = time_8byte_to_octave (c, conn.get_integer_datetimes ());
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
763
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
764 return 0;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
765 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
766
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
767 int from_octave_str_timestamp (const octave_pq_connection &conn,
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
768 const octave_value &ov, oct_pq_dynvec_t &val)
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
769 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
770 return 1;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
771 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
772
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
773 int from_octave_bin_timestamp (const octave_pq_connection &conn,
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
774 const octave_value &ov, oct_pq_dynvec_t &val)
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
775 {
11667
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
776 return (time_8byte_from_octave (ov, val, conn.get_integer_datetimes ()));
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
777 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
778
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
779 oct_pq_conv_t conv_timestamp = {0,
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
780 0,
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
781 oct_pq_el_oids_t (),
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
782 oct_pq_conv_cache_t (),
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
783 false,
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
784 false,
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
785 false,
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
786 "timestamp",
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
787 &to_octave_str_timestamp,
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
788 &to_octave_bin_timestamp,
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
789 &from_octave_str_timestamp,
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
790 &from_octave_bin_timestamp};
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
791
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
792 /* end type timestamp */
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
793
11667
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
794 /* type timestamptz */
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
795
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
796 oct_pq_conv_t conv_timestamptz = {0,
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
797 0,
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
798 oct_pq_el_oids_t (),
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
799 oct_pq_conv_cache_t (),
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
800 false,
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
801 false,
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
802 false,
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
803 "timestamptz",
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
804 &to_octave_str_timestamp,
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
805 &to_octave_bin_timestamp,
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
806 &from_octave_str_timestamp,
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
807 &from_octave_bin_timestamp};
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
808
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
809 /* end type timestamptz */
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
810
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
811 /* type interval */
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
812
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
813 int to_octave_str_interval (const octave_pq_connection &conn,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
814 const char *c, octave_value &ov, int nb)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
815 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
816 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
817 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
818
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
819 int to_octave_bin_interval (const octave_pq_connection &conn,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
820 const char *c, octave_value &ov, int nb)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
821 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
822 Cell tp (dim_vector (3, 1));
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
823
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
824 tp(0) = time_8byte_to_octave (c, conn.get_integer_datetimes ());
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
825
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
826 c += 8;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
827
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
828 tp(1) = octave_value (octave_int32 (int32_t (be32toh (*((int32_t *) c)))));
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
829
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
830 c += 4;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
831
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
832 tp(2) = octave_value (octave_int32 (int32_t (be32toh (*((int32_t *) c)))));
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
833
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
834 ov = octave_value (tp);
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
835
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
836 return 0;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
837 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
838
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
839 int from_octave_str_interval (const octave_pq_connection &conn,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
840 const octave_value &ov, oct_pq_dynvec_t &val)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
841 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
842 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
843 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
844
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
845 int from_octave_bin_interval (const octave_pq_connection &conn,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
846 const octave_value &ov, oct_pq_dynvec_t &val)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
847 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
848 Cell iv = ov.cell_value ();
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
849 if (error_state || iv.numel () != 3)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
850 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
851 error ("interval: can not convert octave_value to cell with 3 elements");
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
852 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
853 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
854
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
855 if (time_8byte_from_octave (iv(0), val, conn.get_integer_datetimes ()))
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
856 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
857
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
858 for (int id = 1; id < 3; id++)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
859 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
860 int32_t i4 = iv(id).int_value ();
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
861
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
862 if (error_state)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
863 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
864 error ("interval: can not convert octave_value to int4 value");
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
865 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
866 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
867
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
868 OCT_PQ_PUT(val, int32_t, htobe32 (i4))
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
869 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
870
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
871 return 0;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
872 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
873
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
874 oct_pq_conv_t conv_interval = {0,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
875 0,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
876 oct_pq_el_oids_t (),
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
877 oct_pq_conv_cache_t (),
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
878 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
879 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
880 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
881 "interval",
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
882 &to_octave_str_interval,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
883 &to_octave_bin_interval,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
884 &from_octave_str_interval,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
885 &from_octave_bin_interval};
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
886
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
887 /* end type interval */
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
888
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
889 /* type time */
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
890
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
891 int to_octave_str_time (const octave_pq_connection &conn,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
892 const char *c, octave_value &ov, int nb)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
893 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
894 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
895 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
896
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
897 int to_octave_bin_time (const octave_pq_connection &conn,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
898 const char *c, octave_value &ov, int nb)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
899 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
900 ov = time_8byte_to_octave (c, conn.get_integer_datetimes ());
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
901
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
902 return 0;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
903 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
904
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
905 int from_octave_str_time (const octave_pq_connection &conn,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
906 const octave_value &ov, oct_pq_dynvec_t &val)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
907 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
908 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
909 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
910
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
911 int from_octave_bin_time (const octave_pq_connection &conn,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
912 const octave_value &ov, oct_pq_dynvec_t &val)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
913 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
914 return (time_8byte_from_octave (ov, val, conn.get_integer_datetimes ()));
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
915 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
916
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
917 oct_pq_conv_t conv_time = {0,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
918 0,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
919 oct_pq_el_oids_t (),
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
920 oct_pq_conv_cache_t (),
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
921 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
922 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
923 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
924 "time",
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
925 &to_octave_str_time,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
926 &to_octave_bin_time,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
927 &from_octave_str_time,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
928 &from_octave_bin_time};
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
929
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
930 /* end type time */
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
931
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
932 /* type timetz */
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
933
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
934 int to_octave_str_timetz (const octave_pq_connection &conn,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
935 const char *c, octave_value &ov, int nb)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
936 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
937 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
938 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
939
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
940 int to_octave_bin_timetz (const octave_pq_connection &conn,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
941 const char *c, octave_value &ov, int nb)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
942 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
943 Cell tp (dim_vector (2, 1));
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
944
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
945 tp(0) = time_8byte_to_octave (c, conn.get_integer_datetimes ());
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
946
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
947 c += 8;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
948
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
949 tp(1) = octave_value (octave_int32 (int32_t (be32toh (*((int32_t *) c)))));
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
950
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
951 ov = octave_value (tp);
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
952
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
953 return 0;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
954 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
955
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
956 int from_octave_str_timetz (const octave_pq_connection &conn,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
957 const octave_value &ov, oct_pq_dynvec_t &val)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
958 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
959 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
960 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
961
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
962 int from_octave_bin_timetz (const octave_pq_connection &conn,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
963 const octave_value &ov, oct_pq_dynvec_t &val)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
964 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
965 Cell iv = ov.cell_value ();
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
966 if (error_state || iv.numel () != 2)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
967 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
968 error ("timetz: can not convert octave_value to cell with 2 elements");
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
969 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
970 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
971
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
972 if (time_8byte_from_octave (iv(0), val, conn.get_integer_datetimes ()))
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
973 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
974
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
975 int32_t i4 = iv(1).int_value ();
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
976
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
977 if (error_state)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
978 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
979 error ("timetz: can not convert octave_value to int4 value");
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
980 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
981 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
982
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
983 OCT_PQ_PUT(val, int32_t, htobe32 (i4))
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
984
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
985 return 0;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
986 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
987
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
988 oct_pq_conv_t conv_timetz = {0,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
989 0,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
990 oct_pq_el_oids_t (),
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
991 oct_pq_conv_cache_t (),
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
992 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
993 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
994 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
995 "timetz",
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
996 &to_octave_str_timetz,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
997 &to_octave_bin_timetz,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
998 &from_octave_str_timetz,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
999 &from_octave_bin_timetz};
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1000
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1001 /* end type timetz */
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1002
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1003 /* type date */
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1004
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1005 int to_octave_str_date (const octave_pq_connection &conn,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1006 const char *c, octave_value &ov, int nb)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1007 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1008 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1009 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1010
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1011 int to_octave_bin_date (const octave_pq_connection &conn,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1012 const char *c, octave_value &ov, int nb)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1013 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1014 ov = octave_value (octave_int32 (int32_t (be32toh (*((int32_t *) c)))));
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1015
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1016 return 0;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1017 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1018
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1019 int from_octave_str_date (const octave_pq_connection &conn,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1020 const octave_value &ov, oct_pq_dynvec_t &val)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1021 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1022 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1023 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1024
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1025 int from_octave_bin_date (const octave_pq_connection &conn,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1026 const octave_value &ov, oct_pq_dynvec_t &val)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1027 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1028 int32_t i4 = ov.int_value ();
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1029
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1030 if (error_state)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1031 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1032 error ("date: can not convert octave_value to int4 value");
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1033 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1034 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1035
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1036 OCT_PQ_PUT(val, int32_t, htobe32 (i4))
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1037
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1038 return 0;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1039 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1040
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1041 oct_pq_conv_t conv_date = {0,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1042 0,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1043 oct_pq_el_oids_t (),
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1044 oct_pq_conv_cache_t (),
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1045 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1046 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1047 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1048 "date",
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1049 &to_octave_str_date,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1050 &to_octave_bin_date,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1051 &from_octave_str_date,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1052 &from_octave_bin_date};
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1053
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1054 /* end type date */
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1055
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1056 /* type point */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1057
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1058 int to_octave_str_point (const octave_pq_connection &conn,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1059 const char *c, octave_value &ov, int nb)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1060 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1061 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1062 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1063
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1064 int to_octave_bin_point (const octave_pq_connection &conn,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1065 const char *c, octave_value &ov, int nb)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1066 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1067 ColumnVector m (2);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1068
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1069 union
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1070 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1071 double d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1072 int64_t i;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1073 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1074 swap;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1075
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1076 for (int id = 0; id < 2; id++, c += 8)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1077 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1078 swap.i = be64toh (*((int64_t *) c));
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1079
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1080 m(id) = swap.d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1081 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1082
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1083 ov = octave_value (m);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1084
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1085 return 0;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1086 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1087
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1088 int from_octave_str_point (const octave_pq_connection &conn,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1089 const octave_value &ov, oct_pq_dynvec_t &val)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1090 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1091 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1092 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1093
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1094 int from_octave_bin_point (const octave_pq_connection &conn,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1095 const octave_value &ov, oct_pq_dynvec_t &val)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1096 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1097 NDArray m = ov.array_value ();
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1098
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1099 if (error_state || m.numel () != 2)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1100 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1101 error ("can not convert octave_value to point representation");
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1102 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1103 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1104
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1105 union
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1106 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1107 double d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1108 int64_t i;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1109 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1110 swap;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1111
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1112 for (int id = 0; id < 2; id++)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1113 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1114 swap.d = m(id);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1115
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1116 OCT_PQ_PUT(val, int64_t, htobe64 (swap.i))
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1117 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1118
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1119 return 0;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1120 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1121
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1122 oct_pq_conv_t conv_point = {0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1123 0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1124 oct_pq_el_oids_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1125 oct_pq_conv_cache_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1126 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1127 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1128 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1129 "point",
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1130 &to_octave_str_point,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1131 &to_octave_bin_point,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1132 &from_octave_str_point,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1133 &from_octave_bin_point};
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1134
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1135 /* end type point */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1136
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1137 /* type lseg */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1138
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1139 int to_octave_str_lseg (const octave_pq_connection &conn,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1140 const char *c, octave_value &ov, int nb)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1141 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1142 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1143 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1144
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1145 int to_octave_bin_lseg (const octave_pq_connection &conn,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1146 const char *c, octave_value &ov, int nb)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1147 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1148 Matrix m (2, 2);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1149
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1150 union
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1151 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1152 double d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1153 int64_t i;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1154 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1155 swap;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1156
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1157 for (int id = 0; id < 4; id++, c += 8)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1158 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1159 swap.i = be64toh (*((int64_t *) c));
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1160
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1161 m(id) = swap.d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1162 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1163
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1164 ov = octave_value (m);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1165
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1166 return 0;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1167 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1168
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1169 int from_octave_str_lseg (const octave_pq_connection &conn,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1170 const octave_value &ov, oct_pq_dynvec_t &val)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1171 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1172 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1173 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1174
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1175 int from_octave_bin_lseg (const octave_pq_connection &conn,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1176 const octave_value &ov, oct_pq_dynvec_t &val)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1177 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1178 NDArray m = ov.array_value ();
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1179
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1180 if (error_state || m.numel () != 4)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1181 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1182 error ("can not convert octave_value to 4 doubles");
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1183 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1184 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1185
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1186 union
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1187 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1188 double d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1189 int64_t i;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1190 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1191 swap;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1192
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1193 for (int id = 0; id < 4; id++)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1194 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1195 swap.d = m(id);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1196
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1197 OCT_PQ_PUT(val, int64_t, htobe64 (swap.i))
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1198 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1199
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1200 return 0;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1201 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1202
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1203 oct_pq_conv_t conv_lseg = {0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1204 0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1205 oct_pq_el_oids_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1206 oct_pq_conv_cache_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1207 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1208 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1209 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1210 "lseg",
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1211 &to_octave_str_lseg,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1212 &to_octave_bin_lseg,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1213 &from_octave_str_lseg,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1214 &from_octave_bin_lseg};
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1215
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1216 /* end type lseg */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1217
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1218 /* type line */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1219
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1220 oct_pq_conv_t conv_line = {0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1221 0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1222 oct_pq_el_oids_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1223 oct_pq_conv_cache_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1224 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1225 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1226 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1227 "line",
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1228 &to_octave_str_lseg,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1229 &to_octave_bin_lseg,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1230 &from_octave_str_lseg,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1231 &from_octave_bin_lseg};
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1232
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1233 /* end type line */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1234
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1235 /* type box */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1236
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1237 oct_pq_conv_t conv_box = {0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1238 0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1239 oct_pq_el_oids_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1240 oct_pq_conv_cache_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1241 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1242 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1243 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1244 "box",
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1245 &to_octave_str_lseg,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1246 &to_octave_bin_lseg,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1247 &from_octave_str_lseg,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1248 &from_octave_bin_lseg};
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1249
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1250 /* end type box */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1251
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1252 /* type circle */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1253
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1254 int to_octave_str_circle (const octave_pq_connection &conn,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1255 const char *c, octave_value &ov, int nb)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1256 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1257 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1258 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1259
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1260 int to_octave_bin_circle (const octave_pq_connection &conn,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1261 const char *c, octave_value &ov, int nb)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1262 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1263 ColumnVector m (3);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1264
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1265 union
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1266 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1267 double d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1268 int64_t i;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1269 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1270 swap;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1271
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1272 for (int id = 0; id < 3; id++, c += 8)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1273 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1274 swap.i = be64toh (*((int64_t *) c));
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1275
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1276 m(id) = swap.d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1277 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1278
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1279 ov = octave_value (m);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1280
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1281 return 0;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1282 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1283
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1284 int from_octave_str_circle (const octave_pq_connection &conn,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1285 const octave_value &ov, oct_pq_dynvec_t &val)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1286 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1287 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1288 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1289
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1290 int from_octave_bin_circle (const octave_pq_connection &conn,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1291 const octave_value &ov, oct_pq_dynvec_t &val)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1292 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1293 NDArray m = ov.array_value ();
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1294
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1295 if (error_state || m.numel () != 3)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1296 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1297 error ("can not convert octave_value to circle representation");
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1298 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1299 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1300
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1301 union
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1302 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1303 double d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1304 int64_t i;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1305 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1306 swap;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1307
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1308 for (int id = 0; id < 3; id++)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1309 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1310 swap.d = m(id);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1311
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1312 OCT_PQ_PUT(val, int64_t, htobe64 (swap.i))
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1313 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1314
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1315 return 0;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1316 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1317
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1318 oct_pq_conv_t conv_circle = {0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1319 0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1320 oct_pq_el_oids_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1321 oct_pq_conv_cache_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1322 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1323 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1324 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1325 "circle",
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1326 &to_octave_str_circle,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1327 &to_octave_bin_circle,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1328 &from_octave_str_circle,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1329 &from_octave_bin_circle};
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1330
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1331 /* end type circle */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1332
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1333 /* type polygon */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1334
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1335 int to_octave_str_polygon (const octave_pq_connection &conn,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1336 const char *c, octave_value &ov, int nb)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1337 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1338 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1339 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1340
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1341 int to_octave_bin_polygon (const octave_pq_connection &conn,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1342 const char *c, octave_value &ov, int nb)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1343 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1344 int32_t np = int32_t (be32toh (*((int32_t *) c)));
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1345
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1346 c += 4;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1347
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1348 Matrix m (2, np);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1349
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1350 union
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1351 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1352 double d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1353 int64_t i;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1354 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1355 swap;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1356
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1357 for (int id = 0; id < np * 2; id++, c += 8)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1358 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1359 swap.i = be64toh (*((int64_t *) c));
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1360
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1361 m(id) = swap.d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1362 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1363
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1364 ov = octave_value (m);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1365
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1366 return 0;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1367 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1368
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1369 int from_octave_str_polygon (const octave_pq_connection &conn,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1370 const octave_value &ov, oct_pq_dynvec_t &val)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1371 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1372 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1373 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1374
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1375 int from_octave_bin_polygon (const octave_pq_connection &conn,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1376 const octave_value &ov, oct_pq_dynvec_t &val)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1377 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1378 octave_idx_type nel;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1379
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1380 NDArray m = ov.array_value ();
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1381
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1382 if (error_state || (nel = m.numel ()) % 2)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1383 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1384 error ("can not convert octave_value to polygon representation");
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1385 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1386 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1387
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1388 union
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1389 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1390 double d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1391 int64_t i;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1392 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1393 swap;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1394
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1395 int32_t np = nel / 2;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1396
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1397 OCT_PQ_PUT(val, int32_t, htobe32 (np))
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1398
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1399 for (int id = 0; id < nel; id++)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1400 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1401 swap.d = m(id);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1402
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1403 OCT_PQ_PUT(val, int64_t, htobe64 (swap.i))
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1404 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1405
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1406 return 0;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1407 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1408
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1409 oct_pq_conv_t conv_polygon = {0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1410 0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1411 oct_pq_el_oids_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1412 oct_pq_conv_cache_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1413 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1414 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1415 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1416 "polygon",
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1417 &to_octave_str_polygon,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1418 &to_octave_bin_polygon,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1419 &from_octave_str_polygon,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1420 &from_octave_bin_polygon};
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1421
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1422 /* end type polygon */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1423
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1424 /* type path */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1425
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1426 int to_octave_str_path (const octave_pq_connection &conn,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1427 const char *c, octave_value &ov, int nb)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1428 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1429 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1430 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1431
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1432 int to_octave_bin_path (const octave_pq_connection &conn,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1433 const char *c, octave_value &ov, int nb)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1434 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1435 bool closed = bool (*(c++));
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1436
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1437 int32_t np = int32_t (be32toh (*((int32_t *) c)));
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1438
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1439 c += 4;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1440
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1441 Matrix m (2, np);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1442
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1443 union
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1444 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1445 double d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1446 int64_t i;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1447 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1448 swap;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1449
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1450 for (int id = 0; id < np * 2; id++, c += 8)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1451 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1452 swap.i = be64toh (*((int64_t *) c));
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1453
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1454 m(id) = swap.d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1455 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1456
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1457 octave_scalar_map tp;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1458 tp.assign ("closed", octave_value (closed));
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1459 tp.assign ("path", octave_value (m));
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1460
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1461 ov = octave_value (tp);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1462
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1463 return 0;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1464 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1465
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1466 int from_octave_str_path (const octave_pq_connection &conn,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1467 const octave_value &ov, oct_pq_dynvec_t &val)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1468 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1469 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1470 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1471
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1472 int from_octave_bin_path (const octave_pq_connection &conn,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1473 const octave_value &ov, oct_pq_dynvec_t &val)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1474 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1475 octave_scalar_map tp = ov.scalar_map_value ();
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1476 if (error_state || ! tp.isfield ("closed") || ! tp.isfield ("path"))
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1477 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1478 error ("can not convert octave_value to path representation");
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1479 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1480 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1481
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1482 octave_idx_type nel;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1483
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1484 char closed = char (tp.contents ("closed").bool_value ());
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1485
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1486 NDArray m = tp.contents ("path").array_value ();
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1487
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1488 if (error_state || (nel = m.numel ()) % 2)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1489 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1490 error ("can not convert octave_value to path representation");
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1491 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1492 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1493
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1494 union
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1495 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1496 double d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1497 int64_t i;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1498 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1499 swap;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1500
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1501 int32_t np = nel / 2;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1502
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1503 val.push_back (closed);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1504
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1505 OCT_PQ_PUT(val, int32_t, htobe32 (np))
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1506
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1507 for (int id = 0; id < nel; id++)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1508 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1509 swap.d = m(id);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1510
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1511 OCT_PQ_PUT(val, int64_t, htobe64 (swap.i))
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1512 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1513
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1514 return 0;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1515 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1516
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1517 oct_pq_conv_t conv_path = {0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1518 0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1519 oct_pq_el_oids_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1520 oct_pq_conv_cache_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1521 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1522 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1523 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1524 "path",
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1525 &to_octave_str_path,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1526 &to_octave_bin_path,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1527 &from_octave_str_path,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1528 &from_octave_bin_path};
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1529
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1530 /* end type path */
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1531
11429
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
1532 oct_pq_conv_t *t_conv_ptrs[OCT_PQ_NUM_CONVERTERS] = {&conv_bool,
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
1533 &conv_oid,
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
1534 &conv_float8,
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
1535 &conv_float4,
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
1536 &conv_text,
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
1537 &conv_varchar,
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
1538 &conv_bpchar,
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
1539 &conv_name,
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
1540 &conv_bytea,
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
1541 &conv_int2,
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
1542 &conv_int4,
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
1543 &conv_int8,
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
1544 &conv_money,
11667
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
1545 &conv_timestamp,
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1546 &conv_timestamptz,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1547 &conv_interval,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1548 &conv_time,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1549 &conv_timetz,
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1550 &conv_date,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1551 &conv_point,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1552 &conv_lseg,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1553 &conv_line,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1554 &conv_box,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1555 &conv_circle,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1556 &conv_polygon,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1557 &conv_path};
11429
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
1558
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
1559 oct_pq_conv_ptrs_t conv_ptrs (OCT_PQ_NUM_CONVERTERS, t_conv_ptrs);