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

Update copyright notices.
author i7tiol
date Sat, 27 Feb 2016 11:21:29 +0000
parents 2257648e8ce1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
1 /*
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
2
12720
52ca082757c2 Update copyright notices.
i7tiol
parents: 12612
diff changeset
3 Copyright (C) 2012-2016 Olaf Till <i7tiol@t-online.de>
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
4
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
5 This program is free software; you can redistribute it and/or modify
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
7 the Free Software Foundation; either version 3 of the License, or
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
8 (at your option) any later version.
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
9
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
13 GNU General Public License for more details.
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
14
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
16 along with this program; If not, see <http://www.gnu.org/licenses/>.
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
17
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
18 */
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
19
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
20 #ifndef __OCT_PQ_CONVERTERS__
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
21
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
22 #define __OCT_PQ_CONVERTERS__
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
23
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
24 #include <octave/oct.h>
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
25
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
26 #include <stdint.h>
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
27
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
28 #include <vector>
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
29 #include <string>
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
30
11553
35e9e4b6ab34 Fix configuration of postgresql include directories.
i7tiol
parents: 11480
diff changeset
31 #include <libpq-fe.h>
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
32
11644
eb48ca3b21a1 Fix #include <endian.h> for Apple, reported by Kamil Badyla.
i7tiol
parents: 11553
diff changeset
33 #include "wrap_endian.h"
eb48ca3b21a1 Fix #include <endian.h> for Apple, reported by Kamil Badyla.
i7tiol
parents: 11553
diff changeset
34
11715
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11714
diff changeset
35 #define OCT_PQ_NUM_CONVERTERS 35
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
36
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
37 typedef std::vector<char> oct_pq_dynvec_t;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
38
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
39 typedef enum {simple, array, composite} pq_oct_type_t;
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
40
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
41 typedef struct
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
42 {
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
43 dim_vector pd, cur;
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
44 octave_idx_type nd;
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
45 }
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
46 oct_mo_count_state;
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
47
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
48 class octave_pq_connection_rep;
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
49
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
50 typedef int (*oct_pq_to_octave_fp_t) (const octave_pq_connection_rep &,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11644
diff changeset
51 const char *, octave_value &, int);
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11644
diff changeset
52
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
53 typedef int (*oct_pq_from_octave_fp_t) (const octave_pq_connection_rep &,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11644
diff changeset
54 const octave_value &,
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11644
diff changeset
55 oct_pq_dynvec_t &);
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
56
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: 11460
diff changeset
57 typedef std::vector<Oid> oct_pq_el_oids_t;
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: 11460
diff changeset
58
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
59 struct oct_pq_conv_t_;
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
60
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
61 typedef std::vector<struct oct_pq_conv_t_ *> oct_pq_conv_cache_t;
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
62
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
63 // some objects will be constants, some will be allocated
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
64 typedef struct oct_pq_conv_t_
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
65 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
66 Oid oid; // read from server
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
67 Oid aoid; // array oid // read from server
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: 11460
diff changeset
68 oct_pq_el_oids_t el_oids; // element oids, empty for non-composite types
11480
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
69 oct_pq_conv_cache_t conv_cache; // element converter structures for
d14a23884d9c Cache map lookups of converters for composite type elements.
i7tiol
parents: 11474
diff changeset
70 //composite types
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
71 bool is_composite; // false for constant objects
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
72 bool is_enum; // false for constant objects
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
73 bool is_not_constant; // false for constant objects
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
74 // const char *name; not all constants, use std::string
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
75 std::string name;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
76 oct_pq_to_octave_fp_t to_octave_str;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
77 oct_pq_to_octave_fp_t to_octave_bin;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
78 oct_pq_from_octave_fp_t from_octave_str;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
79 oct_pq_from_octave_fp_t from_octave_bin;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
80 }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
81 oct_pq_conv_t;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
82
11460
9ef769abf53d Fix segfault reported by Richard <richard@mail.sheugh.com>, due to undefined order of initialization.
i7tiol
parents: 11429
diff changeset
83 std::string &pq_basetype_prefix (void);
11429
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
84
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
85 // a wrapper class for array of pointers to converters which qualifies
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
86 // base type names in initialization
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
87 class oct_pq_conv_ptrs_t
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
88 {
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
89 public:
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
90
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
91 oct_pq_conv_ptrs_t (int n, oct_pq_conv_t **ptrs) : converters (ptrs)
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
92 {
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
93 for (int i = 0; i < n; i++)
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
94 {
11460
9ef769abf53d Fix segfault reported by Richard <richard@mail.sheugh.com>, due to undefined order of initialization.
i7tiol
parents: 11429
diff changeset
95 std::string prefix = pq_basetype_prefix ();
11429
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
96
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
97 converters[i]->name = prefix.append (converters[i]->name);
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
98 }
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
99 }
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
100
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
101 oct_pq_conv_t *operator[] (int i) { return converters[i]; }
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
102
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
103 private:
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
104
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
105 oct_pq_conv_t **converters;
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
106 };
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
107
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
108 // a wrapper class around oct_pq_conv_t* to provide a default
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
109 // constructor which nullifies it, for efficient use of maps, where
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
110 // checking for the presence of a key while inserting it can rely on a
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
111 // newly generated key mapping to a value of NULL
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
112 class oct_pq_conv_wrapper_t
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
113 {
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
114 public:
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
115
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
116 oct_pq_conv_wrapper_t (void) : conv (NULL) {}
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
117
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
118 oct_pq_conv_wrapper_t (oct_pq_conv_t *c) : conv (c) {}
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
119
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
120 operator oct_pq_conv_t *&(void) { return conv; }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
121
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
122 oct_pq_conv_t *&operator->(void) { return conv; }
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
123
11714
7198ecd313b5 A better way of the previous 'command' cleanup.
i7tiol
parents: 11713
diff changeset
124 oct_pq_conv_t *get_copy (void) const { return conv; }
7198ecd313b5 A better way of the previous 'command' cleanup.
i7tiol
parents: 11713
diff changeset
125
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
126 private:
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
127
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
128 oct_pq_conv_t *conv;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
129 };
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
130
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
131 typedef std::map<Oid, oct_pq_conv_wrapper_t> oct_pq_conv_map_t;
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
132
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
133 typedef std::map<const char *, oct_pq_conv_wrapper_t,
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
134 bool (*) (const char *, const char *)> oct_pq_name_conv_map_t;
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
135
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
136 // helper function for debugging
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
137 void print_conv (oct_pq_conv_t *);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
138
11429
61ea672a060a Consider schemas in type specifications by name.
i7tiol
parents: 11410
diff changeset
139 extern oct_pq_conv_ptrs_t conv_ptrs;
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
140
11410
c20550232685 Conversion of enum types implemented.
i7tiol
parents: 11409
diff changeset
141 // these prototypes are needed because pointers to these functions are
c20550232685 Conversion of enum types implemented.
i7tiol
parents: 11409
diff changeset
142 // stored in the converter structures of each found enum type
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
143 int to_octave_str_text (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11644
diff changeset
144 const char *c, octave_value &ov, int nb);
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
145 int to_octave_bin_text (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11644
diff changeset
146 const char *c, octave_value &ov, int nb);
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
147 int from_octave_str_text (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11644
diff changeset
148 const octave_value &ov, oct_pq_dynvec_t &val);
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
149 int from_octave_bin_text (const octave_pq_connection_rep &conn,
11657
465192f682f0 Pass connection information to converters.
i7tiol
parents: 11644
diff changeset
150 const octave_value &ov, oct_pq_dynvec_t &val);
11410
c20550232685 Conversion of enum types implemented.
i7tiol
parents: 11409
diff changeset
151
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
152 oct_pq_conv_t *pgtype_from_octtype (const octave_pq_connection_rep &conn,
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
153 const octave_value &);
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
154
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
155 oct_pq_conv_t *pgtype_from_spec (const octave_pq_connection_rep &, std::string &,
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
156 pq_oct_type_t &);
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
157
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
158 oct_pq_conv_t *pgtype_from_spec (const octave_pq_connection_rep &, Oid,
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
159 pq_oct_type_t &);
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
160
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
161 oct_pq_conv_t *pgtype_from_spec (const octave_pq_connection_rep &, Oid,
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
162 oct_pq_conv_t *&, pq_oct_type_t &);
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
163
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
164 octave_idx_type count_row_major_order (dim_vector &, oct_mo_count_state &,
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
165 bool);
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
166
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
167 int from_octave_bin_array (const octave_pq_connection_rep &conn,
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
168 const octave_value &oct_arr, oct_pq_dynvec_t &val,
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
169 oct_pq_conv_t *);
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
170
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
171 int from_octave_bin_composite (const octave_pq_connection_rep &conn,
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
172 const octave_value &oct_comp,
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
173 oct_pq_dynvec_t &val, oct_pq_conv_t *);
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
174
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
175 int from_octave_str_array (const octave_pq_connection_rep &conn,
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
176 const octave_value &oct_arr, oct_pq_dynvec_t &val,
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
177 octave_value &type);
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
178
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
179 int from_octave_str_composite (const octave_pq_connection_rep &conn,
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
180 const octave_value &oct_comp,
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
181 oct_pq_dynvec_t &val, octave_value &type);
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
182
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
183 int to_octave_bin_array (const octave_pq_connection_rep &conn,
11715
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11714
diff changeset
184 const char *, octave_value &, int, oct_pq_conv_t *);
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
185
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
186 int to_octave_bin_composite (const octave_pq_connection_rep &conn, const char *,
11715
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11714
diff changeset
187 octave_value &, int, oct_pq_conv_t *);
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
188
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
189 int to_octave_str_array (const octave_pq_connection_rep &conn,
11715
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11714
diff changeset
190 const char *, octave_value &, int, oct_pq_conv_t *);
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
191
12612
2257648e8ce1 avoid using const_cast, new release 2.3.2
i7tiol
parents: 11715
diff changeset
192 int to_octave_str_composite (const octave_pq_connection_rep &conn, const char *,
11715
ed5361361a0f Added converter for type 'record'. Some 'const' corrections.
i7tiol
parents: 11714
diff changeset
193 octave_value &, int, oct_pq_conv_t *);
11713
ee2b22964070 Make some functions of class 'command' non-members.
i7tiol
parents: 11712
diff changeset
194
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
195 // append bytes of value 'val' of type 'type' to dynamic char vector 'dv'
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
196 #define OCT_PQ_PUT(dv, type, val) \
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
197 dv.resize (dv.size () + sizeof (type)); \
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
198 *((type *) &(dv.end ()[-sizeof (type)])) = val;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
199
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
200 // increase size of dynamic char vector 'dv' by size of uint32 and
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
201 // store the new size in a variable named 'var' of octave_idx_type;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
202 // after further increasing 'dv', OCT_PQ_FILL_UINT32_PLACEHOLDER
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
203 // should be used with equal arguments
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
204 #define OCT_PQ_SET_UINT32_PLACEHOLDER(dv, var) \
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
205 octave_idx_type var = dv.size () + sizeof (uint32_t); \
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
206 dv.resize (var);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
207 // to be used after OCT_PQ_SET_UINT32_PLACEHOLDER with equal
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
208 // arguments; calculate difference between current size of dynamic
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
209 // char vector 'dv' and a previous size stored in a variable named
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
210 // 'var', and write this difference, converted to uint32_t in network
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
211 // byte order, to the placeholder within 'dv' just before the position
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
212 // stored in 'var'
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
213 #define OCT_PQ_FILL_UINT32_PLACEHOLDER(dv, var) \
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
214 *((uint32_t *) &(dv[var - sizeof (uint32_t)])) = htobe32 (dv.size () - var);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
215
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
216 #define OCT_PQ_DECL_GET_INT32(retvar, pointer, type) \
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
217 type retvar = be32toh (*((type *) pointer)); \
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
218 pointer += 4;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
219
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
220 #define OCT_PQ_GET_INT32(retvar, pointer, type) \
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
221 retvar = be32toh (*((type *) pointer)); \
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
222 pointer += 4;
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 #endif // __OCT_PQ_CONVERTERS__