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 ------------------------------------------- */
16 #include"type_objects.h"
22 void data_type::assign_schema_type(){
29 schema_type = "USHORT";
38 schema_type = "ULLONG";
41 schema_type = "LLONG";
44 schema_type = "FLOAT";
47 schema_type = "V_STR";
50 schema_type = "TIMEVAL";
59 sprintf(tmps,"FSTRING%d",size);
63 schema_type = "UNDEFINED_TYPE";
69 data_type::data_type(string st){
73 assign_type_from_string(st);
77 // Assign data type of a colref using information about
78 // modifiers as well as data type. This should be made robust.
79 data_type::data_type(string st, param_list *modifiers){
83 assign_type_from_string(st);
85 if(modifiers != NULL){
87 for(i=0;i<modifiers->size();i++){
88 if( modifiers->contains_key("increasing") ||
89 modifiers->contains_key("Increasing") ||
90 modifiers->contains_key("INCREASING")){
91 temporal = increasing_t;
93 if( modifiers->contains_key("decreasing") ||
94 modifiers->contains_key("Decreasing") ||
95 modifiers->contains_key("DECREASING")){
96 temporal = decreasing_t;
98 if(modifiers->contains_key("subtype")){
99 subtype = modifiers->val_of("subtype");
106 void data_type::assign_type_from_string(string st){
107 if(st == "bool" || st == "Bool" || st == "BOOL"){
109 assign_schema_type();
112 if(st == "ushort" || st == "Ushort" || st == "USHORT"){
114 assign_schema_type();
117 if(st == "uint" || st == "Uint" || st == "UINT"){
119 assign_schema_type();
122 if(st == "int" || st == "Int" || st == "INT"){
124 assign_schema_type();
127 if(st == "ullong" || st == "Ullong" || st == "ULLONG"){
129 assign_schema_type();
132 if(st == "llong" || st == "llong" || st == "LLONG"){
134 assign_schema_type();
137 if(st == "float" || st == "Float" || st == "FLOAT"){
139 assign_schema_type();
142 if(st == "string" || st == "String" || st == "STRING" ||
143 st == "v_str" || st == "V_str" || st == "V_STR"){
145 assign_schema_type();
148 if(st == "timeval" || st == "Timeval" || st == "TIMEVAL"){
150 assign_schema_type();
155 assign_schema_type();
158 if(st == "IPV6" || st == "IPv6"){
160 assign_schema_type();
163 if(sscanf(st.c_str(),"fstring%d",&size)>0){
165 assign_schema_type();
168 if(sscanf(st.c_str(),"Fstring%d",&size)>0){
170 assign_schema_type();
173 if(sscanf(st.c_str(),"FSTRING%d",&size)>0){
175 assign_schema_type();
180 assign_schema_type();
184 data_type::data_type(data_type *lhs, string &op){
186 // type = undefined_t;
187 // temporal_type l_tempo = lhs->get_temporal();;
188 // if(l_tempo == constant_t) temporal = constant_t;
189 // else temporal = varying_t;
191 temporal = compute_temporal_type(lhs->get_temporal(),op);
194 switch(lhs->get_type()){
201 // if(l_tempo == increasing_t) temporal = decreasing_t;
202 // if(l_tempo == decreasing_t) temporal = increasing_t;
207 // if(l_tempo == increasing_t) temporal = decreasing_t;
208 // if(l_tempo == decreasing_t) temporal = increasing_t;
212 // if(l_tempo == increasing_t) temporal = decreasing_t;
213 // if(l_tempo == decreasing_t) temporal = increasing_t;
221 switch(lhs->get_type()){
229 type = lhs->get_type();
237 switch(lhs->get_type()){
244 type = lhs->get_type();
251 subtype = lhs->subtype;
252 assign_schema_type();
255 temporal_type data_type::compute_temporal_type(temporal_type l_tempo, string &op){
258 if(l_tempo == constant_t) ret = constant_t;
259 else ret = varying_t;
262 if(l_tempo == increasing_t) ret = decreasing_t;
263 else if(l_tempo == decreasing_t) ret = increasing_t;
269 data_type::data_type(data_type *lhs, data_type *rhs, const string &op){
273 dtype l_type = lhs->get_type();
274 dtype r_type = rhs->get_type();
276 // First, deduce the type of the result.
277 if( (op=="-")||(op=="+")||(op=="/")||(op=="*")||(op=="%")||(op==">>")||(op=="<<") ){
278 switch(lhs->get_type()){
280 switch(rhs->get_type()){
284 type = rhs->get_type();
288 if(op != ">>" && op != "<<")
289 type = rhs->get_type();
292 if(op != "%" && op != ">>" && op != "<<")
296 if(op == "+") type = timeval_t;
303 switch(rhs->get_type()){
311 if(op != ">>" && op != "<<")
312 type = rhs->get_type();
315 if(op != "%" && op != ">>" && op != "<<")
319 if(op == "+") type = timeval_t;
326 switch(rhs->get_type()){
332 type = rhs->get_type();
336 if(op != ">>" && op != "<<")
337 type = rhs->get_type();
340 if(op != "%" && op != ">>" && op != "<<")
344 if(op == "+") type = timeval_t;
351 switch(rhs->get_type()){
358 if(op != ">>" && op != "<<")
362 if(op != ">>" && op != "<<")
366 if(op != "%" && op != ">>" && op != "<<")
374 switch(rhs->get_type()){
382 if(op != ">>" && op != "<<")
386 if(op != "%" && op != ">>" && op != "<<")
394 if(op != "%" && op != ">>" && op != "<<"){
395 switch(rhs->get_type()){
411 switch(rhs->get_type()){
415 if(op == "+" || op == "-" || op == "/"){
433 if( (op == "|") || (op == "&") ){
434 switch(lhs->get_type()){
436 switch(rhs->get_type()){
442 type = rhs->get_type();
452 switch(rhs->get_type()){
460 type = rhs->get_type();
473 switch(rhs->get_type()){
484 type = rhs->get_type();
494 switch(rhs->get_type()){
502 type = rhs->get_type();
512 switch(rhs->get_type()){
528 switch(rhs->get_type()){
542 switch(rhs->get_type()){
553 if(rhs->get_type() == ipv6_t)
560 assign_schema_type();
561 temporal = compute_temporal_type(lhs->get_temporal(),rhs->get_temporal(),lhs->get_type(), rhs->get_type(), op);
562 if(lhs->subtype == rhs->subtype){
563 subtype = lhs->subtype;
570 temporal_type data_type::compute_temporal_type(temporal_type l_tempo, temporal_type r_tempo, dtype l_type, dtype r_type, const string &op){
573 // Next, deduce the temporalness of the result.
574 // One complication : if the value of the RHS or LHS is
575 // negative, we can't deduce anything about the temporality
578 // temporal_type l_tempo = lhs->get_temporal();
579 // temporal_type r_tempo = rhs->get_temporal();
580 // dtype l_type = lhs->get_type();
581 // dtype r_type = rhs->get_type();
584 if(l_tempo == constant_t) ret = r_tempo;
585 if(r_tempo == constant_t) ret = l_tempo;
586 if(l_tempo == r_tempo) ret = r_tempo;
589 if(l_tempo == constant_t && r_tempo == constant_t) ret = constant_t;
590 if((l_tempo == constant_t || l_tempo ==decreasing_t) &&
591 r_tempo == increasing_t &&
592 (r_type != int_t && r_type != floating_t) ) ret = decreasing_t;
593 if((l_tempo == constant_t || l_tempo ==increasing_t) &&
594 r_tempo == decreasing_t &&
595 (r_type != int_t && r_type != floating_t) ) ret = increasing_t;
598 // If the value might be negative, can't deduce anything
599 // However Java doesn't have unsigned types so the logic which forbids int has to be relaxed.
601 // if((l_type!=int_t && l_type!=floating_t && l_type!=llong_t) && (r_type!=int_t && r_type!=floating_t && r_type!=llong_t)){
602 if(!((l_type==int_t || l_type==floating_t || l_type==llong_t) && (r_type==int_t || r_type==floating_t || r_type==llong_t))){
603 if(l_tempo == constant_t) ret = r_tempo;
604 if(r_tempo == constant_t) ret = l_tempo;
605 if(l_tempo == r_tempo) ret = r_tempo;
609 // if((l_type!=int_t && l_type!=floating_t && l_type!=llong_t) && (r_type!=int_t && r_type!=floating_t && r_type!=llong_t)){
610 if(!((l_type==int_t || l_type==floating_t || l_type==llong_t) && (r_type==int_t || r_type==floating_t || r_type==llong_t))){
611 if((l_tempo == constant_t || l_tempo ==decreasing_t) &&
612 (r_tempo == increasing_t)) ret = decreasing_t;
613 if((l_tempo == constant_t || l_tempo ==increasing_t) &&
614 (r_tempo == decreasing_t )) ret = increasing_t;
615 if(r_tempo == constant_t) ret = l_tempo;
624 data_type *data_type::duplicate(){
625 data_type *ret = new data_type();
626 ret->schema_type = schema_type;
629 ret->temporal = temporal;
630 ret->subtype = subtype;
635 field_entry *data_type::make_field_entry(string n){
636 field_entry *fe = new field_entry(n, schema_type);
637 if(temporal == increasing_t)
638 fe->add_modifier("INCREASING");
639 if(temporal == decreasing_t)
640 fe->add_modifier("DECREASING");
641 if(subtype != "") fe->add_modifier("subtype",subtype.c_str());
645 bool data_type::fta_legal_operation(
646 data_type *lhs, data_type *rhs, string &op){
648 dtype l_type = lhs->get_type();
649 dtype r_type = rhs->get_type();
652 // Currently, anything goes. Should be controlled by
657 // Only +, -, *, /, |, & are legal in the fta.
658 // The only ops on a llong or ullong are +, -
659 // no ops on float, timeval permitted, but these
660 // are illegal data types in the FTA and are handled elsewhere.
662 if(!( (op == "-") || (op == "+") || (op == "/") || (op == "*") || (op == "|") || (op == "&")))
665 if( (l_type == llong_t) || (l_type == u_llong_t) || (r_type == llong_t) || (r_type == u_llong_t)){
666 if(op == "*" || op == "/")
675 bool data_type::fta_legal_operation(data_type *lhs, string &op){
678 // negation and not are as legal at the fta on all fta-legal types
679 // as at the user level.
683 bool data_type::fta_legal_type(){
685 // Currently, anything goes.
686 // Should control by a config file.
687 // Currently, only the float and the timeval are not legal at the fta.
688 // if(type == floating_t || type == timeval_t) return(false);
694 // The data type of a literal
696 data_type::data_type(int it){
697 temporal = constant_t;
703 case LITERAL_LONGINT:
715 case LITERAL_TIMEVAL:
729 assign_schema_type();
732 void data_type::set_aggr_data_type(const string &op, data_type *dt){
733 dtype se_type = dt->type;
735 temporal = varying_t;
738 if((se_type == u_int_t)||(se_type == u_short_t)||(se_type == int_t)||
739 (se_type == u_llong_t)||(se_type == llong_t)||(se_type == floating_t))
745 if((se_type == u_int_t) || (se_type == u_short_t) || (se_type == bool_t))
747 if((se_type == int_t) || (se_type == u_llong_t) ||
748 (se_type == llong_t) || (se_type == floating_t) )
750 // temporal = dt->temporal; // temporal not preserved by sum.
751 subtype = dt->subtype;
753 if(op == "MIN" || op == "MAX"){
755 // temporal = dt->temporal; // temporal not preserved by min or max.
756 subtype = dt->subtype;
758 if(op == "AND_AGGR" || op == "OR_AGGR" || op == "XOR_AGGR"){
759 if( (se_type == u_int_t) || (se_type == u_short_t) ||
760 (se_type == int_t) || (se_type == llong_t) ||
761 (se_type == u_llong_t) || (se_type == bool_t) )
763 subtype = dt->subtype;
765 assign_schema_type();
771 bool data_type::is_comparable(data_type *rhs, string op){
817 if(rhs->type == ipv6_t)
829 // type string to get val from pass-by-ref fcn.
830 // (Does not seem to be used ?)
831 string data_type::get_CC_accessor_type(){
834 return("gs_int32_t *");
839 return("gs_uint32_t *");
841 return("gs_uint64_t *");
843 return("gs_int64_t *");
845 return("gs_float_t *");
847 return("struct gs_string *");
849 return("gs_int8_t *");
851 return("struct timeval *");
853 return("struct ipv6_str *");
855 return("ERROR: Unknown type in data_type::get_CC_accessor_type\n");
859 // type of a variable holding this value.
860 string data_type::get_cvar_type(){
864 return("gs_int32_t ");
869 return("gs_uint32_t ");
871 return("gs_uint64_t ");
873 return("gs_int64_t ");
875 return("gs_float_t ");
877 return("struct gs_string");
879 return("struct ipv6_str");
881 sprintf(tmps,"gs_int8_t[%d] ",size);
884 return("struct timeval ");
886 return("ERROR: Unknown type in data_type::get_cvar_type\n");
890 // type of a variable holding this value.
891 string data_type::get_tuple_cvar_type(){
895 return("gs_int32_t ");
900 return("gs_uint32_t ");
902 return("gs_uint64_t ");
904 return("gs_int64_t ");
906 return("gs_float_t ");
908 return("struct string32");
910 return("struct ipv6_str");
912 sprintf(tmps,"gs_int8_t[%d] ",size);
915 return("struct timeval ");
917 return("ERROR: Unknown type in data_type::get_cvar_type\n");
923 // type of an in-memory variable holding this value.
924 // TODO: use get_cvar_type as a subroutine
925 string data_type::make_cvar(std::string v){
929 return("gs_int32_t "+v);
934 return("gs_uint32_t "+v);
936 return("gs_uint64_t "+v);
938 return("gs_int64_t "+v);
940 return("gs_float_t "+v);
942 return("struct gs_string "+v);
944 return("struct ipv6_str "+v);
946 sprintf(tmps,"gs_int8_t %s[%d] ",v.c_str(),size);
949 return("struct timeval "+v);
951 return("ERROR: Unknown type in data_type::make_cvar\n");
955 // type of a tuple variable holding this value.
956 // TODO: use get_tuple_cvar_type as a subroutine
957 string data_type::make_tuple_cvar(std::string v){
961 return("gs_int32_t "+v);
966 return("gs_uint32_t "+v);
968 return("gs_uint64_t "+v);
970 return("gs_int64_t "+v);
972 return("gs_float_t "+v);
974 return("struct string32 "+v);
976 return("struct ipv6_str "+v);
978 sprintf(tmps,"gs_int8_t %s[%d] ",v.c_str(),size);
981 return("struct timeval "+v);
983 return("ERROR: Unknown type in data_type::make_cvar\n");
988 // type of a variable holding this value.
989 // The type at the host might be different (esp. string vs. vstring)
990 string data_type::get_host_cvar_type(){
994 return("gs_int32_t ");
999 return("gs_uint32_t ");
1001 return("gs_uint64_t ");
1003 return("gs_int64_t ");
1005 return("gs_float_t ");
1007 return("struct vstring");
1009 return("struct hfta_ipv6_str");
1011 sprintf(tmps,"gs_int8_t[%d] ",size);
1014 return("struct timeval ");
1016 return("ERROR: Unknown type in data_type::get_host_cvar_type\n");
1021 // type of a variable holding this value.
1022 // The type at the host might be different (esp. string vs. vstring)
1023 string data_type::make_host_cvar(std::string v){
1027 return("gs_int32_t "+v);
1032 return("gs_uint32_t "+v);
1034 return("gs_uint64_t "+v);
1036 return("gs_int64_t "+v);
1038 return("gs_float_t "+v);
1040 return("struct vstring "+v);
1042 return("struct hfta_ipv6_str "+v);
1044 sprintf(tmps,"gs_int8_t %s[%d] ",v.c_str(),size);
1047 return("struct timeval "+v);
1049 return("ERROR: Unknown type in data_type::make_host_cvar\n");
1053 string data_type::make_host_tuple_cvar(std::string v){
1057 return("gs_int32_t "+v);
1062 return("gs_uint32_t "+v);
1064 return("gs_uint64_t "+v);
1066 return("gs_int64_t "+v);
1068 return("gs_float_t "+v);
1070 return("struct vstring32 "+v);
1072 return("struct hfta_ipv6_str "+v);
1074 sprintf(tmps,"gs_int8_t %s[%d] ",v.c_str(),size);
1077 return("struct timeval "+v);
1079 return("ERROR: Unknown type in data_type::make_host_cvar\n");
1085 string data_type::get_hfta_unpack_fcn(){
1088 return("fta_unpack_int");
1091 return("fta_unpack_uint");
1093 return("fta_unpack_ushort");
1095 return("fta_unpack_bool");
1097 return("fta_unpack_ullong");
1099 return("fta_unpack_llong");
1101 return("fta_unpack_float");
1103 return("fta_unpack_vstr");
1105 return("fta_unpack_fstring");
1107 return("fta_unpack_timeval");
1109 return("fta_unpack_ipv6");
1111 return("ERROR: Unknown type in dtype::get_hfta_unpack_fcn\n");
1115 string data_type::get_hfta_unpack_fcn_noxf(){
1118 return("fta_unpack_int_noxf");
1121 return("fta_unpack_uint_noxf");
1123 return("fta_unpack_ushort_noxf");
1125 return("fta_unpack_bool_noxf");
1127 return("fta_unpack_ullong_noxf");
1129 return("fta_unpack_llong_noxf");
1131 return("fta_unpack_float_noxf");
1133 return("fta_unpack_vstr_noxf");
1135 return("fta_unpack_fstring_noxf");
1137 return("fta_unpack_timeval_noxf");
1139 return("fta_unpack_ipv6_noxf");
1141 return("ERROR: Unknown type in dtype::get_hfta_unpack_fcn_noxf\n");
1146 // Return true if comparing these types requires
1147 // a special function.
1149 // 1) the function should act like strcmp (-1, 0, 1)
1150 // 2) this fcn assumes that type checking
1151 // has already been done.
1152 bool data_type::complex_comparison(data_type *dt){
1164 string data_type::get_comparison_fcn(data_type *dt){
1167 return("Compare_Timeval");
1169 return("str_compare");
1171 return("ipv6_compare");
1173 return("ERROR_NO_SUCH_COMPARISON_FCN");
1179 string data_type::get_hfta_comparison_fcn(data_type *dt){
1182 return("hfta_Compare_Timeval");
1184 return("hfta_vstr_compare");
1186 return("hfta_ipv6_compare");
1188 return("ERROR_NO_SUCH_COMPARISON_FCN");
1192 // Return true if operating on these types requires
1193 // a special function for this operator.
1195 // 1) the function should act like
1196 // int operator_fcn(*retun_val, *lhs, *rhs)
1197 // 2) this fcn assumes that type checking
1198 // has already been done.
1199 bool data_type::complex_operator(data_type *dt, string &op){
1216 if(op == "+" || op == "-" || op == "/")
1227 if((op=="&" || op=="|") && dt->type == ipv6_t)
1237 bool data_type::complex_operator(string &op){
1241 string data_type::get_complex_operator(data_type *dt, string &op){
1247 return("Add_Int_Timeval");
1259 return("Add_Timeval_Int");
1261 return("Subtract_Timeval_Int");
1263 return("Divide_Timeval_Int");
1267 return("Subtract_Timeval_Timeval");
1274 if(dt->type == ipv6_t){
1285 return("ERROR_NO_COMPLEX_BINARY_OPERATOR");
1288 string data_type::get_complex_operator(string &op){
1290 return("ERROR_NO_COMPLEX_UNARY_OPERATOR");
1294 bool data_type::use_hashfunc(){
1310 fprintf(stderr,"ERROR: Unknown type in data_type::use_hashfunc\n");
1315 string data_type::get_hfta_hashfunc(){
1322 return("ERROR NO HFTA HASHFUNC");
1325 //return("hfta_ullong_hashfunc");
1326 return("hfta_ULLONG_to_hash");
1328 //return("hfta_ullong_hashfunc");
1329 return("hfta_LLONG_to_hash");
1331 //return("hfta_float_hashfunc");
1332 return("hfta_FLOAT_to_hash");
1335 return("hfta_IPV6_to_hash");
1337 return("hfta_timeval_hashfunc");
1339 return("hfta_vstr_hashfunc");
1341 fprintf(stderr,"ERROR: Unknown type in data_type::get_hfta_hashfunc\n");
1343 return("false"); // to make compiler happy
1347 // Return true if the data type contains a ptr to a
1348 // memory buffer. (copying sometimes requires special cate).
1350 bool data_type::is_buffer_type(){
1367 fprintf(stderr,"ERROR: Unknown type in dtype::is_buffer_type\n");
1373 // Fcns which return the names of functions for
1374 // handling complex types.
1376 //-----------------------------
1379 string data_type::get_buffer_assign_copy(){
1382 return("str_assign_with_copy");
1387 return("ERROR_NO_SUCH_buffer_assign_copy_FCN");
1390 string data_type::get_buffer_tuple_copy(){
1393 return("str_assign_with_copy_in_tuple");
1398 return("ERROR_NO_SUCH_buffer_tuple_copy_FCN");
1401 string data_type::get_buffer_replace(){
1404 return("str_replace");
1409 return("ERROR_NO_SUCH_buffer_replace_FCN");
1412 string data_type::get_buffer_size(){
1415 return("str_length");
1420 return("ERROR_NO_SUCH_buffer_size_FCN");
1423 string data_type::get_buffer_destroy(){
1426 return("str_destroy");
1431 return("ERROR_NO_SUCH_buffer_destroy_FCN");
1434 //-----------------------------
1437 string data_type::get_hfta_buffer_assign_copy(){
1440 return("hfta_vstr_assign_with_copy");
1445 return("ERROR_NO_SUCH_buffer_assign_copy_FCN");
1448 string data_type::get_hfta_buffer_tuple_copy(){
1451 return("hfta_vstr_assign_with_copy_in_tuple");
1456 return("ERROR_NO_SUCH_buffer_tuple_copy_FCN");
1459 string data_type::get_hfta_buffer_replace(){
1462 return("hfta_vstr_replace");
1467 return("ERROR_NO_SUCH_buffer_replace_FCN");
1470 string data_type::get_hfta_buffer_size(){
1473 return("hfta_vstr_length");
1478 return("ERROR_NO_SUCH_buffer_size_FCN");
1481 string data_type::get_hfta_buffer_destroy(){
1484 return("hfta_vstr_destroy");
1489 return("ERROR_NO_SUCH_buffer_destroy_FCN");
1491 //-----------------------------
1494 // Return true if the data type is represented by a strucutre.
1495 bool data_type::is_structured_type(){
1512 fprintf(stderr,"ERROR: Unknown type in dtype::is_structured_type\n");
1519 // type of a variable holding this value.
1520 // Seems to be a relic
1522 string data_type::get_interface_type(){
1528 return("unsigned int ");
1530 return("unsigned short int ");
1534 return("unsigned long long int ");
1536 return("long long int ");
1542 sprintf(tmps,"char[%d] ",size);
1549 return("ERROR: Unknown type in dtype::get_interface_type\n");
1555 // This type of handle registration is obsolete
1557 string data_type::handle_registration_name(){
1561 return("str_register_search_string");
1565 return("ERROR UNKNOWN LITERAL");
1568 string data_type::hfta_handle_registration_name(){
1572 return("vstr_register_search_string");
1576 return("ERROR UNKNOWN LITERAL");
1580 string data_type::get_handle_destructor(){
1584 return("str_release_search_string");
1588 return("ERROR UNKNOWN LITERAL");
1592 // should be the inverse of
1593 // data_type::data_type(string st, param_list *modifiers)
1594 vector<string> data_type::get_param_keys(){
1595 vector<string> retval;
1597 if(temporal == increasing_t)
1598 retval.push_back("INCREASING");
1599 if(temporal == decreasing_t)
1600 retval.push_back("DECREASING");
1601 if(subtype != "") retval.push_back("subtype");
1606 string data_type::get_param_val(string k){
1607 if(k=="subtype") return subtype;
1611 std::string data_type::get_temporal_string(){
1612 if(temporal == increasing_t)
1613 return("INCREASING");
1614 if(temporal == decreasing_t)
1615 return("DECREASING");
1620 bool data_type::needs_hn_translation(){
1637 fprintf(stderr,"INTERNAL ERROR: Unknown type in dtype::needs_hn_translation\n");
1643 std::string data_type::hton_translation(){
1644 fprintf(stderr,"INTERNAL ERROR, hton_translation called.\n");
1666 return("hton_ipv6");
1669 return("INTERNAL ERROR, net translation for buffered types needs special handling.\n");
1671 fprintf(stderr,"INTERNAL ERROR: Unknown type in dtype::hton_translation\n");
1673 return("INTERNAL ERROR: NO SUCH TYPE IN hton_translation");
1677 std::string data_type::ntoh_translation(){
1678 fprintf(stderr,"INTERNAL ERROR, ntoh_translation called.\n");
1700 return("ntoh_ipv6");
1703 return("INTERNAL ERROR, net translation for buffered types needs special handling.\n");
1705 fprintf(stderr,"INTERNAL ERROR: Unknown type in dtype::ntoh_translation\n");
1707 return("INTERNAL ERROR: NO SUCH TYPE IN ntoh_translation");
1711 int data_type::type_indicator(){
1718 return(USHORT_TYPE);
1722 return(ULLONG_TYPE);
1728 return(TIMEVAL_TYPE);
1736 return(FSTRING_TYPE);
1738 return(UNDEFINED_TYPE);
1740 return(UNDEFINED_TYPE);
1745 int data_type::type_size(){
1748 return(sizeof(gs_int32_t));
1753 return(sizeof(gs_uint32_t));
1755 return(sizeof(gs_uint64_t));
1757 return(sizeof(gs_int64_t));
1759 return(sizeof(gs_float_t));
1761 return(sizeof(timeval)); // IMPLEMENTATION DEPENDENT
1763 return(sizeof(hfta_ipv6_str)); // IMPLEMENTATION DEPENDENT
1765 return(sizeof(vstring32)); // IMPLEMENTATION DEPENDENT
1774 // for external functions and predicates
1777 bool data_type::call_compatible(data_type *o){
1778 if(type != o->get_type()) return(false);
1779 if(type == fstring_t){
1780 if(size != 0 && size != o->type_size()) return(false);
1785 // test for equality : used by bind_to_schema and by testing for
1788 bool data_type::equal(data_type *o){
1789 if(type != o->get_type()) return(false);
1790 if(type == fstring_t){
1791 if(size != o->type_size()) return(false);
1797 bool data_type::subsumes_type(data_type *o){
1798 if(type != o->get_type()) return(false);
1799 if(type == fstring_t){
1800 if(size != o->type_size()) return(false);
1802 if(this->is_temporal() && temporal != o->get_temporal()) return false;
1803 if(subtype != "" && subtype != o->subtype) return false;
1808 bool data_type::equals(data_type *o){
1809 if(type != o->get_type()) return(false);
1810 if(type == fstring_t){
1811 if(size != o->type_size()) return(false);
1813 if(temporal != o->get_temporal()) return false;
1814 if(subtype != o->subtype) return false;
1819 bool data_type::equal_subtypes(data_type *o){
1820 if(type != o->get_type()) return(false);
1821 if(type == fstring_t){
1822 if(size != o->type_size()) return(false);
1824 if(subtype != o->subtype) return false;
1830 string data_type::to_string(){
1831 string ret = schema_type;
1832 if(this->is_temporal() || subtype != ""){
1834 if(temporal == increasing_t)
1835 ret += "INCREASING";
1836 if(temporal == decreasing_t)
1837 ret += "DECREASING";
1838 if(this->is_temporal() && subtype != "")
1841 ret += "subtype "+subtype;
1849 string data_type::get_min_literal() {
1861 return("LLONG_MIN");
1867 return("0000:0000:0000:0000:0000:0000:0000:0000");
1870 return("ERROR: Min literal is undefined for strings\n");
1872 return("ERROR: Unknown type in data_type::get_min_literal\n");
1876 string data_type::get_max_literal() {
1886 return("ULLONG_MAX");
1888 return("LLONG_MAX");
1892 return("{UINT_MAX,UINT_MAX}");
1894 return("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
1897 return("ERROR: Max literal is undefined for strings\n");
1899 return("ERROR: Unknown type in data_type::get_max_literal\n");