Lines Matching +full:in +full:- +full:tree
4 // Redistribution and use in source and binary forms, with or without
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
41 #include "utils/config/tree.ipp"
56 /// Defines the schema of a configuration tree.
58 /// \param [in,out] tree The tree to populate. The tree should be empty on
59 /// entry to prevent collisions with the keys defined in here.
61 init_tree(config::tree& tree)
63 tree.define< config::string_node >("architecture");
64 tree.define< config::strings_set_node >("execenvs");
65 tree.define< config::positive_int_node >("parallelism");
66 tree.define< config::string_node >("platform");
67 tree.define< engine::user_node >("unprivileged_user");
68 tree.define_dynamic("test_suites");
72 /// Fills in a configuration tree with default values.
74 /// \param [in,out] tree The tree to populate. init_tree() must have been
77 set_defaults(config::tree& tree)
79 tree.set< config::string_node >("architecture", KYUA_ARCHITECTURE);
83 if (em->is_supported())
84 supported.insert(em->name());
86 tree.set< config::strings_set_node >("execenvs", supported);
88 // TODO(jmmv): Automatically derive this from the number of CPUs in the
90 // the new parallel implementation as of 2015-02-27 though.
91 tree.set< config::positive_int_node >("parallelism", 1);
92 tree.set< config::string_node >("platform", KYUA_PLATFORM);
98 /// Initializes the configuration tree.
101 /// syntax() method. We populate the configuration tree from here with the
104 /// \param [in,out] tree The tree to populate.
105 /// \param syntax_version The version of the file format as specified in the
111 setup(config::tree& tree, const int syntax_version)
117 init_tree(tree);
118 set_defaults(tree);
124 /// \param [out] tree_ The tree in which the results of the parsing will be
126 /// we grab a reference to this object, the tree must remain valid for
128 explicit config_parser(config::tree& tree_) :
140 /// \return A dynamically-allocated node.
145 new_node->_value = _value;
160 /// Sets the value of the node from an entry in the Lua stack.
163 /// \param value_index The stack index in which the value resides.
165 /// \throw value_error If the value in state(value_index) cannot be
172 passwd::find_user_by_uid(state.to_integer(-1)));
175 passwd::find_user_by_name(state.to_string(-1)));
222 /// Constructs a config with the built-in settings.
225 config::tree
228 config::tree tree(false);
229 init_tree(tree);
230 set_defaults(tree);
231 return tree;
235 /// Constructs a config with the built-in settings.
238 config::tree
241 config::tree tree(false);
242 init_tree(tree);
248 tree.set< config::strings_set_node >("execenvs", supported);
250 return tree;
258 /// \return High-level representation of the configuration file.
262 config::tree
265 config::tree tree(false);
267 config_parser(tree).parse(file);
271 return tree;