annotate main/database/src/converters.cc @ 12720:52ca082757c2 octave-forge tip

Update copyright notices.
author i7tiol
date Sat, 27 Feb 2016 11:21:29 +0000
parents 1af86934c14e
children
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
12720
52ca082757c2 Update copyright notices.
i7tiol
parents: 12718
diff changeset
3 Copyright (C) 2012-2016 Olaf Till <i7tiol@t-online.de>
11394
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
12317
67adec29dee0 Applied Windows compatibility patch for John Donoghue.
i7tiol
parents: 11715
diff changeset
28 #ifdef __WIN32__
67adec29dee0 Applied Windows compatibility patch for John Donoghue.
i7tiol
parents: 11715
diff changeset
29 #include <winsock2.h>
67adec29dee0 Applied Windows compatibility patch for John Donoghue.
i7tiol
parents: 11715
diff changeset
30 #else
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
31 #include <sys/socket.h> // for AF_INET, needed in network address types
12317
67adec29dee0 Applied Windows compatibility patch for John Donoghue.
i7tiol
parents: 11715
diff changeset
32 #endif
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
33
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
34 #include "converters.h"
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
35 #include "pq_connection.h"
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
36 #include "error-helpers.h"
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
37
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
38 // remember to adjust OCT_PQ_NUM_CONVERTERS in converters.h
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
39
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
40 #define PGSQL_AF_INET6 (AF_INET + 1) // defined so in postgresql, no
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
41 // public header file available
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
42
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
43 // helper function for debugging
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
44 void print_conv (oct_pq_conv_t *c)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
45 {
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
46 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
47 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
48
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
49 printf (", el_oids:");
11645
bd5a8f1bdfb8 Clean out harmless warnings and one unnecessarily returned column.
i7tiol
parents: 11553
diff changeset
50 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
51 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
52
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
53 printf ("\n");
11394
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
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
56 /* type bool */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
57
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
58 int to_octave_str_bool (const octave_pq_connection_rep &conn,
11657
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 bool tp = (*c == 't' ? true : false);
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 ov = octave_value (tp);
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 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
66 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
67
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
68 int to_octave_bin_bool (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
69 const char *c, octave_value &ov, int nb)
11394
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 ov = octave_value (bool (*c));
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 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
74 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
75
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
76 int from_octave_str_bool (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
77 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
78 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
79 bool b, err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
80 SET_ERR (b = ov.bool_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
81
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
82 if (err)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
83 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
84 c_verror ("can not convert octave_value to bool value");
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
85 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
86 }
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 val.push_back (b ? '1' : '0');
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
89 val.push_back ('\0');
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
90
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
91 return 0;
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
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
94 int from_octave_bin_bool (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
95 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
96 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
97 bool b, err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
98 SET_ERR (b = ov.bool_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
99
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
100 if (err)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
101 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
102 c_verror ("can not convert octave_value to bool value");
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
103 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
104 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
105
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
106 val.push_back (char (b));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
107
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
108 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
109 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
110
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
111 oct_pq_conv_t conv_bool = {0, // 16
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
112 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
113 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
114 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
115 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
116 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
117 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
118 "bool",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
119 &to_octave_str_bool,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
120 &to_octave_bin_bool,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
121 &from_octave_str_bool,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
122 &from_octave_bin_bool};
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
123
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
124 /* end type bool */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
125
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
126 /* type oid */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
127
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
128 int to_octave_str_oid (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
129 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
130 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
131 return 1;
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
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
134 int to_octave_bin_oid (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
135 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
136 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
137 ov = octave_value (octave_uint32 (be32toh (*((uint32_t *) c))));
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 return 0;
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
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
142 int from_octave_str_oid (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
143 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
144 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
145 return 1;
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
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
148 int from_octave_bin_oid (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
149 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
150 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
151 uint32_t oid;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
152 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
153 SET_ERR (oid = ov.uint_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
154
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
155 if (err)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
156 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
157 c_verror ("can not convert octave_value to oid value");
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
158 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
159 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
160
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
161 OCT_PQ_PUT(val, uint32_t, htobe32 (oid))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
162
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
163 return 0;
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
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
166 oct_pq_conv_t conv_oid = {0, // 26
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
167 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
168 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
169 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
170 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
171 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
172 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
173 "oid",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
174 &to_octave_str_oid,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
175 &to_octave_bin_oid,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
176 &from_octave_str_oid,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
177 &from_octave_bin_oid};
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
178
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
179 /* end type oid */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
180
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
181 /* type float8 */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
182
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
183 int to_octave_str_float8 (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
184 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
185 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
186 // not implemented
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
187
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
188 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
189 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
190
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
191 int to_octave_bin_float8 (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
192 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
193 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
194 union
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
195 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
196 double d;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
197 int64_t i;
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 swap;
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 swap.i = be64toh (*((int64_t *) c));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
202
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
203 ov = octave_value (swap.d);
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 return 0;
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
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
208 int from_octave_str_float8 (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
209 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
210 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
211 // not implemented
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
212
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
213 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
214 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
215
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
216 int from_octave_bin_float8 (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
217 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
218 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
219 union
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
220 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
221 double d;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
222 int64_t i;
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 swap;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
225
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
226 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
227 SET_ERR (swap.d = ov.double_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
228
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
229 if (err)
11655
6bbb1584d933 More efficient code order in float converters (probably useless with -O0).
i7tiol
parents: 11645
diff changeset
230 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
231 c_verror ("can not convert octave_value to float8 value");
11655
6bbb1584d933 More efficient code order in float converters (probably useless with -O0).
i7tiol
parents: 11645
diff changeset
232 return 1;
6bbb1584d933 More efficient code order in float converters (probably useless with -O0).
i7tiol
parents: 11645
diff changeset
233 }
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
234
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
235 OCT_PQ_PUT(val, int64_t, htobe64 (swap.i))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
236
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
237 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
238 }
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 oct_pq_conv_t conv_float8 = {0, // 701
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
241 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
242 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
243 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
244 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
245 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
246 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
247 "float8",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
248 &to_octave_str_float8,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
249 &to_octave_bin_float8,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
250 &from_octave_str_float8,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
251 &from_octave_bin_float8};
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 /* end type float8 */
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 /* type float4 */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
256
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
257 int to_octave_str_float4 (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
258 const char *c, octave_value &ov, int nb)
11394
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 // not implemented
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 return 1;
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
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
265 int to_octave_bin_float4 (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
266 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
267 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
268 union
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 float f;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
271 int32_t i;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
272 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
273 swap;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
274
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
275 swap.i = be32toh (*((int32_t *) c));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
276
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
277 ov = octave_value (swap.f);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
278
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
279 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
280 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
281
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
282 int from_octave_str_float4 (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
283 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
284 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
285 // not implemented
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
286
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
287 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
288 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
289
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
290 int from_octave_bin_float4 (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
291 const octave_value &ov, oct_pq_dynvec_t &val)
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 union
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 float f;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
296 int32_t i;
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 swap;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
299
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
300 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
301 SET_ERR (swap.f = ov.float_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
302
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
303 if (err)
11655
6bbb1584d933 More efficient code order in float converters (probably useless with -O0).
i7tiol
parents: 11645
diff changeset
304 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
305 c_verror ("can not convert octave_value to float4 value");
11655
6bbb1584d933 More efficient code order in float converters (probably useless with -O0).
i7tiol
parents: 11645
diff changeset
306 return 1;
6bbb1584d933 More efficient code order in float converters (probably useless with -O0).
i7tiol
parents: 11645
diff changeset
307 }
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
308
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
309 OCT_PQ_PUT(val, int32_t, htobe32 (swap.i))
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 return 0;
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
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
314 oct_pq_conv_t conv_float4 = {0,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
315 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
316 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
317 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
318 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
319 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
320 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
321 "float4",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
322 &to_octave_str_float4,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
323 &to_octave_bin_float4,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
324 &from_octave_str_float4,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
325 &from_octave_bin_float4};
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
326
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
327 /* end type float4 */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
328
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
329 /* type bytea */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
330
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
331 int to_octave_str_bytea (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
332 const char *c, octave_value &ov, int nb)
11394
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 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
335 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
336
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
337 int to_octave_bin_bytea (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
338 const char *c, octave_value &ov, int nb)
11394
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 uint8NDArray m (dim_vector (nb, 1));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
341
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
342 uint8_t *p = (uint8_t *) m.fortran_vec ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
343 for (octave_idx_type i = 0; i < nb; i++)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
344 *(p++) = uint8_t (*(c++));
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 ov = octave_value (m);
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 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
349 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
350
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
351 int from_octave_str_bytea (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
352 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
353 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
354 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
355 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
356
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
357 int from_octave_bin_bytea (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
358 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
359 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
360 uint8NDArray b;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
361 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
362 SET_ERR (b = ov.uint8_array_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
363
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
364 if (err)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
365 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
366 c_verror ("can not convert octave_value to bytea representation");
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
367 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
368 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
369
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
370 octave_idx_type nl = b.numel ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
371
11712
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
372 for (octave_idx_type i = 0; i < nl; i++)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
373 val.push_back (b(i).value ());
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
374
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
375 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
376 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
377
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
378 oct_pq_conv_t conv_bytea = {0,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
379 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
380 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
381 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
382 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
383 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
384 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
385 "bytea",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
386 &to_octave_str_bytea,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
387 &to_octave_bin_bytea,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
388 &from_octave_str_bytea,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
389 &from_octave_bin_bytea};
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
390
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
391 /* end type bytea */
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 /* type text */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
394
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
395 int to_octave_str_text (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
396 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
397 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
398 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
399 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
400
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
401 int to_octave_bin_text (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
402 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
403 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
404 std::string s (c, nb);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
405
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
406 ov = octave_value (s);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
407
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
408 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
409 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
410
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
411 int from_octave_str_text (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
412 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
413 {
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
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
417 int from_octave_bin_text (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
418 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
419 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
420 std::string s;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
421 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
422 SET_ERR (s = ov.string_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
423
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
424 if (err)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
425 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
426 c_verror ("can not convert octave_value to string");
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
427 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
428 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
429
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
430 octave_idx_type l = s.size ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
431
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
432 for (int i = 0; i < l; i++)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
433 val.push_back (s[i]);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
434
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
435 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
436 }
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 oct_pq_conv_t conv_text = {0,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
439 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
440 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
441 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
442 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
443 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
444 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
445 "text",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
446 &to_octave_str_text,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
447 &to_octave_bin_text,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
448 &from_octave_str_text,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
449 &from_octave_bin_text};
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
450
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
451 /* end type text */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
452
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
453 /* type varchar */
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 oct_pq_conv_t conv_varchar = {0,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
456 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
457 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
458 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
459 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
460 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
461 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
462 "varchar",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
463 &to_octave_str_text,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
464 &to_octave_bin_text,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
465 &from_octave_str_text,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
466 &from_octave_bin_text};
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
467
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
468 /* end type varchar */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
469
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
470 /* type bpchar */
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 oct_pq_conv_t conv_bpchar = {0,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
473 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
474 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
475 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
476 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
477 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
478 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
479 "bpchar",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
480 &to_octave_str_text,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
481 &to_octave_bin_text,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
482 &from_octave_str_text,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
483 &from_octave_bin_text};
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
484
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
485 /* end type bpchar */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
486
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
487 /* type name */
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 oct_pq_conv_t conv_name = {0,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
490 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
491 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
492 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
493 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
494 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
495 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
496 "name",
11658
f9f1af45e49a Some cleanup in 'name' converters.
i7tiol
parents: 11657
diff changeset
497 &to_octave_str_text,
f9f1af45e49a Some cleanup in 'name' converters.
i7tiol
parents: 11657
diff changeset
498 &to_octave_bin_text,
f9f1af45e49a Some cleanup in 'name' converters.
i7tiol
parents: 11657
diff changeset
499 &from_octave_str_text,
f9f1af45e49a Some cleanup in 'name' converters.
i7tiol
parents: 11657
diff changeset
500 &from_octave_bin_text};
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 /* end type name */
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 /* type int2 */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
505
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
506 int to_octave_str_int2 (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
507 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
508 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
509 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
510 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
511
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
512 int to_octave_bin_int2 (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
513 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
514 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
515 ov = octave_value (octave_int16 (int16_t (be16toh (*((int16_t *) c)))));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
516
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
517 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
518 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
519
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
520 int from_octave_str_int2 (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
521 const octave_value &ov, oct_pq_dynvec_t &val)
11394
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 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
524 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
525
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
526 int from_octave_bin_int2 (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
527 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
528 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
529 int16_t i2;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
530 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
531 SET_ERR (i2 = ov.int_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
532
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
533 if (err)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
534 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
535 c_verror ("can not convert octave_value to int2 value");
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
536 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
537 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
538
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
539 OCT_PQ_PUT(val, int16_t, htobe16 (i2))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
540
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
541 return 0;
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
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
544 oct_pq_conv_t conv_int2 = {0, // 26
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
545 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
546 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
547 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
548 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
549 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
550 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
551 "int2",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
552 &to_octave_str_int2,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
553 &to_octave_bin_int2,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
554 &from_octave_str_int2,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
555 &from_octave_bin_int2};
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
556
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 /* end type int2 */
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 /* type int4 */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
561
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
562 int to_octave_str_int4 (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
563 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
564 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
565 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
566 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
567
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
568 int to_octave_bin_int4 (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
569 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
570 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
571 ov = octave_value (octave_int32 (int32_t (be32toh (*((int32_t *) c)))));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
572
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
573 return 0;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
574 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
575
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
576 int from_octave_str_int4 (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
577 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
578 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
579 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
580 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
581
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
582 int from_octave_bin_int4 (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
583 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
584 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
585 int32_t i4;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
586 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
587 SET_ERR (i4 = ov.int_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
588
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
589 if (err)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
590 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
591 c_verror ("can not convert octave_value to int4 value");
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
592 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
593 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
594
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
595 OCT_PQ_PUT(val, int32_t, htobe32 (i4))
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 return 0;
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
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
600 oct_pq_conv_t conv_int4 = {0,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
601 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
602 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
603 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
604 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
605 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
606 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
607 "int4",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
608 &to_octave_str_int4,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
609 &to_octave_bin_int4,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
610 &from_octave_str_int4,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
611 &from_octave_bin_int4};
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
612
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 /* end type int4 */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
615
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
616 /* type int8 */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
617
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
618 int to_octave_str_int8 (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
619 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
620 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
621 return 1;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
622 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
623
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
624 int to_octave_bin_int8 (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
625 const char *c, octave_value &ov, int nb)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
626 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
627 ov = octave_value (octave_int64 (int64_t (be64toh (*((int64_t *) c)))));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
628
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
629 return 0;
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
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
632 int from_octave_str_int8 (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
633 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
634 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
635 return 1;
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
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
638 int from_octave_bin_int8 (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11656
diff changeset
639 const octave_value &ov, oct_pq_dynvec_t &val)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
640 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
641 int64_t i8;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
642 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
643 SET_ERR (i8 = ov.int64_scalar_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
644
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
645 if (err)
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
646 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
647 c_verror ("can not convert octave_value to int8 value");
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
648 return 1;
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 OCT_PQ_PUT(val, int64_t, htobe64 (i8))
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 return 0;
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
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
656 oct_pq_conv_t conv_int8 = {0,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
657 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
658 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
659 oct_pq_conv_cache_t (),
11394
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 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
663 "int8",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
664 &to_octave_str_int8,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
665 &to_octave_bin_int8,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
666 &from_octave_str_int8,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
667 &from_octave_bin_int8};
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
668
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
669
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
670 /* end type int8 */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
671
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
672 /* type money */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
673
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
674 oct_pq_conv_t conv_money = {0,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
675 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
676 oct_pq_el_oids_t (),
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
677 oct_pq_conv_cache_t (),
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
678 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
679 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
680 false,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
681 "money",
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
682 &to_octave_str_int8,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
683 &to_octave_bin_int8,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
684 &from_octave_str_int8,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
685 &from_octave_bin_int8};
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
686
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
687 /* end type money */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
688
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
689 // helpers for time types
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
690
11667
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
691 static inline octave_value time_8byte_to_octave (const char *c,
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
692 const bool &int_dt)
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
693 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
694 if (int_dt)
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
695 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
696 return octave_value (octave_int64 (int64_t (be64toh (*((int64_t *) c)))));
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
697 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
698 else
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
699 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
700 union
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
701 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
702 double d;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
703 int64_t i;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
704 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
705 swap;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
706
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
707 swap.i = be64toh (*((int64_t *) c));
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
708
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
709 return octave_value (swap.d);
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
710 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
711 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
712
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
713 static inline int time_8byte_from_octave (const octave_value &ov,
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
714 oct_pq_dynvec_t &val,
11667
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
715 const bool &int_dt)
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
716 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
717 if (int_dt)
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
718 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
719 // don't convert automatically because of possible overflow
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
720 if (ov.is_float_type ())
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
721 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
722 c_verror ("floating point octave_value provided for 8-byte time value, but postgresql is configured for int64");
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
723 return 1;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
724 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
725
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
726 int64_t i8;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
727 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
728 SET_ERR (i8 = ov.int64_scalar_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
729
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
730 if (err)
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
731 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
732 c_verror ("can not convert octave_value to int64 time value");
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
733 return 1;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
734 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
735
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
736 OCT_PQ_PUT(val, int64_t, htobe64 (i8))
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
737
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
738 return 0;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
739 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
740 else
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
741 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
742 // don't convert automatically because of possible loss of accuracy
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
743 if (ov.is_integer_type ())
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
744 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
745 c_verror ("integer type octave_value provided for 8-byte time value, but postgresql is configured for double");
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
746 return 1;
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 union
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
750 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
751 double d;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
752 int64_t i;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
753 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
754 swap;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
755
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
756 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
757 SET_ERR (swap.d = ov.double_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
758
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
759 if (err)
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
760 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
761 c_verror ("can not convert octave_value to double time value");
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
762 return 1;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
763 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
764
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
765 OCT_PQ_PUT(val, int64_t, htobe64 (swap.i))
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
766
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
767 return 0;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
768 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
769 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
770
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
771 // end helpers for time types
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
772
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
773 /* type timestamp */
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
774
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
775 int to_octave_str_timestamp (const octave_pq_connection_rep &conn,
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
776 const char *c, octave_value &ov, int nb)
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
777 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
778 return 1;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
779 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
780
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
781 int to_octave_bin_timestamp (const octave_pq_connection_rep &conn,
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
782 const char *c, octave_value &ov, int nb)
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
783 {
11667
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
784 ov = time_8byte_to_octave (c, conn.get_integer_datetimes ());
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
785
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
786 return 0;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
787 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
788
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
789 int from_octave_str_timestamp (const octave_pq_connection_rep &conn,
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
790 const octave_value &ov, oct_pq_dynvec_t &val)
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
791 {
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
792 return 1;
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
793 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
794
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
795 int from_octave_bin_timestamp (const octave_pq_connection_rep &conn,
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
796 const octave_value &ov, oct_pq_dynvec_t &val)
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
797 {
11667
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
798 return (time_8byte_from_octave (ov, val, conn.get_integer_datetimes ()));
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
799 }
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
800
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
801 oct_pq_conv_t conv_timestamp = {0,
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
802 0,
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
803 oct_pq_el_oids_t (),
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
804 oct_pq_conv_cache_t (),
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
805 false,
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
806 false,
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
807 false,
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
808 "timestamp",
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
809 &to_octave_str_timestamp,
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
810 &to_octave_bin_timestamp,
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
811 &from_octave_str_timestamp,
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
812 &from_octave_bin_timestamp};
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
813
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
814 /* end type timestamp */
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
815
11667
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
816 /* type timestamptz */
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
817
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
818 oct_pq_conv_t conv_timestamptz = {0,
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
819 0,
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
820 oct_pq_el_oids_t (),
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
821 oct_pq_conv_cache_t (),
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
822 false,
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
823 false,
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
824 false,
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
825 "timestamptz",
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
826 &to_octave_str_timestamp,
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
827 &to_octave_bin_timestamp,
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
828 &from_octave_str_timestamp,
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
829 &from_octave_bin_timestamp};
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
830
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
831 /* end type timestamptz */
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
832
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
833 /* type interval */
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
834
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
835 int to_octave_str_interval (const octave_pq_connection_rep &conn,
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
836 const char *c, octave_value &ov, int nb)
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 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
839 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
840
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
841 int to_octave_bin_interval (const octave_pq_connection_rep &conn,
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
842 const char *c, octave_value &ov, int nb)
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 Cell tp (dim_vector (3, 1));
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
845
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
846 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
847
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
848 c += 8;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
849
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
850 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
851
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
852 c += 4;
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 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
855
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
856 ov = octave_value (tp);
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 return 0;
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
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
861 int from_octave_str_interval (const octave_pq_connection_rep &conn,
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
862 const octave_value &ov, oct_pq_dynvec_t &val)
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 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
865 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
866
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
867 int from_octave_bin_interval (const octave_pq_connection_rep &conn,
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
868 const octave_value &ov, oct_pq_dynvec_t &val)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
869 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
870 Cell iv;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
871 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
872 SET_ERR (iv = ov.cell_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
873 if (err || iv.numel () != 3)
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
874 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
875 c_verror ("interval: can not convert octave_value to cell with 3 elements");
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
876 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
877 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
878
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
879 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
880 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
881
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
882 for (int id = 1; id < 3; id++)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
883 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
884 int32_t i4;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
885 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
886 SET_ERR (i4 = iv(id).int_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
887
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
888 if (err)
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
889 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
890 c_verror ("interval: can not convert octave_value to int4 value");
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
891 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
892 }
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 OCT_PQ_PUT(val, int32_t, htobe32 (i4))
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 return 0;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
898 }
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 oct_pq_conv_t conv_interval = {0,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
901 0,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
902 oct_pq_el_oids_t (),
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
903 oct_pq_conv_cache_t (),
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
904 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
905 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
906 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
907 "interval",
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
908 &to_octave_str_interval,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
909 &to_octave_bin_interval,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
910 &from_octave_str_interval,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
911 &from_octave_bin_interval};
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
912
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
913 /* end type interval */
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
914
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
915 /* type time */
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
916
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
917 int to_octave_str_time (const octave_pq_connection_rep &conn,
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
918 const char *c, octave_value &ov, int nb)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
919 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
920 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
921 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
922
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
923 int to_octave_bin_time (const octave_pq_connection_rep &conn,
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
924 const char *c, octave_value &ov, int nb)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
925 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
926 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
927
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
928 return 0;
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
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
931 int from_octave_str_time (const octave_pq_connection_rep &conn,
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
932 const octave_value &ov, oct_pq_dynvec_t &val)
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 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
935 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
936
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
937 int from_octave_bin_time (const octave_pq_connection_rep &conn,
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
938 const octave_value &ov, oct_pq_dynvec_t &val)
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 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
941 }
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 oct_pq_conv_t conv_time = {0,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
944 0,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
945 oct_pq_el_oids_t (),
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
946 oct_pq_conv_cache_t (),
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
947 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
948 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
949 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
950 "time",
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
951 &to_octave_str_time,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
952 &to_octave_bin_time,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
953 &from_octave_str_time,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
954 &from_octave_bin_time};
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 /* end type time */
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
957
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
958 /* type timetz */
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
959
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
960 int to_octave_str_timetz (const octave_pq_connection_rep &conn,
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
961 const char *c, octave_value &ov, int nb)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
962 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
963 return 1;
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
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
966 int to_octave_bin_timetz (const octave_pq_connection_rep &conn,
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
967 const char *c, octave_value &ov, int nb)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
968 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
969 Cell tp (dim_vector (2, 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 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
972
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
973 c += 8;
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 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
976
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
977 ov = octave_value (tp);
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 return 0;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
980 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
981
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
982 int from_octave_str_timetz (const octave_pq_connection_rep &conn,
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
983 const octave_value &ov, oct_pq_dynvec_t &val)
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 1;
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
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
988 int from_octave_bin_timetz (const octave_pq_connection_rep &conn,
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
989 const octave_value &ov, oct_pq_dynvec_t &val)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
990 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
991 Cell iv;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
992 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
993 SET_ERR (iv = ov.cell_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
994 if (err || iv.numel () != 2)
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
995 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
996 c_verror ("timetz: can not convert octave_value to cell with 2 elements");
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
997 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
998 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
999
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1000 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
1001 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1002
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1003 int32_t i4;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1004 SET_ERR (i4 = iv(1).int_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1005
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1006 if (err)
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1007 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1008 c_verror ("timetz: can not convert octave_value to int4 value");
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1009 return 1;
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
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1012 OCT_PQ_PUT(val, int32_t, htobe32 (i4))
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 return 0;
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
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1017 oct_pq_conv_t conv_timetz = {0,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1018 0,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1019 oct_pq_el_oids_t (),
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1020 oct_pq_conv_cache_t (),
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1021 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1022 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1023 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1024 "timetz",
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1025 &to_octave_str_timetz,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1026 &to_octave_bin_timetz,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1027 &from_octave_str_timetz,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1028 &from_octave_bin_timetz};
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 /* end type timetz */
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 /* type date */
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1033
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1034 int to_octave_str_date (const octave_pq_connection_rep &conn,
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1035 const char *c, octave_value &ov, int nb)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1036 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1037 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1038 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1039
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1040 int to_octave_bin_date (const octave_pq_connection_rep &conn,
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1041 const char *c, octave_value &ov, int nb)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1042 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1043 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
1044
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1045 return 0;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1046 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1047
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1048 int from_octave_str_date (const octave_pq_connection_rep &conn,
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1049 const octave_value &ov, oct_pq_dynvec_t &val)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1050 {
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1051 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1052 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1053
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1054 int from_octave_bin_date (const octave_pq_connection_rep &conn,
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1055 const octave_value &ov, oct_pq_dynvec_t &val)
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1056 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1057 int32_t i4;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1058 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1059 SET_ERR (i4 = ov.int_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1060
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1061 if (err)
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1062 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1063 c_verror ("date: can not convert octave_value to int4 value");
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1064 return 1;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1065 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1066
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1067 OCT_PQ_PUT(val, int32_t, htobe32 (i4))
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1068
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1069 return 0;
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1070 }
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1071
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1072 oct_pq_conv_t conv_date = {0,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1073 0,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1074 oct_pq_el_oids_t (),
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1075 oct_pq_conv_cache_t (),
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1076 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1077 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1078 false,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1079 "date",
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1080 &to_octave_str_date,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1081 &to_octave_bin_date,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1082 &from_octave_str_date,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1083 &from_octave_bin_date};
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1084
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1085 /* end type date */
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1086
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1087 /* type point */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1088
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1089 int to_octave_str_point (const octave_pq_connection_rep &conn,
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1090 const char *c, octave_value &ov, int nb)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1091 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1092 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1093 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1094
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1095 int to_octave_bin_point (const octave_pq_connection_rep &conn,
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1096 const char *c, octave_value &ov, int nb)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1097 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1098 ColumnVector m (2);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1099
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1100 union
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1101 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1102 double d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1103 int64_t i;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1104 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1105 swap;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1106
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1107 for (int id = 0; id < 2; id++, c += 8)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1108 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1109 swap.i = be64toh (*((int64_t *) c));
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1110
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1111 m(id) = swap.d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1112 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1113
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1114 ov = octave_value (m);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1115
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1116 return 0;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1117 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1118
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1119 int from_octave_str_point (const octave_pq_connection_rep &conn,
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1120 const octave_value &ov, oct_pq_dynvec_t &val)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1121 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1122 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1123 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1124
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1125 int from_octave_bin_point (const octave_pq_connection_rep &conn,
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1126 const octave_value &ov, oct_pq_dynvec_t &val)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1127 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1128 NDArray m;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1129 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1130 SET_ERR (m = ov.array_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1131
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1132 if (err || m.numel () != 2)
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1133 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1134 c_verror ("can not convert octave_value to point representation");
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1135 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1136 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1137
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1138 union
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1139 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1140 double d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1141 int64_t i;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1142 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1143 swap;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1144
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1145 for (int id = 0; id < 2; id++)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1146 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1147 swap.d = m(id);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1148
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1149 OCT_PQ_PUT(val, int64_t, htobe64 (swap.i))
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1150 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1151
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1152 return 0;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1153 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1154
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1155 oct_pq_conv_t conv_point = {0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1156 0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1157 oct_pq_el_oids_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1158 oct_pq_conv_cache_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1159 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1160 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1161 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1162 "point",
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1163 &to_octave_str_point,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1164 &to_octave_bin_point,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1165 &from_octave_str_point,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1166 &from_octave_bin_point};
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1167
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1168 /* end type point */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1169
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1170 /* type lseg */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1171
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1172 int to_octave_str_lseg (const octave_pq_connection_rep &conn,
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1173 const char *c, octave_value &ov, int nb)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1174 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1175 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1176 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1177
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1178 int to_octave_bin_lseg (const octave_pq_connection_rep &conn,
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1179 const char *c, octave_value &ov, int nb)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1180 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1181 Matrix m (2, 2);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1182
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1183 union
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1184 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1185 double d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1186 int64_t i;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1187 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1188 swap;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1189
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1190 for (int id = 0; id < 4; id++, c += 8)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1191 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1192 swap.i = be64toh (*((int64_t *) c));
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1193
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1194 m(id) = swap.d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1195 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1196
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1197 ov = octave_value (m);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1198
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1199 return 0;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1200 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1201
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1202 int from_octave_str_lseg (const octave_pq_connection_rep &conn,
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1203 const octave_value &ov, oct_pq_dynvec_t &val)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1204 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1205 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1206 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1207
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1208 int from_octave_bin_lseg (const octave_pq_connection_rep &conn,
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1209 const octave_value &ov, oct_pq_dynvec_t &val)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1210 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1211 NDArray m;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1212 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1213 SET_ERR (m = ov.array_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1214
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1215 if (err || m.numel () != 4)
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1216 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1217 c_verror ("can not convert octave_value to 4 doubles");
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1218 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1219 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1220
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1221 union
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1222 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1223 double d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1224 int64_t i;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1225 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1226 swap;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1227
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1228 for (int id = 0; id < 4; id++)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1229 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1230 swap.d = m(id);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1231
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1232 OCT_PQ_PUT(val, int64_t, htobe64 (swap.i))
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1233 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1234
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1235 return 0;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1236 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1237
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1238 oct_pq_conv_t conv_lseg = {0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1239 0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1240 oct_pq_el_oids_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1241 oct_pq_conv_cache_t (),
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 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1245 "lseg",
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1246 &to_octave_str_lseg,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1247 &to_octave_bin_lseg,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1248 &from_octave_str_lseg,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1249 &from_octave_bin_lseg};
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1250
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1251 /* end type lseg */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1252
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1253 /* type line */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1254
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1255 oct_pq_conv_t conv_line = {0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1256 0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1257 oct_pq_el_oids_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1258 oct_pq_conv_cache_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1259 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1260 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1261 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1262 "line",
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1263 &to_octave_str_lseg,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1264 &to_octave_bin_lseg,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1265 &from_octave_str_lseg,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1266 &from_octave_bin_lseg};
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1267
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1268 /* end type line */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1269
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1270 /* type box */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1271
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1272 oct_pq_conv_t conv_box = {0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1273 0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1274 oct_pq_el_oids_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1275 oct_pq_conv_cache_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1276 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1277 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1278 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1279 "box",
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1280 &to_octave_str_lseg,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1281 &to_octave_bin_lseg,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1282 &from_octave_str_lseg,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1283 &from_octave_bin_lseg};
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1284
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1285 /* end type box */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1286
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1287 /* type circle */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1288
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1289 int to_octave_str_circle (const octave_pq_connection_rep &conn,
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1290 const char *c, octave_value &ov, int nb)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1291 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1292 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1293 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1294
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1295 int to_octave_bin_circle (const octave_pq_connection_rep &conn,
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1296 const char *c, octave_value &ov, int nb)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1297 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1298 ColumnVector m (3);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1299
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1300 union
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1301 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1302 double d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1303 int64_t i;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1304 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1305 swap;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1306
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1307 for (int id = 0; id < 3; id++, c += 8)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1308 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1309 swap.i = be64toh (*((int64_t *) c));
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1310
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1311 m(id) = swap.d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1312 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1313
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1314 ov = octave_value (m);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1315
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1316 return 0;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1317 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1318
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1319 int from_octave_str_circle (const octave_pq_connection_rep &conn,
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1320 const octave_value &ov, oct_pq_dynvec_t &val)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1321 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1322 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1323 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1324
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1325 int from_octave_bin_circle (const octave_pq_connection_rep &conn,
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1326 const octave_value &ov, oct_pq_dynvec_t &val)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1327 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1328 NDArray m;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1329 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1330 SET_ERR (m = ov.array_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1331
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1332 if (err || m.numel () != 3)
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1333 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1334 c_verror ("can not convert octave_value to circle representation");
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1335 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1336 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1337
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1338 union
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1339 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1340 double d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1341 int64_t i;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1342 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1343 swap;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1344
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1345 for (int id = 0; id < 3; id++)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1346 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1347 swap.d = m(id);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1348
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1349 OCT_PQ_PUT(val, int64_t, htobe64 (swap.i))
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1350 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1351
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1352 return 0;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1353 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1354
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1355 oct_pq_conv_t conv_circle = {0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1356 0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1357 oct_pq_el_oids_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1358 oct_pq_conv_cache_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1359 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1360 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1361 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1362 "circle",
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1363 &to_octave_str_circle,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1364 &to_octave_bin_circle,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1365 &from_octave_str_circle,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1366 &from_octave_bin_circle};
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1367
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1368 /* end type circle */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1369
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1370 /* type polygon */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1371
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1372 int to_octave_str_polygon (const octave_pq_connection_rep &conn,
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1373 const char *c, octave_value &ov, int nb)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1374 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1375 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1376 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1377
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1378 int to_octave_bin_polygon (const octave_pq_connection_rep &conn,
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1379 const char *c, octave_value &ov, int nb)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1380 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1381 int32_t np = int32_t (be32toh (*((int32_t *) c)));
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1382
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1383 c += 4;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1384
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1385 Matrix m (2, np);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1386
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1387 union
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1388 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1389 double d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1390 int64_t i;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1391 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1392 swap;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1393
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1394 for (int id = 0; id < np * 2; id++, c += 8)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1395 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1396 swap.i = be64toh (*((int64_t *) c));
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1397
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1398 m(id) = swap.d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1399 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1400
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1401 ov = octave_value (m);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1402
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1403 return 0;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1404 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1405
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1406 int from_octave_str_polygon (const octave_pq_connection_rep &conn,
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1407 const octave_value &ov, oct_pq_dynvec_t &val)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1408 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1409 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1410 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1411
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1412 int from_octave_bin_polygon (const octave_pq_connection_rep &conn,
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1413 const octave_value &ov, oct_pq_dynvec_t &val)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1414 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1415 octave_idx_type nel;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1416
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1417 NDArray m;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1418 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1419 SET_ERR (m = ov.array_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1420
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1421 if (err || (nel = m.numel ()) % 2)
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1422 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1423 c_verror ("can not convert octave_value to polygon representation");
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1424 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1425 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1426
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1427 union
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1428 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1429 double d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1430 int64_t i;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1431 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1432 swap;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1433
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1434 int32_t np = nel / 2;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1435
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1436 OCT_PQ_PUT(val, int32_t, htobe32 (np))
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1437
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1438 for (int id = 0; id < nel; id++)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1439 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1440 swap.d = m(id);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1441
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1442 OCT_PQ_PUT(val, int64_t, htobe64 (swap.i))
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1443 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1444
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1445 return 0;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1446 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1447
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1448 oct_pq_conv_t conv_polygon = {0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1449 0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1450 oct_pq_el_oids_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1451 oct_pq_conv_cache_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1452 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1453 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1454 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1455 "polygon",
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1456 &to_octave_str_polygon,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1457 &to_octave_bin_polygon,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1458 &from_octave_str_polygon,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1459 &from_octave_bin_polygon};
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1460
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1461 /* end type polygon */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1462
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1463 /* type path */
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1464
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1465 int to_octave_str_path (const octave_pq_connection_rep &conn,
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1466 const char *c, octave_value &ov, int nb)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1467 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1468 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1469 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1470
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1471 int to_octave_bin_path (const octave_pq_connection_rep &conn,
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1472 const char *c, octave_value &ov, int nb)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1473 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1474 bool closed = bool (*(c++));
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1475
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1476 int32_t np = int32_t (be32toh (*((int32_t *) c)));
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1477
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1478 c += 4;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1479
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1480 Matrix m (2, np);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1481
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1482 union
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1483 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1484 double d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1485 int64_t i;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1486 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1487 swap;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1488
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1489 for (int id = 0; id < np * 2; id++, c += 8)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1490 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1491 swap.i = be64toh (*((int64_t *) c));
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1492
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1493 m(id) = swap.d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1494 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1495
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1496 octave_scalar_map tp;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1497 tp.assign ("closed", octave_value (closed));
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1498 tp.assign ("path", octave_value (m));
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1499
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1500 ov = octave_value (tp);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1501
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1502 return 0;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1503 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1504
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1505 int from_octave_str_path (const octave_pq_connection_rep &conn,
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1506 const octave_value &ov, oct_pq_dynvec_t &val)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1507 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1508 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1509 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1510
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1511 int from_octave_bin_path (const octave_pq_connection_rep &conn,
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1512 const octave_value &ov, oct_pq_dynvec_t &val)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1513 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1514 octave_scalar_map tp;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1515 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1516 SET_ERR (tp = ov.scalar_map_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1517 if (err || ! tp.isfield ("closed") || ! tp.isfield ("path"))
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1518 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1519 c_verror ("can not convert octave_value to path representation");
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1520 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1521 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1522
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1523 octave_idx_type nel;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1524
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1525 char closed;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1526 SET_ERR (closed = char (tp.contents ("closed").bool_value ()), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1527
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1528 NDArray m;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1529 if (! err)
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1530 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1531 SET_ERR (m = tp.contents ("path").array_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1532 }
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1533
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1534 if (err || (nel = m.numel ()) % 2)
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1535 {
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1536 c_verror ("can not convert octave_value to path representation");
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1537 return 1;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1538 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1539
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1540 union
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1541 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1542 double d;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1543 int64_t i;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1544 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1545 swap;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1546
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1547 int32_t np = nel / 2;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1548
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1549 val.push_back (closed);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1550
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1551 OCT_PQ_PUT(val, int32_t, htobe32 (np))
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1552
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1553 for (int id = 0; id < nel; id++)
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1554 {
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1555 swap.d = m(id);
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1556
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1557 OCT_PQ_PUT(val, int64_t, htobe64 (swap.i))
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1558 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1559
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1560 return 0;
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1561 }
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1562
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1563 oct_pq_conv_t conv_path = {0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1564 0,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1565 oct_pq_el_oids_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1566 oct_pq_conv_cache_t (),
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1567 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1568 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1569 false,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1570 "path",
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1571 &to_octave_str_path,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1572 &to_octave_bin_path,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1573 &from_octave_str_path,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1574 &from_octave_bin_path};
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1575
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
1576 /* end type path */
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
1577
11698
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1578 /* type unknown */
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1579
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1580 // These are pseudo-converters for postgresql type 'unknown'. They do
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1581 // nothing except signalling an error. The rationale is that the only
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1582 // values of type 'unknown' may be NULL, in which case the converter
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1583 // will not be called, but because a converter exists there won't be a
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1584 // "no converter found" error thrown.
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1585
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1586 int to_octave_str_unknown (const octave_pq_connection_rep &conn,
11698
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1587 const char *c, octave_value &ov, int nb)
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1588 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1589 c_verror ("can not convert postgresql type 'unknown'");
11698
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1590
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1591 return 1;
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1592 }
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1593
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1594 int to_octave_bin_unknown (const octave_pq_connection_rep &conn,
11698
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1595 const char *c, octave_value &ov, int nb)
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1596 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1597 c_verror ("can not convert postgresql type 'unknown'");
11698
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1598
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1599 return 1;
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1600 }
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1601
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1602 int from_octave_str_unknown (const octave_pq_connection_rep &conn,
11698
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1603 const octave_value &ov, oct_pq_dynvec_t &val)
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1604 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1605 c_verror ("can not convert postgresql type 'unknown'");
11698
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1606
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1607 return 1;
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1608 }
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1609
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1610 int from_octave_bin_unknown (const octave_pq_connection_rep &conn,
11698
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1611 const octave_value &ov, oct_pq_dynvec_t &val)
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1612 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1613 c_verror ("can not convert postgresql type 'unknown'");
11698
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1614
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1615 return 1;
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1616 }
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1617
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1618 oct_pq_conv_t conv_unknown = {0,
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1619 0,
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1620 oct_pq_el_oids_t (),
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1621 oct_pq_conv_cache_t (),
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1622 false,
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1623 false,
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1624 false,
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1625 "unknown",
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1626 &to_octave_str_unknown,
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1627 &to_octave_bin_unknown,
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1628 &from_octave_str_unknown,
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1629 &from_octave_bin_unknown};
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1630
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1631 /* end type unknown */
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
1632
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1633 // helpers for network types
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1634
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1635 static inline
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1636 int to_octave_bin_cidr_inet (const char *c, octave_value &ov, bool &cidr)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1637 {
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1638 int8_t nb;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1639
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1640 if (*(c++) == AF_INET)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1641 {
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1642 uint8NDArray a (dim_vector (5, 1), 0);
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1643
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1644 a(4) = uint8_t (*(c++)); // number of set mask bits
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1645
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1646 cidr = *(c++);
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1647
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1648 nb = *(c++);
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1649
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1650 if (nb < 0)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1651 nb = 0;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1652
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1653 if (nb > 4)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1654 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1655 c_verror ("internal error: received too many bytes for AF_INET type");
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1656
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1657 return 1;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1658 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1659
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1660 for (int8_t i = 0; i < nb; i++, c++)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1661 a(i) = uint8_t (*c);
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1662
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1663 ov = octave_value (a);
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1664 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1665 else
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1666 {
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1667 uint16NDArray a (dim_vector (9, 1), 0);
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1668
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1669 a(8) = uint16_t (uint8_t (*(c++))); // number of set mask bits
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1670
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1671 cidr = *(c++);
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1672
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1673 nb = *(c++);
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1674
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1675 if (nb < 0)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1676 nb = 0;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1677
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1678 if (nb > 16)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1679 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1680 c_verror ("internal error: received too many bytes for AF_INET6 type");
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1681
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1682 return 1;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1683 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1684
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1685 int8_t n = nb / 2;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1686 bool odd = nb % 2;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1687
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1688 for (int8_t i = 0; i < n; i++, c += 2)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1689 a(i) = uint16_t (be16toh (*((uint16_t *) c)));
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1690
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1691 if (odd)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1692 {
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1693 uint16_t tp = *c;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1694
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1695 a(n) = uint16_t (be16toh (tp));
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1696 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1697
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1698 ov = octave_value (a);
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1699 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1700
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1701 return 0;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1702 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1703
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1704 static inline
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1705 int from_octave_bin_cidr_inet (const octave_value &ov, oct_pq_dynvec_t &val,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1706 bool cidr)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1707 {
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1708 int nl = ov.numel ();
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1709
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1710 uint8_t n_mbits;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1711
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1712 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1713
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1714 if (nl == 4 || nl == 5)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1715 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1716 uint8NDArray a;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1717 SET_ERR (a = ov.uint8_array_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1719 if (err)
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1720 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1721 c_verror ("can not convert octave_value to network type representation");
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1722 return 1;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1723 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1724
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1725 if (nl == 5)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1726 n_mbits = a(4).value ();
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1727 else
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1728 n_mbits = 32;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1729
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1730 val.push_back (AF_INET);
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1731 val.push_back (n_mbits);
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1732 val.push_back (cidr);
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1733 val.push_back (4);
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1734 for (int i = 0; i < 4; i++)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1735 val.push_back (a(i).value ());
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1736 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1737 else if (nl == 8 || nl == 9)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1738 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1739 uint16NDArray a;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1740 SET_ERR (a = ov.uint16_array_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1741
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1742 if (err)
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1743 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1744 c_verror ("can not convert octave_value to network type representation");
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1745 return 1;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1746 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1747
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1748 if (nl == 9)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1749 n_mbits = a(8).value ();
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1750 else
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1751 n_mbits = 128;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1752
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1753 val.push_back (PGSQL_AF_INET6);
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1754 val.push_back (n_mbits);
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1755 val.push_back (cidr);
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1756 val.push_back (16);
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1757 for (int i = 0; i < 8; i++)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1758 {
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1759 OCT_PQ_PUT(val, uint16_t, htobe16(a(i).value ()))
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1760 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1761 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1762 else
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1763 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1764 c_verror ("invalid network type representation");
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1765 return 1;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1766 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1767
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1768 return 0;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1769 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1770
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1771 // end helpers for network types
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1772
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1773 /* type cidr */
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1774
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1775 int to_octave_str_cidr (const octave_pq_connection_rep &conn,
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1776 const char *c, octave_value &ov, int nb)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1777 {
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1778 return 1;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1779 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1780
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1781 int to_octave_bin_cidr (const octave_pq_connection_rep &conn,
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1782 const char *c, octave_value &ov, int nb)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1783 {
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1784 bool cidr = false;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1785
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1786 if (to_octave_bin_cidr_inet (c, ov, cidr))
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1787 return 1;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1788
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1789 if (! cidr)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1790 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1791 c_verror ("internal error: unexpected flag in cidr type");
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1792
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1793 return 1;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1794 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1795
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1796 return 0;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1797 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1798
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1799 int from_octave_str_cidr (const octave_pq_connection_rep &conn,
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1800 const octave_value &ov, oct_pq_dynvec_t &val)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1801 {
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1802 return 1;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1803 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1804
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1805 int from_octave_bin_cidr (const octave_pq_connection_rep &conn,
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1806 const octave_value &ov, oct_pq_dynvec_t &val)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1807 {
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1808 return from_octave_bin_cidr_inet (ov, val, true);
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1809 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1810
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1811 oct_pq_conv_t conv_cidr = {0,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1812 0,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1813 oct_pq_el_oids_t (),
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1814 oct_pq_conv_cache_t (),
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1815 false,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1816 false,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1817 false,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1818 "cidr",
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1819 &to_octave_str_cidr,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1820 &to_octave_bin_cidr,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1821 &from_octave_str_cidr,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1822 &from_octave_bin_cidr};
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1823
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1824 /* end type cidr */
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1825
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1826 /* type inet */
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1827
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1828 int to_octave_str_inet (const octave_pq_connection_rep &conn,
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1829 const char *c, octave_value &ov, int nb)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1830 {
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1831 return 1;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1832 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1833
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1834 int to_octave_bin_inet (const octave_pq_connection_rep &conn,
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1835 const char *c, octave_value &ov, int nb)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1836 {
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1837 bool cidr = false;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1838
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1839 if (to_octave_bin_cidr_inet (c, ov, cidr))
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1840 return 1;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1841
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1842 if (cidr)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1843 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1844 c_verror ("internal error: unexpected flag in inet type");
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1845
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1846 return 1;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1847 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1848
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1849 return 0;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1850 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1851
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1852 int from_octave_str_inet (const octave_pq_connection_rep &conn,
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1853 const octave_value &ov, oct_pq_dynvec_t &val)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1854 {
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1855 return 1;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1856 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1857
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1858 int from_octave_bin_inet (const octave_pq_connection_rep &conn,
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1859 const octave_value &ov, oct_pq_dynvec_t &val)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1860 {
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1861 return from_octave_bin_cidr_inet (ov, val, false);
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1862 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1863
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1864 oct_pq_conv_t conv_inet = {0,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1865 0,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1866 oct_pq_el_oids_t (),
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1867 oct_pq_conv_cache_t (),
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1868 false,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1869 false,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1870 false,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1871 "inet",
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1872 &to_octave_str_inet,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1873 &to_octave_bin_inet,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1874 &from_octave_str_inet,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1875 &from_octave_bin_inet};
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1876
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1877 /* end type inet */
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1878
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1879 /* type macaddr */
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1880
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1881 int to_octave_str_macaddr (const octave_pq_connection_rep &conn,
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1882 const char *c, octave_value &ov, int nb)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1883 {
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1884 return 1;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1885 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1886
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1887 int to_octave_bin_macaddr (const octave_pq_connection_rep &conn,
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1888 const char *c, octave_value &ov, int nb)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1889 {
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1890 uint8NDArray a (dim_vector (6, 1));
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1891
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1892 for (int i = 0; i < 6; i++, c++)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1893 a(i) = uint8_t (*c);
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1894
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1895 ov = octave_value (a);
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1896
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1897 return 0;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1898 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1899
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1900 int from_octave_str_macaddr (const octave_pq_connection_rep &conn,
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1901 const octave_value &ov, oct_pq_dynvec_t &val)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1902 {
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1903 return 1;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1904 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1905
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1906 int from_octave_bin_macaddr (const octave_pq_connection_rep &conn,
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1907 const octave_value &ov, oct_pq_dynvec_t &val)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1908 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1909 uint8NDArray a;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1910 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1911 SET_ERR (a = ov.uint8_array_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1912
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1913 if (err)
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1914 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1915 c_verror ("can not convert octave_value to macaddr representation");
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1916 return 1;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1917 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1918
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1919 if (a.numel () != 6)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1920 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1921 c_verror ("macaddr representation must have 6 elements");
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1922 return 1;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1923 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1924
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1925 for (int i = 0; i < 6; i++)
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1926 val.push_back (a(i).value ());
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1927
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1928 return 0;
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1929 }
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1930
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1931 oct_pq_conv_t conv_macaddr = {0,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1932 0,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1933 oct_pq_el_oids_t (),
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1934 oct_pq_conv_cache_t (),
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1935 false,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1936 false,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1937 false,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1938 "macaddr",
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1939 &to_octave_str_macaddr,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1940 &to_octave_bin_macaddr,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1941 &from_octave_str_macaddr,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1942 &from_octave_bin_macaddr};
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1943
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1944 /* end type macaddr */
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
1945
11710
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1946 /* type bit */
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1947
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1948 int to_octave_str_bit (const octave_pq_connection_rep &conn,
11710
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1949 const char *c, octave_value &ov, int nb)
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1950 {
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1951 return 1;
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1952 }
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1953
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1954 int to_octave_bin_bit (const octave_pq_connection_rep &conn,
11710
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1955 const char *c, octave_value &ov, int nb)
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1956 {
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1957 int32_t nbits = int32_t (be32toh (*((int32_t *) c)));
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1958
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1959 c += 4;
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1960
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1961 int32_t nbytes = (nbits + 7) / 8;
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1962
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1963 uint8NDArray a (dim_vector (nbytes, 1));
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1964
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1965 for (int i = 0; i < nbytes; i++, c++)
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1966 a(i) = uint8_t (*c);
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1967
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1968 octave_scalar_map tp;
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1969 tp.assign ("bitlen", octave_value (octave_int32 (nbits)));
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1970 tp.assign ("bits", octave_value (a));
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1971
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1972 ov = octave_value (tp);
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1973
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1974 return 0;
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1975 }
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1976
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1977 int from_octave_str_bit (const octave_pq_connection_rep &conn,
11710
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1978 const octave_value &ov, oct_pq_dynvec_t &val)
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1979 {
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1980 return 1;
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1981 }
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1982
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
1983 int from_octave_bin_bit (const octave_pq_connection_rep &conn,
11710
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1984 const octave_value &ov, oct_pq_dynvec_t &val)
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1985 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1986 octave_scalar_map tp;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1987 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1988 SET_ERR (tp = ov.scalar_map_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1989 if (err || ! tp.isfield ("bitlen") || ! tp.isfield ("bits"))
11710
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1990 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1991 c_verror ("can not convert octave_value to bitstring representation");
11710
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1992 return 1;
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1993 }
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
1994
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1995 int32_t nbits;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1996 SET_ERR (nbits = tp.contents ("bitlen").int_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1997
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1998 uint8NDArray a;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
1999 if (! err)
11710
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2000 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
2001 SET_ERR (a = tp.contents ("bits").uint8_array_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
2002 }
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
2003
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
2004 if (err || nbits < 0)
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
2005 {
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
2006 c_verror ("can not convert octave_value to bitstring representation");
11710
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2007 return 1;
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2008 }
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2009
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2010 int32_t nbytes = (nbits + 7) / 8;
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2011
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2012 if (a.numel () != nbytes)
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2013 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
2014 c_verror ("wrong number of elements in bitstring representation");
11710
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2015 return 1;
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2016 }
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2017
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2018 OCT_PQ_PUT(val, int32_t, htobe32 (nbits))
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2019
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2020 for (int i = 0; i < nbytes; i++)
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2021 val.push_back (a(i).value ());
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2022
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2023 return 0;
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2024 }
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2025
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2026 oct_pq_conv_t conv_bit = {0,
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2027 0,
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2028 oct_pq_el_oids_t (),
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2029 oct_pq_conv_cache_t (),
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2030 false,
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2031 false,
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2032 false,
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2033 "bit",
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2034 &to_octave_str_bit,
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2035 &to_octave_bin_bit,
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2036 &from_octave_str_bit,
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2037 &from_octave_bin_bit};
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2038
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2039 /* end type bit */
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2040
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2041 /* type varbit */
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2042
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2043 oct_pq_conv_t conv_varbit = {0,
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2044 0,
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2045 oct_pq_el_oids_t (),
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2046 oct_pq_conv_cache_t (),
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2047 false,
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2048 false,
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2049 false,
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2050 "varbit",
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2051 &to_octave_str_bit,
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2052 &to_octave_bin_bit,
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2053 &from_octave_str_bit,
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2054 &from_octave_bin_bit};
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2055
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2056 /* end type varbit */
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2057
11712
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2058 /* type uuid */
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2059
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
2060 int to_octave_str_uuid (const octave_pq_connection_rep &conn,
11712
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2061 const char *c, octave_value &ov, int nb)
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2062 {
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2063 return 1;
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2064 }
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2065
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
2066 int to_octave_bin_uuid (const octave_pq_connection_rep &conn,
11712
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2067 const char *c, octave_value &ov, int nb)
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2068 {
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2069 uint8NDArray m (dim_vector (16, 1));
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2070
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2071 uint8_t *p = (uint8_t *) m.fortran_vec ();
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2072 for (int i = 0; i < 16; i++, c++)
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2073 *(p++) = uint8_t (*c);
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2074
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2075 ov = octave_value (m);
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2076
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2077 return 0;
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2078 }
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2079
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
2080 int from_octave_str_uuid (const octave_pq_connection_rep &conn,
11712
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2081 const octave_value &ov, oct_pq_dynvec_t &val)
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2082 {
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2083 return 1;
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2084 }
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2085
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
2086 int from_octave_bin_uuid (const octave_pq_connection_rep &conn,
11712
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2087 const octave_value &ov, oct_pq_dynvec_t &val)
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2088 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
2089 uint8NDArray b;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
2090 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
2091 SET_ERR (b = ov.uint8_array_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
2092
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
2093 if (err)
11712
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2094 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
2095 c_verror ("can not convert octave_value to uuid representation");
11712
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2096 return 1;
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2097 }
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2098
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2099 if (b.numel () != 16)
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2100 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
2101 c_verror ("uuid representation must have 16 elements");
11712
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2102 return 1;
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2103 }
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2104
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2105 for (int i = 0; i < 16; i++)
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2106 val.push_back (b(i).value ());
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2107
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2108 return 0;
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2109 }
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2110
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2111 oct_pq_conv_t conv_uuid = {0,
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2112 0,
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2113 oct_pq_el_oids_t (),
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2114 oct_pq_conv_cache_t (),
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2115 false,
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2116 false,
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2117 false,
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2118 "uuid",
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2119 &to_octave_str_uuid,
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2120 &to_octave_bin_uuid,
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2121 &from_octave_str_uuid,
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2122 &from_octave_bin_uuid};
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2123
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2124 /* end type uuid */
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2125
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2126 /* type xml */
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2127
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
2128 int to_octave_str_xml (const octave_pq_connection_rep &conn,
11712
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2129 const char *c, octave_value &ov, int nb)
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2130 {
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2131 return 1;
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2132 }
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2133
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
2134 int to_octave_bin_xml (const octave_pq_connection_rep &conn,
11712
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2135 const char *c, octave_value &ov, int nb)
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2136 {
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2137 std::string s (c, nb);
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2138
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2139 ov = octave_value (s);
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2140
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2141 return 0;
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2142 }
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2143
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
2144 int from_octave_str_xml (const octave_pq_connection_rep &conn,
11712
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2145 const octave_value &ov, oct_pq_dynvec_t &val)
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2146 {
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2147 return 1;
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2148 }
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2149
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
2150 int from_octave_bin_xml (const octave_pq_connection_rep &conn,
11712
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2151 const octave_value &ov, oct_pq_dynvec_t &val)
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2152 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
2153 std::string s;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
2154 bool err;
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
2155 SET_ERR (s = ov.string_value (), err);
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
2156
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
2157 if (err)
11712
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2158 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
2159 c_verror ("can not convert octave_value to string");
11712
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2160 return 1;
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2161 }
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2162
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2163 octave_idx_type l = s.size ();
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2164
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2165 for (int i = 0; i < l; i++)
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2166 val.push_back (s[i]);
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2167
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2168 return 0;
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2169 }
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2170
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2171 oct_pq_conv_t conv_xml = {0,
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2172 0,
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2173 oct_pq_el_oids_t (),
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2174 oct_pq_conv_cache_t (),
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2175 false,
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2176 false,
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2177 false,
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2178 "xml",
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2179 &to_octave_str_text,
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2180 &to_octave_bin_text,
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2181 &from_octave_str_text,
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2182 &from_octave_bin_text};
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2183
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2184 /* end type xml */
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2185
11715
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2186 /* type record */
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2187
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
2188 int to_octave_str_record (const octave_pq_connection_rep &conn,
11715
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2189 const char *c, octave_value &ov, int nb)
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2190 {
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2191 return 1;
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2192 }
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2193
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
2194 int to_octave_bin_record (const octave_pq_connection_rep &conn,
11715
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2195 const char *v, octave_value &ov, int nb)
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2196 {
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2197 const char *p = v;
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2198
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2199 // ncols
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2200 OCT_PQ_DECL_GET_INT32(nl, p, int32_t)
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2201
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2202 // elements
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2203 Cell c (nl, 1);
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2204 for (int i = 0; i < nl; i++)
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2205 {
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2206 // element OID
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2207 OCT_PQ_DECL_GET_INT32(oid, p, uint32_t)
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2208
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2209 OCT_PQ_DECL_GET_INT32(null_id, p, int32_t)
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2210
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2211 if (null_id == -1)
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2212 // NULL
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2213 c(i) = octave_value (octave_NA);
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2214 else
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2215 {
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2216 uint32_t nb_el = uint32_t (null_id);
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2217
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2218 oct_pq_conv_t *el_conv;
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2219 pq_oct_type_t oct_type;
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2220
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2221 if (! (el_conv = pgtype_from_spec (conn, oid, oct_type)))
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2222 return 1;
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2223
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2224 octave_value el;
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2225 switch (oct_type)
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2226 {
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2227 case simple:
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2228 if (el_conv->to_octave_bin (conn, p, el, nb_el))
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2229 return 1;
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2230 break;
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2231
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2232 case array:
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2233 if (to_octave_bin_array (conn, p, el, nb_el, el_conv))
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2234 return 1;
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2235 break;
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2236
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2237 case composite:
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2238 if (to_octave_bin_composite (conn, p, el, nb_el, el_conv))
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2239 return 1;
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2240 break;
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2241
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2242 default:
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2243 // should not get here
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
2244 c_verror ("'record' converter: internal error, undefined type identifier");
11715
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2245 return 1;
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2246 }
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2247
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2248 p += nb_el;
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2249
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2250 c(i) = el;
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2251 }
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2252 }
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2253
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2254 ov = octave_value (c);
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2255
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2256 return 0;
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2257 }
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2258
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
2259 int from_octave_str_record (const octave_pq_connection_rep &conn,
11715
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2260 const octave_value &ov, oct_pq_dynvec_t &val)
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2261 {
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2262 return 1;
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2263 }
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2264
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 12317
diff changeset
2265 int from_octave_bin_record (const octave_pq_connection_rep &conn,
11715
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2266 const octave_value &ov, oct_pq_dynvec_t &val)
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2267 {
12718
1af86934c14e Make compatible with Octaves new exception-based error handling.
i7tiol
parents: 12612
diff changeset
2268 c_verror ("Type 'record' can't be sent to postgresql.");
11715
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2269
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2270 return 1;
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2271 }
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2272
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2273 oct_pq_conv_t conv_record = {0,
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2274 0,
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2275 oct_pq_el_oids_t (),
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2276 oct_pq_conv_cache_t (),
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2277 false,
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2278 false,
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2279 false,
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2280 "record",
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2281 &to_octave_str_record,
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2282 &to_octave_bin_record,
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2283 &from_octave_str_record,
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2284 &from_octave_bin_record};
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2285
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2286 /* end type record */
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2287
11429
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
2288 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
2289 &conv_oid,
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
2290 &conv_float8,
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
2291 &conv_float4,
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
2292 &conv_text,
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
2293 &conv_varchar,
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
2294 &conv_bpchar,
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
2295 &conv_name,
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
2296 &conv_bytea,
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
2297 &conv_int2,
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
2298 &conv_int4,
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
2299 &conv_int8,
11661
1b4e81051b66 Add converter for timestamp.
i7tiol
parents: 11658
diff changeset
2300 &conv_money,
11667
2c21253d3341 Add converter for timestamptz.
i7tiol
parents: 11661
diff changeset
2301 &conv_timestamp,
11668
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
2302 &conv_timestamptz,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
2303 &conv_interval,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
2304 &conv_time,
abd563353849 Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents: 11667
diff changeset
2305 &conv_timetz,
11697
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
2306 &conv_date,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
2307 &conv_point,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
2308 &conv_lseg,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
2309 &conv_line,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
2310 &conv_box,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
2311 &conv_circle,
9e624fa135a1 Added converters for geometric types.
i7tiol
parents: 11668
diff changeset
2312 &conv_polygon,
11698
b3cbebad8a26 Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents: 11697
diff changeset
2313 &conv_path,
11708
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
2314 &conv_unknown,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
2315 &conv_cidr,
efca9c2a8a7e Added converters for network types.
i7tiol
parents: 11698
diff changeset
2316 &conv_inet,
11710
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2317 &conv_macaddr,
4f5471a9bce6 Added converters for bit string types.
i7tiol
parents: 11709
diff changeset
2318 &conv_bit,
11712
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2319 &conv_varbit,
f4c52c68f744 Added converters for types uuid and xml.
i7tiol
parents: 11710
diff changeset
2320 &conv_uuid,
11715
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2321 &conv_xml,
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11712
diff changeset
2322 &conv_record};
11429
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
2323
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11409
diff changeset
2324 oct_pq_conv_ptrs_t conv_ptrs (OCT_PQ_NUM_CONVERTERS, t_conv_ptrs);