Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a stupid function to display the content of a dict (as long as it's a string)
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 1 Oct 2008 14:41:54 +0000 (14:41 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 1 Oct 2008 14:41:54 +0000 (14:41 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5950 48e7efb5-ca39-0410-a469-dd3cf9ba447f

include/xbt/dict.h
src/xbt/dict.c

index 9ebe999..03162e7 100644 (file)
@@ -64,6 +64,7 @@ SG_BEGIN_DECL();
   XBT_PUBLIC(void) xbt_dict_remove(xbt_dict_t dict, const char *key);
   XBT_PUBLIC(void) xbt_dict_reset(xbt_dict_t dict);
   XBT_PUBLIC(int) xbt_dict_length(xbt_dict_t dict);
+  XBT_PUBLIC(void) xbt_dict_dump_output_string(void *s);
   XBT_PUBLIC(void) xbt_dict_dump(xbt_dict_t dict, void (*output)(void*));
   XBT_PUBLIC(void) xbt_dict_dump_sizes(xbt_dict_t dict);
 
index 9533beb..649091b 100644 (file)
@@ -490,11 +490,17 @@ int xbt_dict_length(xbt_dict_t dict) {
   return dict->count;
 }
 
+/** @brief function to be used in xbt_dict_dump as long as the stored values are strings */
+void xbt_dict_dump_output_string(void *s) {
+  fputs(s,stdout);
+}
+
+
 /**
  * \brief Outputs the content of the structure (debugging purpose)
  *
  * \param dict the exibitionist
- * \param output a function to dump each data in the tree
+ * \param output a function to dump each data in the tree (check @ref xbt_dict_dump_output_string)
  *
  * Outputs the content of the structure. (for debugging purpose). \a output is a
  * function to output the data. If NULL, data won't be displayed.
@@ -511,11 +517,11 @@ void xbt_dict_dump(xbt_dict_t     dict,
       if (element) {
         printf("[\n");
         while (element != NULL) {
-          printf(" %s -> ", element->key);
+          printf(" %s -> '", element->key);
           if (output != NULL) {
             (*output)(element->content);
           }
-          printf("\n");
+          printf("'\n");
           element = element->next;
         }
         printf("]\n");