compiler/cpp/src/generate/t_html_generator.cc
/**
 * Prints out the provided type in HTML
 */
Prints out the provided type in HTML
Prints out the provided type in HTML
int t_html_generator::print_type(t_type* ttype) {
  int len = 0;
  f_out_ << "<code>";
  if (ttype->is_container()) {
    if (ttype->is_list()) {
      f_out_ << "list&lt;";
      len = 6 + print_type(((t_list*)ttype)->get_elem_type());
      f_out_ << "&gt;";
    } else if (ttype->is_set()) {
      f_out_ << "set&lt;";
      len = 5 + print_type(((t_set*)ttype)->get_elem_type());
      f_out_ << "&gt;";
    } else if (ttype->is_map()) {
      f_out_ << "map&lt;";
      len = 5 + print_type(((t_map*)ttype)->get_key_type());
      f_out_ << ", ";
      len += print_type(((t_map*)ttype)->get_val_type());
      f_out_ << "&gt;";
    }
  } else if (ttype->is_base_type()) {
    f_out_ << (((t_base_type*)ttype)->is_binary() ? "binary" : ttype->get_name());
    len = ttype->get_name().size();
  } else {
    string prog_name = ttype->get_program()->get_name();
    string type_name = ttype->get_name();
    f_out_ << "<a href=\"" << prog_name << ".html#";
    if (ttype->is_typedef()) {
      f_out_ << "Typedef_";
    } else if (ttype->is_struct() || ttype->is_xception()) {
      f_out_ << "Struct_";
    } else if (ttype->is_enum()) {
      f_out_ << "Enum_";
    } else if (ttype->is_service()) {
      f_out_ << "Svc_";
    }
    f_out_ << type_name << "\">";
    len = type_name.size();
    if (ttype->get_program() != program_) {
      f_out_ << prog_name << ".";
      len += prog_name.size() + 1;
    }
    f_out_ << type_name << "</a>";
  }
  f_out_ << "</code>";
  return len;
}
int t_html_generator :: print_type ( t_type * ttype ) { int len = 0 ; f_out_ << " " ; if ( ttype -> is_container ( ) ) { if ( ttype -> is_list ( ) ) { f_out_ << " " ; len = 6 + print_type ( ( ( t_list * ) ttype ) -> get_elem_type ( ) ) ; f_out_ << " " ; } else if ( ttype -> is_set ( ) ) { f_out_ << " " ; len = 5 + print_type ( ( ( t_set * ) ttype ) -> get_elem_type ( ) ) ; f_out_ << " " ; } else if ( ttype -> is_map ( ) ) { f_out_ << " " ; len = 5 + print_type ( ( ( t_map * ) ttype ) -> get_key_type ( ) ) ; f_out_ << " " ; len += print_type ( ( ( t_map * ) ttype ) -> get_val_type ( ) ) ; f_out_ << " " ; } } else if ( ttype -> is_base_type ( ) ) { f_out_ << ( ( ( t_base_type * ) ttype ) -> is_binary ( ) ? " " : ttype -> get_name ( ) ) ; len = ttype -> get_name ( ) . size ( ) ; } else { string prog_name = ttype -> get_program ( ) -> get_name ( ) ; string type_name = ttype -> get_name ( ) ; f_out_ << " \" " << prog_name << " " ; if ( ttype -> is_typedef ( ) ) { f_out_ << " " ; } else if ( ttype -> is_struct ( ) || ttype -> is_xception ( ) ) { f_out_ << " " ; } else if ( ttype -> is_enum ( ) ) { f_out_ << " " ; } else if ( ttype -> is_service ( ) ) { f_out_ << " " ; } f_out_ << type_name << " \" " ; len = type_name . size ( ) ; if ( ttype -> get_program ( ) != program_ ) { f_out_ << prog_name << " " ; len += prog_name . size ( ) + 1 ; } f_out_ << type_name << " " ; } f_out_ << " " ; return len ; }
Prints out the provided type in HTML
Prints out the provided type in HTML