inline OutIt print_doctype_node(OutIt out, const xml_node<Ch> *node, int flags, int indent) { assert(node->type() == node_doctype); if (!(flags & print_no_indenting)) out = fill_chars(out, indent, Ch('\t')); *out = Ch('<'), ++out; *out = Ch('!'), ++out; *out = Ch('D'), ++out; *out = Ch('O'), ++out; *out = Ch('C'), ++out; *out = Ch('T'), ++out; *out = Ch('Y'), ++out; *out = Ch('P'), ++out; *out = Ch('E'), ++out; *out = Ch(' '), ++out; out = copy_chars(node->value(), node->value() + node->value_size(), out); *out = Ch('>'), ++out; return out; }
inline OutIt print_comment_node(OutIt out, const xml_node<Ch>* node, int flags, int indent) { assert(node->type() == node_comment); if (!(flags & print_no_indenting)) { out = fill_chars(out, indent, Ch('\t')); } *out = Ch('<'), ++out; *out = Ch('!'), ++out; *out = Ch('-'), ++out; *out = Ch('-'), ++out; out = copy_chars(node->value(), node->value() + node->value_size(), out); *out = Ch('-'), ++out; *out = Ch('-'), ++out; *out = Ch('>'), ++out; return out; }
inline OutIt print_declaration_node(OutIt out, const xml_node<Ch> *node, int flags, int indent) { // Print declaration start if (!(flags & print_no_indenting)) out = fill_chars(out, indent, Ch('\t')); *out = Ch('<'), ++out; *out = Ch('?'), ++out; *out = Ch('x'), ++out; *out = Ch('m'), ++out; *out = Ch('l'), ++out; // Print attributes out = print_attributes(out, node, flags); // Print declaration end *out = Ch('?'), ++out; *out = Ch('>'), ++out; return out; }
inline OutIt print_cdata_node(OutIt out, const xml_node<Ch> *node, int flags, int indent) { assert(node->type() == node_cdata); if (!(flags & print_no_indenting)) out = fill_chars(out, indent, Ch('\t')); *out = Ch('<'); ++out; *out = Ch('!'); ++out; *out = Ch('['); ++out; *out = Ch('C'); ++out; *out = Ch('D'); ++out; *out = Ch('A'); ++out; *out = Ch('T'); ++out; *out = Ch('A'); ++out; *out = Ch('['); ++out; out = copy_chars(node->value(), node->value() + node->value_size(), out); *out = Ch(']'); ++out; *out = Ch(']'); ++out; *out = Ch('>'); ++out; return out; }
static void add_test(SQLSMALLINT c_type, SQLSMALLINT sql_type, const char *db_type, unsigned gen1, unsigned gen2) { test_info *t = NULL; size_t buf_len; if (num_tests >= MAX_TESTS) { fprintf(stderr, "too max tests\n"); exit(1); } t = &test_infos[num_tests++]; t->num = num_tests; t->c_type = c_type; t->sql_type = sql_type; t->db_type = db_type; t->gen1 = gen1; t->gen2 = gen2; t->vind = 0; switch (c_type) { case SQL_C_CHAR: buf_len = NBYTES*2+1; break; case SQL_C_WCHAR: buf_len = (NBYTES*2+1) * sizeof(SQLWCHAR); break; default: buf_len = NBYTES; } t->buf = (char*) malloc(buf_len); if (!t->buf) { fprintf(stderr, "memory error\n"); exit(1); } if (c_type != SQL_C_CHAR && c_type != SQL_C_WCHAR) fill_chars(t->buf, NBYTES, t->gen1, t->gen2); else memset(t->buf, 0, buf_len); t->vind = SQL_LEN_DATA_AT_EXEC(buf_len); }
inline OutIt print_element_node(OutIt out, const xml_node<Ch>* node, int flags, int indent) { assert(node->type() == node_element); // Print element name and attributes, if any if (!(flags & print_no_indenting)) { out = fill_chars(out, indent, Ch('\t')); } *out = Ch('<'), ++out; out = copy_chars(node->name(), node->name() + node->name_size(), out); out = print_attributes(out, node, flags); // If node is childless if (node->value_size() == 0 && !node->first_node()) { // Print childless node tag ending *out = Ch('/'), ++out; *out = Ch('>'), ++out; } else { // Print normal node tag ending *out = Ch('>'), ++out; // Test if node contains a single data node only (and no other nodes) xml_node<Ch>* child = node->first_node(); if (!child) { // If node has no children, only print its value without indenting out = copy_and_expand_chars(node->value(), node->value() + node->value_size(), Ch(0), out); } else if (child->next_sibling() == 0 && child->type() == node_data) { // If node has a sole data child, only print its value without indenting out = copy_and_expand_chars(child->value(), child->value() + child->value_size(), Ch(0), out); } else { // Print all children with full indenting if (!(flags & print_no_indenting)) { *out = Ch('\n'), ++out; } out = print_children(out, node, flags, indent + 1); if (!(flags & print_no_indenting)) { out = fill_chars(out, indent, Ch('\t')); } } // Print node end *out = Ch('<'), ++out; *out = Ch('/'), ++out; out = copy_chars(node->name(), node->name() + node->name_size(), out); *out = Ch('>'), ++out; } return out; }