// // This file is generated by fmtgen from "libaegis/metrics.def". // If you want to change the contents of this file // you need to edit libaegis/metrics.def // or you need to enhance fmtgen. // #include #include #include #include #include #include #include #include #include #include #include #include void metrics_write(const output::pointer &fp, metrics_ty *this_thing) { if (!this_thing) return; trace(("metrics_write(this_thing = %08lX)\n{\n", (long)this_thing)); assert(((metrics_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((metrics_ty *)this_thing)->reference_count)); metric_list_write(fp, "metrics", this_thing->metrics); trace(("}\n")); } void metrics_write_xml(const output::pointer &fp, metrics_ty *this_thing) { if (!this_thing) return; trace(("metrics_write_xml(this_thing = %08lX)\n{\n", (long)this_thing)); assert(((metrics_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((metrics_ty *)this_thing)->reference_count)); fp->fputs("\n"); metric_list_write_xml(fp, "metrics", this_thing->metrics); fp->fputs("\n"); } static void * metrics_alloc(void) { metrics_ty *this_thing; trace(("metrics_alloc()\n{\n")); this_thing = (metrics_ty *)mem_alloc(sizeof(metrics_ty)); this_thing->reference_count = 1; this_thing->mask = 0; this_thing->errpos = str_copy(lex_position()); this_thing->metrics = (metric_list_ty *)0; trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } metrics_ty * metrics_copy(metrics_ty *this_thing) { trace(("metrics_copy()\n{\n")); this_thing->reference_count++; trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } metrics_ty * metrics_clone(metrics_ty *this_thing) { if (!this_thing) return 0; trace(("metrics_clone()\n{\n")); metrics_ty *result = (metrics_ty *)metrics_alloc(); result->metrics = metric_list_clone(this_thing->metrics); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } #ifdef DEBUG void metrics_trace_real(const char *name, const metrics_ty *value) { if (name && *name) { trace_printf("%s = ", name); } if (!value) { trace_printf("NULL"); } else { trace_printf("{\n"); metric_list_trace_real("metrics", value->metrics); trace_printf("}"); } trace_printf((name && *name) ? ";\n" : ",\n"); } #endif // DEBUG static void metrics_free(void *that) { metrics_ty *this_thing; this_thing = (metrics_ty *)that; if (!this_thing) return; this_thing->reference_count--; assert(this_thing->reference_count >= 0); if (this_thing->reference_count > 0) return; trace(("metrics_free(this_thing = %08lX)\n{\n", (long)this_thing)); if (this_thing->errpos) { str_free(this_thing->errpos); this_thing->errpos = 0; } metric_list_type.free(this_thing->metrics); mem_free(this_thing); trace(("}\n")); } static type_table_ty metrics_table[] = { { "metrics", offsetof(metrics_ty, metrics), &metric_list_type, metrics_metrics_mask, 0, // redefinition not ok 0, // fast_name }, }; static void * metrics_parse(void *this_thing, string_ty *name, meta_type **type_pp, unsigned long *mask_p, int *redef_p) { void *addr; trace(("metrics_parse(this_thing = %08lX, name = %08lX, type_pp = %08lX)\n{\n", (long)this_thing, (long)name, (long)type_pp)); assert(((metrics_ty *)this_thing)->reference_count > 0); addr = generic_struct_parse ( this_thing, name, type_pp, mask_p, redef_p, metrics_table, SIZEOF(metrics_table) ); trace(("return %08lX;\n}\n", (long)addr)); return addr; } static string_ty * metrics_fuzzy(string_ty *name) { string_ty *result; trace(("metrics_fuzzy(name = %08lX)\n{\n", (long)name)); result = generic_struct_fuzzy ( name, metrics_table, SIZEOF(metrics_table) ); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } static rpt_value::pointer metrics_convert(void *this_thing) { trace(("metrics_convert(name = %08lX)\n{\n", (long)this_thing)); assert(((metrics_ty *)this_thing)->reference_count > 0); rpt_value::pointer result = generic_struct_convert ( this_thing, metrics_table, SIZEOF(metrics_table) ); trace(("return %08lX;\n", (long)result.get())); trace(("}\n")); return result; } meta_type metrics_type = { "metrics", metrics_alloc, metrics_free, 0, // enum_parse 0, // list_parse metrics_parse, metrics_fuzzy, metrics_convert, generic_struct_is_set, }; metrics_ty * metrics_read_file(const nstring &filename) { return metrics_read_file(filename.get_ref()); } metrics_ty * metrics_read_file(string_ty *filename) { metrics_ty *result; trace(("metrics_read_file(filename = \"%s\")\n{\n", (filename ? filename->str_text : ""))); os_become_must_be_active(); result = (metrics_ty *)parse(filename, &metrics_type); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } void metrics_write_file(const nstring &filename, metrics_ty *value, bool comp) { metrics_write_file(filename.get_ref(), value, comp); } void metrics_write_file(string_ty *filename, metrics_ty *value, int needs_compression) { trace(("metrics_write_file(filename = \"%s\", value = %08lX)\n{\n", (filename ? filename->str_text : ""), (long)value)); if (filename) os_become_must_be_active(); output::pointer fp; if (needs_compression) { fp = output_file::binary_open(filename); fp = output_gzip::create(fp); } else { fp = output_file::text_open(filename); } fp = output_indent::create(fp); io_comment_emit(fp); metrics_write(fp, value); type_enum_option_clear(); trace(("}\n")); } void metrics__rpt_init(void) { trace(("metrics__rpt_init()\n{\n")); trace(("}\n")); }