compiler/cpp/src/generate/t_html_generator.cc
/**
 * Prepares for file generation by opening up the necessary file output
 * stream.
 */
Prepares for file generation by opening up the necessary file output
stream.
Prepares for file generation by opening up the necessary file output stream .
void t_html_generator::generate_program() {
  MKDIR(get_out_dir().c_str());
  string fname = get_out_dir() + program_->get_name() + ".html";
  f_out_.open(fname.c_str());
  f_out_ << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"" << endl;
  f_out_ << "    \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">" << endl;
  f_out_ << "<html xmlns=\"http://www.w3.org/1999/xhtml\">" << endl;
  f_out_ << "<head>" << endl;
  f_out_ << "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />" << endl;
  f_out_ << "<link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\"/>" << endl;
  f_out_ << "<title>Thrift module: " << program_->get_name()
   << "</title></head><body>" << endl
   << "<div class=\"container-fluid\">" << endl
   << "<h1>Thrift module: "
   << program_->get_name() << "</h1>" << endl;
  print_doc(program_);
  generate_program_toc();
  if (!program_->get_consts().empty()) {
    f_out_ << "<hr/><h2 id=\"Constants\">Constants</h2>" << endl;
    vector<t_const*> consts = program_->get_consts();
    f_out_ << "<table class=\"table-bordered table-striped table-condensed\">";
    f_out_ << "<thead><th>Constant</th><th>Type</th><th>Value</th></thead>" << endl;
    generate_consts(consts);
    f_out_ << "</table>";
  }
  if (!program_->get_enums().empty()) {
    f_out_ << "<hr/><h2 id=\"Enumerations\">Enumerations</h2>" << endl;
    vector<t_enum*> enums = program_->get_enums();
    vector<t_enum*>::iterator en_iter;
    for (en_iter = enums.begin(); en_iter != enums.end(); ++en_iter) {
      generate_enum(*en_iter);
    }
  }
  if (!program_->get_typedefs().empty()) {
    f_out_ << "<hr/><h2 id=\"Typedefs\">Type declarations</h2>" << endl;
    vector<t_typedef*> typedefs = program_->get_typedefs();
    vector<t_typedef*>::iterator td_iter;
    for (td_iter = typedefs.begin(); td_iter != typedefs.end(); ++td_iter) {
      generate_typedef(*td_iter);
    }
  }
  if (!program_->get_objects().empty()) {
    f_out_ << "<hr/><h2 id=\"Structs\">Data structures</h2>" << endl;
    vector<t_struct*> objects = program_->get_objects();
    vector<t_struct*>::iterator o_iter;
    for (o_iter = objects.begin(); o_iter != objects.end(); ++o_iter) {
      if ((*o_iter)->is_xception()) {
        generate_xception(*o_iter);
      } else {
        generate_struct(*o_iter);
      }
    }
  }
  if (!program_->get_services().empty()) {
    f_out_ << "<hr/><h2 id=\"Services\">Services</h2>" << endl;
    vector<t_service*> services = program_->get_services();
    vector<t_service*>::iterator sv_iter;
    for (sv_iter = services.begin(); sv_iter != services.end(); ++sv_iter) {
      service_name_ = get_service_name(*sv_iter);
      generate_service(*sv_iter);
    }
  }
  f_out_ << "</div></body></html>" << endl;
  f_out_.close();
  generate_index();
  generate_css();
}
void t_html_generator :: generate_program ( ) { MKDIR ( get_out_dir ( ) . c_str ( ) ) ; string fname = get_out_dir ( ) + program_ -> get_name ( ) + " " ; f_out_ . open ( fname . c_str ( ) ) ; f_out_ << " \" \" " << endl ; f_out_ << " \" \" " << endl ; f_out_ << " \" \" " << endl ; f_out_ << " " << endl ; f_out_ << " \" \" \" \" " << endl ; f_out_ << " \" \" \" \" \" \" " << endl ; f_out_ << " " << program_ -> get_name ( ) << " " << endl << " \" \" " << endl << " " << program_ -> get_name ( ) << " " << endl ; print_doc ( program_ ) ; generate_program_toc ( ) ; if ( ! program_ -> get_consts ( ) . empty ( ) ) { f_out_ << " \" \" " << endl ; vector < t_const * > consts = program_ -> get_consts ( ) ; f_out_ << " \" \" " ; f_out_ << " " << endl ; generate_consts ( consts ) ; f_out_ << " " ; } if ( ! program_ -> get_enums ( ) . empty ( ) ) { f_out_ << " \" \" " << endl ; vector < t_enum * > enums = program_ -> get_enums ( ) ; vector < t_enum * > :: iterator en_iter ; for ( en_iter = enums . begin ( ) ; en_iter != enums . end ( ) ; ++ en_iter ) { generate_enum ( * en_iter ) ; } } if ( ! program_ -> get_typedefs ( ) . empty ( ) ) { f_out_ << " \" \" " << endl ; vector < t_typedef * > typedefs = program_ -> get_typedefs ( ) ; vector < t_typedef * > :: iterator td_iter ; for ( td_iter = typedefs . begin ( ) ; td_iter != typedefs . end ( ) ; ++ td_iter ) { generate_typedef ( * td_iter ) ; } } if ( ! program_ -> get_objects ( ) . empty ( ) ) { f_out_ << " \" \" " << endl ; vector < t_struct * > objects = program_ -> get_objects ( ) ; vector < t_struct * > :: iterator o_iter ; for ( o_iter = objects . begin ( ) ; o_iter != objects . end ( ) ; ++ o_iter ) { if ( ( * o_iter ) -> is_xception ( ) ) { generate_xception ( * o_iter ) ; } else { generate_struct ( * o_iter ) ; } } } if ( ! program_ -> get_services ( ) . empty ( ) ) { f_out_ << " \" \" " << endl ; vector < t_service * > services = program_ -> get_services ( ) ; vector < t_service * > :: iterator sv_iter ; for ( sv_iter = services . begin ( ) ; sv_iter != services . end ( ) ; ++ sv_iter ) { service_name_ = get_service_name ( * sv_iter ) ; generate_service ( * sv_iter ) ; } } f_out_ << " " << endl ; f_out_ . close ( ) ; generate_index ( ) ; generate_css ( ) ; }
Prepares for file generation by opening up the necessary file output
 stream.
Prepares for file generation by opening up the necessary file output stream .
// Make output directory // Generate enums // Generate typedefs // Generate structs and exceptions in declared order // Generate services