void fhs_table_close() { ensure(html_locations::in_table,"Table close tag before table open!"); ensure(html_locations::in_fhs_table,"Table type mismatch for table close tag!"); in_table=false; in_fhs_table=false; insert_template(files::fhs_tbody_close); insert_template(files::fhs_table_close); }
struct template_cache_entry *handle_template(struct template_hdr_v9 *hdr, struct packet_ptrs *pptrs, u_int16_t tpl_type, u_int32_t sid, u_int16_t *pens, u_int16_t len) { struct template_cache_entry *tpl = NULL; u_int8_t version = 0; if (pens) *pens = FALSE; if (tpl_type == 0 || tpl_type == 1) version = 9; else if (tpl_type == 2 || tpl_type == 3) version = 10; /* 0 NetFlow v9, 2 IPFIX */ if (tpl_type == 0 || tpl_type == 2) { if (tpl = find_template(hdr->template_id, pptrs, tpl_type, sid)) tpl = refresh_template(hdr, tpl, pptrs, tpl_type, sid, pens, version, len); else tpl = insert_template(hdr, pptrs, tpl_type, sid, pens, version, len); } /* 1 NetFlow v9, 3 IPFIX */ else if (tpl_type == 1 || tpl_type == 3) { if (tpl = find_template(hdr->template_id, pptrs, tpl_type, sid)) tpl = refresh_opt_template(hdr, tpl, pptrs, tpl_type, sid, version, len); else tpl = insert_opt_template(hdr, pptrs, tpl_type, sid, version, len); } return tpl; }
void body_close() { ensure(html_locations::in_body,"Body tag close is not valid!"); ensure(html_locations::out_table,"Cannot close body before closing the last table!"); body_closed=true; insert_template(files::html_body_close); }
void body_open() { ensure(html_locations::head_ended,"Body must be placed after head!"); ensure(html_locations::before_body,"Cannot reinitiate body tag!"); body_opened=true; insert_template(files::html_body_open); }
void head_open() { ensure(html_locations::in_html,"Header must be inside HTML tag!"); ensure(html_locations::before_head,"Cannot reinitiate head tag!"); head_opened=true; insert_template(files::html_head_open); }
void html_open() { ensure_open(); ensure(html_locations::empty,"Cannot reinitiate html tag!"); html_opened=true; insert_template(files::html_open); }
void fhs_table_open(std::vector<std::string> columns) { // fixed header strolling table ensure(html_locations::in_body,"Table must be inside body!"); ensure(html_locations::out_table,"The previous table is still open!"); ensure(html_locations::out_fhs_table,"Table type mismatch for table open tag!"); in_table=true; in_fhs_table=true; insert_template(files::fhs_table_open); insert_template(files::fhs_thead_open); // insert each header column for(const std::string citem : columns) fhs_table_column(citem); insert_template(files::fhs_thead_close); insert_template(files::fhs_tbody_open); }
void UmlRelation::generate_def(QTextStream & f, WrapperStr indent, bool h, WrapperStr templates, WrapperStr cl_names, WrapperStr, WrapperStr) { if (isClassMember() && !cppDecl().isEmpty()) { UmlClass * cl = (UmlClass *) parent(); if ((!templates.isEmpty() || (cl->name().find('<') != -1)) ? h : !h) { const char * p = cppDecl(); const char * pp = 0; while ((*p == ' ') || (*p == '\t')) p += 1; bool re_template = !templates.isEmpty() && insert_template(p, f, indent, templates); if (*p != '#') f << indent; const char * pname = name_spec(p); for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (re_template) f << templates; if (*p == 0) break; if (*p != '#') f << indent; } if (*p == '\n') { f << toLocale(p); if (*p && (*p != '#')) f << indent; } else if (*p == '@') manage_alias(p, f); else if (*p != '$') { if (p == pname) f << cl_names << "::"; f << toLocale(p); } else if (!strncmp(p, "${comment}", 10)) { if (!manage_comment(p, pp, CppSettings::isGenerateJavadocStyleComment()) && re_template) f << templates; } else if (!strncmp(p, "${description}", 14)) { if (!manage_description(p, pp) && re_template) f << templates; } else if (!strncmp(p, "${static}", 9)) { p += 9; } else if (!strncmp(p, "${const}", 8)) { p += 8; if (isReadOnly()) f << "const "; } else if (!strncmp(p, "${volatile}", 11)) { p += 11; if (isVolatile()) f << "volatile "; } else if (!strncmp(p, "${mutable}", 10)) { p += 10; } else if (!strncmp(p, "${type}", 7)) { p += 7; roleType()->write(f); } else if (!strncmp(p, "${name}", 7)) { p += 7; if (*pname == '$') f << cl_names << "::"; f << roleName(); } else if (!strncmp(p, "${inverse_name}", 15)) { p += 15; switch (relationKind()) { case anAssociation: case anAggregation: case anAggregationByValue: f << side(side(TRUE) != this)->roleName(); default: break; } } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; const WrapperStr & m = multiplicity(); if (!m.isEmpty() && (*((const char *) m) == '[')) f << m; else f << '[' << m << ']'; } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; f << CppSettings::relationAttributeStereotype(stereotype()); } else if (!strncmp(p, "${value}", 8)) { if (!defaultValue().isEmpty()) { if (need_equal(p, defaultValue())) f << " = "; f << defaultValue(); } p += 8; } else if (!strncmp(p, "${h_value}", 10)) p += 10; else if (!strncmp(p, "${association}", 14)) { p += 14; UmlClass::write(f, association()); } else // strange f << toLocale(p); } f << '\n'; } } }
uint32_t zdd_intersection() { vmax_check(); if (darray_count(stack) == 0) return 0; if (darray_count(stack) == 1) return (uint32_t) darray_last(stack); uint32_t z0 = (uint32_t) darray_at(stack, darray_count(stack) - 2); uint32_t z1 = (uint32_t) darray_remove_last(stack); struct node_template_s { uint16_t v; // NULL means this template have been instantiated. // Otherwise it points to the LO template. memo_it lo; union { // Points to HI template when template is not yet instantiated. memo_it hi; // During template instantiation we set n to the pool index // of the newly created node. uint32_t n; }; }; typedef struct node_template_s *node_template_ptr; typedef struct node_template_s node_template_t[1]; node_template_t top, bot; bot->v = 0; bot->lo = NULL; bot->n = 0; top->v = 1; top->lo = NULL; top->n = 1; // Naive implementation with two tries. One stores templates, the other // unique nodes. See Knuth for how to meld using just memory allocated // for a pool of nodes. memo_t tab; memo_init(tab); memo_it insert_template(uint32_t k0, uint32_t k1) { uint32_t key[2]; // Taking advantage of symmetry of intersection appears to help a tiny bit. if (k0 < k1) { key[0] = k0; key[1] = k1; } else { key[0] = k1; key[1] = k0; } memo_it it; int just_created = memo_it_insert_u(&it, tab, (void *) key, 8); if (!just_created) return it; if (!k0 || !k1) { memo_it_put(it, bot); return it; } if (k0 == 1 && k1 == 1) { memo_it_put(it, top); return it; } node_ptr n0 = pool[k0]; node_ptr n1 = pool[k1]; if (n0->v == n1->v) { node_template_ptr t = malloc(sizeof(*t)); t->v = n0->v; if (n0->lo == n0->hi && n1->lo == n0->hi) { t->lo = t->hi = insert_template(n0->lo, n1->lo); } else { t->lo = insert_template(n0->lo, n1->lo); t->hi = insert_template(n0->hi, n1->hi); } memo_it_put(it, t); return it; } else if (n0->v < n1->v) { memo_it it2 = insert_template(n0->lo, k1); memo_it_put(it, memo_it_data(it2)); return it2; } else { memo_it it2 = insert_template(k0, n1->lo); memo_it_put(it, memo_it_data(it2)); return it2; } }
void UmlAttribute::generate_def(QTextOStream & f, Q3CString indent, bool h, Q3CString templates, Q3CString cl_names, Q3CString, Q3CString) { if (isClassMember() && !cppDecl().isEmpty()) { UmlClass * cl = (UmlClass *) parent(); if ((!templates.isEmpty() || ((cl->name().find('<') != -1))) ? h : !h) { const char * p = cppDecl(); const char * pp = 0; while ((*p == ' ') || (*p == '\t')) p += 1; bool re_template = !templates.isEmpty() && insert_template(p, f, indent, templates); if (*p != '#') f << indent; const char * pname = name_spec(p); for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (re_template) f << templates; if (*p == 0) break; f << indent; } if (*p == '\n') { f << *p++; if (*p && (*p != '#')) f << indent; } else if (*p == '@') manage_alias(p, f); else if (*p != '$') { if (p == pname) f << cl_names << "::"; f << *p++; } else if (!strncmp(p, "${comment}", 10)) { if (!manage_comment(p, pp, CppSettings::isGenerateJavadocStyleComment()) && re_template) f << templates; } else if (!strncmp(p, "${description}", 14)) { if (!manage_description(p, pp) && re_template) f << templates; } else if (!strncmp(p, "${name}", 7)) { if (*pname == '$') f << cl_names << "::"; p += 7; f << name(); } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; const Q3CString & m = multiplicity(); if (!m.isEmpty() && (*((const char *) m) == '[')) f << m; else f << '[' << m << ']'; } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; f << CppSettings::relationAttributeStereotype(stereotype()); } else if (!strncmp(p, "${value}", 8)) { if (!defaultValue().isEmpty()) { if (need_equal(p, defaultValue())) f << " = "; f << defaultValue(); } p += 8; } else if (!strncmp(p, "${h_value}", 10)) p += 10; else if (!strncmp(p, "${static}", 9)) { p += 9; } else if (!strncmp(p, "${const}", 8)) { p += 8; if (isReadOnly()) f << "const "; } else if (!strncmp(p, "${volatile}", 11)) { p += 11; if (isVolatile()) f << "volatile "; } else if (!strncmp(p, "${mutable}", 10)) { p += 10; } else if (!strncmp(p, "${type}", 7)) { p += 7; UmlClass::write(f, type()); //f << CppSettings::Type(Type().Type()); } else // strange f << *p++; } f << '\n'; } } }
void head_close() { ensure(html_locations::in_head,"Head tag close is not valid!"); head_closed=true; insert_template(files::html_head_close); }
void html_close() { ensure(html_locations::body_ended,"Cannot close html tag before body!"); html_closed=true; insert_template(files::html_close); }