Пример #1
0
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
bool
SuifPrinterModule::print_stl(ostream& output, 
			     const ObjectWrapper &obj,
			     const LString &name, int _indent,int deref = 0)
{
  const Address what = obj.get_address();
  const MetaClass* type = obj.get_meta_class();
   int field_deref = deref?deref-1:0;
   output << type->get_instance_name()
              << '(' << type->get_meta_class_id() << ") ";
   if (name)
         output << ' ' << name << ' ';
   STLMetaClass *p = (STLMetaClass*) type;
   ListIterator* it = (ListIterator*) p->get_iterator(what);
   output << '[' << it->length() << "] ";
   if (it->current()) {
          //output << "{\n";
          output << endl;
          //while (it->is_valid()) {
	  for (; it->is_valid(); it->next())
	    {
	      ObjectWrapper obj(it->current(), it->current_meta_class());
	      //               const MetaClass* currentMetaClass = it->current_meta_class();
	      //               const Address curAddr = it->current();
               if (!obj.is_null()) {
                  indent(output, _indent+istep);
                  print2(output, obj, it->current_name(),
                         _indent+istep, field_deref);
                }
	       //it->next();
	    }
          //}
	  //          } while (it->is_valid());
          indent(output, _indent);
          //output << "}\n";
   }
   else
          output <<" {0x0}\n";
   delete it;
   return true;
}
Пример #2
0
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
bool
SuifPrinterModule::print_list(ostream& output, 
			      const ObjectWrapper &obj,
			      const LString &name, 
			      int _indent, int deref = 0)
{
  const Address what = obj.get_address();
  const MetaClass* type = obj.get_meta_class(); 
  //output << "list:deref = " << deref << endl;
  int l_sep = list_separator;
  int field_deref = deref?deref-1:0;
  ListMetaClass *p = (ListMetaClass*) type;
  ListIterator* it = (ListIterator*) p->get_iterator(what);
  //  bool verbose_list = false;
  if (!print_all() && !it->is_valid()) {
      if (list_separator != '\n')
	output << "<None>";
    return true;
  }
  size_t length = it->length();
  if (!deref) {
    if (print_all()) {
      output << type->get_instance_name()
	     << '(' << type->get_meta_class_id() << ") ";
      if (name)
	output << ' ' << name << ' ';
    }
    else // if (length != 1)
      {
	output <<"list ";
	if (name)
	  output << ' ' << name << ' ';
      }
  }
  else if (_indent > 0)
    _indent -= istep;
  {
    if (print_all())
      output << '[' << length << "]:";
    if (it->current()) {
      int num_elts = 0;
      bool last_printed = true;
      bool nl_needed = false;
      if (deref && length == 1)
	last_printed = false;
      else {
	//output << endl;
      }
      //output << '{';
      //indent(output, istep);
      //while (it->is_valid()) {
      for (; it->is_valid();  it->next())
	{
	  list_separator = l_sep;
	  ObjectWrapper element(it->current(),
				it->current_meta_class());
	  //	    const MetaClass* currentMetaClass = it->current_meta_class();
	  //	    const Address curAddr = it->current();
	  if (!element.is_null()) {
	    //	    if (curAddr) {
	    if (last_printed &&
		nl_needed) {
	      output << (char)list_separator;
	      if (list_separator != ' ') {
		if (list_separator == '\n')
		  indent(output, _indent+istep);
		else if (list_separator == ',')
		  output << ' ';
	      }
	    }
	    char buff[100] = { 0 };
	    if (print_all())
	      sprintf(buff,"[%d]", num_elts++);
	    last_printed = print2(output, element,
				  buff, _indent+istep, field_deref);
	    nl_needed = last_printed;
	  }
	}
      if (last_printed &&
	  nl_needed) {
	if (list_separator == '\n') {
	  output << (char)list_separator;
	  indent(output, _indent+istep);
	}
      }
    } else
      output <<" {0x0} ";
  }
  delete it;
  list_separator = l_sep;
  return true;
}