Currently, the object class in json.h does not provide a way to iterate
over its keys. This commit adds an `iterate` method to the object class,
allowing users to iterate over the keys of a JSON object.

Signed-off-by: Yangyu Chen <c...@cyyself.name>

gcc/ChangeLog:

        * json.h (class object): Add iterate method to object class.
---
 gcc/json.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gcc/json.h b/gcc/json.h
index da4da852a1e..8ec78f061bd 100644
--- a/gcc/json.h
+++ b/gcc/json.h
@@ -180,6 +180,11 @@ class object : public value
   /* Set to literal true/false.  */
   void set_bool (const char *key, bool v);
 
+  bool iterate (unsigned i, const char **key) const
+  {
+    return m_keys.iterate (i, key);
+  }
+
   static int compare (const json::object &obj_a, const json::object &obj_b);
 
  private:
-- 
2.49.0

Reply via email to