config Class Reference

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

#include <config.hpp>

List of all members.

Public Types

typedef std::vector< config * > child_list
typedef std::map< std::string,
child_list
child_map
typedef std::vector< config * >
::iterator 
child_iterator
typedef std::vector< config * >
::const_iterator 
const_child_iterator
typedef std::pair
< child_iterator,
child_iterator
child_itors
typedef std::pair
< const_child_iterator,
const_child_iterator
const_child_itors

Public Member Functions

 config ()
 config (const config &cfg)
 config (const std::string &child)
 ~config ()
configoperator= (const config &cfg)
child_itors child_range (const std::string &key)
const_child_itors child_range (const std::string &key) const
const child_listget_children (const std::string &key) const
const child_mapall_children () const
configchild (const std::string &key)
const configchild (const std::string &key) const
configadd_child (const std::string &key)
configadd_child (const std::string &key, const config &val)
configadd_child_at (const std::string &key, const config &val, size_t index)
t_stringoperator[] (const std::string &key)
const t_stringoperator[] (const std::string &key) const
const t_stringget_attribute (const std::string &key) const
bool has_attribute (const std::string &key) const
configfind_child (const std::string &key, const std::string &name, const t_string &value)
const configfind_child (const std::string &key, const std::string &name, const t_string &value) const
void clear_children (const std::string &key)
void remove_child (const std::string &key, size_t index)
void recursive_clear_value (const std::string &key)
void clear ()
bool empty () const
std::string debug () const
std::string hash () const
all_children_iterator ordered_begin () const
 In-order iteration over all children.
all_children_iterator ordered_end () const
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.
void get_diff (const config &c, config &res) const
void apply_diff (const config &diff)
void merge_with (const config &c)
 Merge config 'c' into this config.
void merge_and_keep (const config &c)
 Merge config 'c' into this config.
bool matches (const config &filter) const
void prune ()
 Removes keys with empty values.
void append (const config &cfg)
 Append data from another config object to this one.
void merge_children (const std::string &key)
 All children with the given key will be merged into the first element with that key.
void reset_translation () const
 Resets the translated values of all strings contained in this object.
void swap (config &cfg)

Public Attributes

string_map values
 All the attributes of this node.

Private Attributes

child_map children
 A list of all children of this node.
std::vector< child_posordered_children

Classes

struct  all_children_iterator
struct  child_pos
struct  error


Detailed Description

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

Definition at line 43 of file config.hpp.


Member Typedef Documentation

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

Definition at line 57 of file config.hpp.

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

Definition at line 58 of file config.hpp.

typedef std::vector<config*>::iterator config::child_iterator

Definition at line 60 of file config.hpp.

typedef std::vector<config*>::const_iterator config::const_child_iterator

Definition at line 61 of file config.hpp.

Definition at line 63 of file config.hpp.

Definition at line 64 of file config.hpp.


Constructor & Destructor Documentation

config::config (  ) 

Definition at line 32 of file config.cpp.

Referenced by add_child(), and add_child_at().

config::config ( const config cfg  ) 

Definition at line 36 of file config.cpp.

References append().

config::config ( const std::string &  child  ) 

Definition at line 41 of file config.cpp.

References add_child().

config::~config (  ) 

Definition at line 46 of file config.cpp.

References clear().


Member Function Documentation

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

Definition at line 51 of file config.cpp.

References append(), and clear().

config::child_itors config::child_range ( const std::string &  key  ) 

config::const_child_itors config::child_range ( const std::string &  key  )  const

Definition at line 103 of file config.cpp.

References children.

const config::child_list & config::get_children ( const std::string &  key  )  const

Definition at line 114 of file config.cpp.

References children.

Referenced by unit::ability_active(), unit::ability_affects_adjacent(), unit_animation::add_anims(), game_config::add_color_info(), terrain_builder::add_images_from_config(), about::add_lines(), theme::add_object(), unit::advance_to(), apply_diff(), unit::apply_modifications(), variable_info::as_container(), ai::avoided_locations(), unit_type::build_full(), check_checksums(), check_names_legal(), replay::commands(), mp::create::create(), cutter::cut_surface(), default_generate_map(), do_replay_handle(), expand_partialresolution(), extract_summary_data_from_save(), extract_summary_from_config(), find_scripts(), ai::find_threats(), find_translations(), game_state::game_state(), mp::ui::gamelist_updated(), gamemap::gamemap(), gamestatus::gamestatus(), cave_map_generator::generate_chambers(), mp::wait::generate_menu(), unit::generate_traits(), unit::get_abilities(), unit::get_ability_bool(), get_checksum(), mp::create::get_parameters(), rng::get_random(), rng::get_random_results(), attack_type::get_special_bool(), attack_type::get_specials(), about::get_text(), get_tip_of_day(), unit_type::has_ability(), unit::has_ability_type(), play_controller::init(), unit::internal_matches_filter(), mp::wait::join_game(), mp::lobby::lobby_sorter::less(), mp::level_to_gamestate(), font::load_font_config(), mp::connect::load_game(), hotkey::load_hotkeys(), cutter::load_masks(), gui2::load_settings(), game_events::manager::manager(), matches(), merge_children(), unit_type::modification_advancements(), unit::modification_advancements(), unit::modification_count(), theme::modify(), gamemap::overlay(), terrain_builder::parse_config(), parse_times(), play_game(), playsingle_controller::play_scenario(), dfool::dfool_ai::play_turn(), unit_type::possible_traits(), mp::create::process_event(), turn_info::process_network_data(), mp::wait::process_network_data(), gui2::twindow_builder::read(), unit::read(), gui2::tgui_definition::read(), map_labels::read(), wesnothd::ban_manager::read(), read_battle_result_map(), read_player(), statistics::read_stats(), unit::remove_temporary_modifications(), preferences::server_list(), about::set_about(), wesnothd::ban_manager::set_default_ban_times(), unit::set_game_context(), mp::gamebrowser::set_game_items(), theme::set_known_themes(), rng::set_random_results(), theme::set_resolution(), show_intro_part(), attack_type::special_active(), mp::wait::start_game(), mp::connect::start_game(), scoped_wml_variable::store(), gui2::tbuilder_grid::tbuilder_grid(), gui2::tbutton_definition::tbutton_definition(), team::team(), team::team_info::team_info(), map_editor::terrain_palette::terrain_palette(), gui2::tlabel_definition::tlabel_definition(), gui2::tlistbox_definition::tlistbox_definition(), gui2::tpanel_definition::tpanel_definition(), gui2::tspacer_definition::tspacer_definition(), gui2::ttext_box_definition::ttext_box_definition(), gui2::ttoggle_button_definition::ttoggle_button_definition(), gui2::ttooltip_definition::ttooltip_definition(), gui2::tvertical_scrollbar_definition::tvertical_scrollbar_definition(), unarchive_dir(), dfool::unit_memory::unit_memory(), variable_info::variable_info(), verify(), events::menu_handler::write_game_snapshot(), and scoped_wml_variable::~scoped_wml_variable().

const config::child_map & config::all_children (  )  const

config * config::child ( const std::string &  key  ) 

Definition at line 127 of file config.cpp.

References children.

Referenced by unit::abilities_affects_adjacent(), unit::ability_active(), unit::ability_affects_self(), unit::ability_tooltips(), replay::add_attack(), replay::add_config(), unit::add_modification(), theme::add_object(), terrain_builder::add_off_map_rule(), apply_diff(), attack_type::apply_modification(), variable_info::as_container(), unit::backup_state(), unit_type::build_full(), unit_type::build_help_index(), mp::check_response(), vconfig::child(), copy_era(), default_map_generator::create_scenario(), cave_map_generator::create_scenario(), mp::connect::current_config(), unit_movement_type::damage_table(), default_generate_map(), unit_movement_type::defense_modifier(), unit::defense_modifier(), do_replay_handle(), extract_summary_data_from_save(), extract_summary_from_config(), attack::fire_event(), upload_log::game_finished(), game_state::game_state(), mp::lobby::gamelist_updated(), cave_map_generator::generate_chambers(), help::generate_contents(), unit::get_abilities(), unit::get_ability_bool(), unit::get_base_resistances(), preferences::get_child(), mp::connect::side::get_config(), rng::get_random_results(), attack_type::get_special_bool(), attack_type::get_specials(), unit_type::has_ability(), unit_type::has_ability_by_id(), unit::has_ability_by_id(), unit::has_ability_type(), vconfig::has_child(), attack_type::has_special_by_id(), hash(), mp::wait::join_game(), mp::lobby::lobby_sorter::less(), mp::level_to_gamestate(), font::load_font_config(), mp::connect::load_game(), ai::move_leader_to_goals(), unit_movement_type::movement_cost(), unit::movement_cost_internal(), map_editor::new_map_dialog(), open_connection(), help::parse_config(), cave_map_generator::place_items(), play_game(), mp::create::process_event(), turn_info::process_network_data(), mp::wait::process_network_data(), mp::ui::process_network_data(), mp::connect::process_network_data(), prune(), statistics::stats::read(), gui2::tgui_definition::read(), replay_controller::rebuild_replay_theme(), unit::remove_ability_by_id(), reset_translation(), unit_movement_type::resistance_against(), unit::resistance_against(), help::section_is_referenced(), help::help_text_area::set_items(), mp::connect::side::side(), attack_type::special_active(), attack_type::special_tooltips(), mp::wait::start_game(), mp::connect::start_game(), theme::status_item::status_item(), gui2::tbuilder_listbox::tbuilder_listbox(), gui2::tbuilder_panel::tbuilder_panel(), help::topic_is_referenced(), gui2::twindow_builder::tresolution::tresolution(), gui2::tvertical_scrollbar_definition::tresolution::tresolution(), gui2::ttooltip_definition::tresolution::tresolution(), gui2::ttoggle_button_definition::tresolution::tresolution(), gui2::ttext_box_definition::tresolution::tresolution(), gui2::tpanel_definition::tresolution::tresolution(), gui2::tlistbox_definition::tresolution::tresolution(), gui2::tlabel_definition::tresolution::tresolution(), gui2::tbutton_definition::tresolution::tresolution(), gui2::tstate_definition::tstate_definition(), replay::undo(), unit::unit_ability_tooltips(), unit_movement_type::unit_movement_type(), variable_info::variable_info(), attack_type::weapon_specials(), wml_menu_item::wml_menu_item(), unit::write(), and write_game().

const config * config::child ( const std::string &  key  )  const

Definition at line 137 of file config.cpp.

References children.

config & config::add_child ( const std::string &  key  ) 

Definition at line 147 of file config.cpp.

References children, config(), and ordered_children.

Referenced by replay::add_advancement(), unit_animation::add_anims(), replay::add_command(), replay::add_config(), replay::add_countdown_update(), replay::add_disband(), replay::add_event(), upload_log::add_game_result(), replay::add_label(), add_license(), unit::add_modification(), terrain_builder::add_off_map_rule(), replay::add_pos(), replay::add_recall(), replay::add_recruit(), replay::add_rename(), replay::add_start(), replay::add_unit_checksum(), replay::add_value(), game_state::add_variable_cfg(), append(), attack_type::apply_modification(), archive_campaign(), archive_dir(), variable_info::as_container(), attack::attack(), unit_type::build_full(), turn_info::change_side_controller(), events::menu_handler::change_side_controller(), replay::clear_labels(), replay_network_sender::commit_and_sync(), commit_wmi_commands(), config(), mp::connect::connect(), construct_error(), construct_message(), copy_era(), default_map_generator::create_scenario(), do_resolve_rects(), events::chat_command_handler::do_whisper(), replay::end_turn(), expand_partialresolution(), find_translations(), attack::fire_event(), help::generate_contents(), unit::generate_traits(), get_checksum(), mp::connect::side::get_config(), replay::get_data_range(), get_diff(), vconfig::get_parsed_config(), rng::get_random(), mp::ui::handle_event(), mp::connect::kick_player(), mp::level_to_gamestate(), mp::connect::load_game(), merge_and_keep(), merge_children(), merge_with(), open_connection(), cave_map_generator::place_items(), play_game(), playsingle_controller::play_scenario(), unit_animation::prepare_animation(), mp::lobby::process_event(), mp::create::process_event(), mp::connect::process_event(), server::process_login(), turn_info::process_network_data(), mp::connect::process_network_data(), read_compressed_internal(), mp::wait::request_snapshot(), unit::reset_modifications(), hotkey::save_hotkeys(), save_summary(), mp::ui::send_chat_message(), events::chat_handler::send_command(), about::set_about(), preferences::set_child(), rng::set_random_results(), replay::set_random_value(), replay::speak(), mp::connect::start_game(), replay_network_sender::sync_non_undoable(), replay::text_input(), unit_movement_type::unit_movement_type(), mp::connect::update_and_send_diff(), mp::connect::update_level(), variable_info::variable_info(), unit::write(), team::write(), team::team_info::write(), statistics::stats::write(), map_labels::write(), gamestatus::write(), wesnothd::ban_manager::write(), dfool::unit_memory::write(), write_battle_result_map(), dfool::unit_memory::write_element(), game_events::write_events(), write_game(), events::menu_handler::write_game_snapshot(), game_display::write_overlays(), write_player(), statistics::write_stats(), and upload_log::~upload_log().

config & config::add_child ( const std::string &  key,
const config val 
)

Definition at line 155 of file config.cpp.

References children, config(), and ordered_children.

config & config::add_child_at ( const std::string &  key,
const config val,
size_t  index 
)

Definition at line 163 of file config.cpp.

References children, config(), ordered_children, and value.

Referenced by unit_animation::add_anims(), and apply_diff().

t_string & config::operator[] ( const std::string &  key  ) 

Definition at line 280 of file config.cpp.

References values.

const t_string & config::operator[] ( const std::string &  key  )  const

Definition at line 285 of file config.cpp.

References get_attribute().

const t_string & config::get_attribute ( const std::string &  key  )  const

bool config::has_attribute ( const std::string &  key  )  const [inline]

Definition at line 81 of file config.hpp.

References values.

Referenced by vconfig::has_attribute(), and variable_info::variable_info().

config * config::find_child ( const std::string &  key,
const std::string &  name,
const t_string value 
)

const config * config::find_child ( const std::string &  key,
const std::string &  name,
const t_string value 
) const

Definition at line 333 of file config.cpp.

References children.

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

void config::remove_child ( const std::string &  key,
size_t  index 
)

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

Definition at line 218 of file config.cpp.

References ordered_begin(), ordered_end(), and values.

Referenced by get_checksum().

void config::clear ( void   ) 

bool config::empty (  )  const

std::string config::debug (  )  const

Definition at line 722 of file config.cpp.

Referenced by do_replay_handle().

std::string config::hash (  )  const

Definition at line 747 of file config.cpp.

References child(), children, utils::portable_isspace(), and values.

Referenced by get_checksum(), get_hash_of(), and mp::connect::load_game().

config::all_children_iterator config::ordered_begin (  )  const

config::all_children_iterator config::ordered_end (  )  const

config::all_children_iterator config::erase ( const all_children_iterator i  ) 

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 cfg1 identical to cfg2.

Definition at line 430 of file config.cpp.

Referenced by get_diff(), and mp::connect::update_and_send_diff().

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

Definition at line 437 of file config.cpp.

References a, add_child(), b, buf, children, get_diff(), and values.

void config::apply_diff ( const config diff  ) 

void config::merge_with ( const config c  ) 

Merge config 'c' into this config.

Overwrites this config's values.

Definition at line 597 of file config.cpp.

References add_child(), children, ordered_children, and values.

Referenced by unit::advance_to(), unit_type::build_full(), mp::connect::side::get_config(), and unit_type_data::unit_type_map_wrapper::set_config().

void config::merge_and_keep ( const config c  ) 

Merge config 'c' into this config.

Keeps this config's values and does not add existing elements. NOTICE: other nonstandard behavior includes no merge recursion into child and has limited merging for child lists of differing lengths

Definition at line 630 of file config.cpp.

References add_child(), children, and values.

bool config::matches ( const config filter  )  const

void config::prune (  ) 

Removes keys with empty values.

Definition at line 691 of file config.cpp.

References child(), children, and values.

Referenced by mp::connect::side::get_config().

void config::append ( const config cfg  ) 

Append data from another config object to this one.

Attributes in the latter config object will clobber attributes in this one.

Definition at line 64 of file config.cpp.

References add_child(), ordered_begin(), ordered_end(), value, and values.

Referenced by unit::add_modification(), config(), mp::connect::side::get_config(), merge_children(), operator=(), unit_animation::prepare_animation(), scoped_wml_variable::store(), team::team_info::team_info(), and unit::write().

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 76 of file config.cpp.

References add_child(), append(), children, clear_children(), and get_children().

void config::reset_translation (  )  const

Resets the translated values of all strings contained in this object.

Definition at line 708 of file config.cpp.

References child(), children, and values.

Referenced by map_editor::change_language().

void config::swap ( config cfg  ) 

Definition at line 808 of file config.cpp.

References children, ordered_children, and values.

Referenced by network_worker_pool::get_received_data().


Member Data Documentation

std::vector<child_pos> config::ordered_children [private]


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

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs