Introduce all_objfiles and next_iterator
[deliverable/binutils-gdb.git] / gdb / objfiles.h
index b3ceb8c6c70a9fa8eaae3d1225545214c8923198..8d7a3c35e11ae6e19006c1e7a7e7fabf535cbde7 100644 (file)
@@ -28,6 +28,7 @@
 #include "registry.h"
 #include "gdb_bfd.h"
 #include <vector>
+#include "common/next-iterator.h"
 
 struct bcache;
 struct htab;
@@ -565,6 +566,22 @@ extern void default_iterate_over_objfiles_in_search_order
    void *cb_data, struct objfile *current_objfile);
 \f
 
+/* An iterarable object that can be used to iterate over all
+   objfiles.  The basic use is in a foreach, like:
+
+   for (objfile *objf : all_objfiles (pspace)) { ... }  */
+
+class all_objfiles : public next_adapter<struct objfile>
+{
+public:
+
+  explicit all_objfiles (struct program_space *pspace)
+    : next_adapter<struct objfile> (pspace->objfiles)
+  {
+  }
+};
+
+
 /* Traverse all object files in the current program space.
    ALL_OBJFILES_SAFE works even if you delete the objfile during the
    traversal.  */
This page took 0.025638 seconds and 4 git commands to generate.