[v6,2/3] json: add iterate method to object class

Message ID tencent_20BE2741196D70472D5C811890909FC65207@qq.com
State New
Headers
Series fmv: Add -ftarget-clones-table option support |

Commit Message

Yangyu Chen Oct. 7, 2025, 12:45 p.m. UTC
  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 <cyy@cyyself.name>

gcc/ChangeLog:

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

Patch

diff --git a/gcc/json.h b/gcc/json.h
index c706f2a4fe9..b87da9464de 100644
--- a/gcc/json.h
+++ b/gcc/json.h
@@ -183,6 +183,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);
 
   size_t get_num_keys () const { return m_keys.length (); }