/* * Copyright (c) 1995 Gunther Schadow. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "t2c.h" #include #include void output_interface(const char *owner, char *name, const char* type, const struct decl_rec *decl) { resetnames(); char filename[strlen(name) + sizeof(".h") + 1]; strcpy(filename, classname(name)); strcat(filename, ".h"); fstream out(filename, ios::out); out << "/*" << endl << " * This file was generated by t2c. Copyright (c) 1995 Gunther Schadow." << endl << " *" << endl << " * " << owner << "." << name << " (" << type << ")" << endl << " */" << endl << endl << "#ifndef " << macroname(name) << "_H_" << endl << "#define " << macroname(name) << "_H_" << endl << endl << "#include " << endl << "#include " << endl << "#include " << endl << endl << "class " << classname(name) << " : public Table" << endl << "{" << endl << " public:" << endl; const struct decl_rec *p; /* * sizes */ for(p = decl; p != NULL; p = p->next) if(p->size) out << " const size_t S_" << p->name << " = " << p->size << ";" << endl; out << endl; /* * set_...() methods */ for(p = decl; p != NULL; p = p->next) { out << " void set_" << p->name << "(" << p->type->c_type; if(p->size) if(strcmp(p->type->c_type, "char") == 0) { out << " *" << "x);" << endl; } else { cerr << "sorry, not implemented: arrays of non-chars" << endl; exit(1); } else out << " x);" << endl; } out << endl; /* * get_...() methods */ for(p = decl; p != NULL; p = p->next) { out << " " << p->type->c_type << ' '; if(p->size) out << '*'; out << "get_" << p->name << "();" << endl; } out << endl; /* * unset_...() methods */ out << " void unset(); // unset everything" << endl; for(p = decl; p != NULL; p = p->next) { out << " void unset_" << p->name << "();" << endl; } out << endl; /* * ..._is_null() methods */ for(p = decl; p != NULL; p = p->next) { out << " bool " << p->name << "_is_null();" << endl; } out << endl << " " << classname(name) << "();" << endl << " void insert();" << endl << " result retrieve(const char *clause = \"\");" << endl << " result next();" << endl << " void update();" << endl << " void update(const char *clause);" << endl << " void remove();" << endl << " static void remove(const char *clause);" << endl << " static void create();" << endl << " static void drop(TabType t = table);" << endl << " static const char *owner(const char *);" << endl << " static const char *owner();" << endl << endl << " private:" << endl; /* * values */ for(p = decl; p != NULL; p = p->next) { out << " " << p->type->c_type << " V_" << p->name; if(p->size) out << "[S_" << p->name << " + 1]"; out << ";" << endl; } out << endl; /* indicators */ for(p = decl; p != NULL; p = p->next) out << " short I_" << p->name << ";" << endl; out << endl << " static const char select_cmd[];" << endl << " static const char insert_cmd[];" << endl << " static const char update_cmd[];" << endl << " static const char create_cmd[];" << endl << " static const char *the_owner;" << endl << " static TabType the_type;" << endl << "};" << endl << endl << "#ifndef OUTLINE" << endl << "# include \"" << classname(name) << ".icc\"" << endl << "#endif" << endl << endl << "#endif /* ! " << macroname(name) << "_H_ */" << endl; }