initstatic.cpp

Go to the documentation of this file.
00001 
00002 #include "clssdf.h"
00003 
00004 namespace class_def {
00005 
00006   void class_definition::print_init_static_attributes( std::ostream& os ) const {
00007     std::vector<attribute*>::const_iterator ppa;
00008 
00009     os << "EXEC SQL BEGIN DECLARE SECTION;" << std::endl;
00010 
00011     for (ppa  = _all_row_attributes.begin();
00012          ppa != _all_row_attributes.end();
00013          ppa++) 
00014       {
00015         if ((*ppa)->get_type()!="std::string") {
00016           os << "static " << (*ppa)->get_type() << " " << (*ppa)->get_Name() << ";" << std::endl;
00017         } else {
00018           os << "static char " << (*ppa)->get_Name() << "[" << (*ppa)->get_max_length() << "];" << std::endl;
00019           if ((*ppa)->get_max_length()<=0) {
00020             std::cerr << "max_length < 0 for attribute " << (*ppa)->get_Name().c_str() << std::endl;
00021             error();
00022           }
00023         }
00024       }
00025     os << "static long Num;" << std::endl;
00026     os << "EXEC SQL END DECLARE SECTION;" << std::endl << std::endl;
00027 
00028     os << "int " << _name <<"::_erno = 0;" << std::endl;
00029     os << "const char *" << _name << "::_error_msg = \"\";" << std::endl << std::endl;
00030 
00031     os << "void " << _name << "::init_static_attributes() const {" << std::endl;
00032     for (ppa  = _all_row_attributes.begin();
00033          ppa != _all_row_attributes.end();
00034          ppa++)
00035       {
00036         if ((*ppa)->get_type()!="std::string") {
00037           os << "  " << (*ppa)->get_Name() << " = " << 
00038             (*ppa)->storage_format_of_name() << ";" << std::endl;
00039         } else {
00040           os << "  " << "mystring::string_2_string_desc( " <<
00041             (*ppa)->storage_format_of_name() << ", " << (*ppa)->get_Name() << ", " <<
00042             "sizeof(" << (*ppa)->get_Name() << "));" << std::endl;
00043         }
00044       }
00045     os << "}" << std::endl << std::endl;
00046   }
00047 
00048 }      

Generated on Tue Jul 14 12:22:31 2009 for cstpp by  doxygen 1.5.1