/******************************************************************************/ /* function : gen_ops.c */ /* */ /* subsystem : chgen */ /* */ /* input : */ /* */ /* output : (writes to XXops.cc output file) */ /* */ /* returns : void */ /* */ /* author : ntansala */ /* */ /* created : May, 2000 */ /* */ /* revisions : */ /* */ /* 12/08/2000 kmiu -Add support for STL containers */ /* 11/30/2000 kmiu -NT port: replace hardcoded file extensions with */ /* outfile_ext */ /* 11/30/2000 kmiu -Fixed bug: arg to decode_retstr() should be */ /* "unsigned int *" */ /* 11/30/2000 kmiu -Fixed bug: removed extra semicolon after '\n' in */ /* fprintf(XXops_fp[i],"void %s::set_%s (char *value)\n;"...*/ /* 11/30/2000 kmiu -Fixed bug: replaced strcpy with strncpy */ /* 11/30/2000 kmiu -Removed unreferenced variables */ /* 2kf522 mottesen & kmiu STL modifications: Added gen_table* and */ /* gen_row* functions to write out new table and row methods*/ /* */ /* description : This routine generate XXops.cc */ /* */ /******************************************************************************/ #include #include #include "chgen_define.h" #include "chgen_externs.h" #include "prototypes.h" #include void gen_ops() { int i ; struct tt_type *tt_tmp ; tt_curr = tt; while (tt_curr != NULL) { i = encoding(tt_curr->TTabbr); fprintf(XXops_fp[i],"/******************************************************************************/\n"); /* kmiu-replacing cc file ext with machine dependent variable */ /* fprintf(XXops_fp[i],"* File : %sops.cc *\n", tt_curr->TTabbr); */ fprintf(XXops_fp[i],"/* File : %sops.%s */\n", tt_curr->TTabbr, outfile_ext); fprintf(XXops_fp[i],"/* Schema : %-58s */\n",sch_text_file_name); fprintf(XXops_fp[i],"/* GENCPP Version : %-58s */\n",CHGEN_VERSION); fprintf(XXops_fp[i],"/******************************************************************************/\n\n"); fprintf (XXops_fp[i], "#include \n") ; fprintf (XXops_fp[i], "#include \n") ; fprintf (XXops_fp[i], "#include \n") ; fprintf (XXops_fp[i], "#include \"%s\"\n", sch_header_file_name) ; tt_tmp = tt ; while (tt_tmp != NULL) { fprintf(XXops_fp[i], "#include \"%sschema.h\"\n", tt_tmp->TTabbr) ; tt_tmp = tt_tmp->next_ptr; } fprintf(XXops_fp[i], "\n") ; tt_curr = tt_curr->next_ptr; } /* end while tt_cur */ /* table class */ gen_table_get_ops(); gen_table_insertRow(); gen_table_removeRow(); gen_table_constructor(); gen_table_destructor(); gen_set_ops(); gen_get_ops(); gen_create_row(); gen_add_row(); gen_link_row(); gen_parse_row(); gen_delete_row(); gen_dump_table(); gen_dump_row(); gen_row_children_methods(); gen_row_parent_methods(); gen_row_constructor(); gen_row_destructor(); if (cli_log == 1) { gen_add_row_log(); gen_log_do_add_row(); gen_log_do_set_int_row(); gen_log_do_set_flt_row(); gen_log_do_set_key_row(); gen_log_do_set_str_row(); } } void gen_table_constructor() { int i; tt_curr = tt; while (tt_curr != NULL) { i = encoding(tt_curr->TTabbr); fprintf(XXops_fp[i],"#ifdef USE_STL\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"/* Constructor for table class. */\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"%stable::%stable(char *newAbbrev, char *newName)\n",tt_curr->TTabbr, tt_curr->TTabbr); fprintf(XXops_fp[i],"{\n"); fprintf(XXops_fp[i]," strcpy(abbrev, newAbbrev);\n"); fprintf(XXops_fp[i]," name = new char[sizeof( newName )];\n"); fprintf(XXops_fp[i]," strcpy(name, newName);\n"); fprintf(XXops_fp[i],"}\n"); fprintf(XXops_fp[i],"#endif\n\n"); tt_curr = tt_curr->next_ptr; } /* while */ } void gen_table_get_ops() { int i; tt_curr = tt; while (tt_curr != NULL) { i = encoding(tt_curr->TTabbr); fprintf(XXops_fp[i],"#ifdef USE_STL\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"/* This routine returns table abbreviation. */\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"char *%stable::getAbbrev()\n",tt_curr->TTabbr); fprintf(XXops_fp[i],"{\n"); fprintf(XXops_fp[i]," return abbrev;\n"); fprintf(XXops_fp[i],"}\n\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"/* This routine returns table name. */\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"char *%stable::getName()\n",tt_curr->TTabbr); fprintf(XXops_fp[i],"{\n"); fprintf(XXops_fp[i]," return name;\n"); fprintf(XXops_fp[i],"}\n\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"/* This routine returns number of rows in the table. */\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"unsigned int %stable::getRowCount()\n",tt_curr->TTabbr); fprintf(XXops_fp[i],"{\n"); fprintf(XXops_fp[i]," return row.size();\n"); fprintf(XXops_fp[i],"}\n\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"/* This routine returns an iterator to the first row in the table. */\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"list<%s*>::iterator %stable::getFirstRow()\n",tt_curr->TTabbr,tt_curr->TTabbr); fprintf(XXops_fp[i],"{\n"); fprintf(XXops_fp[i]," return row.begin();\n"); fprintf(XXops_fp[i],"}\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"/* This routine returns the last row in the table. */\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"%s *%stable::getLastRow()\n",tt_curr->TTabbr,tt_curr->TTabbr); fprintf(XXops_fp[i],"{\n"); fprintf(XXops_fp[i]," %s *retval;\n",tt_curr->TTabbr); fprintf(XXops_fp[i]," list<%s *>::iterator iter;\n\n",tt_curr->TTabbr); fprintf(XXops_fp[i]," if (row.empty())\n"); fprintf(XXops_fp[i]," {\n"); fprintf(XXops_fp[i]," retval = NULL;\n"); fprintf(XXops_fp[i]," }\n"); fprintf(XXops_fp[i]," else\n"); fprintf(XXops_fp[i]," {\n"); fprintf(XXops_fp[i]," iter = row.end();\n"); fprintf(XXops_fp[i]," iter--;\n"); fprintf(XXops_fp[i]," retval = *iter;\n"); fprintf(XXops_fp[i]," }\n"); fprintf(XXops_fp[i]," return retval;\n"); fprintf(XXops_fp[i],"}\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"/* This routine returns the terminator after last row in the table. */\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"list<%s*>::iterator %stable::Terminator()\n",tt_curr->TTabbr,tt_curr->TTabbr); fprintf(XXops_fp[i],"{\n"); fprintf(XXops_fp[i]," return row.end();\n"); fprintf(XXops_fp[i],"}\n"); fprintf(XXops_fp[i],"\nbool %stable::isFirstRow(%s* curr)\n",tt_curr->TTabbr, tt_curr->TTabbr); fprintf(XXops_fp[i],"{\n"); fprintf(XXops_fp[i]," return(curr != NULL && curr != (*getFirstRow()));\n"); fprintf(XXops_fp[i],"}\n"); fprintf(XXops_fp[i],"\nbool %stable::isLastRow(%s* curr)\n",tt_curr->TTabbr,tt_curr->TTabbr); fprintf(XXops_fp[i],"{\n"); fprintf(XXops_fp[i]," return(curr != NULL && curr != getLastRow());\n"); fprintf(XXops_fp[i],"}\n"); fprintf(XXops_fp[i],"#endif /* ifdef USE_STL */\n\n"); tt_curr = tt_curr->next_ptr; } /* while */ } void gen_table_insertRow() { int i; tt_curr = tt; while (tt_curr != NULL) { i = encoding(tt_curr->TTabbr); fprintf(XXops_fp[i],"#ifdef USE_STL\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"/* This routine inserts a row into the table. */\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"void %stable::insertRow(%s *newRow)\n", tt_curr->TTabbr, tt_curr->TTabbr); fprintf(XXops_fp[i],"{\n"); fprintf(XXops_fp[i]," list<%s*>::iterator iter;\n\n",tt_curr->TTabbr); fprintf(XXops_fp[i]," iter = row.begin();\n"); fprintf(XXops_fp[i]," while (iter != row.end() && (*iter)->get_pkid() < newRow->get_pkid())\n"); fprintf(XXops_fp[i]," iter++;\n\n"); fprintf(XXops_fp[i]," row.insert(iter, newRow);\n"); fprintf(XXops_fp[i],"}\n\n"); fprintf(XXops_fp[i],"#endif /* USE_STL */\n"); tt_curr = tt_curr->next_ptr; } } void gen_table_removeRow() { int i; tt_curr = tt; while (tt_curr != NULL) { i = encoding(tt_curr->TTabbr); fprintf(XXops_fp[i],"#ifdef USE_STL\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"/* This routine returns removes the specified row from the table. */\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"list<%s*>::iterator %stable::removeRow(list<%s*>::iterator i)\n", tt_curr->TTabbr,tt_curr->TTabbr, tt_curr->TTabbr); fprintf(XXops_fp[i],"{\n"); fprintf(XXops_fp[i]," %s *tmpRow = (*i);\n\n",tt_curr->TTabbr); fprintf(XXops_fp[i]," return row.erase(i);\n"); fprintf(XXops_fp[i],"}\n"); fprintf(XXops_fp[i],"#endif\n\n"); tt_curr = tt_curr->next_ptr; } } void gen_table_destructor() { int i; tt_curr = tt; while (tt_curr != NULL) { i = encoding(tt_curr->TTabbr); fprintf(XXops_fp[i],"#ifdef USE_STL\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"/* Table destructor. */\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"%stable::~%stable()\n",tt_curr->TTabbr,tt_curr->TTabbr); fprintf(XXops_fp[i],"{\n"); fprintf(XXops_fp[i]," %s *currRow;\n",tt_curr->TTabbr); fprintf(XXops_fp[i]," list<%s*>::iterator iterator;\n\n",tt_curr->TTabbr); fprintf(XXops_fp[i]," iterator = row.begin();\n\n"); fprintf(XXops_fp[i]," while (iterator != row.end())\n"); fprintf(XXops_fp[i]," {\n"); fprintf(XXops_fp[i]," currRow = *iterator;\n"); fprintf(XXops_fp[i]," iterator = currRow->delete_row(iterator);\n"); fprintf(XXops_fp[i]," }\n"); fprintf(XXops_fp[i]," delete [] name;\n"); fprintf(XXops_fp[i],"}\n"); fprintf(XXops_fp[i],"#endif\n\n"); tt_curr = tt_curr->next_ptr; } } void gen_set_ops() { int dimension, i; tt_curr = tt; while (tt_curr != NULL) { i = encoding(tt_curr->TTabbr) ; /* added by ntansala 042800 */ ta_curr = tt_curr->ta_ptr->next_ptr; while (ta_curr != NULL) { fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"/* This routine is used to set value to a data member. */\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); if(ta_curr->IsKey) { fprintf(XXops_fp[i], "void %s::set_%s (hcg_key value)\n", tt_curr->TTabbr, ta_curr->FieldName); fprintf(XXops_fp[i], "{\n"); if (cli_log ==1) { fprintf(XXops_fp[i],"char log_text[BUFSIZE];\n"); fprintf(XXops_fp[i],"char temp_key[HCG_KEY_SIZE+1];\n"); fprintf(XXops_fp[i],"char temp_fkey[HCG_KEY_SIZE+1];\n"); fprintf(XXops_fp[i],"hcg_key %sid;\n\n", tt_curr->TTabbr); fprintf(XXops_fp[i]," logwait();\n"); } fprintf(XXops_fp[i], " if (get_RFLAG()==1 && hcg_log ==1 )\n"); fprintf(XXops_fp[i], " {\n"); fprintf(XXops_fp[i], " fprintf( hcg_logfileptr, \"SET_KEY %%s %%s %%s\\n\",\n"); /* kmiu: change value to &value in next line */ fprintf(XXops_fp[i], " decode_retstr( (hcg_key*)(get_pkid()) ), \"%s\", decode_retstr(&value) );\n", ta_curr->FieldName); fprintf(XXops_fp[i], " }\n"); fprintf(XXops_fp[i], " %s = value ; \n", ta_curr->FieldName); if (cli_log ==1) { fprintf(XXops_fp[i]," %sid = RC::get_pkid();\n", tt_curr->TTabbr); fprintf(XXops_fp[i]," decode(temp_key, &%sid);\n", tt_curr->TTabbr); fprintf(XXops_fp[i]," decode(temp_fkey, &value);\n", tt_curr->TTabbr); fprintf(XXops_fp[i]," sprintf(log_text,\"PR_SET_KEY %%s %s %%s\\n\",", ta_curr->FieldName) ; fprintf(XXops_fp[i],"temp_key, temp_fkey);\n"); fprintf(XXops_fp[i]," logstr(log_text);\n\n"); } fprintf(XXops_fp[i], "}\n"); } else switch(ta_curr->FieldType[0]) { case 'i' : fprintf(XXops_fp[i],"void %s::set_%s (int value)\n", tt_curr->TTabbr,ta_curr->FieldName); fprintf(XXops_fp[i],"{\n"); if (cli_log ==1) { fprintf(XXops_fp[i],"char log_text[BUFSIZE];\n"); fprintf(XXops_fp[i],"char temp_key[HCG_KEY_SIZE+1];\n"); fprintf(XXops_fp[i],"hcg_key %sid;\n\n", tt_curr->TTabbr); fprintf(XXops_fp[i]," logwait();\n"); } fprintf(XXops_fp[i]," if (get_RFLAG()==1 && hcg_log ==1 )\n"); fprintf(XXops_fp[i]," {\n"); fprintf(XXops_fp[i]," fprintf( hcg_logfileptr, \"SET_INT %%s %%s %%d\\n\",\n"); fprintf(XXops_fp[i]," decode_retstr( (hcg_key*)(get_pkid()) ),\"%s\", (value) );\n", ta_curr->FieldName); fprintf(XXops_fp[i]," }\n"); fprintf(XXops_fp[i]," %s = value ; \n", ta_curr->FieldName); if (cli_log ==1) { fprintf(XXops_fp[i],"#ifdef USE_STL\n"); fprintf(XXops_fp[i]," %sid = get_pkid();\n", tt_curr->TTabbr); fprintf(XXops_fp[i],"#else\n"); fprintf(XXops_fp[i]," %sid = RC::get_pkid();\n", tt_curr->TTabbr); fprintf(XXops_fp[i],"#endif\n"); fprintf(XXops_fp[i]," decode(temp_key, &%sid);\n", tt_curr->TTabbr); fprintf(XXops_fp[i]," sprintf(log_text,\"PR_SET_INT %%s %s %%d\\n\",", ta_curr->FieldName) ; fprintf(XXops_fp[i],"temp_key, value);\n"); fprintf(XXops_fp[i]," logstr(log_text);\n\n"); } fprintf(XXops_fp[i],"}\n"); break; case 'f' : fprintf(XXops_fp[i],"void %s::set_%s (float value)\n",tt_curr->TTabbr,ta_curr->FieldName); fprintf(XXops_fp[i],"{\n"); if (cli_log ==1) { fprintf(XXops_fp[i],"char log_text[BUFSIZE];\n"); fprintf(XXops_fp[i],"char temp_key[HCG_KEY_SIZE+1];\n"); fprintf(XXops_fp[i],"hcg_key %sid;\n\n", tt_curr->TTabbr); fprintf(XXops_fp[i]," logwait();\n\n"); } fprintf(XXops_fp[i]," if (get_RFLAG()==1 && hcg_log ==1 )\n"); fprintf(XXops_fp[i]," {\n"); fprintf(XXops_fp[i]," fprintf( hcg_logfileptr, \"SET_FLT %%s %%s %%f\\n\",\n"); fprintf(XXops_fp[i]," decode_retstr( (hcg_key*)(get_pkid()) ),\"%s\", (value) );\n", ta_curr->FieldName); fprintf(XXops_fp[i]," }\n"); fprintf(XXops_fp[i]," %s = value ; \n", ta_curr->FieldName); if (cli_log ==1) { fprintf(XXops_fp[i]," %sid = RC::get_pkid();\n", tt_curr->TTabbr); fprintf(XXops_fp[i]," decode(temp_key, &%sid);\n", tt_curr->TTabbr); fprintf(XXops_fp[i]," sprintf(log_text,\"PR_SET_FLT %%s %s %%f\\n\",", ta_curr->FieldName) ; fprintf(XXops_fp[i],"temp_key, value);\n"); fprintf(XXops_fp[i]," logstr(log_text);\n\n"); } fprintf(XXops_fp[i],"}\n"); break; case 'c' : case 't' : dimension = atoi(&(ta_curr->FieldType[1])) +1; fprintf(XXops_fp[i],"void %s::set_%s (char *value)\n",tt_curr->TTabbr,ta_curr->FieldName); fprintf(XXops_fp[i],"{\n"); if (cli_log ==1) { fprintf(XXops_fp[i],"char log_text[BUFSIZE];\n"); fprintf(XXops_fp[i],"char temp_key[HCG_KEY_SIZE+1];\n"); fprintf(XXops_fp[i],"hcg_key %sid;\n\n", tt_curr->TTabbr); fprintf(XXops_fp[i]," logwait();\n\n"); } fprintf(XXops_fp[i]," if ( strlen(value) >= sizeof(%s) )\n",ta_curr->FieldName ); fprintf(XXops_fp[i]," fprintf(stderr, \"Warning: field %s in class %s is too long- truncated\\n\");\n", ta_curr->FieldName, tt_curr->TTabbr ); fprintf(XXops_fp[i]," if (get_RFLAG()==1 && hcg_log ==1 )\n"); fprintf(XXops_fp[i]," {\n"); fprintf(XXops_fp[i]," fprintf( hcg_logfileptr, \"SET_STR %%s %%s %%s\\n\",\n"); fprintf(XXops_fp[i]," decode_retstr( (hcg_key*)(get_pkid()) ),\"%s\", (value) );\n", ta_curr->FieldName); fprintf(XXops_fp[i]," }\n"); fprintf(XXops_fp[i]," strncpy(%s, value, sizeof(%s)) ; \n", ta_curr->FieldName,ta_curr->FieldName); if (cli_log ==1) { fprintf(XXops_fp[i]," %sid = RC::get_pkid();\n", tt_curr->TTabbr); fprintf(XXops_fp[i]," decode(temp_key, &%sid);\n", tt_curr->TTabbr); fprintf(XXops_fp[i]," sprintf(log_text,\"PR_SET_STR %%s %s %%s\\n\",", ta_curr->FieldName) ; fprintf(XXops_fp[i],"temp_key, value);\n"); fprintf(XXops_fp[i]," logstr(log_text);\n\n"); } fprintf(XXops_fp[i],"}\n"); break; case 'd' : /* kmiu-removed extra semicolon after '\n' */ fprintf(XXops_fp[i],"void %s::set_%s (char *value)\n",tt_curr->TTabbr,ta_curr->FieldName); fprintf(XXops_fp[i],"{\n"); if (cli_log ==1) { fprintf(XXops_fp[i],"char log_text[BUFSIZE];\n"); fprintf(XXops_fp[i],"char temp_key[HCG_KEY_SIZE+1];\n"); fprintf(XXops_fp[i],"hcg_key %sid;\n\n", tt_curr->TTabbr); fprintf(XXops_fp[i]," logwait();\n\n"); } fprintf(XXops_fp[i]," if ( strlen(value) >= 26 )\n"); fprintf(XXops_fp[i]," fprintf(stderr, \"Warning: field %s in class %s is too long- truncated\\n\");\n", ta_curr->FieldName, tt_curr->TTabbr ); fprintf(XXops_fp[i]," if (get_RFLAG()==1 && hcg_log ==1 )\n"); fprintf(XXops_fp[i]," {\n"); fprintf(XXops_fp[i]," fprintf( hcg_logfileptr, \"SET_STR %%s %%s %%s\\n\",\n"); fprintf(XXops_fp[i]," decode_retstr( (hcg_key*)(get_pkid()) ),\"%s\", (value) );\n", ta_curr->FieldName); fprintf(XXops_fp[i]," }\n"); /* kmiu-replace strcpy with strncpy */ fprintf(XXops_fp[i]," strncpy(%s, value, 26) ; \n", ta_curr->FieldName); if (cli_log ==1) { fprintf(XXops_fp[i]," %sid = RC::get_pkid();\n", tt_curr->TTabbr); fprintf(XXops_fp[i]," decode(temp_key, &%sid);\n", tt_curr->TTabbr); fprintf(XXops_fp[i]," sprintf(log_text,\"PR_SET_STR %%s %s %%s\\n\",", ta_curr->FieldName) ; fprintf(XXops_fp[i],"temp_key, value);\n"); fprintf(XXops_fp[i]," logstr(log_text);\n\n"); } fprintf(XXops_fp[i],"}\n"); break; } /* switch */ fprintf(XXops_fp[i],"\n"); ta_curr = ta_curr->next_ptr; } /* end while ta_curr */ tt_curr = tt_curr->next_ptr; } /* end while tt_cur */ } void gen_get_ops() { int dimension, i; tt_curr = tt; while (tt_curr != NULL) { i = encoding(tt_curr->TTabbr) ; /* added by ntansala 042800 */ ta_curr = tt_curr->ta_ptr->next_ptr; while (ta_curr != NULL) { fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"/* This routine is used to get value from a data member. */\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); if(ta_curr->IsKey) { fprintf(XXops_fp[i], "hcg_key %s::get_%s ()\n", tt_curr->TTabbr,ta_curr->FieldName); fprintf(XXops_fp[i], "{\n"); fprintf(XXops_fp[i], " return %s; \n", ta_curr->FieldName); fprintf(XXops_fp[i], "}\n"); } else switch(ta_curr->FieldType[0]) { case 'i' : fprintf(XXops_fp[i],"int %s::get_%s ()\n", tt_curr->TTabbr,ta_curr->FieldName); fprintf(XXops_fp[i],"{\n"); fprintf(XXops_fp[i]," return %s; \n", ta_curr->FieldName); fprintf(XXops_fp[i],"}\n"); break; case 'f' : fprintf(XXops_fp[i],"float %s::get_%s ()\n",tt_curr->TTabbr,ta_curr->FieldName); fprintf(XXops_fp[i],"{\n"); fprintf(XXops_fp[i]," return %s; \n", ta_curr->FieldName); fprintf(XXops_fp[i],"}\n"); break; case 'c' : case 't' : dimension = atoi(&(ta_curr->FieldType[1])) +1; fprintf(XXops_fp[i],"char* %s::get_%s ()\n",tt_curr->TTabbr,ta_curr->FieldName); fprintf(XXops_fp[i],"{\n"); fprintf(XXops_fp[i]," return %s; \n", ta_curr->FieldName); fprintf(XXops_fp[i],"}\n"); break; case 'd' : fprintf(XXops_fp[i]," char* %s::get_%s ()\n",tt_curr->TTabbr,ta_curr->FieldName); fprintf(XXops_fp[i]," {\n"); fprintf(XXops_fp[i]," return %s; \n", ta_curr->FieldName); fprintf(XXops_fp[i]," }\n"); break; } /* switch */ fprintf(XXops_fp[i],"\n"); ta_curr = ta_curr->next_ptr; } /* end while ta_curr */ tt_curr = tt_curr->next_ptr; } /* end while tt_cur */ } void gen_create_row() { int i; struct rr_type *tmp_ptr; /* to hold the current position */ char temp_string[ABBREV_NAME_LENGTH]; tt_curr = tt; while ( tt_curr != NULL) { i = encoding(tt_curr->TTabbr); fprintf(XXops_fp[i],"#ifndef USE_STL\n"); fprintf(XXops_fp[i],"%s* %s::create_row()\n", tt_curr->TTabbr,tt_curr->TTabbr); fprintf(XXops_fp[i],"{\n"); fprintf(XXops_fp[i]," %s *%stmp;\n\n", tt_curr->TTabbr,tt_curr->TTabbr); fprintf(XXops_fp[i]," %stmp = new %s;\n\n", tt_curr->TTabbr,tt_curr->TTabbr); fprintf(XXops_fp[i]," %stmp->set_pkid(0);\n\n",tt_curr->TTabbr); ta_curr = tt_curr->ta_ptr->next_ptr; while (ta_curr != NULL) { if(ta_curr->IsKey) fprintf(XXops_fp[i], " %stmp->set_%s(0);\n",tt_curr->TTabbr,ta_curr->FieldName); else switch(ta_curr->FieldType[0]) { case 'i' : /* int */ fprintf(XXops_fp[i]," %stmp->set_%s(0);\n",tt_curr->TTabbr,ta_curr->FieldName); break; case 'f' : /* float */ fprintf(XXops_fp[i]," %stmp->set_%s(0.0);\n",tt_curr->TTabbr,ta_curr->FieldName); break; case 'c' : /* char */ case 't' : /* text */ fprintf(XXops_fp[i]," %stmp->set_%s(\"\\0\");\n",tt_curr->TTabbr,ta_curr->FieldName); break; case 'd' : /* date char */ fprintf(XXops_fp[i]," %stmp->set_%s(\"\\0\");\n",tt_curr->TTabbr,ta_curr->FieldName); break; } /* switch */ ta_curr = ta_curr->next_ptr; } /* end while ta_curr */ fprintf(XXops_fp[i],"\n %stmp->next_ptr = NULL;\n",tt_curr->TTabbr); fprintf(XXops_fp[i]," %stmp->prev_ptr = NULL;\n",tt_curr->TTabbr); tmp_ptr = cp_table; while(tmp_ptr) /* not end of list */ { if (strncmp(tt_curr->ta_ptr->FieldName,tmp_ptr->firstid,strlen(tt_curr->ta_ptr->FieldName)) == 0) { strncpy_null(temp_string, tmp_ptr->secondid, hcg_abbr_size); fprintf(XXops_fp[i],"\n %stmp->%s_pp = NULL;\n",tt_curr->TTabbr,tmp_ptr->secondid); fprintf(XXops_fp[i]," %stmp->%s_fpp = NULL;\n",tt_curr->TTabbr, tmp_ptr->secondid); if (!cli_nobp) fprintf(XXops_fp[i]," %stmp->%s_bpp = NULL;\n",tt_curr->TTabbr,tmp_ptr->secondid); } tmp_ptr = tmp_ptr->next_ptr; } /* child methods */ tmp_ptr = pc_table; while(tmp_ptr) /* not end of list */ { if (strncmp(tt_curr->ta_ptr->FieldName,tmp_ptr->firstid, strlen(tt_curr->ta_ptr->FieldName)) == 0) { strncpy_null(temp_string, tmp_ptr->secondid, hcg_abbr_size); fprintf(XXops_fp[i],"\n %stmp->%s_fcp = NULL;\n",tt_curr->TTabbr, tmp_ptr->secondid); if (!cli_nobp) fprintf(XXops_fp[i]," %stmp->%s_bcp = NULL;\n",tt_curr->TTabbr, tmp_ptr->secondid); } tmp_ptr = tmp_ptr->next_ptr; } fprintf(XXops_fp[i],"\n return %stmp;\n", tt_curr->TTabbr); fprintf(XXops_fp[i],"}\n\n"); fprintf(XXops_fp[i],"#endif\n"); tt_curr = tt_curr->next_ptr; } /* while tt */ } void gen_add_row() /* generating function pr_add() */ { static char rcsid[] = "$Id: gen_pr_add.c,v 1.4.4.2 1999/05/07 01:25:08 jkarner Exp $"; int i; tt_curr = tt; while ( tt_curr != NULL) { i = encoding(tt_curr->TTabbr) ; fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"/* This routine is used to add a single row to a virtual database table. */\n"); fprintf(XXops_fp[i],"/* Validations for valid table-id, table is within view, and the version */\n"); fprintf(XXops_fp[i],"/* number is the right one for this table in this view. if all this passes, */\n"); fprintf(XXops_fp[i],"/* the row is added to the database, and linked in to its parents, etc... */\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"void %s::add_row (char *viewname)\n", tt_curr->TTabbr); fprintf(XXops_fp[i], "{\n" ); fprintf(XXops_fp[i], "char error_table[HCG_ABBR_SIZE+1];\n" ); fprintf(XXops_fp[i], "char tempkey[HCG_KEY_SIZE+1];\n" ); fprintf(XXops_fp[i], "hcg_key %sid;\n",tt_curr->TTabbr ); if (cli_log == 1) fprintf(XXops_fp[i],"char VNstring[NAMELENGTH] = \"VN \"; \n\n"); /* fprintf(XXops_fp[i]," while( *tbl_abbrv == ' ') ++tbl_abbrv; \n\n"); */ if (cli_log == 1) { fprintf(XXops_fp[i],"\tif (hcg_log == 1)\n") ; fprintf(XXops_fp[i],"\t{\n") ; fprintf(XXops_fp[i],"\t logwait();\n") ; fprintf(XXops_fp[i],"\t if (strcmp(viewname, hcg_viewname))\n") ; fprintf(XXops_fp[i],"\t {\n") ; fprintf(XXops_fp[i],"\t logstr(strcat (strcat (VNstring, viewname), \"\\n\"));\n") ; fprintf(XXops_fp[i],"\t strcpy (hcg_viewname, viewname);\n") ; fprintf(XXops_fp[i],"\t }\n") ; fprintf(XXops_fp[i],"\t }\n") ; } fprintf(XXops_fp[i],"\tif (!hcg_initialized)\n"); fprintf(XXops_fp[i],"\t{\n"); fprintf(XXops_fp[i],"\t printf(\"Error: pr_add() called when database is not yet initialized.\\n\");\n"); if (cli_log == 1) fprintf(XXops_fp[i],"\t add_row_log (viewname); \n"); fprintf(XXops_fp[i],"\t return;\n") ; fprintf(XXops_fp[i],"\t}\n\n"); fprintf(XXops_fp[i],"\tif (!find_view_idx(viewname))\n"); fprintf(XXops_fp[i],"\t{\n"); fprintf(XXops_fp[i],"\t printf(\"Error: view %%s passed to pr_load is not defined.\\n\",viewname);\n"); if (cli_log == 1) fprintf(XXops_fp[i],"\t add_row_log (viewname); \n"); fprintf(XXops_fp[i],"\t return; \n") ; fprintf(XXops_fp[i],"\t}\n"); fprintf(XXops_fp[i],"\tif (!find_tbl_idx(\"%s\"))\n", tt_curr->TTabbr) ; fprintf(XXops_fp[i],"\t{\n"); fprintf(XXops_fp[i],"\t strncpy_null(error_table, \"%s\", HCG_ABBR_SIZE);\n",tt_curr->TTabbr); fprintf(XXops_fp[i],"\t printf(\"Warning: unknown table (%%s) passed to pr_add, ignored.\\n\",error_table);\n"); if (cli_log == 1) fprintf(XXops_fp[i],"\t add_row_log (viewname); \n"); fprintf(XXops_fp[i],"\t return;\n"); fprintf(XXops_fp[i],"\t}\n"); #ifndef NEW_VERSION fprintf(XXops_fp[i],"\tif (hcg_view_list.view_list[hcg_view_idx].version_list[hcg_tbl_idx] == '\\0')\n"); fprintf(XXops_fp[i],"\t return;\n"); #endif fprintf(XXops_fp[i],"\thcg_version = hcg_view_list.view_list[hcg_view_idx].version_list[hcg_tbl_idx];\n"); fprintf(XXops_fp[i],"\thcg_table_seq_list[hcg_tbl_idx].rcount++;\n"); fprintf(XXops_fp[i],"\thcg_ts_list[hcg_tbl_idx].ts_list[hcg_version].rcount++;\n\n"); ta_curr = tt_curr->ta_ptr; fprintf(XXops_fp[i],"#ifndef USE_STL\n"); fprintf(XXops_fp[i],"\t%selt = this;\n", tt_curr->TTabbr); fprintf(XXops_fp[i],"#endif\n"); fprintf(XXops_fp[i], "\tpr_gen_pkey(viewname,%s,%s);\n", tt_curr->TTabbr, ta_curr->FieldName); fprintf(XXops_fp[i],"#ifdef USE_STL\n"); fprintf(XXops_fp[i],"\tset_pkid(%sid);\n",tt_curr->TTabbr); fprintf(XXops_fp[i],"#else\n"); fprintf(XXops_fp[i],"\tRC::set_pkid(%sid);\n",tt_curr->TTabbr); fprintf(XXops_fp[i],"#endif\n"); for (tmp= cp_table; tmp; tmp = tmp->next_ptr ) { struct rr_data rr_entry; if (! pr_get_cp_entry( tmp, tt_curr->TTabbr, & rr_entry ) ) continue; fprintf( XXops_fp[i],"#ifndef USE_STL\n"); fprintf( XXops_fp[i], "\tpr_check_fkey(%s,%selt,%s,%s,%s,%selt);\n", rr_entry.child_abbrev, rr_entry.child_abbrev, rr_entry.parent, rr_entry.prnt_abbrev, rr_entry.parent_pkey, rr_entry.prnt_abbrev); fprintf( XXops_fp[i],"#else\n"); /* kmiu-replace %selt with 'this' */ fprintf( XXops_fp[i],"\tpr_check_fkey(%s,this,%s,%s,%s,%selt);\n",rr_entry.child_abbrev, rr_entry.parent, rr_entry.prnt_abbrev, rr_entry.parent_pkey, rr_entry.prnt_abbrev); fprintf( XXops_fp[i],"#endif\n"); } while ( ta_curr != NULL) { if (ta_curr->IsKey) { /* field is the primary/foreign key which is already done */ ta_curr = ta_curr->next_ptr; continue; } else switch ( ta_curr->FieldType[0] ) { case 'i': case 'f': break; case 'd': fprintf( XXops_fp[i], "\tpr_check_str (%s,%selt,%s,%d);\n", tt_curr->TTabbr, tt_curr->TTabbr, ta_curr->FieldName, 26); break; default: fprintf( XXops_fp[i], "\tpr_check_str (%s,%selt,%s,%d);\n", tt_curr->TTabbr, tt_curr->TTabbr, ta_curr->FieldName, atoi(ta_curr->FieldType+1)); } ta_curr = ta_curr->next_ptr; } if (cli_log == 1) fprintf(XXops_fp[i],"\tadd_row_log (viewname);\n"); fprintf(XXops_fp[i], "\tlink_row();\n" ); fprintf(XXops_fp[i],"\thcg_ts_list[hcg_tbl_idx].ts_list[hcg_version].maxrow++;\n"); fprintf(XXops_fp[i], "}\n\n" ); tt_curr = tt_curr->next_ptr; } /* while tt */ } void gen_link_row() /* generating function pr_link() */ { struct rr_type *tmp; struct rr_data rr_entry; int i; tt_curr = tt; while ( tt_curr != NULL) { i = encoding(tt_curr->TTabbr); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"/* This routine is used to link a single row to a virtual database table. */\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"void %s::link_row()\n", tt_curr->TTabbr ); fprintf(XXops_fp[i],"{\n" ); fprintf(XXops_fp[i]," hcg_key %sid;\n",tt_curr->TTabbr); fprintf(XXops_fp[i],"\n#ifndef USE_STL\n"); fprintf(XXops_fp[i], "\tinsert_element(%s);\n", tt_curr->TTabbr); fprintf(XXops_fp[i],"#else\n"); fprintf(XXops_fp[i], "%stab->insertRow(this);\n",tt_curr->TTabbr); /* fprintf(XXops_fp[i], "%sbegin = %stab->getFirstRow();\n",tt_curr->TTabbr,tt_curr->TTabbr); */ /* fprintf(XXops_fp[i], "%send = %stab->getLastRow();\n", tt_curr->TTabbr, tt_curr->TTabbr); */ /* fprintf(XXops_fp[i], "tbl##curr = tbl##elt \n"); */ fprintf(XXops_fp[i], "#endif /* USE_STL */\n\n"); if( tt_curr->comment[0] != '\0') if(tt_curr->comment[2] == '1') fprintf(XXops_fp[i], "\tbtree_add_row(%s);\n", tt_curr->TTabbr); if (!cli_noforward) { /* for each of the pc_table entries, generating a while loop linking all the rings accordingly */ for(tmp = pc_table; tmp; tmp = tmp->next_ptr) { if ( ! pr_get_pc_entry( tmp, tt_curr->TTabbr, &rr_entry) ) continue; fprintf(XXops_fp[i],"\tlink_child_"); if (tmp->Singleton) fprintf(XXops_fp[i],"1"); else { if ((!cli_nobp) && (tmp->HasBp)) fprintf(XXops_fp[i], "bp_m"); else fprintf(XXops_fp[i], "nobp_m"); } fprintf(XXops_fp[i],"(%s,%s,%s,%s,%s,%s);\n", rr_entry.child_abbrev, rr_entry.prnt_abbrev, rr_entry.parent, rr_entry.parent_pkey, rr_entry.parent, rr_entry.child); } } /* if cli_noforward */ /* for each of the cp_table entries, generating a while loop linking all the rings accordingly */ for(tmp= cp_table; tmp; tmp = tmp->next_ptr ) { if( ! pr_get_cp_entry( tmp, tt_curr->TTabbr, &rr_entry ) ) continue; fprintf(XXops_fp[i],"\tlink_parent_"); if (tmp->Singleton) fprintf(XXops_fp[i],"1"); else { if ((!cli_nobp) && (tmp->HasBp)) fprintf(XXops_fp[i],"bp_m"); else fprintf(XXops_fp[i],"nobp_m"); } fprintf(XXops_fp[i],"(%s,%s,%s,%s,%s,%s);\n", rr_entry.child_abbrev, rr_entry.prnt_abbrev, rr_entry.parent, rr_entry.parent_pkey, rr_entry.parent, rr_entry.child); } fprintf(XXops_fp[i],"}\n\n" ); tt_curr = tt_curr->next_ptr; } /* while tt */ } void gen_parse_row() { int i; char unpad; tt_curr = tt; while ( tt_curr != NULL) { i = encoding(tt_curr->TTabbr) ; fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"/* This routine is used to parse a single row to a virtual database table. */\n"); fprintf(XXops_fp[i],"/* Validations for valid table-id, table is within view, and the version */\n"); fprintf(XXops_fp[i],"/* number is the right one for this table in this view. if all this passes, */\n"); fprintf(XXops_fp[i],"/* the row is added to the database, and linked in to its parents, etc... */\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"void %s::parse_row (char *buffer, int idx, hcg_key hcg_k)\n", tt_curr->TTabbr); fprintf(XXops_fp[i],"{\n"); ta_curr = tt_curr->ta_ptr; while ( ta_curr != NULL) { if(ta_curr->IsKey) { if (ta_curr == tt_curr->ta_ptr) /* pkey, already encoded*/ { /* fprintf(XXops_fp[i],"\t%s = hcg_k;\n", ta_curr->FieldName); */ fprintf(XXops_fp[i],"#ifdef USE_STL\n"); fprintf(XXops_fp[i],"\tset_pkid(hcg_k);\n"); fprintf(XXops_fp[i],"#else\n"); fprintf(XXops_fp[i],"\tRC::set_pkid(hcg_k);\n"); fprintf(XXops_fp[i],"#endif\n"); } else { fprintf(XXops_fp[i],"\thcg_parse(buffer, hcg_t, &idx);\n"); fprintf(XXops_fp[i],"\tencode(hcg_t, &hcg_k);\n"); fprintf(XXops_fp[i],"\t%s = hcg_k;\n", ta_curr->FieldName); } } /* 93su523 PGEN merge (END) */ else switch ( ta_curr->FieldType[0] ) { case 'i': fprintf(XXops_fp[i],"\thcg_parse(buffer,hcg_t,&idx);\n"); fprintf(XXops_fp[i],"\tset_%s(atoi(hcg_t));\n",ta_curr->FieldName); break; case 'f': fprintf(XXops_fp[i],"\thcg_parse(buffer,hcg_t,&idx);\n"); if ( ta_curr->FieldType[1] == '4' ) fprintf(XXops_fp[i],"\tset_%s((float) atof(hcg_t));\n", ta_curr->FieldName); else fprintf(XXops_fp[i],"\tset_%s(atof(hcg_t));\n", ta_curr->FieldName); break; case 'd': if (ta_curr->next_ptr != NULL) /* not first and not last field, so parse and mystrcpy */ { fprintf(XXops_fp[i],"\thcg_parse(buffer,hcg_t,&idx);\n"); fprintf(XXops_fp[i],"\tmystrcpy(%s,hcg_t,26,1);\n",ta_curr->FieldName); } else /* last field of table is a date, so dont parse so it can have spaces within */ fprintf(XXops_fp[i],"\tmystrcpy(%s,buffer+idx,26,1);\n",ta_curr->FieldName); break; default: if (ta_curr->FieldType[0] == 't') unpad = '1'; else unpad = '0'; if (ta_curr == tt_curr->ta_ptr) /* first field is pkey, and its already been parsed */ fprintf(XXops_fp[i],"\tmystrcpy(%s,hcg_t,%d,%c);\n",ta_curr->FieldName, atoi(&(ta_curr->FieldType[1])),unpad); else if (ta_curr->next_ptr != NULL) /* not first and not last field, so parse and mystrcpy */ { fprintf(XXops_fp[i],"\thcg_parse(buffer,hcg_t,&idx);\n"); fprintf(XXops_fp[i],"\tmystrcpy(%s,hcg_t,%d,%c);\n", ta_curr->FieldName, atoi(&(ta_curr->FieldType[1])),unpad); } else /* last field of table is a string, so dont parse so it can have spaces within */ fprintf(XXops_fp[i],"\tmystrcpy(%s,buffer+idx,%d,%c);\n",ta_curr->FieldName, atoi(&(ta_curr->FieldType[1])),unpad); } ta_curr = ta_curr->next_ptr; } fprintf(XXops_fp[i],"}\n\n"); tt_curr = tt_curr->next_ptr; } /* while tt */ } void gen_delete_row() /* generating function pr_del() */ { static char rcsid[] = "$Id: gen_pr_delete.c,v 1.5.4.1 1999/05/04 16:59:52 jkarner Exp $"; int foundnum, i, j ; char parent_pkey[NAMELENGTH]; tt_curr = tt; while (tt_curr != NULL) { j = encoding(tt_curr->TTabbr) ; fprintf(XXops_fp[j],"/******************************************************************************/\n"); fprintf(XXops_fp[j],"/* This routine will delete a single row from the database. The row is the */\n"); fprintf(XXops_fp[j],"/* one pointed to by the XXcurr variable. */\n"); fprintf(XXops_fp[j],"/******************************************************************************/\n"); fprintf(XXops_fp[j],"#ifdef USE_STL\n"); fprintf(XXops_fp[j],"list<%s*>::iterator %s::delete_row (list<%s*>::iterator rowIter)\n", tt_curr->TTabbr, tt_curr->TTabbr, tt_curr->TTabbr); fprintf(XXops_fp[j],"#else\n"); fprintf(XXops_fp[j],"void %s::delete_row ()\n",tt_curr->TTabbr); fprintf(XXops_fp[j],"#endif\n"); fprintf(XXops_fp[j],"{\n"); fprintf(XXops_fp[j]," static char rcsid[] = \"$Id\";\n"); fprintf(XXops_fp[j]," char temp_key[HCG_KEY_SIZE+1];\n"); fprintf(XXops_fp[j]," hcg_key %sid;\n\n",tt_curr->TTabbr); if (cli_log ==1) { fprintf(XXops_fp[j],"char log_text[BUFSIZE];\n\n"); fprintf(XXops_fp[j],"\tlogwait();\n\n"); } /* for each of the pc_table entries, generating a while loop linking all the rings accordingly */ tmp = pc_table; while (tmp != NULL ) { if (strncmp(tmp->firstid,tt_curr->TTabbr,hcg_abbr_size) != 0) { tmp = tmp->next_ptr; continue; } /* getting table type and abbreviates for parent and child */ strncpy_null(prnt_abbrev,tmp->firstid,hcg_abbr_size); strcpy(parent,tmp->firstid); strncpy_null(child_abbrev,tmp->secondid,hcg_abbr_size); strcpy(child,tmp->secondid); strcpy(parent_pkey,parent); foundnum = 0; i = 0 ; while ((!foundnum) && (i < strlen(parent))) if (isdigit(parent[i]) != 0) foundnum = 1; else i++; if (foundnum) parent_pkey[i] = '\0'; fprintf(XXops_fp[j],"\n\tunlink_child_"); if (tmp->Singleton) fprintf(XXops_fp[j],"1"); else { if ((!cli_nobp) && (tmp->HasBp)) fprintf(XXops_fp[j],"bp_m"); else fprintf(XXops_fp[j],"nobp_m"); } fprintf(XXops_fp[j],"(%s,%s,%s,%s);\n",child_abbrev,prnt_abbrev,parent,child); tmp = tmp->next_ptr; } /* for each of the cp_table entries, generating a while loop linking all the rings accordingly */ tmp = cp_table; while (tmp != NULL ) { if (strncmp(tmp->firstid,tt_curr->TTabbr,hcg_abbr_size) != 0) { tmp = tmp->next_ptr; continue; } /* getting table type and abbreviates for parent and child */ strncpy_null(child_abbrev,tmp->firstid,hcg_abbr_size); strcpy(child,tmp->firstid); strncpy_null(prnt_abbrev,tmp->secondid,hcg_abbr_size); strcpy(parent,tmp->secondid); strcpy(parent_pkey,parent); foundnum = 0; i = 0 ; while ((!foundnum) && (i < strlen(parent))) if (isdigit(parent[i]) != 0) foundnum = 1; else i++; if (foundnum) parent_pkey[i] = '\0'; fprintf(XXops_fp[j],"#ifdef USE_STL \n"); fprintf(XXops_fp[j],"\t%scurr = rowIter;\n",child_abbrev); fprintf(XXops_fp[j],"#endif\n"); fprintf(XXops_fp[j],"\tunlink_parent_"); if (tmp->Singleton) fprintf(XXops_fp[j],"1"); else { if ((!cli_nobp) && (tmp->HasBp)) fprintf(XXops_fp[j],"bp_m"); else fprintf(XXops_fp[j],"nobp_m"); } fprintf(XXops_fp[j],"(%s,%s,%s,%s);\n",child_abbrev,prnt_abbrev,parent,child); tmp = tmp->next_ptr; } fprintf(XXops_fp[j],"\t#ifdef DEBUG\n"); fprintf(XXops_fp[j],"#ifdef USE_STL\n"); fprintf(XXops_fp[j],"\t\t%sid = get_pkid();\n", tt_curr->TTabbr); fprintf(XXops_fp[j],"#else\n"); fprintf(XXops_fp[j],"\t\t%sid = RC::get_pkid();\n", tt_curr->TTabbr); fprintf(XXops_fp[j],"#endif\n"); fprintf(XXops_fp[j],"\t\tdecode(temp_key, &%sid);\n", tt_curr->TTabbr); fprintf(XXops_fp[j],"\t\tprintf(\"The primary key deleted is %%s\\n\",temp_key);\n"); fprintf(XXops_fp[j],"\t#endif\n"); fprintf(XXops_fp[j],"#ifdef USE_STL\n"); fprintf(XXops_fp[j],"\trowIter = %stab->removeRow(rowIter);\n", tt_curr->TTabbr); fprintf(XXops_fp[j],"\tdelete this;\n"); fprintf(XXops_fp[j],"#else\n"); fprintf(XXops_fp[j],"\tdel_row(%s);\n", tt_curr->TTabbr); fprintf(XXops_fp[j],"#endif\n"); if (cli_log==1) { fprintf(XXops_fp[j],"\n\t/* The following is to support logging */\n"); fprintf(XXops_fp[j],"#ifdef USE_STL\n"); fprintf(XXops_fp[j],"\t%sid = get_pkid();\n", tt_curr->TTabbr); fprintf(XXops_fp[j],"#else\n"); fprintf(XXops_fp[j],"\t%sid = RC::get_pkid();\n", tt_curr->TTabbr); fprintf(XXops_fp[j],"#endif\n"); fprintf(XXops_fp[j],"\tdecode(temp_key, &%sid);\n", tt_curr->TTabbr); fprintf(XXops_fp[j],"\tsprintf(log_text,\"DL %%s\\n\",temp_key);\n"); fprintf(XXops_fp[j],"\tlogstr(log_text);\n\n"); } fprintf(XXops_fp[j],"#ifdef USE_STL\n"); fprintf(XXops_fp[j],"return rowIter;\n"); fprintf(XXops_fp[j],"#endif\n"); fprintf(XXops_fp[j], "}\n\n"); tt_curr = tt_curr->next_ptr; } } void gen_dump_table ( ) { static char rcsid[] = "$Id: gen_pr_dump.c,v 1.3.4.1 1999/05/04 16:59:53 jkarner Exp $"; int i; tt_curr = tt; while ( tt_curr != NULL) { i = encoding(tt_curr->TTabbr) ; fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i],"/* This routine will write-out (dump) all rows that meet the specified */\n"); fprintf(XXops_fp[i],"/* view to the specified file_name. The tbl indicates which table's row */\n"); fprintf(XXops_fp[i],"/* will be dumped. The open_file flag of 1 indicates open a file for dumping */\n"); fprintf(XXops_fp[i],"/* a single row. Otherwise doesn't open file because pr_dump had opened a */\n"); fprintf(XXops_fp[i],"/* file. If the mode of the view is write, the caller is allowed to specify a */\n"); fprintf(XXops_fp[i],"/* new_version flag of 1, which will cause a version number update. Finally, */\n"); fprintf(XXops_fp[i],"/* the modestr parameter indicates if a new file should be generated ('w'), */\n"); fprintf(XXops_fp[i],"/* or append to an existing file ('a'). */\n"); fprintf(XXops_fp[i],"/******************************************************************************/\n"); fprintf(XXops_fp[i], "#ifdef USE_STL\n"); fprintf(XXops_fp[i], "void %stable::dump_table ( char *viewname, char *file_name, int new_version, char *modestr )\n",tt_curr->TTabbr ); fprintf(XXops_fp[i], "#else\n"); fprintf(XXops_fp[i], "void %s::dump_table ( char *viewname, char *file_name, int new_version, char *modestr )\n",tt_curr->TTabbr ); fprintf(XXops_fp[i], "#endif\n"); fprintf(XXops_fp[i], "{\n"); fprintf(XXops_fp[i],"\ttable_loop(viewname,%s)\n",tt_curr->TTabbr); fprintf(XXops_fp[i],"\t{\n"); fprintf(XXops_fp[i],"#ifndef USE_STL\n"); fprintf(XXops_fp[i], "\t\t%scurr->dump_row(viewname,file_name,new_version,modestr); \n", tt_curr->TTabbr); fprintf(XXops_fp[i],"#else\n"); fprintf(XXops_fp[i], "\t\t(*%scurr)->dump_row(viewname,file_name,new_version,modestr); \n", tt_curr->TTabbr); fprintf(XXops_fp[i],"#endif /* USE_STL */\n"); fprintf(XXops_fp[i], "\t}\n"); fprintf(XXops_fp[i], "}\n\n"); tt_curr = tt_curr->next_ptr; } } void gen_dump_row ( ) /* generating function pr_dump() */ { static char rcsid[] = "$Id: gen_pr_dump.c,v 1.3.4.1 1999/05/04 16:59:53 jkarner Exp $"; int line_len, i, j, max; char temp_string[ABBREV_NAME_LENGTH]; max=0; tt_curr = tt; while ( tt_curr != NULL) { ta_curr = tt_curr->ta_ptr; i=0; while ( ta_curr != NULL) { if (ta_curr->IsKey) i++; ta_curr = ta_curr->next_ptr; } if (i > max) max = i; tt_curr = tt_curr->next_ptr; } tt_curr = tt; while ( tt_curr != NULL) { j = encoding(tt_curr->TTabbr) ; fprintf(XXops_fp[j],"/******************************************************************************/\n"); fprintf(XXops_fp[j],"/* This routine will write-out (dump) a single row that meet the specified */\n"); fprintf(XXops_fp[j],"/* view to the specified file_name. The tbl indicates which table's row */\n"); fprintf(XXops_fp[j],"/* will be dumped. The open_file flag of 1 indicates open a file for dumping */\n"); fprintf(XXops_fp[j],"/* a single row. Otherwise doesn't open file because pr_dump had opened a */\n"); fprintf(XXops_fp[j],"/* file. If the mode of the view is write, the caller is allowed to specify a */\n"); fprintf(XXops_fp[j],"/* new_version flag of 1, which will cause a version number update. Finally, */\n"); fprintf(XXops_fp[j],"/* the modestr parameter indicates if a new file should be generated ('w'), */\n"); fprintf(XXops_fp[j],"/* or append to an existing file ('a'). */\n"); fprintf(XXops_fp[j],"/******************************************************************************/\n"); fprintf(XXops_fp[j],"void %s::dump_row (char *viewname, char *file_name, int new_version, char *modestr )\n",tt_curr->TTabbr); fprintf(XXops_fp[j],"{\n"); fprintf(XXops_fp[j],"char outkey[%d][HCG_KEY_SIZE+1];\n",max); fprintf(XXops_fp[j],"hcg_key %sid;\n",tt_curr->TTabbr); fprintf(XXops_fp[j],"\tif (open_file==1)\n"); fprintf(XXops_fp[j],"\t{\n"); fprintf(XXops_fp[j],"\t\tif ((hcg_dump_fp=fopen(file_name,modestr)) == NULL\ )\n"); fprintf(XXops_fp[j],"\t\t{\n"); fprintf(XXops_fp[j],"\t\t\tprintf(\"Error: dump_row() cannot open %%s using fi\ le mode %%s\\n\", file_name,modestr);\n"); fprintf(XXops_fp[j],"\t\t\texit(1);\n"); fprintf(XXops_fp[j],"\t\t}\n"); fprintf(XXops_fp[j],"\t}\n\n"); fprintf(XXops_fp[j],"#ifdef USE_STL\n"); fprintf(XXops_fp[j],"\t%sid = get_pkid();\n", tt_curr->TTabbr); fprintf(XXops_fp[j],"#else\n"); fprintf(XXops_fp[j],"\t%sid = RC::get_pkid();\n", tt_curr->TTabbr); fprintf(XXops_fp[j],"#endif\n"); ta_curr = tt_curr->ta_ptr; i=0; while ( ta_curr != NULL) { if (ta_curr->IsKey) { strncpy_null(temp_string,ta_curr->FieldName, hcg_abbr_size); fprintf(XXops_fp[j],"\thcg_update_version(&%s,%s_idx,new_version);\n", ta_curr->FieldName, temp_string); fprintf(XXops_fp[j],"\tdecode(outkey[%d], &%s);\n", i, ta_curr->FieldName); i++; } ta_curr = ta_curr->next_ptr; } fprintf(XXops_fp[j],"\tPrintCheck(fprintf(hcg_dump_fp, \""); ta_curr = tt_curr->ta_ptr; k = 1; while ( ta_curr != NULL) { switch ( ta_curr->FieldType[0] ) { case 'i': fprintf(XXops_fp[j]," %%%dd", MAXINTLENGTH); break; case 'f': fprintf(XXops_fp[j]," %%%d.%df", MAXFLOATLENGTH, FRACLENGTH); break; default: fprintf(XXops_fp[j]," %%-%ds", atoi(ta_curr->FieldType+1) ); /* 93su523 PGEN merge */ } ta_curr = ta_curr->next_ptr; k++; } fprintf(XXops_fp[j],"\\n\"\n\t\t\t\t\t"); ta_curr = tt_curr->ta_ptr; k = 1; line_len=5; i=0; while ( ta_curr != NULL) { if (ta_curr->IsKey) { fprintf(XXops_fp[j],", outkey[%d]", i); i++; } else fprintf(XXops_fp[j],", %s", ta_curr->FieldName ); /* include comma,space, and XXcurr-> */ line_len += (strlen(ta_curr->FieldName) + 8+hcg_abbr_size); ta_curr = ta_curr->next_ptr; k++; if ((ta_curr != NULL) && (line_len >= 128)) { line_len = 0; fprintf(XXops_fp[j],"\n\t\t\t\t\t"); } } fprintf(XXops_fp[j],"));\n"); fprintf(XXops_fp[j],"\tif (open_file==1)\n"); fprintf(XXops_fp[j],"\t\tfclose(hcg_dump_fp);\n"); fprintf(XXops_fp[j],"}\n\n"); tt_curr = tt_curr->next_ptr; } } /**************************************************************/ /* FUNCTION: gen_pr_add_log() */ /* This function is used to add the logging function to handle*/ /* pr_add. */ /* Created by: D.Nelson 96s532 GENLOG */ /**************************************************************/ void gen_add_row_log() { int i, j, k, line_len ; tt_curr = tt; while (tt_curr != NULL) { j = encoding(tt_curr->TTabbr) ; fprintf(XXops_fp[j],"\n/********************************************************************************/\n"); fprintf(XXops_fp[j],"/* This routine is used to log a call to pr_add to hcg_logfile */\n"); fprintf(XXops_fp[j],"/* The tbl indicates which table is having a row added. */\n"); fprintf(XXops_fp[j],"/* tbl_ptr points to the record to be added. */\n"); fprintf(XXops_fp[j],"/********************************************************************************/\n"); fprintf(XXops_fp[j],"void %s::add_row_log (char *viewname)\n",tt_curr->TTabbr); fprintf(XXops_fp[j],"{\n"); fprintf(XXops_fp[j],"char outkey[3][HCG_KEY_SIZE+1];\n"); fprintf(XXops_fp[j],"int idx;\n\n"); fprintf(XXops_fp[j],"hcg_key %sid;\n\n", tt_curr->TTabbr); fprintf(XXops_fp[j],"\t/* Return if logging not on */\n"); fprintf(XXops_fp[j],"\tif (hcg_log != 1)\n"); fprintf(XXops_fp[j],"\t\treturn;\n\n"); fprintf(XXops_fp[j],"\tfind_tbl_idx(\"%s\");\n",tt_curr->TTabbr); fprintf(XXops_fp[j],"\tidx=hcg_tbl_idx;\n\n"); fprintf(XXops_fp[j],"\t/* Write to hcg_logfile based on idx */\n\n"); fprintf(XXops_fp[j],"#ifdef USE_STL\n"); fprintf(XXops_fp[j],"\t%sid = get_pkid();\n",tt_curr->TTabbr); fprintf(XXops_fp[j],"#else\n"); fprintf(XXops_fp[j],"\t%sid = RC::get_pkid();\n",tt_curr->TTabbr); fprintf(XXops_fp[j],"#endif\n"); ta_curr = tt_curr->ta_ptr; i=0; while (ta_curr != NULL) { if (ta_curr->IsKey) { char temp_string[BUFSIZE]; strncpy_null(temp_string,ta_curr->FieldName, hcg_abbr_size); fprintf(XXops_fp[j],"\thcg_update_version(&%s,%s_idx,0);\n", ta_curr->FieldName,temp_string); fprintf(XXops_fp[j],"\tdecode(outkey[%d], &%s);\n", i, ta_curr->FieldName); i++; } ta_curr = ta_curr->next_ptr; } /* generate the PrintCheck statement */ fprintf(XXops_fp[j],"\tPrintCheck(fprintf(hcg_logfileptr, \""); ta_curr = tt_curr->ta_ptr; k = 1; while ( ta_curr != NULL) { switch (ta_curr->FieldType[0] ) { case 'i': fprintf(XXops_fp[j]," %%%dd", MAXINTLENGTH); break; case 'f': fprintf(XXops_fp[j]," %%%d.%df", MAXFLOATLENGTH, FRACLENGTH); break; default: fprintf(XXops_fp[j]," %%-%ds", atoi(ta_curr->FieldType+1) ); } ta_curr = ta_curr->next_ptr; k++; } fprintf(XXops_fp[j],"\\n\"\n\t\t\t"); ta_curr = tt_curr->ta_ptr; k = 1; line_len = 5; i = 0; while (ta_curr != NULL) { if (ta_curr->IsKey) { fprintf(XXops_fp[j],", outkey[%d]", i); i++; } else fprintf(XXops_fp[j],", %s", ta_curr->FieldName ); /* include comma, space, & XXcurr-> */ line_len += (strlen(ta_curr->FieldName) + 8 * hcg_abbr_size); ta_curr = ta_curr->next_ptr; k++; if ((ta_curr != NULL) && (line_len >= 128)) { line_len = 0; fprintf(XXops_fp[j],"\n\t\t\t\t"); } } fprintf(XXops_fp[j],"));\n"); fprintf(XXops_fp[j], "}\n"); tt_curr = tt_curr->next_ptr; } } void gen_log_do_add_row() { int i; char unpad ; tt_curr = tt; while ( tt_curr != NULL) { i = encoding(tt_curr->TTabbr) ; fprintf(XXops_fp[i],"\n/********************************************************************************/\n"); fprintf(XXops_fp[i],"/* This routine is used to to do the add given the viewname, the tablename */\n"); fprintf(XXops_fp[i],"/* and a string of the additional information */\n"); fprintf(XXops_fp[i],"/********************************************************************************/\n"); fprintf(XXops_fp[i], "void %s::log_do_add_row (char *view, char *theRest, int idx)\n", tt_curr->TTabbr); fprintf(XXops_fp[i], "{\n"); /* for each column, do appropriate field init */ ta_curr = tt_curr->ta_ptr; while ( ta_curr != NULL ) { if (ta_curr->IsKey) { if (ta_curr == tt_curr->ta_ptr) /* primary key - skip, since pr_add will determine this */ { } else { fprintf(XXops_fp[i], "\thcg_parse(theRest, hcg_t, &idx);\n"); fprintf(XXops_fp[i], "\tencode(hcg_t, &hcg_k);\n"); fprintf(XXops_fp[i], "\t%s = hcg_k;\n", ta_curr->FieldName); } } else /* field is not a key */ { switch ( ta_curr->FieldType[0] ) { case 'i': fprintf(XXops_fp[i], "\thcg_parse(theRest, hcg_t, &idx);\n"); fprintf(XXops_fp[i], "\t%s = (atoi(hcg_t));\n", ta_curr->FieldName); break; case 'f': fprintf(XXops_fp[i], "\thcg_parse(theRest, hcg_t, &idx);\n"); if ( ta_curr->FieldType[1] == '4') /* is this a float or double ? */ fprintf(XXops_fp[i], "\t%s = ((float) atof(hcg_t));\n", ta_curr->FieldName); else fprintf(XXops_fp[i], "\t%s = (atof(hcg_t));\n", ta_curr->FieldName); break; case 'd': if (ta_curr->next_ptr != NULL) /* not first and not last field, so parse and mystrcpy */ { fprintf(XXops_fp[i], "\thcg_parse(theRest, hcg_t, &idx);\n"); fprintf(XXops_fp[i], "\tmystrcpy(%s, hcg_t, 26, 1);\n", ta_curr->FieldName); } else /* last field of table is a date, so don't parse to let it have spaces within */ fprintf(XXops_fp[i], "\tmystrcpy(%s, theRest+idx, 26, 1);\n", ta_curr->FieldName); break; /* the tactic of assuming that an unassigned type is a string is adapted from gen_pr_log. Note that the switch statement here must be revised whenever new data types are added */ default: if (ta_curr->FieldType[0] == 't') unpad = '1'; else unpad = '0'; if (ta_curr == tt_curr->ta_ptr) /* first field is pkey - skip it */ { } else if (ta_curr->next_ptr != NULL) { fprintf(XXops_fp[i], "\thcg_parse(theRest, hcg_t, &idx);\n"); fprintf(XXops_fp[i], "\tmystrcpy(%s, hcg_t, %d, %c);\n", ta_curr->FieldName, atoi(&(ta_curr->FieldType[1])), unpad); } else /* last field of table is a string - don't parse, so it can have spaces */ { fprintf(XXops_fp[i], "\tmystrcpy(%s, theRest+idx, %d, %c);\n", ta_curr->FieldName, atoi(&(ta_curr->FieldType[1])), unpad); } } /* switch */ } ta_curr = ta_curr->next_ptr; } fprintf(XXops_fp[i], "\tadd_row(view);\n"); fprintf(XXops_fp[i], "}\n"); tt_curr = tt_curr->next_ptr; } } void gen_log_do_set_int_row() { int i, elseflag; tt_curr = tt; while ( tt_curr != NULL) { i = encoding(tt_curr->TTabbr); fprintf(XXops_fp[i],"\n/********************************************************************************/\n"); fprintf(XXops_fp[i],"/* This routine is used to set the value of an int field. */\n"); fprintf(XXops_fp[i],"/********************************************************************************/\n"); fprintf(XXops_fp[i], "void %s::log_do_set_int_row (const char fieldname[NAMELENGTH+1], const int newval)\n", tt_curr->TTabbr); fprintf(XXops_fp[i], "{\n"); ta_curr = tt_curr->ta_ptr; elseflag = 0; while (ta_curr != NULL) { if (*ta_curr->FieldType=='i') { if (elseflag) fprintf(XXops_fp[i], " else\n"); else elseflag = 1; fprintf(XXops_fp[i], " if(strcmp(fieldname,\"%s\")==0)\n",ta_curr->FieldName); fprintf(XXops_fp[i], " %s = newval;\n",ta_curr->FieldName); } ta_curr = ta_curr->next_ptr; } fprintf(XXops_fp[i], "}\n"); tt_curr = tt_curr->next_ptr; } } void gen_log_do_set_flt_row() { int i, elseflag; tt_curr = tt; while ( tt_curr != NULL ) { i = encoding(tt_curr->TTabbr); fprintf(XXops_fp[i],"\n/********************************************************************************/\n"); fprintf(XXops_fp[i],"/* This routine is used to set the value of an float field. */\n"); fprintf(XXops_fp[i],"/********************************************************************************/\n"); fprintf(XXops_fp[i], "void %s::log_do_set_flt_row (const char fieldname[NAMELENGTH+1], const int newval)\n", tt_curr->TTabbr); fprintf(XXops_fp[i], "{\n"); ta_curr = tt_curr->ta_ptr; elseflag = 0; while (ta_curr != NULL) { if (*ta_curr->FieldType=='f') { if (elseflag) fprintf(XXops_fp[i], " else\n"); else elseflag = 1; fprintf(XXops_fp[i], " if (strcmp(fieldname,\"%s\")==0)\n",ta_curr->FieldName); fprintf(XXops_fp[i], " %s = newval;\n",ta_curr->FieldName); } ta_curr = ta_curr->next_ptr; } fprintf(XXops_fp[i], "}\n"); tt_curr = tt_curr->next_ptr; } } void gen_log_do_set_key_row() { int i, elseflag; tt_curr = tt; while ( tt_curr != NULL ) { i = encoding(tt_curr->TTabbr); fprintf(XXops_fp[i],"\n/********************************************************************************/\n"); fprintf(XXops_fp[i],"/* This routine is used to set the value of an key field. */\n"); fprintf(XXops_fp[i],"/********************************************************************************/\n"); fprintf(XXops_fp[i], "void %s::log_do_set_key_row (const char fieldname[NAMELENGTH+1], hcg_key new_key)\n", tt_curr->TTabbr); fprintf(XXops_fp[i], "{\n"); ta_curr = tt_curr->ta_ptr; elseflag = 1; if (ta_curr != NULL) { fprintf(XXops_fp[i], " if (strcmp(fieldname,\"%s\")==0)\n",ta_curr->FieldName); fprintf(XXops_fp[i], "#ifdef USE_STL\n"); fprintf(XXops_fp[i], " set_pkid (new_key);\n"); fprintf(XXops_fp[i], "#else\n"); fprintf(XXops_fp[i], " RC::set_pkid (new_key);\n"); fprintf(XXops_fp[i], "#endif\n"); ta_curr = ta_curr->next_ptr; } while (ta_curr != NULL) { if (ta_curr->IsKey==1) { if (elseflag) fprintf(XXops_fp[i], " else\n"); else elseflag = 1; fprintf(XXops_fp[i], " if (strcmp(fieldname,\"%s\")==0)\n",ta_curr->FieldName); fprintf(XXops_fp[i], " %s = new_key;\n",ta_curr->FieldName); } ta_curr = ta_curr->next_ptr; } fprintf(XXops_fp[i], "}\n"); tt_curr = tt_curr->next_ptr; } } void gen_log_do_set_str_row() { int i, elseflag; tt_curr = tt; while ( tt_curr != NULL ) { i = encoding(tt_curr->TTabbr); fprintf(XXops_fp[i],"\n/********************************************************************************/\n"); fprintf(XXops_fp[i],"/* This routine is used to set the value of an string field. */\n"); fprintf(XXops_fp[i],"/********************************************************************************/\n"); fprintf(XXops_fp[i], "void %s::log_do_set_str_row (const char fieldname[NAMELENGTH+1], const char newval[BUFSIZE+1])\n", tt_curr->TTabbr); fprintf(XXops_fp[i], "{\n"); ta_curr = tt_curr->ta_ptr; elseflag = 0; while (ta_curr != NULL) { if (*ta_curr->FieldType=='c' && ta_curr->IsKey==0) { if (elseflag) fprintf(XXops_fp[i], " else\n"); else elseflag = 1; fprintf(XXops_fp[i], " if (strcmp(fieldname,\"%s\")==0)\n",ta_curr->FieldName); fprintf(XXops_fp[i], " strcpy(%s,newval);\n",ta_curr->FieldName); } ta_curr = ta_curr->next_ptr; } fprintf(XXops_fp[i], "}\n"); tt_curr = tt_curr->next_ptr; } } void gen_row_constructor() { int i; struct rr_type *tmp_ptr; /* to hold the current position */ char temp_string[ABBREV_NAME_LENGTH]; tt_curr = tt; while ( tt_curr != NULL ) { i = encoding(tt_curr->TTabbr); fprintf(XXops_fp[i],"#ifdef USE_STL\n"); fprintf(XXops_fp[i],"\n/********************************************************************************/\n"); fprintf(XXops_fp[i],"/* Default constructor for %s. */\n", tt_curr->TTabbr); fprintf(XXops_fp[i],"/********************************************************************************/\n"); fprintf(XXops_fp[i],"%s::%s ()\n",tt_curr->TTabbr, tt_curr->TTabbr); fprintf(XXops_fp[i],"{\n"); fprintf(XXops_fp[i]," set_pkid(0); /* initialize */\n"); ta_curr = tt_curr->ta_ptr->next_ptr; while (ta_curr != NULL) { if(ta_curr->IsKey) fprintf(XXops_fp[i], " set_%s(0);\n", ta_curr->FieldName); else switch(ta_curr->FieldType[0]) { case 'i' : /* int */ fprintf(XXops_fp[i]," set_%s(0);\n",ta_curr->FieldName); break; case 'f' : /* float */ fprintf(XXops_fp[i]," set_%s(0.0);\n",ta_curr->FieldName); break; case 'c' : /* char */ case 't' : /* text */ fprintf(XXops_fp[i]," set_%s(\"\\0\");\n",ta_curr->FieldName); break; case 'd' : /* date char */ fprintf(XXops_fp[i]," set_%s(\"\\0\");\n",ta_curr->FieldName); break; } /* switch */ ta_curr = ta_curr->next_ptr; } /* end while ta_curr */ tmp_ptr = cp_table; while(tmp_ptr) /* not end of list */ { if (strncmp(tt_curr->ta_ptr->FieldName,tmp_ptr->firstid,strlen(tt_curr->ta_ptr->FieldName)) == 0) { strncpy_null(temp_string, tmp_ptr->secondid, hcg_abbr_size); fprintf(XXops_fp[i]," setParent_%s(NULL);\n",tmp_ptr->secondid); } tmp_ptr = tmp_ptr->next_ptr; } fprintf(XXops_fp[i],"}\n"); fprintf(XXops_fp[i],"#endif\n"); tt_curr = tt_curr->next_ptr; } } void gen_row_destructor() { int i; tt_curr = tt; while ( tt_curr != NULL ) { i = encoding(tt_curr->TTabbr); fprintf(XXops_fp[i],"#ifdef USE_STL\n"); fprintf(XXops_fp[i],"\n/********************************************************************************/\n"); fprintf(XXops_fp[i]," /* Destructor for %s. */\n", tt_curr->TTabbr); fprintf(XXops_fp[i],"/********************************************************************************/\n"); fprintf(XXops_fp[i],"%s::~%s ()\n", tt_curr->TTabbr, tt_curr->TTabbr); fprintf(XXops_fp[i],"{\n"); fprintf(XXops_fp[i],"/* Empty */\n"); fprintf(XXops_fp[i],"}\n"); fprintf(XXops_fp[i],"#endif\n"); tt_curr = tt_curr->next_ptr; } } void gen_row_children_methods() { struct rr_type *tmp_ptr; /* to hold the current position */ char temp_string[ABBREV_NAME_LENGTH]; tt_curr = tt; while (tt_curr != NULL) { j = encoding(tt_curr->TTabbr) ; tmp_ptr = pc_table; while(tmp_ptr) /* not end of list */ { if (strncmp(tt_curr->ta_ptr->FieldName,tmp_ptr->firstid, strlen(tt_curr->ta_ptr->FieldName)) == 0) { strncpy_null(temp_string, tmp_ptr->secondid, hcg_abbr_size); fprintf(XXops_fp[j],"#ifdef USE_STL\n"); fprintf(XXops_fp[j],"void %s::insertChild_%s(%s *childRow)\n",tt_curr->TTabbr, tmp_ptr->secondid,temp_string); fprintf(XXops_fp[j],"{\n"); fprintf(XXops_fp[j]," %s_children.push_back(childRow);\n",tmp_ptr->secondid); fprintf(XXops_fp[j],"}\n\n"); fprintf(XXops_fp[j],"void %s::removeChild_%s(list<%s*>::iterator rowIter)\n", tt_curr->TTabbr,tmp_ptr->secondid, temp_string); fprintf(XXops_fp[j],"{\n"); fprintf(XXops_fp[j]," %s_children.remove((*rowIter));\n",tmp_ptr->secondid); fprintf(XXops_fp[j],"}\n\n"); fprintf(XXops_fp[j],"list<%s*>::iterator %s::getFirstChild_%s()\n", temp_string, tt_curr->TTabbr,tmp_ptr->secondid); fprintf(XXops_fp[j],"{\n"); fprintf(XXops_fp[j]," return %s_children.begin();\n",tmp_ptr->secondid); fprintf(XXops_fp[j],"}\n\n"); fprintf(XXops_fp[j],"list<%s*>::iterator %s::getLastChild_%s()\n", temp_string, tt_curr->TTabbr, tmp_ptr->secondid); fprintf(XXops_fp[j],"{\n"); fprintf(XXops_fp[j]," list<%s*>::iterator iter;\n\n",temp_string); fprintf(XXops_fp[j]," iter = %s_children.end();\n",tmp_ptr->secondid); fprintf(XXops_fp[j]," if (!%s_children.empty())\n",tmp_ptr->secondid); fprintf(XXops_fp[j]," iter--;\n"); fprintf(XXops_fp[j]," return iter;\n"); fprintf(XXops_fp[j],"}\n\n"); fprintf(XXops_fp[j],"list<%s*>::iterator %s::%s_Terminator()\n", temp_string, tt_curr->TTabbr, tmp_ptr->secondid); fprintf(XXops_fp[j],"{\n"); fprintf(XXops_fp[j]," return %s_children.end();\n",tmp_ptr->secondid); fprintf(XXops_fp[j],"}\n"); fprintf(XXops_fp[j],"#endif /* USE_STL */\n"); } tmp_ptr = tmp_ptr->next_ptr; } tt_curr = tt_curr->next_ptr; } /* end while tt_cur */ } void gen_row_parent_methods() { struct rr_type *tmp_ptr; /* to hold the current position */ char temp_string[ABBREV_NAME_LENGTH]; tt_curr = tt; while (tt_curr != NULL) { j = encoding(tt_curr->TTabbr) ; tmp_ptr = cp_table; while(tmp_ptr) /* not end of list */ { if (strncmp(tt_curr->ta_ptr->FieldName,tmp_ptr->firstid, strlen(tt_curr->ta_ptr->FieldName)) == 0) { strncpy_null(temp_string, tmp_ptr->secondid, hcg_abbr_size); fprintf(XXops_fp[j],"#ifdef USE_STL\n"); fprintf(XXops_fp[j],"void %s::setParent_%s(%s *currentRow)\n", tt_curr->TTabbr,tmp_ptr->secondid, temp_string); fprintf(XXops_fp[j],"{\n"); fprintf(XXops_fp[j]," %s_pp = currentRow;\n",tmp_ptr->secondid); fprintf(XXops_fp[j],"}\n\n"); fprintf(XXops_fp[j],"%s *%s::getParent_%s()\n",temp_string,tt_curr->TTabbr, tmp_ptr->secondid); fprintf(XXops_fp[j],"{\n"); fprintf(XXops_fp[j]," return %s_pp;\n",tmp_ptr->secondid); fprintf(XXops_fp[j],"}\n"); fprintf(XXops_fp[j],"#endif /* USE_STL */\n\n"); } tmp_ptr = tmp_ptr->next_ptr; } tt_curr = tt_curr->next_ptr; } }