compiler/cpp/src/generate/t_html_generator.cc
/**
 * Generates a struct definition for a thrift data type.
 *
 * @param tstruct The struct definition
 */
Generates a struct definition for a thrift data type.
@param tstruct The struct definition
Generates a struct definition for a thrift data type . @param tstruct The struct definition
void t_html_generator::generate_struct(t_struct* tstruct) {
  string name = tstruct->get_name();
  f_out_ << "<div class=\"definition\">";
  f_out_ << "<h3 id=\"Struct_" << name << "\">";
  if (tstruct->is_xception()) {
    f_out_ << "Exception: ";
  } else if (tstruct->is_union()) {
    f_out_ << "Union: ";
  } else {
    f_out_ << "Struct: ";
  }
  f_out_ << name << "</h3>" << endl;
  vector<t_field*> members = tstruct->get_members();
  vector<t_field*>::iterator mem_iter = members.begin();
  f_out_ << "<table class=\"table-bordered table-striped table-condensed\">";
  f_out_ << "<thead><th>Key</th><th>Field</th><th>Type</th><th>Description</th><th>Requiredness</th><th>Default value</th></thead>"
    << endl;
  for ( ; mem_iter != members.end(); mem_iter++) {
    f_out_ << "<tr><td>" << (*mem_iter)->get_key() << "</td><td>";
    f_out_ << (*mem_iter)->get_name();
    f_out_ << "</td><td>";
    print_type((*mem_iter)->get_type());
    f_out_ << "</td><td>";
    f_out_ << escape_html( (*mem_iter)->get_doc());
    f_out_ << "</td><td>";
    if ((*mem_iter)->get_req() == t_field::T_OPTIONAL) {
      f_out_ << "optional";
    } else if ((*mem_iter)->get_req() == t_field::T_REQUIRED) {
      f_out_ << "required";
    } else {
      f_out_ << "default";
    }
    f_out_ << "</td><td>";
    t_const_value* default_val = (*mem_iter)->get_value();
    if (default_val != NULL) {
      print_const_value(default_val);
    }
    f_out_ << "</td></tr>" << endl;
  }
  f_out_ << "</table><br/>";
  print_doc(tstruct);
  f_out_ << "</div>";
}
void t_html_generator :: generate_struct ( t_struct * tstruct ) { string name = tstruct -> get_name ( ) ; f_out_ << " \" \" " ; f_out_ << " \" " << name << " \" " ; if ( tstruct -> is_xception ( ) ) { f_out_ << " " ; } else if ( tstruct -> is_union ( ) ) { f_out_ << " " ; } else { f_out_ << " " ; } f_out_ << name << " " << endl ; vector < t_field * > members = tstruct -> get_members ( ) ; vector < t_field * > :: iterator mem_iter = members . begin ( ) ; f_out_ << " \" \" " ; f_out_ << " " << endl ; for ( ; mem_iter != members . end ( ) ; mem_iter ++ ) { f_out_ << " " << ( * mem_iter ) -> get_key ( ) << " " ; f_out_ << ( * mem_iter ) -> get_name ( ) ; f_out_ << " " ; print_type ( ( * mem_iter ) -> get_type ( ) ) ; f_out_ << " " ; f_out_ << escape_html ( ( * mem_iter ) -> get_doc ( ) ) ; f_out_ << " " ; if ( ( * mem_iter ) -> get_req ( ) == t_field :: T_OPTIONAL ) { f_out_ << " " ; } else if ( ( * mem_iter ) -> get_req ( ) == t_field :: T_REQUIRED ) { f_out_ << " " ; } else { f_out_ << " " ; } f_out_ << " " ; t_const_value * default_val = ( * mem_iter ) -> get_value ( ) ; if ( default_val != NULL ) { print_const_value ( default_val ) ; } f_out_ << " " << endl ; } f_out_ << " " ; print_doc ( tstruct ) ; f_out_ << " " ; }
Generates a struct definition for a thrift data type.
Generates a struct definition for a thrift data type .