• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/* Copyright 2013 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
5
6/**
7 * This file defines the <code>PPB_VarDictionary</code> struct providing
8 * a way to interact with dictionary vars.
9 */
10
11label Chrome {
12  M29 = 1.0
13};
14
15/**
16 * A dictionary var contains key-value pairs with unique keys. The keys are
17 * strings while the values can be arbitrary vars. Key comparison is always
18 * done by value instead of by reference.
19 */
20[macro="PPB_VAR_DICTIONARY_INTERFACE"]
21interface PPB_VarDictionary {
22  /**
23   * Creates a dictionary var, i.e., a <code>PP_Var</code> with type set to
24   * <code>PP_VARTYPE_DICTIONARY</code>.
25   *
26   * @return An empty dictionary var, whose reference count is set to 1 on
27   * behalf of the caller.
28   */
29  PP_Var Create();
30
31  /**
32   * Gets the value associated with the specified key.
33   *
34   * @param[in] dict A dictionary var.
35   * @param[in] key A string var.
36   *
37   * @return The value that is associated with <code>key</code>. The reference
38   * count of the element returned is incremented on behalf of the caller. If
39   * <code>key</code> is not a string var, or it doesn't exist in
40   * <code>dict</code>, an undefined var is returned.
41   */
42  PP_Var Get([in] PP_Var dict, [in] PP_Var key);
43
44  /**
45   * Sets the value associated with the specified key.
46   *
47   * @param[in] dict A dictionary var.
48   * @param[in] key A string var. If this key hasn't existed in
49   * <code>dict</code>, it is added and associated with <code>value</code>;
50   * otherwise, the previous value is replaced with <code>value</code>.
51   * @param[in] value The value to set. The dictionary holds a reference to it
52   * on success.
53   *
54   * @return A <code>PP_Bool</code> indicating whether the operation succeeds.
55   */
56  PP_Bool Set([in] PP_Var dict, [in] PP_Var key, [in] PP_Var value);
57
58  /**
59   * Deletes the specified key and its associated value, if the key exists. The
60   * reference to the element will be released.
61   *
62   * @param[in] dict A dictionary var.
63   * @param[in] key A string var.
64   */
65  void Delete([in] PP_Var dict, [in] PP_Var key);
66
67  /**
68   * Checks whether a key exists.
69   *
70   * @param[in] dict A dictionary var.
71   * @param[in] key A string var.
72   *
73   * @return A <code>PP_Bool</code> indicating whether the key exists.
74   */
75  PP_Bool HasKey([in] PP_Var dict, [in] PP_Var key);
76
77  /**
78   * Gets all the keys in a dictionary. Please note that for each key that you
79   * set into the dictionary, a string var with the same contents is returned;
80   * but it may not be the same string var (i.e., <code>value.as_id</code> may
81   * be different).
82   *
83   * @param[in] dict A dictionary var.
84   *
85   * @return An array var which contains all the keys of <code>dict</code>. Its
86   * reference count is incremented on behalf of the caller. The elements are
87   * string vars. Returns a null var if failed.
88   */
89  PP_Var GetKeys([in] PP_Var dict);
90};
91