Skip to content
  • Thomas Haller's avatar
    libnm: add NMUtilsStrStrDictKey utility · ec92eced
    Thomas Haller authored
    When having a hash-of-hashes where each hash is indexed by a name,
    (such as GKeyFile), you can either implement it as a hash-of-hashes
    or define your own version of indexes that pack both levels of names
    into one key.
    
    This is an implementation of such a key. Use it as:
    
      GHashTable *hash = g_hash_table_new_full (_nm_utils_strstrdictkey_hash,
                                                _nm_utils_strstrdictkey_equal,
                                                g_free, _destroy_value);
    
    and create keys via:
    
      NMUtilsStrStrDictKey *k = _nm_utils_strstrdictkey_create (s1, s2);
    
    For lookup you can use static strings (note that the static string
    might increase the size of the binary):
    
      g_hash_table_contains (hash, _nm_utils_strstrdictkey_static ("outer", "inner"))
    ec92eced