Mercurial > forge
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 |
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 | 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 | 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 | 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 | 33 |
11394
9aee227e296c
Populated new database package with initial postgresql interface.
i7tiol
parents:
diff
changeset
|
34 #include "converters.h" |
11661 | 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 | 40 #define PGSQL_AF_INET6 (AF_INET + 1) // defined so in postgresql, no |
41 // public header file available | |
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 | 58 int to_octave_str_bool (const octave_pq_connection_rep &conn, |
11657 | 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 | 68 int to_octave_bin_bool (const octave_pq_connection_rep &conn, |
11657 | 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 | 76 int from_octave_str_bool (const octave_pq_connection_rep &conn, |
11657 | 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 | 94 int from_octave_bin_bool (const octave_pq_connection_rep &conn, |
11657 | 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 | 128 int to_octave_str_oid (const octave_pq_connection_rep &conn, |
11657 | 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 | 134 int to_octave_bin_oid (const octave_pq_connection_rep &conn, |
11657 | 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 | 142 int from_octave_str_oid (const octave_pq_connection_rep &conn, |
11657 | 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 | 148 int from_octave_bin_oid (const octave_pq_connection_rep &conn, |
11657 | 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 | 183 int to_octave_str_float8 (const octave_pq_connection_rep &conn, |
11657 | 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 | 191 int to_octave_bin_float8 (const octave_pq_connection_rep &conn, |
11657 | 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 | 208 int from_octave_str_float8 (const octave_pq_connection_rep &conn, |
11657 | 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 | 216 int from_octave_bin_float8 (const octave_pq_connection_rep &conn, |
11657 | 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 | 257 int to_octave_str_float4 (const octave_pq_connection_rep &conn, |
11657 | 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 | 265 int to_octave_bin_float4 (const octave_pq_connection_rep &conn, |
11657 | 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 | 282 int from_octave_str_float4 (const octave_pq_connection_rep &conn, |
11657 | 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 | 290 int from_octave_bin_float4 (const octave_pq_connection_rep &conn, |
11657 | 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 | 331 int to_octave_str_bytea (const octave_pq_connection_rep &conn, |
11657 | 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 | 337 int to_octave_bin_bytea (const octave_pq_connection_rep &conn, |
11657 | 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 | 351 int from_octave_str_bytea (const octave_pq_connection_rep &conn, |
11657 | 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 | 357 int from_octave_bin_bytea (const octave_pq_connection_rep &conn, |
11657 | 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 | 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 | 395 int to_octave_str_text (const octave_pq_connection_rep &conn, |
11657 | 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 | 401 int to_octave_bin_text (const octave_pq_connection_rep &conn, |
11657 | 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 | 411 int from_octave_str_text (const octave_pq_connection_rep &conn, |
11657 | 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 | 417 int from_octave_bin_text (const octave_pq_connection_rep &conn, |
11657 | 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 | 497 &to_octave_str_text, |
498 &to_octave_bin_text, | |
499 &from_octave_str_text, | |
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 | 506 int to_octave_str_int2 (const octave_pq_connection_rep &conn, |
11657 | 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 | 512 int to_octave_bin_int2 (const octave_pq_connection_rep &conn, |
11657 | 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 | 520 int from_octave_str_int2 (const octave_pq_connection_rep &conn, |
11657 | 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 | 526 int from_octave_bin_int2 (const octave_pq_connection_rep &conn, |
11657 | 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 | 562 int to_octave_str_int4 (const octave_pq_connection_rep &conn, |
11657 | 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 | 568 int to_octave_bin_int4 (const octave_pq_connection_rep &conn, |
11657 | 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 | 576 int from_octave_str_int4 (const octave_pq_connection_rep &conn, |
11657 | 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 | 582 int from_octave_bin_int4 (const octave_pq_connection_rep &conn, |
11657 | 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 | 618 int to_octave_str_int8 (const octave_pq_connection_rep &conn, |
11657 | 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 | 624 int to_octave_bin_int8 (const octave_pq_connection_rep &conn, |
11657 | 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 | 632 int from_octave_str_int8 (const octave_pq_connection_rep &conn, |
11657 | 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 | 638 int from_octave_bin_int8 (const octave_pq_connection_rep &conn, |
11657 | 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 | 689 // helpers for time types |
690 | |
11667 | 691 static inline octave_value time_8byte_to_octave (const char *c, |
692 const bool &int_dt) | |
11661 | 693 { |
694 if (int_dt) | |
695 { | |
696 return octave_value (octave_int64 (int64_t (be64toh (*((int64_t *) c))))); | |
697 } | |
698 else | |
699 { | |
700 union | |
701 { | |
702 double d; | |
703 int64_t i; | |
704 } | |
705 swap; | |
706 | |
707 swap.i = be64toh (*((int64_t *) c)); | |
708 | |
709 return octave_value (swap.d); | |
710 } | |
711 } | |
712 | |
713 static inline int time_8byte_from_octave (const octave_value &ov, | |
714 oct_pq_dynvec_t &val, | |
11667 | 715 const bool &int_dt) |
11661 | 716 { |
717 if (int_dt) | |
718 { | |
719 // don't convert automatically because of possible overflow | |
720 if (ov.is_float_type ()) | |
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 | 723 return 1; |
724 } | |
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 | 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 | 733 return 1; |
734 } | |
735 | |
736 OCT_PQ_PUT(val, int64_t, htobe64 (i8)) | |
737 | |
738 return 0; | |
739 } | |
740 else | |
741 { | |
742 // don't convert automatically because of possible loss of accuracy | |
743 if (ov.is_integer_type ()) | |
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 | 746 return 1; |
747 } | |
748 | |
749 union | |
750 { | |
751 double d; | |
752 int64_t i; | |
753 } | |
754 swap; | |
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 | 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 | 762 return 1; |
763 } | |
764 | |
765 OCT_PQ_PUT(val, int64_t, htobe64 (swap.i)) | |
766 | |
767 return 0; | |
768 } | |
769 } | |
770 | |
771 // end helpers for time types | |
772 | |
773 /* type timestamp */ | |
774 | |
12612 | 775 int to_octave_str_timestamp (const octave_pq_connection_rep &conn, |
11661 | 776 const char *c, octave_value &ov, int nb) |
777 { | |
778 return 1; | |
779 } | |
780 | |
12612 | 781 int to_octave_bin_timestamp (const octave_pq_connection_rep &conn, |
11661 | 782 const char *c, octave_value &ov, int nb) |
783 { | |
11667 | 784 ov = time_8byte_to_octave (c, conn.get_integer_datetimes ()); |
11661 | 785 |
786 return 0; | |
787 } | |
788 | |
12612 | 789 int from_octave_str_timestamp (const octave_pq_connection_rep &conn, |
11661 | 790 const octave_value &ov, oct_pq_dynvec_t &val) |
791 { | |
792 return 1; | |
793 } | |
794 | |
12612 | 795 int from_octave_bin_timestamp (const octave_pq_connection_rep &conn, |
11661 | 796 const octave_value &ov, oct_pq_dynvec_t &val) |
797 { | |
11667 | 798 return (time_8byte_from_octave (ov, val, conn.get_integer_datetimes ())); |
11661 | 799 } |
800 | |
801 oct_pq_conv_t conv_timestamp = {0, | |
802 0, | |
803 oct_pq_el_oids_t (), | |
804 oct_pq_conv_cache_t (), | |
805 false, | |
806 false, | |
807 false, | |
808 "timestamp", | |
809 &to_octave_str_timestamp, | |
810 &to_octave_bin_timestamp, | |
811 &from_octave_str_timestamp, | |
812 &from_octave_bin_timestamp}; | |
813 | |
814 /* end type timestamp */ | |
815 | |
11667 | 816 /* type timestamptz */ |
817 | |
818 oct_pq_conv_t conv_timestamptz = {0, | |
819 0, | |
820 oct_pq_el_oids_t (), | |
821 oct_pq_conv_cache_t (), | |
822 false, | |
823 false, | |
824 false, | |
825 "timestamptz", | |
826 &to_octave_str_timestamp, | |
827 &to_octave_bin_timestamp, | |
828 &from_octave_str_timestamp, | |
829 &from_octave_bin_timestamp}; | |
830 | |
831 /* end type timestamptz */ | |
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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 1085 /* end type date */ |
11668
abd563353849
Added remaining date/time converters (time, timetz, date, interval).
i7tiol
parents:
11667
diff
changeset
|
1086 |
11697 | 1087 /* type point */ |
1088 | |
12612 | 1089 int to_octave_str_point (const octave_pq_connection_rep &conn, |
11697 | 1090 const char *c, octave_value &ov, int nb) |
1091 { | |
1092 return 1; | |
1093 } | |
1094 | |
12612 | 1095 int to_octave_bin_point (const octave_pq_connection_rep &conn, |
11697 | 1096 const char *c, octave_value &ov, int nb) |
1097 { | |
1098 ColumnVector m (2); | |
1099 | |
1100 union | |
1101 { | |
1102 double d; | |
1103 int64_t i; | |
1104 } | |
1105 swap; | |
1106 | |
1107 for (int id = 0; id < 2; id++, c += 8) | |
1108 { | |
1109 swap.i = be64toh (*((int64_t *) c)); | |
1110 | |
1111 m(id) = swap.d; | |
1112 } | |
1113 | |
1114 ov = octave_value (m); | |
1115 | |
1116 return 0; | |
1117 } | |
1118 | |
12612 | 1119 int from_octave_str_point (const octave_pq_connection_rep &conn, |
11697 | 1120 const octave_value &ov, oct_pq_dynvec_t &val) |
1121 { | |
1122 return 1; | |
1123 } | |
1124 | |
12612 | 1125 int from_octave_bin_point (const octave_pq_connection_rep &conn, |
11697 | 1126 const octave_value &ov, oct_pq_dynvec_t &val) |
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 | 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 | 1135 return 1; |
1136 } | |
1137 | |
1138 union | |
1139 { | |
1140 double d; | |
1141 int64_t i; | |
1142 } | |
1143 swap; | |
1144 | |
1145 for (int id = 0; id < 2; id++) | |
1146 { | |
1147 swap.d = m(id); | |
1148 | |
1149 OCT_PQ_PUT(val, int64_t, htobe64 (swap.i)) | |
1150 } | |
1151 | |
1152 return 0; | |
1153 } | |
1154 | |
1155 oct_pq_conv_t conv_point = {0, | |
1156 0, | |
1157 oct_pq_el_oids_t (), | |
1158 oct_pq_conv_cache_t (), | |
1159 false, | |
1160 false, | |
1161 false, | |
1162 "point", | |
1163 &to_octave_str_point, | |
1164 &to_octave_bin_point, | |
1165 &from_octave_str_point, | |
1166 &from_octave_bin_point}; | |
1167 | |
1168 /* end type point */ | |
1169 | |
1170 /* type lseg */ | |
1171 | |
12612 | 1172 int to_octave_str_lseg (const octave_pq_connection_rep &conn, |
11697 | 1173 const char *c, octave_value &ov, int nb) |
1174 { | |
1175 return 1; | |
1176 } | |
1177 | |
12612 | 1178 int to_octave_bin_lseg (const octave_pq_connection_rep &conn, |
11697 | 1179 const char *c, octave_value &ov, int nb) |
1180 { | |
1181 Matrix m (2, 2); | |
1182 | |
1183 union | |
1184 { | |
1185 double d; | |
1186 int64_t i; | |
1187 } | |
1188 swap; | |
1189 | |
1190 for (int id = 0; id < 4; id++, c += 8) | |
1191 { | |
1192 swap.i = be64toh (*((int64_t *) c)); | |
1193 | |
1194 m(id) = swap.d; | |
1195 } | |
1196 | |
1197 ov = octave_value (m); | |
1198 | |
1199 return 0; | |
1200 } | |
1201 | |
12612 | 1202 int from_octave_str_lseg (const octave_pq_connection_rep &conn, |
11697 | 1203 const octave_value &ov, oct_pq_dynvec_t &val) |
1204 { | |
1205 return 1; | |
1206 } | |
1207 | |
12612 | 1208 int from_octave_bin_lseg (const octave_pq_connection_rep &conn, |
11697 | 1209 const octave_value &ov, oct_pq_dynvec_t &val) |
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 | 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 | 1218 return 1; |
1219 } | |
1220 | |
1221 union | |
1222 { | |
1223 double d; | |
1224 int64_t i; | |
1225 } | |
1226 swap; | |
1227 | |
1228 for (int id = 0; id < 4; id++) | |
1229 { | |
1230 swap.d = m(id); | |
1231 | |
1232 OCT_PQ_PUT(val, int64_t, htobe64 (swap.i)) | |
1233 } | |
1234 | |
1235 return 0; | |
1236 } | |
1237 | |
1238 oct_pq_conv_t conv_lseg = {0, | |
1239 0, | |
1240 oct_pq_el_oids_t (), | |
1241 oct_pq_conv_cache_t (), | |
1242 false, | |
1243 false, | |
1244 false, | |
1245 "lseg", | |
1246 &to_octave_str_lseg, | |
1247 &to_octave_bin_lseg, | |
1248 &from_octave_str_lseg, | |
1249 &from_octave_bin_lseg}; | |
1250 | |
1251 /* end type lseg */ | |
1252 | |
1253 /* type line */ | |
1254 | |
1255 oct_pq_conv_t conv_line = {0, | |
1256 0, | |
1257 oct_pq_el_oids_t (), | |
1258 oct_pq_conv_cache_t (), | |
1259 false, | |
1260 false, | |
1261 false, | |
1262 "line", | |
1263 &to_octave_str_lseg, | |
1264 &to_octave_bin_lseg, | |
1265 &from_octave_str_lseg, | |
1266 &from_octave_bin_lseg}; | |
1267 | |
1268 /* end type line */ | |
1269 | |
1270 /* type box */ | |
1271 | |
1272 oct_pq_conv_t conv_box = {0, | |
1273 0, | |
1274 oct_pq_el_oids_t (), | |
1275 oct_pq_conv_cache_t (), | |
1276 false, | |
1277 false, | |
1278 false, | |
1279 "box", | |
1280 &to_octave_str_lseg, | |
1281 &to_octave_bin_lseg, | |
1282 &from_octave_str_lseg, | |
1283 &from_octave_bin_lseg}; | |
1284 | |
1285 /* end type box */ | |
1286 | |
1287 /* type circle */ | |
1288 | |
12612 | 1289 int to_octave_str_circle (const octave_pq_connection_rep &conn, |
11697 | 1290 const char *c, octave_value &ov, int nb) |
1291 { | |
1292 return 1; | |
1293 } | |
1294 | |
12612 | 1295 int to_octave_bin_circle (const octave_pq_connection_rep &conn, |
11697 | 1296 const char *c, octave_value &ov, int nb) |
1297 { | |
1298 ColumnVector m (3); | |
1299 | |
1300 union | |
1301 { | |
1302 double d; | |
1303 int64_t i; | |
1304 } | |
1305 swap; | |
1306 | |
1307 for (int id = 0; id < 3; id++, c += 8) | |
1308 { | |
1309 swap.i = be64toh (*((int64_t *) c)); | |
1310 | |
1311 m(id) = swap.d; | |
1312 } | |
1313 | |
1314 ov = octave_value (m); | |
1315 | |
1316 return 0; | |
1317 } | |
1318 | |
12612 | 1319 int from_octave_str_circle (const octave_pq_connection_rep &conn, |
11697 | 1320 const octave_value &ov, oct_pq_dynvec_t &val) |
1321 { | |
1322 return 1; | |
1323 } | |
1324 | |
12612 | 1325 int from_octave_bin_circle (const octave_pq_connection_rep &conn, |
11697 | 1326 const octave_value &ov, oct_pq_dynvec_t &val) |
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 | 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 | 1335 return 1; |
1336 } | |
1337 | |
1338 union | |
1339 { | |
1340 double d; | |
1341 int64_t i; | |
1342 } | |
1343 swap; | |
1344 | |
1345 for (int id = 0; id < 3; id++) | |
1346 { | |
1347 swap.d = m(id); | |
1348 | |
1349 OCT_PQ_PUT(val, int64_t, htobe64 (swap.i)) | |
1350 } | |
1351 | |
1352 return 0; | |
1353 } | |
1354 | |
1355 oct_pq_conv_t conv_circle = {0, | |
1356 0, | |
1357 oct_pq_el_oids_t (), | |
1358 oct_pq_conv_cache_t (), | |
1359 false, | |
1360 false, | |
1361 false, | |
1362 "circle", | |
1363 &to_octave_str_circle, | |
1364 &to_octave_bin_circle, | |
1365 &from_octave_str_circle, | |
1366 &from_octave_bin_circle}; | |
1367 | |
1368 /* end type circle */ | |
1369 | |
1370 /* type polygon */ | |
1371 | |
12612 | 1372 int to_octave_str_polygon (const octave_pq_connection_rep &conn, |
11697 | 1373 const char *c, octave_value &ov, int nb) |
1374 { | |
1375 return 1; | |
1376 } | |
1377 | |
12612 | 1378 int to_octave_bin_polygon (const octave_pq_connection_rep &conn, |
11697 | 1379 const char *c, octave_value &ov, int nb) |
1380 { | |
1381 int32_t np = int32_t (be32toh (*((int32_t *) c))); | |
1382 | |
1383 c += 4; | |
1384 | |
1385 Matrix m (2, np); | |
1386 | |
1387 union | |
1388 { | |
1389 double d; | |
1390 int64_t i; | |
1391 } | |
1392 swap; | |
1393 | |
1394 for (int id = 0; id < np * 2; id++, c += 8) | |
1395 { | |
1396 swap.i = be64toh (*((int64_t *) c)); | |
1397 | |
1398 m(id) = swap.d; | |
1399 } | |
1400 | |
1401 ov = octave_value (m); | |
1402 | |
1403 return 0; | |
1404 } | |
1405 | |
12612 | 1406 int from_octave_str_polygon (const octave_pq_connection_rep &conn, |
11697 | 1407 const octave_value &ov, oct_pq_dynvec_t &val) |
1408 { | |
1409 return 1; | |
1410 } | |
1411 | |
12612 | 1412 int from_octave_bin_polygon (const octave_pq_connection_rep &conn, |
11697 | 1413 const octave_value &ov, oct_pq_dynvec_t &val) |
1414 { | |
1415 octave_idx_type nel; | |
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 | 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 | 1424 return 1; |
1425 } | |
1426 | |
1427 union | |
1428 { | |
1429 double d; | |
1430 int64_t i; | |
1431 } | |
1432 swap; | |
1433 | |
1434 int32_t np = nel / 2; | |
1435 | |
1436 OCT_PQ_PUT(val, int32_t, htobe32 (np)) | |
1437 | |
1438 for (int id = 0; id < nel; id++) | |
1439 { | |
1440 swap.d = m(id); | |
1441 | |
1442 OCT_PQ_PUT(val, int64_t, htobe64 (swap.i)) | |
1443 } | |
1444 | |
1445 return 0; | |
1446 } | |
1447 | |
1448 oct_pq_conv_t conv_polygon = {0, | |
1449 0, | |
1450 oct_pq_el_oids_t (), | |
1451 oct_pq_conv_cache_t (), | |
1452 false, | |
1453 false, | |
1454 false, | |
1455 "polygon", | |
1456 &to_octave_str_polygon, | |
1457 &to_octave_bin_polygon, | |
1458 &from_octave_str_polygon, | |
1459 &from_octave_bin_polygon}; | |
1460 | |
1461 /* end type polygon */ | |
1462 | |
1463 /* type path */ | |
1464 | |
12612 | 1465 int to_octave_str_path (const octave_pq_connection_rep &conn, |
11697 | 1466 const char *c, octave_value &ov, int nb) |
1467 { | |
1468 return 1; | |
1469 } | |
1470 | |
12612 | 1471 int to_octave_bin_path (const octave_pq_connection_rep &conn, |
11697 | 1472 const char *c, octave_value &ov, int nb) |
1473 { | |
1474 bool closed = bool (*(c++)); | |
1475 | |
1476 int32_t np = int32_t (be32toh (*((int32_t *) c))); | |
1477 | |
1478 c += 4; | |
1479 | |
1480 Matrix m (2, np); | |
1481 | |
1482 union | |
1483 { | |
1484 double d; | |
1485 int64_t i; | |
1486 } | |
1487 swap; | |
1488 | |
1489 for (int id = 0; id < np * 2; id++, c += 8) | |
1490 { | |
1491 swap.i = be64toh (*((int64_t *) c)); | |
1492 | |
1493 m(id) = swap.d; | |
1494 } | |
1495 | |
1496 octave_scalar_map tp; | |
1497 tp.assign ("closed", octave_value (closed)); | |
1498 tp.assign ("path", octave_value (m)); | |
1499 | |
1500 ov = octave_value (tp); | |
1501 | |
1502 return 0; | |
1503 } | |
1504 | |
12612 | 1505 int from_octave_str_path (const octave_pq_connection_rep &conn, |
11697 | 1506 const octave_value &ov, oct_pq_dynvec_t &val) |
1507 { | |
1508 return 1; | |
1509 } | |
1510 | |
12612 | 1511 int from_octave_bin_path (const octave_pq_connection_rep &conn, |
11697 | 1512 const octave_value &ov, oct_pq_dynvec_t &val) |
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 | 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 | 1520 return 1; |
1521 } | |
1522 | |
1523 octave_idx_type nel; | |
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 | 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 | 1537 return 1; |
1538 } | |
1539 | |
1540 union | |
1541 { | |
1542 double d; | |
1543 int64_t i; | |
1544 } | |
1545 swap; | |
1546 | |
1547 int32_t np = nel / 2; | |
1548 | |
1549 val.push_back (closed); | |
1550 | |
1551 OCT_PQ_PUT(val, int32_t, htobe32 (np)) | |
1552 | |
1553 for (int id = 0; id < nel; id++) | |
1554 { | |
1555 swap.d = m(id); | |
1556 | |
1557 OCT_PQ_PUT(val, int64_t, htobe64 (swap.i)) | |
1558 } | |
1559 | |
1560 return 0; | |
1561 } | |
1562 | |
1563 oct_pq_conv_t conv_path = {0, | |
1564 0, | |
1565 oct_pq_el_oids_t (), | |
1566 oct_pq_conv_cache_t (), | |
1567 false, | |
1568 false, | |
1569 false, | |
1570 "path", | |
1571 &to_octave_str_path, | |
1572 &to_octave_bin_path, | |
1573 &from_octave_str_path, | |
1574 &from_octave_bin_path}; | |
1575 | |
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 | 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 | 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 | 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 | 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 | 1633 // helpers for network types |
1634 | |
1635 static inline | |
1636 int to_octave_bin_cidr_inet (const char *c, octave_value &ov, bool &cidr) | |
1637 { | |
1638 int8_t nb; | |
1639 | |
1640 if (*(c++) == AF_INET) | |
1641 { | |
1642 uint8NDArray a (dim_vector (5, 1), 0); | |
1643 | |
1644 a(4) = uint8_t (*(c++)); // number of set mask bits | |
1645 | |
1646 cidr = *(c++); | |
1647 | |
1648 nb = *(c++); | |
1649 | |
1650 if (nb < 0) | |
1651 nb = 0; | |
1652 | |
1653 if (nb > 4) | |
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 | 1656 |
1657 return 1; | |
1658 } | |
1659 | |
1660 for (int8_t i = 0; i < nb; i++, c++) | |
1661 a(i) = uint8_t (*c); | |
1662 | |
1663 ov = octave_value (a); | |
1664 } | |
1665 else | |
1666 { | |
1667 uint16NDArray a (dim_vector (9, 1), 0); | |
1668 | |
1669 a(8) = uint16_t (uint8_t (*(c++))); // number of set mask bits | |
1670 | |
1671 cidr = *(c++); | |
1672 | |
1673 nb = *(c++); | |
1674 | |
1675 if (nb < 0) | |
1676 nb = 0; | |
1677 | |
1678 if (nb > 16) | |
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 | 1681 |
1682 return 1; | |
1683 } | |
1684 | |
1685 int8_t n = nb / 2; | |
1686 bool odd = nb % 2; | |
1687 | |
1688 for (int8_t i = 0; i < n; i++, c += 2) | |
1689 a(i) = uint16_t (be16toh (*((uint16_t *) c))); | |
1690 | |
1691 if (odd) | |
1692 { | |
1693 uint16_t tp = *c; | |
1694 | |
1695 a(n) = uint16_t (be16toh (tp)); | |
1696 } | |
1697 | |
1698 ov = octave_value (a); | |
1699 } | |
1700 | |
1701 return 0; | |
1702 } | |
1703 | |
1704 static inline | |
1705 int from_octave_bin_cidr_inet (const octave_value &ov, oct_pq_dynvec_t &val, | |
1706 bool cidr) | |
1707 { | |
1708 int nl = ov.numel (); | |
1709 | |
1710 uint8_t n_mbits; | |
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 | 1714 if (nl == 4 || nl == 5) |
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 | 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 | 1722 return 1; |
1723 } | |
1724 | |
1725 if (nl == 5) | |
1726 n_mbits = a(4).value (); | |
1727 else | |
1728 n_mbits = 32; | |
1729 | |
1730 val.push_back (AF_INET); | |
1731 val.push_back (n_mbits); | |
1732 val.push_back (cidr); | |
1733 val.push_back (4); | |
1734 for (int i = 0; i < 4; i++) | |
1735 val.push_back (a(i).value ()); | |
1736 } | |
1737 else if (nl == 8 || nl == 9) | |
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 | 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 | 1745 return 1; |
1746 } | |
1747 | |
1748 if (nl == 9) | |
1749 n_mbits = a(8).value (); | |
1750 else | |
1751 n_mbits = 128; | |
1752 | |
1753 val.push_back (PGSQL_AF_INET6); | |
1754 val.push_back (n_mbits); | |
1755 val.push_back (cidr); | |
1756 val.push_back (16); | |
1757 for (int i = 0; i < 8; i++) | |
1758 { | |
1759 OCT_PQ_PUT(val, uint16_t, htobe16(a(i).value ())) | |
1760 } | |
1761 } | |
1762 else | |
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 | 1765 return 1; |
1766 } | |
1767 | |
1768 return 0; | |
1769 } | |
1770 | |
1771 // end helpers for network types | |
1772 | |
1773 /* type cidr */ | |
1774 | |
12612 | 1775 int to_octave_str_cidr (const octave_pq_connection_rep &conn, |
11708 | 1776 const char *c, octave_value &ov, int nb) |
1777 { | |
1778 return 1; | |
1779 } | |
1780 | |
12612 | 1781 int to_octave_bin_cidr (const octave_pq_connection_rep &conn, |
11708 | 1782 const char *c, octave_value &ov, int nb) |
1783 { | |
1784 bool cidr = false; | |
1785 | |
1786 if (to_octave_bin_cidr_inet (c, ov, cidr)) | |
1787 return 1; | |
1788 | |
1789 if (! cidr) | |
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 | 1792 |
1793 return 1; | |
1794 } | |
1795 | |
1796 return 0; | |
1797 } | |
1798 | |
12612 | 1799 int from_octave_str_cidr (const octave_pq_connection_rep &conn, |
11708 | 1800 const octave_value &ov, oct_pq_dynvec_t &val) |
1801 { | |
1802 return 1; | |
1803 } | |
1804 | |
12612 | 1805 int from_octave_bin_cidr (const octave_pq_connection_rep &conn, |
11708 | 1806 const octave_value &ov, oct_pq_dynvec_t &val) |
1807 { | |
1808 return from_octave_bin_cidr_inet (ov, val, true); | |
1809 } | |
1810 | |
1811 oct_pq_conv_t conv_cidr = {0, | |
1812 0, | |
1813 oct_pq_el_oids_t (), | |
1814 oct_pq_conv_cache_t (), | |
1815 false, | |
1816 false, | |
1817 false, | |
1818 "cidr", | |
1819 &to_octave_str_cidr, | |
1820 &to_octave_bin_cidr, | |
1821 &from_octave_str_cidr, | |
1822 &from_octave_bin_cidr}; | |
1823 | |
1824 /* end type cidr */ | |
1825 | |
1826 /* type inet */ | |
1827 | |
12612 | 1828 int to_octave_str_inet (const octave_pq_connection_rep &conn, |
11708 | 1829 const char *c, octave_value &ov, int nb) |
1830 { | |
1831 return 1; | |
1832 } | |
1833 | |
12612 | 1834 int to_octave_bin_inet (const octave_pq_connection_rep &conn, |
11708 | 1835 const char *c, octave_value &ov, int nb) |
1836 { | |
1837 bool cidr = false; | |
1838 | |
1839 if (to_octave_bin_cidr_inet (c, ov, cidr)) | |
1840 return 1; | |
1841 | |
1842 if (cidr) | |
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 | 1845 |
1846 return 1; | |
1847 } | |
1848 | |
1849 return 0; | |
1850 } | |
1851 | |
12612 | 1852 int from_octave_str_inet (const octave_pq_connection_rep &conn, |
11708 | 1853 const octave_value &ov, oct_pq_dynvec_t &val) |
1854 { | |
1855 return 1; | |
1856 } | |
1857 | |
12612 | 1858 int from_octave_bin_inet (const octave_pq_connection_rep &conn, |
11708 | 1859 const octave_value &ov, oct_pq_dynvec_t &val) |
1860 { | |
1861 return from_octave_bin_cidr_inet (ov, val, false); | |
1862 } | |
1863 | |
1864 oct_pq_conv_t conv_inet = {0, | |
1865 0, | |
1866 oct_pq_el_oids_t (), | |
1867 oct_pq_conv_cache_t (), | |
1868 false, | |
1869 false, | |
1870 false, | |
1871 "inet", | |
1872 &to_octave_str_inet, | |
1873 &to_octave_bin_inet, | |
1874 &from_octave_str_inet, | |
1875 &from_octave_bin_inet}; | |
1876 | |
1877 /* end type inet */ | |
1878 | |
1879 /* type macaddr */ | |
1880 | |
12612 | 1881 int to_octave_str_macaddr (const octave_pq_connection_rep &conn, |
11708 | 1882 const char *c, octave_value &ov, int nb) |
1883 { | |
1884 return 1; | |
1885 } | |
1886 | |
12612 | 1887 int to_octave_bin_macaddr (const octave_pq_connection_rep &conn, |
11708 | 1888 const char *c, octave_value &ov, int nb) |
1889 { | |
1890 uint8NDArray a (dim_vector (6, 1)); | |
1891 | |
1892 for (int i = 0; i < 6; i++, c++) | |
1893 a(i) = uint8_t (*c); | |
1894 | |
1895 ov = octave_value (a); | |
1896 | |
1897 return 0; | |
1898 } | |
1899 | |
12612 | 1900 int from_octave_str_macaddr (const octave_pq_connection_rep &conn, |
11708 | 1901 const octave_value &ov, oct_pq_dynvec_t &val) |
1902 { | |
1903 return 1; | |
1904 } | |
1905 | |
12612 | 1906 int from_octave_bin_macaddr (const octave_pq_connection_rep &conn, |
11708 | 1907 const octave_value &ov, oct_pq_dynvec_t &val) |
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 | 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 | 1916 return 1; |
1917 } | |
1918 | |
1919 if (a.numel () != 6) | |
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 | 1922 return 1; |
1923 } | |
1924 | |
1925 for (int i = 0; i < 6; i++) | |
1926 val.push_back (a(i).value ()); | |
1927 | |
1928 return 0; | |
1929 } | |
1930 | |
1931 oct_pq_conv_t conv_macaddr = {0, | |
1932 0, | |
1933 oct_pq_el_oids_t (), | |
1934 oct_pq_conv_cache_t (), | |
1935 false, | |
1936 false, | |
1937 false, | |
1938 "macaddr", | |
1939 &to_octave_str_macaddr, | |
1940 &to_octave_bin_macaddr, | |
1941 &from_octave_str_macaddr, | |
1942 &from_octave_bin_macaddr}; | |
1943 | |
1944 /* end type macaddr */ | |
1945 | |
11710 | 1946 /* type bit */ |
1947 | |
12612 | 1948 int to_octave_str_bit (const octave_pq_connection_rep &conn, |
11710 | 1949 const char *c, octave_value &ov, int nb) |
1950 { | |
1951 return 1; | |
1952 } | |
1953 | |
12612 | 1954 int to_octave_bin_bit (const octave_pq_connection_rep &conn, |
11710 | 1955 const char *c, octave_value &ov, int nb) |
1956 { | |
1957 int32_t nbits = int32_t (be32toh (*((int32_t *) c))); | |
1958 | |
1959 c += 4; | |
1960 | |
1961 int32_t nbytes = (nbits + 7) / 8; | |
1962 | |
1963 uint8NDArray a (dim_vector (nbytes, 1)); | |
1964 | |
1965 for (int i = 0; i < nbytes; i++, c++) | |
1966 a(i) = uint8_t (*c); | |
1967 | |
1968 octave_scalar_map tp; | |
1969 tp.assign ("bitlen", octave_value (octave_int32 (nbits))); | |
1970 tp.assign ("bits", octave_value (a)); | |
1971 | |
1972 ov = octave_value (tp); | |
1973 | |
1974 return 0; | |
1975 } | |
1976 | |
12612 | 1977 int from_octave_str_bit (const octave_pq_connection_rep &conn, |
11710 | 1978 const octave_value &ov, oct_pq_dynvec_t &val) |
1979 { | |
1980 return 1; | |
1981 } | |
1982 | |
12612 | 1983 int from_octave_bin_bit (const octave_pq_connection_rep &conn, |
11710 | 1984 const octave_value &ov, oct_pq_dynvec_t &val) |
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 | 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 | 1992 return 1; |
1993 } | |
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 | 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 | 2007 return 1; |
2008 } | |
2009 | |
2010 int32_t nbytes = (nbits + 7) / 8; | |
2011 | |
2012 if (a.numel () != nbytes) | |
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 | 2015 return 1; |
2016 } | |
2017 | |
2018 OCT_PQ_PUT(val, int32_t, htobe32 (nbits)) | |
2019 | |
2020 for (int i = 0; i < nbytes; i++) | |
2021 val.push_back (a(i).value ()); | |
2022 | |
2023 return 0; | |
2024 } | |
2025 | |
2026 oct_pq_conv_t conv_bit = {0, | |
2027 0, | |
2028 oct_pq_el_oids_t (), | |
2029 oct_pq_conv_cache_t (), | |
2030 false, | |
2031 false, | |
2032 false, | |
2033 "bit", | |
2034 &to_octave_str_bit, | |
2035 &to_octave_bin_bit, | |
2036 &from_octave_str_bit, | |
2037 &from_octave_bin_bit}; | |
2038 | |
2039 /* end type bit */ | |
2040 | |
2041 /* type varbit */ | |
2042 | |
2043 oct_pq_conv_t conv_varbit = {0, | |
2044 0, | |
2045 oct_pq_el_oids_t (), | |
2046 oct_pq_conv_cache_t (), | |
2047 false, | |
2048 false, | |
2049 false, | |
2050 "varbit", | |
2051 &to_octave_str_bit, | |
2052 &to_octave_bin_bit, | |
2053 &from_octave_str_bit, | |
2054 &from_octave_bin_bit}; | |
2055 | |
2056 /* end type varbit */ | |
2057 | |
11712 | 2058 /* type uuid */ |
2059 | |
12612 | 2060 int to_octave_str_uuid (const octave_pq_connection_rep &conn, |
11712 | 2061 const char *c, octave_value &ov, int nb) |
2062 { | |
2063 return 1; | |
2064 } | |
2065 | |
12612 | 2066 int to_octave_bin_uuid (const octave_pq_connection_rep &conn, |
11712 | 2067 const char *c, octave_value &ov, int nb) |
2068 { | |
2069 uint8NDArray m (dim_vector (16, 1)); | |
2070 | |
2071 uint8_t *p = (uint8_t *) m.fortran_vec (); | |
2072 for (int i = 0; i < 16; i++, c++) | |
2073 *(p++) = uint8_t (*c); | |
2074 | |
2075 ov = octave_value (m); | |
2076 | |
2077 return 0; | |
2078 } | |
2079 | |
12612 | 2080 int from_octave_str_uuid (const octave_pq_connection_rep &conn, |
11712 | 2081 const octave_value &ov, oct_pq_dynvec_t &val) |
2082 { | |
2083 return 1; | |
2084 } | |
2085 | |
12612 | 2086 int from_octave_bin_uuid (const octave_pq_connection_rep &conn, |
11712 | 2087 const octave_value &ov, oct_pq_dynvec_t &val) |
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 | 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 | 2096 return 1; |
2097 } | |
2098 | |
2099 if (b.numel () != 16) | |
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 | 2102 return 1; |
2103 } | |
2104 | |
2105 for (int i = 0; i < 16; i++) | |
2106 val.push_back (b(i).value ()); | |
2107 | |
2108 return 0; | |
2109 } | |
2110 | |
2111 oct_pq_conv_t conv_uuid = {0, | |
2112 0, | |
2113 oct_pq_el_oids_t (), | |
2114 oct_pq_conv_cache_t (), | |
2115 false, | |
2116 false, | |
2117 false, | |
2118 "uuid", | |
2119 &to_octave_str_uuid, | |
2120 &to_octave_bin_uuid, | |
2121 &from_octave_str_uuid, | |
2122 &from_octave_bin_uuid}; | |
2123 | |
2124 /* end type uuid */ | |
2125 | |
2126 /* type xml */ | |
2127 | |
12612 | 2128 int to_octave_str_xml (const octave_pq_connection_rep &conn, |
11712 | 2129 const char *c, octave_value &ov, int nb) |
2130 { | |
2131 return 1; | |
2132 } | |
2133 | |
12612 | 2134 int to_octave_bin_xml (const octave_pq_connection_rep &conn, |
11712 | 2135 const char *c, octave_value &ov, int nb) |
2136 { | |
2137 std::string s (c, nb); | |
2138 | |
2139 ov = octave_value (s); | |
2140 | |
2141 return 0; | |
2142 } | |
2143 | |
12612 | 2144 int from_octave_str_xml (const octave_pq_connection_rep &conn, |
11712 | 2145 const octave_value &ov, oct_pq_dynvec_t &val) |
2146 { | |
2147 return 1; | |
2148 } | |
2149 | |
12612 | 2150 int from_octave_bin_xml (const octave_pq_connection_rep &conn, |
11712 | 2151 const octave_value &ov, oct_pq_dynvec_t &val) |
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 | 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 | 2160 return 1; |
2161 } | |
2162 | |
2163 octave_idx_type l = s.size (); | |
2164 | |
2165 for (int i = 0; i < l; i++) | |
2166 val.push_back (s[i]); | |
2167 | |
2168 return 0; | |
2169 } | |
2170 | |
2171 oct_pq_conv_t conv_xml = {0, | |
2172 0, | |
2173 oct_pq_el_oids_t (), | |
2174 oct_pq_conv_cache_t (), | |
2175 false, | |
2176 false, | |
2177 false, | |
2178 "xml", | |
2179 &to_octave_str_text, | |
2180 &to_octave_bin_text, | |
2181 &from_octave_str_text, | |
2182 &from_octave_bin_text}; | |
2183 | |
2184 /* end type xml */ | |
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 | 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 | 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 | 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 | 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 | 2288 oct_pq_conv_t *t_conv_ptrs[OCT_PQ_NUM_CONVERTERS] = {&conv_bool, |
2289 &conv_oid, | |
2290 &conv_float8, | |
2291 &conv_float4, | |
2292 &conv_text, | |
2293 &conv_varchar, | |
2294 &conv_bpchar, | |
2295 &conv_name, | |
2296 &conv_bytea, | |
2297 &conv_int2, | |
2298 &conv_int4, | |
2299 &conv_int8, | |
11661 | 2300 &conv_money, |
11667 | 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 | 2306 &conv_date, |
2307 &conv_point, | |
2308 &conv_lseg, | |
2309 &conv_line, | |
2310 &conv_box, | |
2311 &conv_circle, | |
2312 &conv_polygon, | |
11698
b3cbebad8a26
Fix segfault after internal error. Add converter for type 'unknown'.
i7tiol
parents:
11697
diff
changeset
|
2313 &conv_path, |
11708 | 2314 &conv_unknown, |
2315 &conv_cidr, | |
2316 &conv_inet, | |
11710 | 2317 &conv_macaddr, |
2318 &conv_bit, | |
11712 | 2319 &conv_varbit, |
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 | 2323 |
2324 oct_pq_conv_ptrs_t conv_ptrs (OCT_PQ_NUM_CONVERTERS, t_conv_ptrs); |