> On 6 May 2025, at 10:30, Soumya AR <soum...@nvidia.com> wrote:
> 
> From: Soumya AR <soum...@nvidia.com>
> 
> This patch adds a get_map () method to the JSON object class to provide access
> to the underlying hash map that stores the JSON key-value pairs.
> 
> It also reorganizes the private and public sections of the class to expose the
> map_t typedef, which is the return type of get_map().
> 
> This change is needed to allow traversal of key-value pairs when parsing
> user-provided JSON tuning data.
> 
> This patch was bootstrapped and regtested on aarch64-linux-gnu, no regression.
> 

I think this needs rebasing on top of the recent changes from David here.
Thanks,
Kyrill

> Signed-off-by: Soumya AR <soum...@nvidia.com>
> 
> gcc/ChangeLog:
> 
> * json.h (class object): Add get_map () method.
> ---
> gcc/json.h | 21 ++++++++++++---------
> 1 file changed, 12 insertions(+), 9 deletions(-)
> 
> diff --git a/gcc/json.h b/gcc/json.h
> index e369244cf8b..6fc2ac62e2c 100644
> --- a/gcc/json.h
> +++ b/gcc/json.h
> @@ -94,7 +94,16 @@ class value
> 
> class object : public value
> {
> - public:
> +private:
> +  typedef hash_map<char *, value *,
> +   simple_hashmap_traits<nofree_string_hash, value *> >
> +    map_t;
> +  map_t m_map;
> +
> +  /* Keep track of order in which keys were inserted.  */
> +  auto_vec<const char *> m_keys;
> +
> +public:
>   ~object ();
> 
>   enum kind get_kind () const final override { return JSON_OBJECT; }
> @@ -120,20 +129,14 @@ class object : public value
> 
>   value *get (const char *key) const;
> 
> +  const map_t &get_map () const { return m_map; }
> +
>   void set_string (const char *key, const char *utf8_value);
>   void set_integer (const char *key, long v);
>   void set_float (const char *key, double v);
> 
>   /* Set to literal true/false.  */
>   void set_bool (const char *key, bool v);
> -
> - private:
> -  typedef hash_map <char *, value *,
> -    simple_hashmap_traits<nofree_string_hash, value *> > map_t;
> -  map_t m_map;
> -
> -  /* Keep track of order in which keys were inserted.  */
> -  auto_vec <const char *> m_keys;
> };
> 
> /* Subclass of value for arrays.  */
> -- 
> 2.44.0
> 

Reply via email to