#include <class_definition.h>
Collaboration diagram for class_def::class_definition:

Definition at line 10 of file class_definition.h.
Public Member Functions | |
| const char * | get_class_name () const |
| void | set_null () |
| void | init_calc_derived_attributes () |
| void | init (const std::string &Name, int Inheritance, const std::vector< std::string > &Class_qualifiers, const std::vector< std::string > &Parents, const std::vector< class_def::key_attribute > &Key_attributes, const std::vector< class_def::functional_attribute > &Functional_attributes, const std::vector< class_def::derived_attribute > &Derived_attributes, const std::vector< std::string > &other_lines_at_begining, const std::vector< class_def::enum_constant > &Enum_constants, const std::vector< class_def::static_constant > &Static_constants, const std::vector< std::string > &other_lines_at_end, bool Protected_constructor, bool Singleton) |
| class_definition () | |
| void | print (std::ostream &s) const |
| void | print_header_output (std::ostream &s) const |
| void | print_simple_output (std::ostream &s) const |
| void | print_init_static_attributes (std::ostream &s) const |
| void | print_exists (std::ostream &s) const |
| void | print_singleton_select (std::ostream &s) const |
| void | print_insert (std::ostream &s) const |
| This function prints the function insert, for inserting into a PostgreSQL database. | |
| void | print_update (std::ostream &s) const |
| void | print_mysql_exists (std::ostream &os) const |
| void | print_mysql_delete (std::ostream &os) const |
| void | print_mysql_insert (std::ostream &os) const |
| void | print_mysql_update (std::ostream &os) const |
| void | print_mysql_singleton_select (std::ostream &os) const |
| void | print_mysql_insert_or_update (std::ostream &os) const |
| void | print_tag (std::ostream &os, const std::string &tag, const std::string &nmspc, const std::string &consttag) const |
| void | print_read_binary (std::ostream &s) const |
| void | print_write_binary (std::ostream &s) const |
| void | print_send_binary (std::ostream &s) const |
| void | print_recv_binary (std::ostream &s) const |
| void | print_map_by_offset (std::ostream &s) const |
| void | Read (std::istream &s) |
| void | print_mysql_create_table (std::ostream &os) const |
| This function prints the mysql create table syntax for creating a table. | |
Static Public Member Functions | |
| static const char * | _class_name () |
| static int | is_white (char c) |
| static void | get_arg_vect (std::istream &, std::vector< std::string > &, std::vector< std::string > &) |
| static void | set_output_format (const char *fmt) |
| static void | set_lower_case_mysql_names (bool newval) |
| static void | set_error_function (int i) |
| static void | set_domain_error (int i) |
| static void | set_back_white (int i) |
| static int | stricmp (const char *lhs, const char *rhs) |
| static bool | is_string (const char *str) |
| static bool | is_int (const char *str) |
| static bool | is_double (const char *str) |
| static string | eat_white (const std::string &str, const std::string &seps) |
| static string | eat_back_white (const std::string &str, const std::string &seps) |
Public Attributes | |
| std::string | _name |
| int | _inheritance |
| std::vector< std::string > | _class_qualifiers |
| std::vector< std::string > | _parents |
| std::vector< class_def::key_attribute > | _key_attributes |
| std::vector< class_def::functional_attribute > | _functional_attributes |
| std::vector< class_def::derived_attribute > | _derived_attributes |
| std::vector< std::string > | _other_lines_at_begining |
| std::vector< class_def::enum_constant > | _enum_constants |
| std::vector< class_def::static_constant > | _static_constants |
| std::vector< std::string > | _other_lines_at_end |
| bool | _protected_constructor |
| bool | _singleton |
| std::vector< class_def::attribute * > | _defined_attributes |
| std::vector< class_def::attribute * > | _row_attributes |
| this is the set of functional attributes and derived attributes | |
| std::vector< class_def::attribute * > | _non_key_attributes |
| this appears to be a design mistake, it is the same as row attributes | |
| std::vector< class_def::attribute * > | _all_key_attributes |
| std::vector< class_def::attribute * > | _all_functional_attributes |
| std::vector< class_def::attribute * > | _all_derived_attributes |
| std::vector< class_def::attribute * > | _all_defined_attributes |
| std::vector< class_def::attribute * > | _all_row_attributes |
| std::vector< class_def::attribute * > | _all_non_key_attributes |
Static Public Attributes | |
| static std::vector< class_def::class_definition * > | _univ |
| static std::string | _input_line |
| static std::vector< std::string > | _arg_vect |
| static std::vector< std::string > | _com_vect |
| static int | _erno |
| static const char * | _error_msg |
| static const char * | int_alias [] |
| static const char * | double_alias [] |
Protected Member Functions | |
| void | print_throw_message (const std::string &funcname, int numspace, std::ostream &os) const |
Static Protected Member Functions | |
| static void | read_num_param (std::istream &from, const char *param_name, int ¶m) |
| static string | mysql_case_adjusted_name (const string &rhs) |
Static Protected Attributes | |
| static std::string | _output_format |
| static bool | _lower_case_mysql_names |
| static int | _error_function |
| static int | _domain_error |
| static int | _back_white |
Friends | |
| class | attribute |
| class | derived_attribute |
| std::istream & | operator>> (std::istream &s, class_definition &atr) |
| std::ostream & | operator<< (std::ostream &s, const class_definition &atr) |
| void class_def::class_definition::print_insert | ( | std::ostream & | s | ) | const |
This function prints the function insert, for inserting into a PostgreSQL database.
It loops through all of the defined attributes, ie. the key and functional attributes, for all of the parents and the current class, and inserts them into PostgreSQL database.
Definition at line 6 of file insert.cpp.
References _all_defined_attributes, and _name.
Referenced by print().
00006 { 00007 std::vector<attribute*>::const_iterator ppa; 00008 00009 os << "int " << _name << "::insert() const {" << std::endl << std::endl; 00010 00011 os << " init_static_attributes();" << std::endl << std::endl; 00012 00013 os << " EXEC SQL INSERT INTO " << _name << "(" << std::endl; 00014 for (ppa=_all_defined_attributes.begin();;) { 00015 os << " " << (*ppa)->get_name(); 00016 ppa++; 00017 if (ppa==_all_defined_attributes.end()) { 00018 os << ")" << std::endl; 00019 break; 00020 } else { 00021 os << "," << std::endl; 00022 } 00023 } 00024 os << " VALUES(" << std::endl; 00025 for (ppa=_all_defined_attributes.begin();;) { 00026 os << " :" << (*ppa)->get_Name(); 00027 ppa++; 00028 if (ppa==_all_defined_attributes.end()) { 00029 os << ");" << std::endl << std::endl; 00030 break; 00031 } else { 00032 os << "," << std::endl; 00033 } 00034 } 00035 00036 os << " _sql_err();" << std::endl << std::endl; 00037 00038 os << " return 1;" << std::endl; 00039 os << "}" << std::endl << std::endl; 00040 }
| void class_def::class_definition::print_mysql_create_table | ( | std::ostream & | os | ) | const |
This function prints the mysql create table syntax for creating a table.
It loops through all of the key attributes, and makes them key attributes in the sql table. Similarly it loops through the functional attributes. The derived attributes are skipped.
Definition at line 1307 of file class_definition.cpp.
References _all_defined_attributes, _all_functional_attributes, _all_key_attributes, _name, is_double(), is_int(), and is_string().
Referenced by print().
01307 { 01308 os << "DROP TABLE IF EXISTS `" << _name << "`;" << endl; 01309 os << endl; 01310 os << "create table " << _name << " (" << endl; 01311 01312 std::vector<attribute*>::const_iterator pap = _all_defined_attributes.begin(); 01313 int width = 0; 01314 01315 for (;pap != _all_defined_attributes.end(); ++pap) { 01316 if ((*pap)->get_name().size() > width) { 01317 width = (*pap)->get_name().size(); 01318 } 01319 } 01320 width += 3; 01321 01322 bool first_row = true; 01323 01324 std::vector<attribute*>::const_iterator pa = _all_key_attributes.begin(); 01325 01326 for (; pa != _all_key_attributes.end(); ++pa) { 01327 if (first_row) { 01328 first_row = false; 01329 } else { 01330 os << "," << endl; 01331 } 01332 01333 os << " " << setiosflags(ios::left) << setw(width) << (*pa)->get_name() << " "; 01334 01335 if (is_int( (*pa)->get_type().c_str())) { 01336 os << "integer NOT NULL"; 01337 } 01338 01339 if (is_double( (*pa)->get_type().c_str())) { 01340 os << "real NOT NULL"; 01341 } 01342 01343 if (is_string( (*pa)->get_type().c_str())) { 01344 os << "varchar(255) NOT NULL"; 01345 } 01346 } 01347 01348 if (!_all_functional_attributes.empty()) { 01349 01350 pa = _all_functional_attributes.begin(); 01351 for (; pa != _all_functional_attributes.end(); ++pa) { 01352 01353 if (first_row) { 01354 first_row = false; 01355 } else { 01356 os << "," << endl; 01357 } 01358 01359 if (!_all_key_attributes.empty() && pa == _all_functional_attributes.begin()) { 01360 os << endl; 01361 } 01362 01363 os << " " << setiosflags(ios::left) << setw(width) << (*pa)->get_name() << " "; 01364 01365 if (is_int( (*pa)->get_type().c_str())) { 01366 os << "integer default " << (*pa)->get_null_value(); 01367 } 01368 01369 if (is_double( (*pa)->get_type().c_str())) { 01370 os << "real default " << (*pa)->get_null_value(); 01371 } 01372 01373 if (is_string( (*pa)->get_type().c_str())) { 01374 os << "varchar(255) default " << (*pa)->get_null_value() << ""; 01375 } 01376 } 01377 } 01378 01379 if (!_all_key_attributes.empty()) { 01380 os << "," << endl << endl; 01381 01382 os << " primary key( "; 01383 01384 pa = _all_key_attributes.begin(); 01385 01386 for (; pa != _all_key_attributes.end();) { 01387 os << (*pa)->get_name(); 01388 ++pa; 01389 if (pa == _all_key_attributes.end()) break; 01390 os << ", "; 01391 } 01392 os << ")" << endl; 01393 } 01394 os << ") Engine=MyISAM;" << endl << endl; 01395 }
Here is the call graph for this function:

1.5.1