示例#1
0
// Dump the contents of a list of RegistrationBinding's.
void dumpList(const UtlSList& list)
{
   fprintf(stderr, "=== start\n");
   UtlSListIterator list_iter(list);
   RegistrationBinding* item;
   int item_no = 0;
   while ((item = dynamic_cast <RegistrationBinding*> (list_iter())))
   {
      fprintf(stderr, "--- item %d\n", item_no);
      UtlHashMap contents;
      item->copy(contents);
      UtlHashMapIterator iter(contents);
      UtlString* name;
      while ((name = dynamic_cast <UtlString*> (iter())))
      {
         UtlContainable* value = iter.value();
         UtlContainableType type = value->getContainableType();
         if (type == UtlString::TYPE)
         {
            fprintf(stderr, "%s = '%s'\n",
                    name->data(),
                    (dynamic_cast <UtlString*> (iter.value()))->data());
         }
         else if (type == UtlLongLongInt::TYPE)
         {
            Int64 value =
               (dynamic_cast <UtlLongLongInt*> (iter.value()))->getValue();
            fprintf(stderr, "%s = 0x%" FORMAT_INTLL "x = %" FORMAT_INTLL "d\n",
                    name->data(), value, value);
         }
         else if (type == UtlInt::TYPE)
         {
            fprintf(stderr, "%s = %" PRIdPTR "\n",
                    name->data(),
                    (dynamic_cast <UtlInt*> (iter.value()))->getValue());
         }
         else
         {
            fprintf(stderr, "%s has unknown type %s\n",
                    name->data(), type);
         }                  
      }
      item_no++;
   }
   fprintf(stderr, "=== end\n");
}