void PPFtScan::do_next(xqp_tuple &t) { if (first_time) { tuple_cell tc; index_type.op->next(t); if (t.is_eos()) throw XQUERY_EXCEPTION(SE1071); tc = t.cells[0]; if (!tc.is_atomic() || !is_string_type(tc.get_atomic_type())) throw XQUERY_EXCEPTION(SE1071); tc = tuple_cell::make_sure_light_atomic(tc); ft_index_type itype = str2ft_index_type(tc.get_str_mem()); if (cust_rules.op) { ptr = ft_custom_tree_t::init(); ft_index_template_t * templ = make_cust_rules_vector(&cust_rules, cxt); ft_index_template_t::iterator tmp=templ->begin(); while (tmp!=templ->end()) { ptr->put(new ft_custom_cell(tmp->first, tmp->second)); tmp++; } delete_cust_rules_vector(templ); } sj=se_new SednaSearchJob(&seq, itype, ptr); query.op->next(t); if (t.is_eos()) throw XQUERY_EXCEPTION(SE1071); tc = t.cells[0]; if (!tc.is_atomic() || !is_string_type(tc.get_atomic_type())) throw XQUERY_EXCEPTION(SE1071); sj->set_request(tc); query.op->next(t); if (!t.is_eos()) throw XQUERY_EXCEPTION(SE1071); first_time = false; } sj->get_next_result(t); if (t.is_eos()) { delete sj; sj = NULL; first_time = true; } }
void PPFtHighlight::do_next(xqp_tuple &t) { if (first_time) { tuple_cell tc; U_ASSERT(fthl == NULL); if (options.op) { options.op->next(t); if (t.is_eos()) throw XQUERY_EXCEPTION(SE1071); tc = t.cells[0]; if (!tc.is_atomic() || !is_string_type(tc.get_atomic_type())) throw XQUERY_EXCEPTION(SE1071); op_str_buf buf(tc); fthl = new FtHighlighter(hl_fragment, &seq); fthl->set_options(buf.c_str()); options.op->next(t); if (!t.is_eos()) throw XQUERY_EXCEPTION(SE1071); } else fthl = new FtHighlighter(hl_fragment, &seq); query.op->next(t); if (t.is_eos()) throw XQUERY_EXCEPTION(SE1071); tc = t.cells[0]; if (!tc.is_atomic() || !is_string_type(tc.get_atomic_type())) throw XQUERY_EXCEPTION(SE1071); fthl->set_request(tc); query.op->next(t); if (!t.is_eos()) throw XQUERY_EXCEPTION(SE1071); first_time = false; } fthl->get_next_result(t); if (t.is_eos()) { delete fthl; fthl = NULL; first_time = true; } }
static unsigned short builtin_vt(const type_t *t) { const char *kw = t->name; struct oatype key; const struct oatype *kwp; key.kw = kw; #ifdef KW_BSEARCH kwp = bsearch(&key, oatypes, NTYPES, sizeof(oatypes[0]), kw_cmp_func); #else { unsigned int i; for (kwp=NULL, i=0; i < NTYPES; i++) if (!kw_cmp_func(&key, &oatypes[i])) { kwp = &oatypes[i]; break; } } #endif if (kwp) { return kwp->vt; } if (is_string_type (t->attrs, t)) switch (t->ref->type) { case RPC_FC_CHAR: return VT_LPSTR; case RPC_FC_WCHAR: return VT_LPWSTR; default: break; } return 0; }
static IntentTag constIntentForType(Type* t) { if (isSyncType(t) || isRecordWrappedType(t) || // domain, array, or distribution isRecord(t) || // may eventually want to decide based on size is_string_type(t)) { return INTENT_CONST_REF; } else if (is_bool_type(t) || is_int_type(t) || is_uint_type(t) || is_real_type(t) || is_imag_type(t) || is_complex_type(t) || is_enum_type(t) || isClass(t) || isUnion(t) || isAtomicType(t) || t == dtOpaque || t == dtTaskID || t == dtFile || t == dtTaskList || t == dtNil || t == dtStringC || t == dtStringCopy || t->symbol->hasFlag(FLAG_EXTERN)) { return INTENT_CONST_IN; } INT_FATAL(t, "Unhandled type in constIntentForType()"); return INTENT_CONST; }
IntentTag blankIntentForType(Type* t) { if (isSyncType(t) || isAtomicType(t) || t->symbol->hasFlag(FLAG_ARRAY)) { return INTENT_REF; } else if (is_bool_type(t) || is_int_type(t) || is_uint_type(t) || is_real_type(t) || is_imag_type(t) || is_complex_type(t) || is_enum_type(t) || is_string_type(t) || t == dtStringC || t == dtStringCopy || isClass(t) || isRecord(t) || isUnion(t) || t == dtTaskID || t == dtFile || t == dtTaskList || t == dtNil || t == dtOpaque || t->symbol->hasFlag(FLAG_DOMAIN) || t->symbol->hasFlag(FLAG_DISTRIBUTION) || t->symbol->hasFlag(FLAG_EXTERN)) { return constIntentForType(t); } INT_FATAL(t, "Unhandled type in blankIntentForType()"); return INTENT_BLANK; }
void PPFnResolveQName::do_next(xqp_tuple &t) { if (first_time) { child_qname.op->next(t); if (t.is_eos()) return; first_time = false; tuple_cell qname_tc = atomize(child_qname.get(t)); if (!is_string_type(qname_tc.get_atomic_type())) { throw XQUERY_EXCEPTION2(XPTY0004, "Wrong first argument of fn:resolve-QName function"); } child_qname.op->next(t); if (!(t.is_eos())) { throw XQUERY_EXCEPTION2(XPTY0004, "Wrong first argument of fn:resolve-QName function"); } qname_tc = tuple_cell::make_sure_light_atomic(qname_tc); child_elem.op->next(t); if (t.is_eos() || !child_elem.get(t).is_node()) { throw XQUERY_EXCEPTION2(XPTY0004, "Wrong second argument of fn:resolve-QName function"); } xptr node = child_elem.get(t).get_node(); child_elem.op->next(t); if (!(t.is_eos())) { throw XQUERY_EXCEPTION2(XPTY0004, "Wrong second argument of fn:resolve-QName function"); } CHECKP(node); if (getNodeType(node) != element) throw XQUERY_EXCEPTION2(XPTY0004, "Wrong second argument of fn:resolve-QName function"); scoped_ptr<InscopeNamespaceMap> inscopeNamespaces = new InscopeNamespaceMap(node, cxt->get_static_context()->getStaticallyKnownNamespaces()); t.copy(tuple_cell::atomic(xsd::QName::createResolve(qname_tc.get_str_mem(), inscopeNamespaces.get()))); } else { first_time = true; t.set_eos(); } }
static inline tuple_cell check_string_argument(xqp_tuple &t, PPOpIn &seq, bool is_empty_allowed, PPPatMatch::patmatch_type pmt, int arg_num) { seq.op->next(t); if(t.is_eos()) { if(is_empty_allowed) return EMPTY_STRING_TC; else throw XQUERY_EXCEPTION2(XPTY0004, (std::string("Invalid arity of the ") + get_argument_name(arg_num) + " of " + PPPatMatch::patmatch_type2c_string(pmt) + ". Argument contains empty sequence.").c_str()); } tuple_cell res = atomize(seq.get(t)); if(!is_string_type(res.get_atomic_type())) throw XQUERY_EXCEPTION2(XPTY0004, (std::string("Invalid type of the ") + get_argument_name(arg_num) + " of " + PPPatMatch::patmatch_type2c_string(pmt) + " (xs_string/derived/promotable is expected).").c_str()); seq.op->next(t); if(!t.is_eos()) throw XQUERY_EXCEPTION2(XPTY0004, (std::string("Invalid arity of the ") + get_argument_name(arg_num) + " of " + PPPatMatch::patmatch_type2c_string(pmt) + ". Argument contains more than one item.").c_str()); return res; }
void PPFnTrace::do_next(xqp_tuple &t) { if (first_time) { first_time = false; label_child.op->next(t); if (t.is_eos()) throw XQUERY_EXCEPTION2(XPTY0004, "Wrong arguments in function fn:trace. Label argument cannot be empty sequence."); tc = atomize(label_child.get(t)); if (!is_string_type(tc.get_atomic_type())) throw XQUERY_EXCEPTION2(XPTY0004, "Wrong arguments in function fn:trace. Invalid label type (xs_string/derived/promotable is expected)."); label_child.op->next(t); if (!t.is_eos()) throw XQUERY_EXCEPTION2(XPTY0004, "Wrong arguments in function fn:trace. Argument contains more than one item."); tc = tuple_cell::make_sure_light_atomic(tc); if (tc.get_strlen_mem() > 500) throw XQUERY_EXCEPTION2(XPTY0004, "Too long trace prefix is given in fn:trace function"); tr_globals::create_serializer(tr_globals::client->get_result_type()); } value_child.op->next(t); if (t.is_eos()) { first_time = true; } else { dostr->set_debug_info_type(se_QueryTrace); (*dostr) << tc.get_str_mem() << " "; tr_globals::serializer->prepare( dostr, cxt->get_static_context()->get_serialization_options() ); tr_globals::serializer->serialize(t); dostr->flush(); } }
int CBS_get_asn1_implicit_string(CBS *in, CBS *out, uint8_t **out_storage, unsigned outer_tag, unsigned inner_tag) { assert(!(outer_tag & CBS_ASN1_CONSTRUCTED)); assert(!(inner_tag & CBS_ASN1_CONSTRUCTED)); assert(is_string_type(inner_tag)); if (CBS_peek_asn1_tag(in, outer_tag)) { /* Normal implicitly-tagged string. */ *out_storage = NULL; return CBS_get_asn1(in, out, outer_tag); } /* Otherwise, try to parse an implicitly-tagged constructed string. * |CBS_asn1_ber_to_der| is assumed to have run, so only allow one level deep * of nesting. */ CBB result; CBS child; if (!CBB_init(&result, CBS_len(in)) || !CBS_get_asn1(in, &child, outer_tag | CBS_ASN1_CONSTRUCTED)) { goto err; } while (CBS_len(&child) > 0) { CBS chunk; if (!CBS_get_asn1(&child, &chunk, inner_tag) || !CBB_add_bytes(&result, CBS_data(&chunk), CBS_len(&chunk))) { goto err; } } uint8_t *data; size_t len; if (!CBB_finish(&result, &data, &len)) { goto err; } CBS_init(out, data, len); *out_storage = data; return 1; err: CBB_cleanup(&result); return 0; }
static unsigned short builtin_vt(const type_t *t) { const char *kw = t->name; struct oatype key; const struct oatype *kwp; key.kw = kw; #ifdef KW_BSEARCH kwp = bsearch(&key, oatypes, NTYPES, sizeof(oatypes[0]), kw_cmp_func); #else { unsigned int i; for (kwp=NULL, i=0; i < NTYPES; i++) if (!kw_cmp_func(&key, &oatypes[i])) { kwp = &oatypes[i]; break; } } #endif if (kwp) { return kwp->vt; } if (is_string_type (t->attrs, t)) { const type_t *elem_type; if (is_array(t)) elem_type = type_array_get_element(t); else elem_type = type_pointer_get_ref(t); if (type_get_type(elem_type) == TYPE_BASIC) { switch (type_basic_get_type(elem_type)) { case TYPE_BASIC_CHAR: return VT_LPSTR; case TYPE_BASIC_WCHAR: return VT_LPWSTR; default: break; } } } return 0; }
/* cbs_find_ber walks an ASN.1 structure in |orig_in| and sets |*ber_found| * depending on whether an indefinite length element or constructed string was * found. The value of |orig_in| is not changed. It returns one on success (i.e. * |*ber_found| was set) and zero on error. */ static int cbs_find_ber(const CBS *orig_in, char *ber_found, unsigned depth) { CBS in; if (depth > kMaxDepth) { return 0; } CBS_init(&in, CBS_data(orig_in), CBS_len(orig_in)); *ber_found = 0; while (CBS_len(&in) > 0) { CBS contents; unsigned tag; size_t header_len; if (!CBS_get_any_ber_asn1_element(&in, &contents, &tag, &header_len)) { return 0; } if (CBS_len(&contents) == header_len && header_len > 0 && CBS_data(&contents)[header_len-1] == 0x80) { /* Found an indefinite-length element. */ *ber_found = 1; return 1; } if (tag & CBS_ASN1_CONSTRUCTED) { if (is_string_type(tag)) { /* Constructed strings are only legal in BER and require conversion. */ *ber_found = 1; return 1; } if (!CBS_skip(&contents, header_len) || !cbs_find_ber(&contents, ber_found, depth + 1)) { return 0; } } } return 1; }
void string_instrumentationt::do_format_string_read( goto_programt &dest, goto_programt::const_targett target, const code_function_callt::argumentst &arguments, unsigned format_string_inx, unsigned argument_start_inx, const std::string &function_name) { const exprt &format_arg = arguments[format_string_inx]; if(format_arg.id()=="address_of" && format_arg.op0().id()=="index" && format_arg.op0().op0().id()==ID_string_constant) { format_token_listt token_list; parse_format_string(format_arg.op0().op0(), token_list); unsigned args=0; for(format_token_listt::const_iterator it=token_list.begin(); it!=token_list.end(); it++) { if(it->type==format_tokent::STRING) { const exprt &arg = arguments[argument_start_inx+args]; const typet &arg_type = ns.follow(arg.type()); if(arg.id()!=ID_string_constant) // we don't need to check constants { goto_programt::targett assertion=dest.add_instruction(); assertion->location=target->location; assertion->location.set("property", "string"); std::string comment("zero-termination of string argument of "); comment += function_name; assertion->location.set("comment", comment); exprt temp(arg); if(arg_type.id()!="pointer") { index_exprt index; index.array()=temp; index.index()=gen_zero(uint_type()); index.type()=arg_type.subtype(); temp=address_of_exprt(index); } assertion->make_assertion(is_zero_string(temp)); } } if(it->type!=format_tokent::TEXT && it->type!=format_tokent::UNKNOWN) args++; if(find(it->flags.begin(), it->flags.end(), format_tokent::ASTERISK)!= it->flags.end()) args++; // just eat the additional argument } } else // non-const format string { goto_programt::targett format_ass=dest.add_instruction(); format_ass->make_assertion(is_zero_string(arguments[1])); format_ass->location=target->location; format_ass->location.set("property", "string"); std::string comment("zero-termination of format string of "); comment += function_name; format_ass->location.set("comment", comment); for(unsigned i=2; i<arguments.size(); i++) { const exprt &arg = arguments[i]; const typet &arg_type=ns.follow(arguments[i].type()); if(arguments[i].id()!=ID_string_constant && is_string_type(arg_type)) { goto_programt::targett assertion=dest.add_instruction(); assertion->location=target->location; assertion->location.set("property", "string"); std::string comment("zero-termination of string argument of "); comment += function_name; assertion->location.set("comment", comment); exprt temp(arg); if(arg_type.id()!="pointer") { index_exprt index; index.array()=temp; index.index()=gen_zero(uint_type()); index.type()=arg_type.subtype(); temp=address_of_exprt(index); } assertion->make_assertion(is_zero_string(temp)); } } } }
bool operator()(CassString, const DataType::ConstPtr& data_type) const { return is_string_type(data_type->value_type()); }
void string_instrumentationt::do_format_string_write( goto_programt &dest, goto_programt::const_targett target, const code_function_callt::argumentst &arguments, unsigned format_string_inx, unsigned argument_start_inx, const std::string &function_name) { const exprt &format_arg = arguments[format_string_inx]; if(format_arg.id()=="address_of" && format_arg.op0().id()=="index" && format_arg.op0().op0().id()==ID_string_constant) // constant format { format_token_listt token_list; parse_format_string(format_arg.op0().op0(), token_list); unsigned args=0; for(format_token_listt::const_iterator it=token_list.begin(); it!=token_list.end(); it++) { if(find(it->flags.begin(), it->flags.end(), format_tokent::ASTERISK)!= it->flags.end()) continue; // asterisk means `ignore this' switch(it->type) { case format_tokent::STRING: { const exprt &argument=arguments[argument_start_inx+args]; const typet &arg_type=ns.follow(argument.type()); goto_programt::targett assertion=dest.add_instruction(); assertion->location=target->location; assertion->location.set("property", "string"); std::string comment("format string buffer overflow in "); comment += function_name; assertion->location.set("comment", comment); if(it->field_width!=0) { exprt fwidth = from_integer(it->field_width, uint_type()); exprt fw_1("+", uint_type()); exprt one = gen_one(uint_type()); fw_1.move_to_operands(fwidth); fw_1.move_to_operands(one); // +1 for 0-char exprt fw_lt_bs; if(arg_type.id()=="pointer") fw_lt_bs=binary_relation_exprt(fw_1, "<=", buffer_size(argument)); else { index_exprt index; index.array()=argument; index.index()=gen_zero(uint_type()); address_of_exprt aof(index); fw_lt_bs=binary_relation_exprt(fw_1, "<=", buffer_size(aof)); } assertion->make_assertion(fw_lt_bs); } else { // this is a possible overflow. assertion->make_assertion(false_exprt()); } // now kill the contents invalidate_buffer(dest, target, argument, arg_type, it->field_width); args++; break; } case format_tokent::TEXT: case format_tokent::UNKNOWN: { // nothing break; } default: // everything else { const exprt &argument=arguments[argument_start_inx+args]; const typet &arg_type=ns.follow(argument.type()); goto_programt::targett assignment=dest.add_instruction(ASSIGN); assignment->location=target->location; exprt lhs("dereference", arg_type.subtype()); lhs.copy_to_operands(argument); exprt rhs=side_effect_expr_nondett(lhs.type()); rhs.location()=target->location; assignment->code=code_assignt(lhs, rhs); args++; break; } } } } else // non-const format string { for(unsigned i=argument_start_inx; i<arguments.size(); i++) { const typet &arg_type=ns.follow(arguments[i].type()); // Note: is_string_type() is a `good guess' here. Actually // any of the pointers could point into an array. But it // would suck if we had to invalidate all variables. // Luckily this case isn't needed too often. if(is_string_type(arg_type)) { goto_programt::targett assertion=dest.add_instruction(); assertion->location=target->location; assertion->location.set("property", "string"); std::string comment("format string buffer overflow in "); comment += function_name; assertion->location.set("comment", comment); // as we don't know any field width for the %s that // should be here during runtime, we just report a // possibly false positive assertion->make_assertion(false_exprt()); invalidate_buffer(dest, target, arguments[i], arg_type, 0); } else { goto_programt::targett assignment = dest.add_instruction(ASSIGN); assignment->location=target->location; exprt lhs("dereference", arg_type.subtype()); lhs.copy_to_operands(arguments[i]); exprt rhs=side_effect_expr_nondett(lhs.type()); rhs.location()=target->location; assignment->code=code_assignt(lhs, rhs); } } } }
/* cbs_convert_ber reads BER data from |in| and writes DER data to |out|. If * |string_tag| is non-zero, then all elements must match |string_tag| up to the * constructed bit and primitive element bodies are written to |out| without * element headers. This is used when concatenating the fragments of a * constructed string. If |looking_for_eoc| is set then any EOC elements found * will cause the function to return after consuming it. It returns one on * success and zero on error. */ static int cbs_convert_ber(CBS *in, CBB *out, unsigned string_tag, char looking_for_eoc, unsigned depth) { assert(!(string_tag & CBS_ASN1_CONSTRUCTED)); if (depth > kMaxDepth) { return 0; } while (CBS_len(in) > 0) { CBS contents; unsigned tag, child_string_tag = string_tag; size_t header_len; CBB *out_contents, out_contents_storage; if (!CBS_get_any_ber_asn1_element(in, &contents, &tag, &header_len)) { return 0; } if (is_eoc(header_len, &contents)) { return looking_for_eoc; } if (string_tag != 0) { /* This is part of a constructed string. All elements must match * |string_tag| up to the constructed bit and get appended to |out| * without a child element. */ if ((tag & ~CBS_ASN1_CONSTRUCTED) != string_tag) { return 0; } out_contents = out; } else { unsigned out_tag = tag; if ((tag & CBS_ASN1_CONSTRUCTED) && is_string_type(tag)) { /* If a constructed string, clear the constructed bit and inform * children to concatenate bodies. */ out_tag &= ~CBS_ASN1_CONSTRUCTED; child_string_tag = out_tag; } if (!CBB_add_asn1(out, &out_contents_storage, out_tag)) { return 0; } out_contents = &out_contents_storage; } if (CBS_len(&contents) == header_len && header_len > 0 && CBS_data(&contents)[header_len - 1] == 0x80) { /* This is an indefinite length element. */ if (!cbs_convert_ber(in, out_contents, child_string_tag, 1 /* looking for eoc */, depth + 1) || !CBB_flush(out)) { return 0; } continue; } if (!CBS_skip(&contents, header_len)) { return 0; } if (tag & CBS_ASN1_CONSTRUCTED) { /* Recurse into children. */ if (!cbs_convert_ber(&contents, out_contents, child_string_tag, 0 /* not looking for eoc */, depth + 1)) { return 0; } } else { /* Copy primitive contents as-is. */ if (!CBB_add_bytes(out_contents, CBS_data(&contents), CBS_len(&contents))) { return 0; } } if (!CBB_flush(out)) { return 0; } } return looking_for_eoc == 0; }
PUBLIC tree lib_call(def d, tree args) { int n_args = list_len(args); tree call = NULL; bool ok = TRUE; type t = d->t_type; switch (d->d_libid) { case L_CHR: ok = (n_args == 1 && same_type(car(args)->t_type, int_type)); break; case L_ORD: ok = (n_args == 1 && (same_type(car(args)->t_type, char_type) || same_type(car(args)->t_type, bool_type))); break; case L_HALT: case L_FLUSH: ok = (n_args == 0); break; case L_EOF: case L_EOLN: if (n_args == 0) args = list1((tree) _input_); else ok = (n_args = 1 && same_type(car(args)->t_type, text_type)); break; case L_READ: case L_READLN: case L_WRITE: case L_WRITELN: { tree p = args; if (p != nil && same_type(car(p)->t_type, text_type)) p = cdr(p); for (; p != nil; p = cdr(p)) { type at = car(p)->t_type; if (! (same_type(at, int_type) || same_type(at, char_type) || same_type(at, string_type))) { ok = FALSE; break; } } return node_t(LIBCALL, (tree) d, args, void_type); } case L_ARGC: ok = (n_args == 0); break; case L_ARGV: ok = (n_args == 2 && same_type(car(args)->t_type, int_type) && is_string_type(cadr(args)->t_type)); break; case L_OPENIN: ok = (n_args == 2 && same_type(car(args)->t_type, text_type) && is_string_type(cadr(args)->t_type)); break; case L_CLOSEIN: ok = (n_args == 1 && same_type(car(args)->t_type, text_type)); break; default: ok = FALSE; t = err_type; } if (! ok) { error("I choked on a library call"); return (tree) dummy_def; } if (call == NULL) return node_t(CALL, (tree) d, args, t); return call; }
bool Grammar::is_object_type(const std::string& str) { return is_boolean_type(str) || is_character_type(str) || is_integer_type(str) || is_float_type(str) || is_string_type(str); }
std::list<std::string> pk_columns; bool match_PK = false; std::list<std::string> select_columns; try { boost::scoped_ptr<sql::Statement> stmt(_db_conn->createStatement()); boost::scoped_ptr<sql::ResultSet> rs(stmt->executeQuery(std::string(base::sqlstring("SHOW COLUMNS FROM !.! WHERE ", base::QuoteOnlyIfNeeded) << schema_name << table_name).append(like_clause))); while(rs->next()) { std::string column = rs->getString(1); std::string column_type = rs->getString(2); if ((_search_data_type == search_all_types) || ((_search_data_type & numeric_type) && is_numeric_type(column_type)) || ((_search_data_type & datetime_type) && is_datetime_type(column_type)) || ((_search_data_type & text_type) && is_string_type(column_type)) ) { if (rs->getString(4) == "PRI") { select_columns.push_front(column); pk_columns.push_back(column); match_PK = true;//PK should be searched, not just displayed } select_columns.push_back(column); } else { if (rs->getString(4) == "PRI") { select_columns.push_front(column);
void PPFnCompare::do_next(xqp_tuple &t) { if (first_time) { CollationHandler* handler = is_codepoint_equal ? charset_handler->get_unicode_codepoint_collation() : cxt->get_static_context()->get_default_collation(); if (collation_child.op) { collation_child.op->next(t); if(t.is_eos()) throw XQUERY_EXCEPTION2(XPTY0004, "Invalid arity of the third argument. Argument contains zero items in fn:compare()"); tuple_cell col = atomize(collation_child.get(t)); if (!is_string_type(col.get_atomic_type())) throw XQUERY_EXCEPTION2(XPTY0004, "Invalid type of the third argument in fn:compare() (xs_string/derived/promotable is expected)"); collation_child.op->next(t); if (!t.is_eos()) throw XQUERY_EXCEPTION2(XPTY0004, "Invalid arity of the third argument in fn:compare(). Argument contains more than one item"); col = tuple_cell::make_sure_light_atomic(col); int res = cxt->get_static_context()->get_collation(col.get_str_mem(), &handler); if(res != 0) throw XQUERY_EXCEPTION2(FOCH0002, (static_context::get_error_description(res) + " in fn:compare().").c_str()); } tuple_cell tc1, tc2; str1_child.op->next(t); if (t.is_eos()) return; tc1 = atomize(str1_child.get(t)); if (!is_string_type(tc1.get_atomic_type())) throw XQUERY_EXCEPTION2(XPTY0004, "Invalid type of the first argument in fn:compare() (xs_string/derived/promotable is expected)"); str1_child.op->next(t); if (!t.is_eos()) throw XQUERY_EXCEPTION2(XPTY0004, "Invalid arity of the first argument in fn:compare(). Argument contains more than one item"); str2_child.op->next(t); if (t.is_eos()) return; tc2 = atomize(str2_child.get(t)); if (!is_string_type(tc2.get_atomic_type())) throw XQUERY_EXCEPTION2(XPTY0004, "Invalid type of the second argument in fn:compare() (xs_string/derived/promotable is expected)"); str2_child.op->next(t); if (!t.is_eos()) throw XQUERY_EXCEPTION2(XPTY0004, "Invalid arity of the second argument in fn:compare(). Argument contains more than one item"); first_time = false; if (is_codepoint_equal) t.copy(tuple_cell::atomic(fn_compare(tc1, tc2, handler) == 0)); else t.copy(tuple_cell::atomic((int64_t)(fn_compare(tc1, tc2, handler)))); } else { t.set_eos(); first_time = true; } }
bool operator()(CassString, const DataType::ConstPtr& data_type) const { // Also allow "bytes" types to be bound as "string" types return is_string_type(data_type->value_type()) || is_bytes_type(data_type->value_type()); }