1 /* ------------------------------------------------
2 Copyright 2014 AT&T Intellectual Property
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
7 http://www.apache.org/licenses/LICENSE-2.0
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ------------------------------------------- */
15 #ifndef __INTERFACE_IMPL_INCLUDED__
16 #define __INTERFACE_IMPL_INCLUDED__
18 #include"schemaparser.h"
21 #include"type_indicators.h"
22 #include"type_objects.h"
29 // access_result (access_fcn)(char *tuple, int offset);
30 class tuple_access_info{
32 std::string field_name;
42 int init(field_entry *fe){
43 field_name = fe->get_name();
44 pdt = new data_type(fe->get_type());
45 return(pdt->type_indicator());
49 class param_block_info{
51 std::string param_name;
63 int init(var_pair_t *vp){
65 param_name = vp->name;
66 pdt = new data_type(vp->val);
67 switch(pdt->get_type()){
75 value.r.f = 0.0; break;
77 value.r.ul = 0; break;
81 value.r.t.tv_sec=0; value.r.t.tv_usec=0; break;
83 value.r.vs.length = 0; value.r.vs.offset = 0; value.r.vs.reserved=0; break;
85 value.r.fs.data = NULL;
91 return(pdt->type_indicator());
101 std::vector<tuple_access_info> field_info;
104 std::vector<param_block_info> param_info;
107 query_rep(std::string nm, int ntuples, int nparams) :
108 name(nm), field_info(ntuples), param_info(nparams) {
113 int set_field_info(int f, field_entry *fe){
114 if(f<0 || f>=field_info.size()) return(-1);
115 return(field_info[f].init(fe));
118 int finalize_field_info(){
121 int fld_undefined = 0;
122 for(f=0;f<field_info.size();++f){
123 field_info[f].offset = curr_pos;
124 int sz = field_info[f].pdt->type_size();
125 if(sz==0) fld_undefined = 1;
128 min_tuple_size = curr_pos;
129 if(fld_undefined) return(-1);
133 int set_param_info(int p, var_pair_t *vp){
134 if(p<0 || p>=param_info.size()) return(-1);
135 return(param_info[p].init(vp));
138 int finalize_param_info(){
141 int fld_undefined = 0;
142 for(p=0;p<param_info.size();++p){
143 param_info[p].offset = curr_pos;
144 int sz = param_info[p].pdt->type_size();
145 if(sz==0) fld_undefined = 1;
148 min_param_size = curr_pos;
149 if(fld_undefined) return(-1);
157 void ftaschema_debugdump(int sch_handle);