The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
config Class Reference

A config object defines a single node in a WML file, with access to child nodes. More...

#include <config.hpp>

Classes

struct  all_children_iterator
 
struct  any_child
 
struct  attribute_iterator
 
struct  child_iterator
 
struct  child_pos
 
struct  const_all_children_iterator
 
struct  const_attribute_iterator
 
struct  const_child_iterator
 
struct  error
 

Public Types

typedef std::vector
< std::unique_ptr< config > > 
child_list
 
typedef std::map< std::string,
child_list
child_map
 
typedef boost::iterator_range
< child_iterator
child_itors
 
typedef boost::iterator_range
< const_child_iterator
const_child_itors
 
using attribute_value = config_attribute_value
 Variant for storing WML attributes. More...
 
typedef std::map< std::string,
attribute_value
attribute_map
 
typedef attribute_map::value_type attribute
 
typedef boost::iterator_range
< const_attribute_iterator
const_attr_itors
 
typedef boost::iterator_range
< attribute_iterator
attr_itors
 
typedef boost::iterator_range
< all_children_iterator
all_children_itors
 
typedef boost::iterator_range
< const_all_children_iterator
const_all_children_itors
 

Public Member Functions

 config ()
 
 config (const config &)
 
configoperator= (const config &)
 
 config (config &&)
 
configoperator= (config &&)
 
 config (config_key_type child)
 Creates a config object with an empty child of name child. More...
 
template<typename... T>
 config (config_key_type first, T &&...args)
 
 ~config ()
 
 operator bool () const
 
child_itors child_range (config_key_type key)
 
const_child_itors child_range (config_key_type key) const
 
unsigned child_count (config_key_type key) const
 
unsigned all_children_count () const
 
unsigned attribute_count () const
 Count the number of non-blank attributes. More...
 
bool has_child (config_key_type key) const
 Determine whether a config has a child or not. More...
 
const configchild_or_empty (config_key_type key) const
 Returns the first child with the given key, or an empty config if there is none. More...
 
configchild (config_key_type key, int n=0)
 Returns the nth child with the given key, or a reference to an invalid config if there is none. More...
 
const configchild (config_key_type key, int n=0) const
 Returns the nth child with the given key, or a reference to an invalid config if there is none. More...
 
configchild (config_key_type key, const std::string &parent)
 Returns a mandatory child node. More...
 
const configchild (config_key_type key, const std::string &parent) const
 Returns a mandatory child node. More...
 
configadd_child (config_key_type key)
 
configadd_child (config_key_type key, const config &val)
 
configadd_child_at (config_key_type key, const config &val, unsigned index)
 
configadd_child (config_key_type key, config &&val)
 
attribute_valueoperator[] (config_key_type key)
 Returns a reference to the attribute with the given key. More...
 
const attribute_valueoperator[] (config_key_type key) const
 Returns a reference to the attribute with the given key or to a dummy empty attribute if it does not exist. More...
 
attribute_valueoperator[] (const char *key)
 Returns a reference to the attribute with the given key. More...
 
const attribute_valueoperator[] (const char *key) const
 Returns a reference to the attribute with the given key or to a dummy empty attribute if it does not exist. More...
 
const attribute_valueget (config_key_type key) const
 Returns a pointer to the attribute with the given key or nullptr if it does not exist. More...
 
const attribute_valueget_old_attribute (config_key_type key, const std::string &old_key, const std::string &msg="") const
 Function to handle backward compatibility Get the value of key and if missing try old_key and log msg as a WML error (if not empty) More...
 
template<typename T >
void insert (config_key_type key, T &&value)
 Returns a reference to the first child with the given key. More...
 
configchild_or_add (config_key_type key)
 
bool has_attribute (config_key_type key) const
 
bool has_old_attribute (config_key_type key, const std::string &old_key, const std::string &msg="") const
 Function to handle backward compatibility Check if has key or old_key and log msg as a WML error (if not empty) More...
 
void remove_attribute (config_key_type key)
 
void merge_attributes (const config &)
 
template<typename... T>
void remove_attributes (T...keys)
 
const_attr_itors attribute_range () const
 
attr_itors attribute_range ()
 
configfind_child (config_key_type key, const std::string &name, const std::string &value)
 Returns the first child of tag key with a name attribute containing value. More...
 
const configfind_child (config_key_type key, const std::string &name, const std::string &value) const
 
void clear_children_impl (config_key_type key)
 
template<typename... T>
void clear_children (T...keys)
 
void splice_children (config &src, const std::string &key)
 Moves all the children with tag key from src to this. More...
 
void remove_child (config_key_type key, unsigned index)
 
void remove_children (config_key_type key, std::function< bool(const config &)> p)
 Removes all children with tag key for which p returns true. More...
 
void recursive_clear_value (config_key_type key)
 
void clear ()
 
void clear_all_children ()
 
void clear_attibutes ()
 
bool empty () const
 
std::string debug () const
 
std::string hash () const
 
const_all_children_itors all_children_range () const
 In-order iteration over all children. More...
 
all_children_itors all_children_range ()
 
const_all_children_iterator ordered_cbegin () const
 
const_all_children_iterator ordered_cend () const
 
const_all_children_iterator ordered_begin () const
 
const_all_children_iterator ordered_end () const
 
all_children_iterator ordered_begin ()
 
all_children_iterator ordered_end ()
 
all_children_iterator erase (const all_children_iterator &i)
 
config get_diff (const config &c) const
 A function to get the differences between this object, and 'c', as another config object. More...
 
void get_diff (const config &c, config &res) const
 
void apply_diff (const config &diff, bool track=false)
 A function to apply a diff config onto this config object. More...
 
void clear_diff_track (const config &diff)
 Clear any tracking info from a previous apply_diff call with tracking. More...
 
void merge_with (const config &c)
 Merge config 'c' into this config, overwriting this config's values. More...
 
void inherit_from (const config &c)
 Merge config 'c' into this config, preserving this config's values. More...
 
bool matches (const config &filter) const
 
void append (const config &cfg)
 Append data from another config object to this one. More...
 
void append (config &&cfg)
 
void append_children (const config &cfg)
 Adds children from cfg. More...
 
void append_children (config &&cfg)
 
void append_children (const config &cfg, const std::string &key)
 Adds children from cfg. More...
 
void append_children_by_move (config &cfg, const std::string &key)
 Moves children with the given name from the given config to this one. More...
 
void append_attributes (const config &cfg)
 Adds attributes from cfg. More...
 
void merge_children (const std::string &key)
 All children with the given key will be merged into the first element with that key. More...
 
void merge_children_by_attribute (const std::string &key, const std::string &attribute)
 All children with the given key and with equal values of the specified attribute will be merged into the element with that key and that value of the attribute. More...
 
void swap (config &cfg)
 

Static Public Member Functions

static bool valid_id (config_key_type id)
 

Static Public Attributes

static const char * diff_track_attribute = "__diff_track"
 The name of the attribute used for tracking diff changes. More...
 

Private Member Functions

void check_valid () const
 Raises an exception if this is not valid. More...
 
void check_valid (const config &cfg) const
 Raises an exception if this or cfg is not valid. More...
 
std::vector< child_pos >::iterator remove_child (const child_map::iterator &l, unsigned pos)
 Removes the child at position pos of l. More...
 

Private Attributes

attribute_map values_
 All the attributes of this node. More...
 
child_map children_
 A list of all children of this node. More...
 
std::vector< child_posordered_children
 

Static Private Attributes

static config invalid
 

Friends

struct config_implementation
 
bool operator== (const config &a, const config &b)
 

Detailed Description

A config object defines a single node in a WML file, with access to child nodes.

Definition at line 93 of file config.hpp.

Member Typedef Documentation

typedef boost::iterator_range<all_children_iterator> config::all_children_itors

Definition at line 660 of file config.hpp.

typedef boost::iterator_range<attribute_iterator> config::attr_itors

Definition at line 315 of file config.hpp.

typedef attribute_map::value_type config::attribute

Definition at line 254 of file config.hpp.

typedef std::map< std::string , attribute_value > config::attribute_map

Definition at line 253 of file config.hpp.

Variant for storing WML attributes.

The most efficient type is used when assigning a value. For instance, strings "yes", "no", "true", "false" will be detected and stored as boolean.

Note
The blank variant is only used when querying missing attributes. It is not stored in config objects.

Definition at line 245 of file config.hpp.

typedef boost::iterator_range<child_iterator> config::child_itors

Definition at line 235 of file config.hpp.

typedef std::vector<std::unique_ptr<config> > config::child_list

Definition at line 141 of file config.hpp.

typedef std::map<std::string, child_list > config::child_map

Definition at line 146 of file config.hpp.

Definition at line 661 of file config.hpp.

typedef boost::iterator_range<const_attribute_iterator> config::const_attr_itors

Definition at line 314 of file config.hpp.

typedef boost::iterator_range<const_child_iterator> config::const_child_itors

Definition at line 236 of file config.hpp.

Constructor & Destructor Documentation

config::config ( )

Definition at line 126 of file config.cpp.

Referenced by add_child(), and add_child_at().

config::config ( const config cfg)

Definition at line 133 of file config.cpp.

References append_children().

config::config ( config &&  cfg)

Definition at line 165 of file config.cpp.

config::config ( config_key_type  child)
explicit

Creates a config object with an empty child of name child.

Definition at line 141 of file config.cpp.

References add_child().

template<typename... T>
config::config ( config_key_type  first,
T &&...  args 
)
inlineexplicit

Definition at line 830 of file config.hpp.

References unpack().

config::~config ( )

Definition at line 149 of file config.cpp.

References clear().

Member Function Documentation

config & config::add_child ( config_key_type  key)

Definition at line 456 of file config.cpp.

References check_valid(), children_, config(), and ordered_children.

Referenced by replay::add_countdown_update(), add_image(), replay::add_label(), campaignd::add_license(), replay::add_log_data(), unit::add_modification(), terrain_builder::add_off_map_rule(), replay::add_rename(), replay::add_start(), replay::add_synced_command(), add_text(), replay::add_unit_checksum(), desktop::add_user_bookmark(), append_children(), append_children_by_move(), unit::apply_builtin_effect(), attack_type::apply_modification(), archive_addon(), archive_dir(), BOOST_AUTO_TEST_CASE(), unit_type::build_help_index(), cave_map_generator::cave_map_generator_job::cave_map_generator_job(), turn_info::change_side_controller(), child_or_add(), replay::clear_labels(), persist_file_context::clear_var(), gui2::chatbox::close_window(), replay_network_sender::commit_and_sync(), config(), savegame::convert_old_saves_1_11_0(), savegame::convert_old_saves_1_13_0(), savegame::loadgame::copy_era(), default_map_generator::create_scenario(), savegame::save_index_class::data(), addons_client::delete_remote_addon(), gui2::dialogs::story_viewer::display_part(), events::chat_command_handler::do_details(), events::chat_command_handler::do_drop(), events::chat_command_handler::do_gen_room_query(), events::chat_command_handler::do_info(), events::chat_command_handler::do_register(), do_resolve_rects(), events::chat_command_handler::do_room_query(), events::chat_command_handler::do_room_query_noarg(), events::chat_command_handler::do_set(), addons_client::download_addon(), gui2::dialogs::story_viewer::draw_floating_image(), gui2::dialogs::attack_predictions::draw_hp_graph(), editor::editor_display::draw_sidebar(), replay::end_turn(), gui2::dialogs::mp_lobby::enter_game(), expand_partialresolution(), saved_game::expand_random_scenario(), ai::configuration::expand_simplified_aspects(), savegame::extract_summary_from_config(), gui2::dialogs::mp_join_game::fetch_game_config(), campaignd::find_translations(), help::generate_contents(), gui2::dialogs::generate_difficulty_config(), unit::generate_traits(), replay_helper::get_attack(), ai::readonly_context_impl::get_avoid(), get_checksum(), variable_info_implementation::vi_policy_create::get_child_at(), replay::get_data_range(), get_diff(), replay_helper::get_event(), gui2::dialogs::mp_options_helper::get_options_config(), vconfig::get_parsed_config(), replay_helper::get_recall(), replay_helper::get_recruit(), persist_file_context::get_var(), campaignd::server::handle_request_campaign_list(), campaignd::server::handle_upload(), game_lua_kernel::impl_current_get(), replay::init_side(), mp::initial_level_config(), addons_client::install_addon(), ai::default_recruitment::recruitment::integrate_recruitment_pattern_in_recruitment_instructions(), intf_append_ai(), intf_debug_ai(), game_lua_kernel::intf_fire_event(), intf_modify_ai(), gui2::dialogs::addon_manager::load_addon_list(), game_config_manager::load_game_config(), saved_game::load_mod(), synced_checkup::local_checkup(), luaW_toconfig(), wb::side_actions::make_net_cmd_insert(), wb::side_actions::make_net_cmd_refresh(), wb::side_actions::make_net_cmd_replace(), animation_branch::merge(), merge_children(), merge_children_by_attribute(), merge_with(), variable_info_implementation::merge_range_h::operator()(), ai::configuration::parse_side_config(), cave_map_generator::cave_map_generator_job::place_chamber(), ai::ai_composite::preparse_cfg(), ng::connect_engine::process_network_data(), playmp_controller::process_oos(), persist_choice::query_user(), playturn_network_adapter::read(), ai::default_recruitment::recruitment_aspect::recalculate(), ai::default_recruitment::recruitment_aspect::recruitment_aspect(), display::refresh_report(), preferences::save_acquaintances(), hotkey::save_hotkeys(), events::chat_handler::send_chat_room_message(), events::chat_handler::send_command(), ng::connect_engine::send_level_data(), wb::manager::send_network_data(), addons_client::send_simple_request(), events::chat_handler::send_whisper(), about::set_about(), set_global_variable(), game_config_manager::set_multiplayer_hashes(), ng::side_engine::set_side_children(), ng::scenario::set_sides(), persist_file_context::set_var(), setup_test_config(), ng::side_engine::side_engine(), replay::speak(), scoped_wml_variable::store(), replay_network_sender::sync_non_undoable(), mp_game_settings::to_config(), tod_manager::to_config(), ai::engine_fai::to_config(), ai::ai_default_rca::candidate_action_evaluation_loop::to_config(), carryover::to_config(), saved_game::to_config(), wb::attack::to_config(), wb::suppose_dead::to_config(), wb::recall::to_config(), ai::engine_lua::to_config(), ai::ai_composite::to_config(), ai::ai_default_rca::aspect_attacks::to_config(), wb::recruit::to_config(), game_events::wmi_manager::to_config(), ai::formula_ai::to_config(), wb::move::to_config(), ai::lua_candidate_action_wrapper_base::to_config(), ai::aspect_attacks_lua::to_config(), carryover_info::to_config(), game_events::wml_menu_item::to_config(), pathfind::manager::to_config(), play_controller::to_config(), ai::lua_stage_wrapper::to_config(), editor::map_context::to_config(), ai::composite_aspect< T >::to_config(), team::to_config(), ai::lua_aspect< T >::to_config(), ai::readonly_context_impl::to_readonly_context_config(), carryover::transfer_all_recalls_to(), carryover_info::transfer_to(), unit::unit(), ng::connect_engine::update_and_send_diff(), ng::connect_engine::update_level(), addons_client::upload_addon(), replay::user_input(), ai::config_value_translator< config >::value_to_cfg(), ai::config_value_translator< terrain_filter >::value_to_cfg(), detail::config_construct_unpacker< T, config, Rest...>::visit(), detail::config_construct_unpacker< T, config &, Rest...>::visit(), statistics::stats::write(), sound::music_track::write(), actions::undo::recruit_action::write(), actions::undo::recall_action::write(), actions::undo::dismiss_action::write(), map_labels::write(), unit_formula_manager::write(), actions::clearer_info::write(), replay_recorder_base::write(), actions::shroud_clearing_action::write(), game_state::write(), actions::undo_list::write(), attack_type::write(), team::team_info::write(), movetype::terrain_info::data::write(), addon_info::write(), wesnothd::ban_manager::write(), movetype::resistances::write(), team::write(), display::write(), unit::write(), write_battle_result_map(), game_board::write_config(), actions::undo_action::write_event_vector(), game_events::manager::write_events(), game_data::write_snapshot(), soundsource::manager::write_sourcespecs(), statistics::write_stats(), and preferences::manager::~manager().

config & config::add_child ( config_key_type  key,
const config val 
)

Definition at line 466 of file config.cpp.

References check_valid(), children_, config(), and ordered_children.

config & config::add_child ( config_key_type  key,
config &&  val 
)

Definition at line 477 of file config.cpp.

References check_valid(), children_, config(), and ordered_children.

config & config::add_child_at ( config_key_type  key,
const config val,
unsigned  index 
)
unsigned config::all_children_count ( ) const
config::const_all_children_itors config::all_children_range ( ) const
config::all_children_itors config::all_children_range ( )

Definition at line 866 of file config.cpp.

References ordered_children.

void config::append ( const config cfg)
void config::append ( config &&  cfg)

Definition at line 278 of file config.cpp.

References append_children(), and values_.

void config::append_attributes ( const config cfg)

Adds attributes from cfg.

Definition at line 253 of file config.cpp.

References check_valid(), and values_.

Referenced by unit_type::build_unit_cfg(), and default_map_generator_job::default_generate_map().

void config::append_children ( const config cfg)
void config::append_children ( config &&  cfg)

Definition at line 233 of file config.cpp.

References add_child(), check_valid(), children_, and ordered_children.

void config::append_children ( const config cfg,
const std::string &  key 
)

Adds children from cfg.

Definition at line 261 of file config.cpp.

References add_child(), check_valid(), and child_range().

void config::append_children_by_move ( config cfg,
const std::string &  key 
)

Moves children with the given name from the given config to this one.

Definition at line 295 of file config.cpp.

References add_child(), check_valid(), and child_range().

void config::apply_diff ( const config diff,
bool  track = false 
)

A function to apply a diff config onto this config object.

If the "track" parameter is true, the changes made will be marked in a magic attribute (defined above) of this and child nodes of this config, with "new" value indicating an added child, "modified" a modified one, and "deleted" for the deleted items, which will not be actually deleted (so calling code can easily see what they are). Use clear_diff_track with the same diff object to clear the tracking info and actually delete the nodes.

Definition at line 995 of file config.cpp.

References add_child_at(), check_valid(), child(), child_range(), children_, diff_track_attribute, error(), i, utf8::index(), lexical_cast(), remove_child(), and values_.

Referenced by gui2::dialogs::mp_join_game::network_handler(), and mp::lobby_info::process_gamelist_diff().

unsigned config::attribute_count ( ) const

Count the number of non-blank attributes.

Definition at line 388 of file config.cpp.

References values_.

Referenced by intf_remove_modifications().

config::const_attr_itors config::attribute_range ( ) const
config::attr_itors config::attribute_range ( )

Definition at line 750 of file config.cpp.

References check_valid(), and values_.

void config::check_valid ( ) const
private
void config::check_valid ( const config cfg) const
private

Raises an exception if this or cfg is not valid.

Definition at line 119 of file config.cpp.

References error().

config & config::child ( config_key_type  key,
int  n = 0 
)

Returns the nth child with the given key, or a reference to an invalid config if there is none.

Note
A negative n accesses from the end of the object. For instance, -1 is the index of the last child.

Definition at line 400 of file config.cpp.

References check_valid(), children_, DBG_CF, i, invalid, and n.

Referenced by unit::ability_active(), unit::ability_affects_self(), ai::component_manager::add_component(), unit::add_modification(), theme::add_object(), replay_controller::add_replay_theme(), ai::target_unit_goal::add_targets(), ai::protect_goal::add_targets(), replay_recorder_base::append_config(), unit::apply_builtin_effect(), apply_diff(), attack_type::apply_modification(), synced_context::ask_server_choice(), ai::ai_default_rca::aspect_attacks::aspect_attacks(), BOOST_AUTO_TEST_CASE(), team::build(), replay::build_chat_log(), unit_type::build_created(), unit_type::build_help_index(), gui2::implementation::builder_grid_listbox::builder_grid_listbox(), gui2::implementation::builder_horizontal_listbox::builder_horizontal_listbox(), gui2::implementation::builder_listbox::builder_listbox(), gui2::implementation::builder_matrix::builder_matrix(), gui2::implementation::builder_multi_page::builder_multi_page(), gui2::implementation::builder_panel::builder_panel(), gui2::implementation::builder_scrollbar_panel::builder_scrollbar_panel(), gui2::implementation::builder_size_lock::builder_size_lock(), gui2::implementation::builder_slider::builder_slider(), gui2::implementation::builder_stacked_widget::builder_stacked_widget(), gui2::implementation::builder_toggle_panel::builder_toggle_panel(), campaignd::server::campaigns(), wfl::candidate_action_with_filters::candidate_action_with_filters(), ai::config_value_translator< config >::cfg_to_value(), ai::config_value_translator< terrain_filter >::cfg_to_value(), ai::component_manager::change_component(), mp::check_response(), vconfig::child(), child(), persist_file_context::clear_var(), ai::composite_aspect< T >::composite_aspect(), default_map_generator::config_name(), ng::connect_engine::connect_engine(), savegame::convert_old_saves_1_11_0(), savegame::convert_old_saves_1_13_0(), savegame::convert_old_saves_1_13_1(), savegame::loadgame::copy_era(), actions::undo_list::create_action(), gui2::create_builder_widget(), create_side_engine(), default_map_generator_job::default_generate_map(), addons_client::delete_remote_addon(), do_gameloop(), do_replay_handle(), wb::side_actions::execute_net_cmd(), saved_game::expand_random_scenario(), unit::expire_modifications(), game_lua_kernel::extract_preload_scripts(), savegame::extract_summary_from_config(), gui2::dialogs::mp_join_game::fetch_game_config(), unit_abilities::filter_base_matches(), game_events::wml_event_pump::filter_event(), fix_rename_command(), test_utils::game_config_manager::game_config_manager(), mp::game_info::game_info(), game_state::game_state(), help::generate_contents(), unit_type::get_ability_list(), variable_info_implementation::vi_policy_const::get_child_at(), variable_info_implementation::vi_policy_create::get_child_at(), variable_info_implementation::vi_policy_throw::get_child_at(), ng::flg_manager::get_default_faction(), get_diff(), get_global_variable(), persist_context::get_node(), saved_game::get_replay_starting_pos(), gui2::dialogs::mp_join_game::get_scenario(), persist_file_context::get_var(), campaignd::server::handle_upload(), unit_type::has_ability_by_id(), vconfig::has_child(), game_lua_kernel::impl_current_get(), ai::configuration::init(), ng::create_engine::init_all_levels(), game_config_manager::init_game_config(), mp::initial_level_config(), intf_append_ai(), game_config::load_config(), font::load_font_config(), ng::connect_engine::load_previous_sides_users(), synced_checkup::local_checkup(), pathfind::manager::manager(), wb::move::move(), gui2::dialogs::mp_join_game::network_handler(), ai::target_location_goal::on_create(), ai::formula_ai::on_create(), ai::protect_goal::on_create(), variable_info_implementation::replace_range_h::operator()(), operator<<(), gamemap::overlay(), help::parse_config(), ai::configuration::parse_side_config(), cave_map_generator::cave_map_generator_job::place_chamber(), gui2::dialogs::mp_join_game::post_show(), gui2::dialogs::campaign_difficulty::post_show(), game_events::wml_event_pump::process_event(), mp::lobby_info::process_gamelist(), mp::lobby_info::process_gamelist_diff(), turn_info::process_network_data(), ng::connect_engine::process_network_data(), wb::manager::process_network_data(), gui2::dialogs::mp_lobby::process_network_data(), ng::random_map::random_map(), statistics::stats::read(), unit_formula_manager::read(), wesnothd::ban_manager::read(), gui2::gui_definition::read(), unit_type_data::read_hide_help(), replay_controller::rebuild_replay_theme(), ai::default_recruitment::recruitment_aspect::recruitment_aspect(), actions::undo_list::redo(), refresh_addon_version_info_cache(), display::refresh_report(), remove_children(), addons_client::request_addons_list(), addons_client::request_distribution_terms(), unit_type::resistance_against(), gui2::scrollbar_panel_definition::resolution::resolution(), gui2::vertical_scrollbar_definition::resolution::resolution(), gui2::panel_definition::resolution::resolution(), gui2::progress_bar_definition::resolution::resolution(), gui2::horizontal_scrollbar_definition::resolution::resolution(), gui2::size_lock_definition::resolution::resolution(), gui2::image_definition::resolution::resolution(), gui2::unit_preview_pane_definition::resolution::resolution(), gui2::minimap_definition::resolution::resolution(), gui2::scroll_label_definition::resolution::resolution(), gui2::button_definition::resolution::resolution(), gui2::repeating_button_definition::resolution::resolution(), gui2::menu_button_definition::resolution::resolution(), gui2::label_definition::resolution::resolution(), gui2::stacked_widget_definition::resolution::resolution(), gui2::addon_list_definition::resolution::resolution(), gui2::tree_view_definition::resolution::resolution(), gui2::multimenu_button_definition::resolution::resolution(), gui2::multi_page_definition::resolution::resolution(), gui2::slider_definition::resolution::resolution(), gui2::matrix_definition::resolution::resolution(), gui2::chatbox_definition::resolution::resolution(), gui2::text_box_definition::resolution::resolution(), gui2::listbox_definition::resolution::resolution(), gui2::window_definition::resolution::resolution(), lua_kernel_base::run_lua_tag(), ng::connect_engine::save_reserved_sides_information(), ng::connect_engine::scenario(), user_choice_manager::search_in_replay(), help::section_is_referenced(), campaignd::server::server_info(), unit_type_data::set_config(), saved_game::set_data(), set_global_variable(), game_config_manager::set_unit_data(), ng::side_engine::side_engine(), ng::connect_engine::start_game(), theme::status_item::status_item(), SYNCED_COMMAND_HANDLER_FUNCTION(), help::topic_is_referenced(), gui2::implementation::tree_node::tree_node(), replay::undo_cut(), unit::unit(), addons_client::update_last_error(), addons_client::upload_addon(), gui2::builder_window::window_resolution::window_resolution(), actions::undo::recruit_action::write(), and actions::undo::move_action::write().

const config& config::child ( config_key_type  key,
int  n = 0 
) const
inline

Returns the nth child with the given key, or a reference to an invalid config if there is none.

Note
A negative n accesses from the end of the object. For instance, -1 is the index of the last child.

Definition at line 352 of file config.hpp.

References child(), and n.

config & config::child ( config_key_type  key,
const std::string &  parent 
)

Returns a mandatory child node.

If the child is not found a wml_exception is thrown.

Precondition
parent[0] == '['
parent[parent.size() - 1] == ']'
Parameters
keyThe key of the child item to return.
parentThe section in which the child should reside. This is only used for error reporting.
Returns
The wanted child node.

Definition at line 423 of file config.cpp.

References config_implementation::child().

const config & config::child ( config_key_type  key,
const std::string &  parent 
) const

Returns a mandatory child node.

If the child is not found a wml_exception is thrown.

Precondition
parent[0] == '['
parent[parent.size() - 1] == ']'
Parameters
keyThe key of the child item to return.
parentThe section in which the child should reside. This is only used for error reporting.
Returns
The wanted child node.

Definition at line 428 of file config.cpp.

References config_implementation::child().

unsigned config::child_count ( config_key_type  key) const
config & config::child_or_add ( config_key_type  key)
const config & config::child_or_empty ( config_key_type  key) const
config::child_itors config::child_range ( config_key_type  key)

Definition at line 343 of file config.cpp.

References check_valid(), children_, dummy, i, and p.

Referenced by unit::ability_active(), unit::ability_affects_adjacent(), unit_type_data::add_advancement(), gui2::dialogs::campaign_selection::add_campaign_to_tree(), game_config::add_color_info(), replay::add_config(), terrain_builder::add_images_from_config(), unit::add_modification(), theme::add_object(), unit_type::advancements(), ai::holder::append_ai(), append_children(), append_children_by_move(), replay_recorder_base::append_config(), unit::apply_builtin_effect(), apply_diff(), unit::apply_modifications(), unit_type::attacks(), editor::brush::brush(), team::build(), unit_type::build_help_index(), unit_type_data::build_unit_type(), gui2::builder_grid::builder_grid(), gui2::implementation::builder_menu_button::builder_menu_button(), gui2::implementation::builder_multi_page::builder_multi_page(), gui2::implementation::builder_multimenu_button::builder_multimenu_button(), gui2::implementation::builder_slider::builder_slider(), gui2::implementation::builder_stacked_widget::builder_stacked_widget(), gui2::implementation::builder_tree_view::builder_tree_view(), saved_game::cancel_orders(), carryover::carryover(), carryover_info::carryover_info(), vconfig::child(), schema_validation::class_tag::class_tag(), clear_diff_track(), ai::composite_aspect< T >::composite_aspect(), ng::connect_engine::connect_engine(), savegame::convert_old_saves_1_11_0(), savegame::convert_old_saves_1_13_1(), default_map_generator_job::default_generate_map(), gui2::dialogs::mp_options_helper::display_custom_options(), gui2::dialogs::game_load::display_savegame(), events::console_handler::do_choose_level(), do_gameloop(), unit_type::events(), gui2::dialogs::sp_options_configure::execute(), wb::side_actions::execute_net_cmd(), saved_game::expand_mp_events(), saved_game::expand_mp_options(), expand_partialresolution(), saved_game::expand_random_scenario(), ai::configuration::expand_simplified_aspects(), game_lua_kernel::extract_preload_scripts(), savegame::extract_summary_from_config(), gui2::dialogs::mp_join_game::fetch_game_config(), campaignd::find_translations(), savegame::save_index_class::fix_leader_image_path(), ng::flg_manager::flg_manager(), mp::game_info::game_info(), cave_map_generator::cave_map_generator_job::generate_chambers(), help::generate_contents(), help::generate_era_sections(), help::generate_faction_topics(), gui2::dialogs::mp_join_game::generate_side_list(), unit::generate_traits(), help::generate_weapon_special_topics(), unit::get_abilities(), unit::get_ability_bool(), get_checksum(), ai::default_recruitment::recruitment::get_most_important_job(), gui2::dialogs::addon_manager::get_name_filter_visibility(), get_resolution(), ng::side_engine::get_side_children(), attack_type::get_specials(), unit::get_traits_list(), wfl::config_callable::get_value(), campaignd::server::handle_delete(), campaignd::server::handle_request_campaign_list(), unit::has_ability_type(), vconfig::has_child(), game_lua_kernel::impl_game_config_get(), impl_music_get(), ai::configuration::init(), game_state::init(), ai::holder::init(), ng::create_engine::init_all_levels(), editor::editor_toolkit::init_brushes(), ng::create_engine::init_extras(), editor::context_manager::init_map_generators(), editor::editor_controller::init_music(), init_strings(), init_textdomains(), editor::editor_controller::init_tods(), game_lua_kernel::initialize(), intf_remove_modifications(), team_builder::leader(), ai::default_recruitment::recruitment::limit_ok(), terrain_type_data::list(), gui2::tip_of_the_day::load(), preferences::load_acquaintances(), wesnothd::server::load_config(), wesnothd::ban_manager::load_config(), game_config::load_config(), font::load_font_config(), savegame::loadgame::load_game(), game_config_manager::load_game_config(), hotkey::load_hotkeys(), load_language_list(), saved_game::load_mod(), gui2::styled_widget_definition::load_resolutions(), editor::map_context::load_scenario(), gui2::load_settings(), preferences::manager::manager(), terrain_type_data::map(), ng::campaign::mark_if_completed(), matches(), movetype::merge(), merge_children(), merge_children_by_attribute(), unit_type::modification_advancements(), unit::modification_count(), theme::modify(), wb::move::move(), mp_game_settings::mp_game_settings(), unit_type::musthave_status(), gui2::dialogs::mp_join_game::network_handler(), ng::side_engine::new_config(), ai::ai_default_rca::candidate_action_evaluation_loop::on_create(), ai::ai_composite::on_create(), ai::formula_ai::on_create(), ai::readonly_context_impl::on_readonly_context_create(), terrain_builder::parse_config(), gui2::parse_linked_group_definitions(), gui2::implementation::parse_list_data(), ai::configuration::parse_side_config(), time_of_day::parse_times(), unit_animation::particle::particle(), game_state::place_sides_in_preferred_locations(), playsingle_controller::play_scenario(), unit_type::possible_traits(), gui2::dialogs::preferences_dialog::post_build(), gui2::dialogs::unit_advance::pre_show(), gui2::dialogs::end_credits::pre_show(), gui2::dialogs::help_browser::pre_show(), gui2::dialogs::campaign_difficulty::pre_show(), prepare_animation(), team_builder::prepare_units(), mp::lobby_info::process_gamelist(), mp::lobby_info::process_gamelist_diff(), wb::manager::process_network_data(), mp::room_info::process_room_members(), mp::lobby_info::process_userlist(), map_labels::read(), preproc_define::read(), actions::undo_list::read(), addon_info::read(), wesnothd::ban_manager::read(), gui2::gui_definition::read(), gui2::builder_window::read(), read_addons_list(), read_battle_result_map(), schema_validation::schema_validator::read_config_file(), actions::undo_action::read_event_vector(), game_events::manager::read_scenario(), statistics::read_stats(), ai::default_recruitment::recruitment_aspect::recruitment_aspect(), replay::redo(), display::refresh_report(), gui2::toggle_button_definition::resolution::resolution(), gui2::toggle_panel_definition::resolution::resolution(), help::section_is_referenced(), preferences::server_list(), about::set_about(), unit_type_data::set_config(), saved_game::set_data(), saved_game::set_defaults(), theme::set_known_themes(), game_events::wmi_manager::set_menu_items(), game_config_manager::set_multiplayer_hashes(), filesystem::binary_paths_manager::set_paths(), theme::set_resolution(), ng::scenario::set_sides(), editor::item_palette::setup(), editor::terrain_palette::setup(), savegame::loadgame::show_difficulty_dialog(), attack_type::special_active(), gui2::styled_widget_definition::styled_widget_definition(), help::topic_is_referenced(), unit_type_data::traits(), unarchive_dir(), saved_game::unify_controllers(), unit::unit(), unit_animation::unit_animation(), ng::flg_manager::update_available_genders(), gui2::dialogs::mp_options_helper::update_options_data_map_menu_button(), desktop::user_bookmarks(), verify(), ng::configure_engine::write_parameters(), and scoped_wml_variable::~scoped_wml_variable().

config::const_child_itors config::child_range ( config_key_type  key) const

Definition at line 357 of file config.cpp.

References check_valid(), children_, dummy, i, and p.

void config::clear ( )
void config::clear_all_children ( )

Definition at line 798 of file config.cpp.

References children_, and ordered_children.

void config::clear_attibutes ( )

Definition at line 805 of file config.cpp.

References values_.

template<typename... T>
void config::clear_children ( T...  keys)
inline
void config::clear_children_impl ( config_key_type  key)

Definition at line 541 of file config.cpp.

References check_valid(), children_, i, and ordered_children.

Referenced by clear_children(), merge_children(), and merge_children_by_attribute().

void config::clear_diff_track ( const config diff)

Clear any tracking info from a previous apply_diff call with tracking.

This also removes the nodes that are to be deleted, in effect making apply_diff(c, true); clear_diff_tracking(c); equivalent to apply_diff(c, false);

Definition at line 1058 of file config.cpp.

References child_range(), children_, diff_track_attribute, error(), i, utf8::index(), lexical_cast(), p, remove_attribute(), and remove_child().

Referenced by mp::lobby_info::process_gamelist_diff().

std::string config::debug ( ) const
bool config::empty ( ) const

Definition at line 811 of file config.cpp.

References check_valid(), children_, and values_.

Referenced by unit::add_modification(), hotkey::add_wml_hotkey(), BOOST_AUTO_TEST_CASE(), unit_type::build_unit_cfg(), gui2::implementation::builder_drawing::builder_drawing(), ng::campaign::can_launch_game(), persist_file_context::clear_var(), replay_network_sender::commit_and_sync(), ng::connect_engine::connect_engine(), savegame::convert_old_saves_1_11_0(), savegame::convert_old_saves_1_13_0(), default_map_generator_job::default_generate_map(), gui2::dialogs::story_viewer::display_part(), gui2::dialogs::game_load::display_savegame(), unit_abilities::effect::effect(), vconfig::empty(), movetype::terrain_info::data::empty(), unit_filter::empty(), gui2::dialogs::mp_lobby::enter_game(), ai::ai_default_rca::move_leader_to_goals_phase::evaluate(), gui2::dialogs::sp_options_configure::execute(), savegame::extract_summary_from_config(), unit_filter_impl::unit_filter_compound::fill(), game_events::wml_menu_item::finish_handler(), campaignd::format_addon_feedback_url(), gui2::dialogs::generate_difficulty_config(), get_heal_sound(), saved_game::get_replay_starting_pos(), campaignd::server::handle_request_campaign_list(), game_events::wml_menu_item::init_handler(), game_lua_kernel::initialize(), game_lua_kernel::intf_get_sound_source(), game_config_manager::load_addons_cfg(), wesnothd::server::load_config(), game_config_manager::load_game_config_with_loadscreen(), synced_checkup::local_checkup(), ignored_checkup::local_checkup(), mp_debug_checkup::local_checkup(), ng::side_engine::new_config(), unit_animation::particle::particle(), playsingle_controller::play_scenario(), playsingle_controller::play_scenario_init(), gui2::dialogs::faction_select::pre_show(), playturn_network_adapter::read(), read_config(), playturn_network_adapter::read_from_network(), savegame::read_save_file(), display::refresh_report(), hotkey::reset_default_hotkeys(), persist_file_context::save_context(), wb::manager::send_network_data(), about::set_about(), lua_gui2::show_message_dialog(), ng::side_engine::side_engine(), replay_network_sender::sync_non_undoable(), saved_game::to_config(), ai::aspect_attacks_lua::to_config(), game_events::wml_menu_item::to_config(), ai::lua_aspect< T >::to_config(), carryover_info::transfer_all_to(), replay::undo_cut(), ng::connect_engine::update_and_send_diff(), game_events::wml_menu_item::update_command(), gui2::dialogs::mp_create_game::update_details(), valid_id(), team::team_info::write(), movetype::terrain_info::data::write(), and saved_game::write_config().

config & config::find_child ( config_key_type  key,
const std::string &  name,
const std::string &  value 
)
const config& config::find_child ( config_key_type  key,
const std::string &  name,
const std::string &  value 
) const
inline

Definition at line 501 of file config.hpp.

References find_child().

const config::attribute_value * config::get ( config_key_type  key) const
config config::get_diff ( const config c) const

A function to get the differences between this object, and 'c', as another config object.

I.e. calling cfg2.apply_diff(cfg1.get_diff(cfg2)) will make cfg2 identical to cfg1.

Definition at line 874 of file config.cpp.

References check_valid().

Referenced by get_diff(), and ng::connect_engine::update_and_send_diff().

void config::get_diff ( const config c,
config res 
) const

Definition at line 883 of file config.cpp.

References a, add_child(), b, check_valid(), child(), children_, dummy, get_diff(), and values_.

const config::attribute_value & config::get_old_attribute ( config_key_type  key,
const std::string &  old_key,
const std::string &  msg = "" 
) const

Function to handle backward compatibility Get the value of key and if missing try old_key and log msg as a WML error (if not empty)

Definition at line 692 of file config.cpp.

References check_valid(), i, wfl::msg(), values_, and lg::wml_error().

Referenced by default_map_generator_job::default_generate_map().

bool config::has_attribute ( config_key_type  key) const

Definition at line 196 of file config.cpp.

References check_valid(), and values_.

Referenced by name_generator_factory::add_name_generator_from_config(), ai::aspect_attacks_lua::aspect_attacks_lua(), storyscreen::background_layer::background_layer(), gui2::implementation::builder_addon_list::builder_addon_list(), ng::campaign::campaign(), mp::game_info::check_addon_version_compatibility(), schema_validation::class_key::class_key(), schema_validation::class_tag::class_tag(), persist_file_context::clear_var(), default_map_generator_job::default_generate_map(), ai::engine_lua::do_parse_candidate_action_from_config(), ai::configuration::expand_simplified_aspects(), savegame::extract_summary_from_config(), gui2::dialogs::mp_join_game::fetch_game_config(), unit_creator::find_location(), frame_builder::frame_builder(), mp::game_info::game_info(), get_addon_tracking_info(), ai::engine_lua::get_engine_code(), wfl::config_callable::get_value(), ai::vector_property_handler< T >::handle_change(), ai::aspect_property_handler< T >::handle_change(), team::team_info::handle_legacy_share_vision(), vconfig::has_attribute(), ng::create_engine::init_generated_level_data(), theme::label::label(), game_config::load_config(), ai::lua_aspect< T >::lua_aspect(), ai::lua_candidate_action_wrapper_external::lua_candidate_action_wrapper_external(), ai::lua_goal::lua_goal(), lua_map_generator::lua_map_generator(), ai::target_location_goal::on_create(), gui2::dialogs::mp_lobby::pre_show(), ng::random_map::random_map(), wesnothd::banned::read(), team::team_info::read(), playturn_network_adapter::read_from_network(), unit_type_data::set_config(), persist_file_context::set_var(), lua_gui2::show_message_dialog(), theme::status_item::status_item(), font::subset_descriptor::subset_descriptor(), pathfind::teleport_group::teleport_group(), carryover_info::transfer_all_to(), carryover_info::transfer_to(), and write_str_int_map().

bool config::has_child ( config_key_type  key) const

Determine whether a config has a child or not.

Parameters
keyThe key of the child to find.
Returns
Whether a child is available.

Definition at line 393 of file config.cpp.

References check_valid(), and children_.

Referenced by unit_type::add_advancement(), replay::add_chat_message_location(), replay::add_start_if_not_there_yet(), unit::apply_builtin_effect(), unit::apply_modifications(), synced_context::ask_server_choice(), gui2::implementation::builder_grid_listbox::builder_grid_listbox(), gui2::implementation::builder_horizontal_listbox::builder_horizontal_listbox(), gui2::implementation::builder_listbox::builder_listbox(), gui2::implementation::builder_size_lock::builder_size_lock(), gui2::implementation::builder_stacked_widget::builder_stacked_widget(), persist_file_context::clear_var(), savegame::convert_old_saves_1_11_0(), savegame::convert_old_saves_1_13_0(), ng::create_engine::current_level_has_side_data(), default_map_generator_job::default_generate_map(), gui2::dialogs::mp_options_helper::display_custom_options(), do_replay_handle(), ai::configuration::expand_simplified_aspects(), savegame::extract_summary_from_config(), persist_context::get_node(), wfl::config_callable::get_value(), persist_file_context::get_var(), editor::editor_controller::init_music(), intf_append_ai(), gui2::dialogs::mp_join_game::network_handler(), gui2::dialogs::parse_about_tag(), ai::configuration::parse_side_config(), turn_info::process_network_data(), ng::random_map::random_map(), ai::default_recruitment::recruitment_aspect::recruitment_aspect(), user_choice_manager::search_in_replay(), unit_type_data::set_config(), carryover_info::transfer_to(), unit::unit(), and desktop::user_bookmarks().

bool config::has_old_attribute ( config_key_type  key,
const std::string &  old_key,
const std::string &  msg = "" 
) const

Function to handle backward compatibility Check if has key or old_key and log msg as a WML error (if not empty)

Definition at line 202 of file config.cpp.

References check_valid(), wfl::msg(), values_, and lg::wml_error().

std::string config::hash ( ) const
void config::inherit_from ( const config c)

Merge config 'c' into this config, preserving this config's values.

Definition at line 1147 of file config.cpp.

References merge_with(), and swap().

template<typename T >
void config::insert ( config_key_type  key,
T &&  value 
)
inline

Returns a reference to the first child with the given key.

Creates the child if it does not yet exist. Inserts an attribute into the config

Parameters
keyThe name of the attribute
valueThe attribute value

Definition at line 467 of file config.hpp.

References operator[]().

Referenced by detail::config_construct_unpacker< K, V, Rest...>::visit().

bool config::matches ( const config filter) const

Definition at line 1156 of file config.cpp.

References all_children_range(), attribute_range(), check_valid(), child_range(), and i.

Referenced by intf_wml_matches_filter().

void config::merge_attributes ( const config cfg)

Definition at line 715 of file config.cpp.

References check_valid(), and values_.

Referenced by do_resolve_rects(), expand_partialresolution(), and merge_with().

void config::merge_children ( const std::string &  key)

All children with the given key will be merged into the first element with that key.

Definition at line 306 of file config.cpp.

References add_child(), append(), check_valid(), child_count(), child_range(), and clear_children_impl().

Referenced by test_utils::game_config_manager::game_config_manager(), and game_config_manager::set_unit_data().

void config::merge_children_by_attribute ( const std::string &  key,
const std::string &  attribute 
)

All children with the given key and with equal values of the specified attribute will be merged into the element with that key and that value of the attribute.

Definition at line 323 of file config.cpp.

References add_child(), check_valid(), child_count(), child_range(), clear_children_impl(), and i.

Referenced by ai::configuration::parse_side_config().

void config::merge_with ( const config c)
config::operator bool ( ) const
inlineexplicit

Definition at line 138 of file config.hpp.

References invalid.

config & config::operator= ( const config cfg)

Definition at line 154 of file config.cpp.

References swap().

config & config::operator= ( config &&  cfg)

Definition at line 172 of file config.cpp.

References clear(), and swap().

config::attribute_value & config::operator[] ( config_key_type  key)

Returns a reference to the attribute with the given key.

Creates it if it does not exist.

Definition at line 679 of file config.cpp.

References check_valid(), and values_.

Referenced by insert(), and operator[]().

const config::attribute_value & config::operator[] ( config_key_type  key) const

Returns a reference to the attribute with the given key or to a dummy empty attribute if it does not exist.

Definition at line 659 of file config.cpp.

References check_valid(), i, and values_.

attribute_value& config::operator[] ( const char *  key)
inline

Returns a reference to the attribute with the given key.

Creates it if it does not exist.

Definition at line 430 of file config.hpp.

References operator[]().

const attribute_value& config::operator[] ( const char *  key) const
inline

Returns a reference to the attribute with the given key or to a dummy empty attribute if it does not exist.

Definition at line 439 of file config.hpp.

References operator[]().

config::const_all_children_iterator config::ordered_begin ( ) const
config::all_children_iterator config::ordered_begin ( )

Definition at line 856 of file config.cpp.

References ordered_children.

config::const_all_children_iterator config::ordered_cbegin ( ) const

Definition at line 833 of file config.cpp.

References ordered_children.

config::const_all_children_iterator config::ordered_cend ( ) const

Definition at line 843 of file config.cpp.

References ordered_children.

config::const_all_children_iterator config::ordered_end ( ) const
config::all_children_iterator config::ordered_end ( )

Definition at line 861 of file config.cpp.

References ordered_children.

void config::recursive_clear_value ( config_key_type  key)

Definition at line 582 of file config.cpp.

References check_valid(), children_, p, and values_.

Referenced by get_checksum().

void config::remove_attribute ( config_key_type  key)
template<typename... T>
void config::remove_attributes ( T...  keys)
inline

Definition at line 485 of file config.hpp.

References remove_attribute().

Referenced by carryover::carryover(), create_side_engine(), and ng::side_engine::new_config().

void config::remove_child ( config_key_type  key,
unsigned  index 
)
std::vector< config::child_pos >::iterator config::remove_child ( const child_map::iterator &  l,
unsigned  pos 
)
private

Removes the child at position pos of l.

Definition at line 595 of file config.cpp.

References utf8::index(), ordered_children, and p.

void config::remove_children ( config_key_type  key,
std::function< bool(const config &)>  p 
)

Removes all children with tag key for which p returns true.

Definition at line 637 of file config.cpp.

References check_valid(), child(), children_, utf8::index(), p, and remove_child().

void config::splice_children ( config src,
const std::string &  key 
)

Moves all the children with tag key from src to this.

Definition at line 556 of file config.cpp.

References check_valid(), children_, and ordered_children.

Referenced by game_config_manager::load_game_config(), and game_lua_kernel::save_game().

void config::swap ( config cfg)
bool config::valid_id ( config_key_type  id)
static

Friends And Related Function Documentation

friend struct config_implementation
friend

Definition at line 96 of file config.hpp.

bool operator== ( const config a,
const config b 
)
friend

Definition at line 1306 of file config.cpp.

Member Data Documentation

child_map config::children_
private
const char * config::diff_track_attribute = "__diff_track"
static

The name of the attribute used for tracking diff changes.

Definition at line 687 of file config.hpp.

Referenced by apply_diff(), clear_diff_track(), and mp::lobby_info::process_gamelist_diff().

config config::invalid
staticprivate

Definition at line 98 of file config.hpp.

Referenced by child(), find_child(), and operator bool().

std::vector<child_pos> config::ordered_children
private
attribute_map config::values_
private

The documentation for this class was generated from the following files: