def gen_tbl_define_h_one(table, key_array, data_array, master_array, field_array): tbl_name = table[0] fname = CONST.CDB_H_PATH + string.lower(tbl_name) + '_define.h' file_tbl = open(fname, 'w') _macro_h_ = "__" + tbl_name + "_DEFINE_H__" print >> file_tbl, "" print >> file_tbl, "#ifndef %s" % (_macro_h_) print >> file_tbl, "#define %s" % (_macro_h_) print >> file_tbl, "" build_tbl_data_include_tbl(file_tbl, tbl_name, data_array) cdb_util.build_sub_ds_include(file_tbl, tbl_name, field_array, 1) cdb_util.insert_tbl_user_define_begin(file_tbl, tbl_name+'_define', '.h') build_tbl_field_id(file_tbl, tbl_name, field_array) print >> file_tbl, "/* %s defines */" % (tbl_name) if (len(key_array)): build_tbl_key(file_tbl, tbl_name, key_array) build_tbl_data(file_tbl, tbl_name, data_array) cdb_util.insert_tbl_user_define_beginmaster(file_tbl, tbl_name+'_define', '.h') build_tbl_master(file_tbl, tbl_name, master_array) cdb_util.insert_tbl_user_define_end(file_tbl, tbl_name+'_define', '.h') print >> file_tbl, "#endif /* !%s */" % (_macro_h_) print >> file_tbl, "" file_tbl.close() print "generate file %-50s field_num: %d" % (fname, len(field_array))
def gen_tbl_h_one(table, data_array, field_array): tbl_name = table[0] tbl_db_type = table[2] fname = CONST.CDB_H_PATH + string.lower(tbl_name) + '.h' file_tbl = open(fname, 'w') _macro_h_ = "__" + tbl_name + "_H__" print >> file_tbl, "" print >> file_tbl, "#ifndef %s" % (_macro_h_) print >> file_tbl, "#define %s" % (_macro_h_) print >> file_tbl, "" cdb_util.build_sub_ds_include(file_tbl, tbl_name, field_array, 0) cdb_util.insert_tbl_user_define_begin(file_tbl, tbl_name, '.h') if ('GLOBAL' == tbl_db_type): gen_tbl_set_field_func_prototype(file_tbl, table, "_sync") gen_tbl_set_field_func_prototype(file_tbl, table) gen_tbl_basic_func_prototype(file_tbl, table, 'get', CONST.PARAM_TYPE_NONE) gen_tbl_key_val2str_func_prototype(file_tbl, table) gen_tbl_key_str2val_func_prototype(file_tbl, table) gen_tbl_dump_one_func_prototype(file_tbl, table) gen_tbl_key_name_func_prototype(file_tbl, table) gen_tbl_key_value_func_prototype(file_tbl, table) gen_tbl_field_name_func_prototype(file_tbl, table) gen_tbl_field_value_func_prototype(file_tbl, table) gen_tbl_table_dump_func_prototype(file_tbl, table) gen_tbl_table_parser_func_prototype(file_tbl, table) gen_tbl_iterate_func_prototype(file_tbl, table) gen_tbl_iterate_func_prototype(file_tbl, table) gen_tbl_basic_func_prototype(file_tbl, table, 'init', CONST.PARAM_TYPE_NONE) else: gen_tbl_basic_func_prototype(file_tbl, table, 'add', CONST.PARAM_TYPE_TBL_KEY, "_sync") gen_tbl_basic_func_prototype(file_tbl, table, 'del', CONST.PARAM_TYPE_TBL, "_sync") gen_tbl_set_field_func_prototype(file_tbl, table, "_sync") gen_tbl_basic_func_prototype(file_tbl, table, 'add', CONST.PARAM_TYPE_TBL_KEY) gen_tbl_basic_func_prototype(file_tbl, table, 'del', CONST.PARAM_TYPE_TBL) gen_tbl_set_field_func_prototype(file_tbl, table) gen_tbl_basic_func_prototype(file_tbl, table, 'get', CONST.PARAM_TYPE_TBL) gen_tbl_key_val2str_func_prototype(file_tbl, table) gen_tbl_key_str2val_func_prototype(file_tbl, table) gen_tbl_dump_one_func_prototype(file_tbl, table) gen_tbl_key_name_func_prototype(file_tbl, table) gen_tbl_key_value_func_prototype(file_tbl, table) gen_tbl_field_name_func_prototype(file_tbl, table) gen_tbl_field_value_func_prototype(file_tbl, table) gen_tbl_table_dump_func_prototype(file_tbl, table) gen_tbl_table_parser_func_prototype(file_tbl, table) gen_tbl_iterate_func_prototype(file_tbl, table) gen_tbl_get_master_func_prototype(file_tbl, table) gen_tbl_basic_func_prototype(file_tbl, table, 'init', CONST.PARAM_TYPE_NONE, "") referlist_array = cdb_util.has_cdb_refer_list(field_array) for i, referlist_field in enumerate(referlist_array): gen_tbl_set_refer_list_func_prototype(file_tbl, table, referlist_field) cdb_util.insert_tbl_user_define_end(file_tbl, tbl_name, '.h') print >> file_tbl, "#endif /* !%s */" % (_macro_h_) print >> file_tbl, "" file_tbl.close() print "generate file %s" % (fname)
def gen_ds_h_one(ds, key_array, data_array, parent_tbl, ds_array): ds_name = ds[0] is_array_ds = cdb_util.is_parent_tbl_array_ds(ds_name, parent_tbl) tbl_db_type = ds[2] parent_table = parent_tbl[0] parent_ds = None parent_ds_param_str = '' fname = CONST.CDB_H_PATH + string.lower(ds_name) + '.h' file_tbl = open(fname, 'w') _macro_h_ = "__" + ds_name + "_H__" print >> file_tbl, "" print >> file_tbl, "#ifndef %s" % (_macro_h_) print >> file_tbl, "#define %s" % (_macro_h_) print >> file_tbl, "" cdb_util.build_ds_sub_ds_include(file_tbl, ds_name, data_array, 0) if (4 == len(ds)): parent_ds = cdb_util.get_parent_ds(ds, ds_array) parent_ds = parent_ds[0] parent_ds_name = string.lower(parent_ds[0]) parent_ds_type = parent_ds_name + '_t' parent_ds_value_name = 'p_' + parent_ds[1] parent_ds_param_str = parent_ds_type + ' *' + parent_ds_value_name + ', ' if (0 == is_array_ds): gen_ds_add_func_prototype(file_tbl, ds, parent_table, parent_ds_param_str, key_array, "_sync") gen_ds_del_func_prototype(file_tbl, ds, parent_table, parent_ds_param_str, key_array, "_sync") gen_ds_set_field_func_prototype(file_tbl, ds, parent_table, parent_ds_param_str, key_array, "_sync") if (0 == is_array_ds): gen_ds_add_func_prototype(file_tbl, ds, parent_table, parent_ds_param_str, key_array) gen_ds_del_func_prototype(file_tbl, ds, parent_table, parent_ds_param_str, key_array) gen_ds_set_field_func_prototype(file_tbl, ds, parent_table, parent_ds_param_str, key_array) gen_ds_get_func_prototype(file_tbl, ds, parent_table, parent_ds_param_str, key_array) gen_ds_key_str2val_func_prototype(file_tbl, ds, parent_table, parent_ds_param_str, key_array) gen_ds_key_name_dump_func_prototype(file_tbl, ds, parent_table, parent_ds_param_str, key_array) gen_ds_key_value_dump_func_prototype(file_tbl, ds, parent_table, parent_ds_param_str, key_array) gen_ds_field_name_dump_func_prototype(file_tbl, ds, parent_table, parent_ds_param_str, key_array) gen_ds_field_value_dump_func_prototype(file_tbl, ds, parent_table, parent_ds_param_str, key_array) gen_ds_table_dump_func_prototype(file_tbl, ds, parent_table, parent_ds_param_str, key_array) gen_ds_field_value_parser_func_prototype(file_tbl, ds, parent_table, parent_ds_param_str, key_array) gen_ds_table_parser_func_prototype(file_tbl, ds, parent_table, parent_ds_param_str, key_array) gen_tbl_dump_one_func_prototype(file_tbl, ds, parent_table, key_array) referlist_array = cdb_util.has_cdb_refer_list(data_array) for i, referlist_field in enumerate(referlist_array): gen_ds_set_refer_list_func_prototype(file_tbl, ds, parent_table, key_array, referlist_field) cdb_util.insert_tbl_user_define_end(file_tbl, ds_name, '.h') print >> file_tbl, "#endif /* !%s */" % (_macro_h_) print >> file_tbl, "" file_tbl.close() print "generate file %s" % (fname)