#include <simple_wml.hpp>
Classes | |
struct | attribute |
struct | node_pos |
Public Types | |
enum | CACHE_STATUS { REFRESH_CACHE , DO_NOT_MODIFY_CACHE } |
typedef std::vector< node * > | child_list |
Public Member Functions | |
node (document &doc, node *parent) | |
node (document &doc, node *parent, const char **str, int depth=0) | |
~node () | |
const string_span & | operator[] (const char *key) const |
const string_span & | attr (const char *key) const |
bool | has_attr (const char *key) const |
node & | set_attr (const char *key, const char *value) |
node & | set_attr_dup (const char *key, const char *value) |
node & | set_attr_dup (const char *key, const string_span &value) |
node & | set_attr_int (const char *key, int value) |
node & | add_child (const char *name) |
node & | add_child_at (const char *name, std::size_t index) |
void | remove_child (const char *name, std::size_t index) |
void | remove_child (const string_span &name, std::size_t index) |
node * | child (const char *name) |
const node * | child (const char *name) const |
node & | child_or_add (const char *name) |
const child_list & | children (const char *name) const |
const string_span & | first_child () const |
bool | is_dirty () const |
int | output_size () const |
void | output (char *&buf, CACHE_STATUS status=DO_NOT_MODIFY_CACHE) |
void | copy_into (node &n) const |
bool | no_children () const |
bool | one_child () const |
void | apply_diff (const node &diff) |
void | set_doc (document *doc) |
int | nchildren () const |
int | nattributes_recursive () const |
Private Types | |
typedef std::vector< attribute > | attribute_list |
typedef std::pair< string_span, child_list > | child_pair |
typedef std::vector< child_pair > | child_map |
Private Member Functions | |
node (const node &)=delete | |
node & | operator= (const node &)=delete |
int | get_children (const string_span &name) |
int | get_children (const char *name) |
void | set_dirty () |
void | shift_buffers (ptrdiff_t offset) |
void | insert_ordered_child (int child_map_index, int child_list_index) |
void | remove_ordered_child (int child_map_index, int child_list_index) |
void | insert_ordered_child_list (int child_map_index) |
void | remove_ordered_child_list (int child_map_index) |
void | check_ordered_children () const |
Static Private Member Functions | |
static child_map::const_iterator | find_in_map (const child_map &m, const string_span &attr) |
static child_map::iterator | find_in_map (child_map &m, const string_span &attr) |
Private Attributes | |
document * | doc_ |
attribute_list | attr_ |
node * | parent_ |
child_map | children_ |
std::vector< node_pos > | ordered_children_ |
string_span | output_cache_ |
Definition at line 113 of file simple_wml.hpp.
|
private |
Definition at line 194 of file simple_wml.hpp.
typedef std::vector<node*> simple_wml::node::child_list |
Definition at line 125 of file simple_wml.hpp.
|
private |
Definition at line 200 of file simple_wml.hpp.
|
private |
Definition at line 199 of file simple_wml.hpp.
Enumerator | |
---|---|
REFRESH_CACHE | |
DO_NOT_MODIFY_CACHE |
Definition at line 165 of file simple_wml.hpp.
Definition at line 208 of file simple_wml.cpp.
Referenced by add_child(), and node().
Definition at line 222 of file simple_wml.cpp.
References attr_, check_ordered_children(), children_, ERR_SWML, get_children(), node(), ordered_children_, output_cache_, and s.
simple_wml::node::~node | ( | ) |
Definition at line 365 of file simple_wml.cpp.
|
privatedelete |
node & simple_wml::node::add_child | ( | const char * | name | ) |
Definition at line 466 of file simple_wml.cpp.
References check_ordered_children(), children_, doc_, get_children(), node(), ordered_children_, and set_dirty().
Referenced by wesnothd::game::add_player(), server_base::async_send_error(), server_base::async_send_warning(), wesnothd::game::change_controller_type(), child_or_add(), wesnothd::game::handle_controller_choice(), wesnothd::server::handle_message(), wesnothd::server::handle_player_in_game(), wesnothd::game::handle_random_choice(), wesnothd::server::handle_whisper(), wesnothd::game::load_next_scenario(), wesnothd::server::login_client(), wesnothd::make_add_diff(), wesnothd::make_change_diff(), wesnothd::make_delete_diff(), wesnothd::game::notify_new_host(), wesnothd::game::process_turn(), wesnothd::game::remove_player(), campaignd::server::send_error(), campaignd::server::send_message(), wesnothd::game::send_observerjoins(), wesnothd::game::send_observerquit(), wesnothd::server::send_password_request(), wesnothd::game::send_server_message(), wesnothd::game::send_user_list(), and wesnothd::game::transfer_side_control().
node & simple_wml::node::add_child_at | ( | const char * | name, |
std::size_t | index | ||
) |
Definition at line 447 of file simple_wml.cpp.
References check_ordered_children(), children_, doc_, get_children(), utf8::index(), insert_ordered_child(), and set_dirty().
Referenced by apply_diff(), wesnothd::server::dummy_player_updates(), wesnothd::server::handle_player_in_game(), and wesnothd::server::load_config().
void simple_wml::node::apply_diff | ( | const node & | diff | ) |
Definition at line 842 of file simple_wml.cpp.
References add_child_at(), attr_, child(), children(), children_, doc_, simple_wml::string_span::duplicate(), find_in_map(), i, utf8::index(), remove_child(), set_attr(), set_dirty(), and simple_wml::document::take_ownership_of_buffer().
|
inline |
Definition at line 128 of file simple_wml.hpp.
Referenced by find_in_map(), wesnothd::server::handle_player_in_game(), wesnothd::game::is_legal_command(), and output().
|
private |
Definition at line 573 of file simple_wml.cpp.
References children_, i, n, and ordered_children_.
Referenced by add_child(), add_child_at(), node(), and output_size().
node * simple_wml::node::child | ( | const char * | name | ) |
Definition at line 608 of file simple_wml.cpp.
Referenced by apply_diff(), BOOST_AUTO_TEST_CASE(), simple_wml::document::child(), child_or_add(), wesnothd::get_multiplayer(), wesnothd::server::handle_nickserv(), wesnothd::server::handle_player(), wesnothd::server::handle_player_in_game(), wesnothd::game::is_legal_command(), wesnothd::server::login_client(), wesnothd::game::process_turn(), and wesnothd::game::start_game().
const node * simple_wml::node::child | ( | const char * | name | ) | const |
Definition at line 620 of file simple_wml.cpp.
node & simple_wml::node::child_or_add | ( | const char * | name | ) |
Definition at line 635 of file simple_wml.cpp.
References add_child(), and child().
Referenced by wesnothd::game::describe_slots(), wesnothd::game::process_change_turns_wml(), and wesnothd::game::update_turn_data().
const node::child_list & simple_wml::node::children | ( | const char * | name | ) | const |
Definition at line 643 of file simple_wml.cpp.
Referenced by apply_diff(), simple_wml::document::children(), wesnothd::server::cleanup_game(), wesnothd::server::dummy_player_updates(), wesnothd::game::get_sides_list(), wesnothd::server::handle_player_in_game(), wesnothd::game::process_turn(), and wesnothd::server::remove_player().
void simple_wml::node::copy_into | ( | node & | n | ) | const |
Definition at line 821 of file simple_wml.cpp.
References attr_, children_, i, n, and ordered_children_.
Referenced by wesnothd::server::handle_create_game(), wesnothd::game::load_next_scenario(), wesnothd::game::process_change_turns_wml(), and wesnothd::game::process_turn().
|
staticprivate |
Definition at line 684 of file simple_wml.cpp.
|
staticprivate |
Definition at line 672 of file simple_wml.cpp.
Referenced by apply_diff(), and remove_child().
const string_span & simple_wml::node::first_child | ( | ) | const |
Definition at line 696 of file simple_wml.cpp.
References children_.
|
private |
Definition at line 655 of file simple_wml.cpp.
References get_children().
|
private |
Definition at line 660 of file simple_wml.cpp.
Referenced by add_child(), add_child_at(), get_children(), and node().
bool simple_wml::node::has_attr | ( | const char * | key | ) | const |
Definition at line 405 of file simple_wml.cpp.
References attr_.
Referenced by wesnothd::game::is_legal_command(), and wesnothd::game::is_reload().
|
private |
Definition at line 505 of file simple_wml.cpp.
References i, and ordered_children_.
Referenced by add_child_at().
|
private |
Definition at line 546 of file simple_wml.cpp.
References i, and ordered_children_.
|
inline |
Definition at line 163 of file simple_wml.hpp.
References simple_wml::string_span::is_null(), and output_cache_.
Referenced by simple_wml::document::output(), and simple_wml::document::output_compressed().
int simple_wml::node::nattributes_recursive | ( | ) | const |
Definition at line 934 of file simple_wml.cpp.
int simple_wml::node::nchildren | ( | ) | const |
Definition at line 921 of file simple_wml.cpp.
|
inline |
Definition at line 172 of file simple_wml.hpp.
References children_.
Referenced by wesnothd::game::process_turn().
|
inline |
Definition at line 173 of file simple_wml.hpp.
References children_.
Referenced by wesnothd::game::is_legal_command().
const string_span & simple_wml::node::operator[] | ( | const char * | key | ) | const |
Definition at line 392 of file simple_wml.cpp.
References attr_.
void simple_wml::node::output | ( | char *& | buf, |
CACHE_STATUS | status = DO_NOT_MODIFY_CACHE |
||
) |
Definition at line 752 of file simple_wml.cpp.
References attr(), attr_, simple_wml::string_span::begin(), children_, simple_wml::string_span::empty(), i, ordered_children_, output_cache_, REFRESH_CACHE, shift_buffers(), and simple_wml::string_span::size().
Referenced by simple_wml::node_to_string(), and simple_wml::document::output().
int simple_wml::node::output_size | ( | ) | const |
Definition at line 706 of file simple_wml.cpp.
References attr_, check_ordered_children(), children_, simple_wml::string_span::empty(), i, ordered_children_, output_cache_, and simple_wml::string_span::size().
Referenced by simple_wml::node_to_string(), and simple_wml::document::output().
void simple_wml::node::remove_child | ( | const char * | name, |
std::size_t | index | ||
) |
Definition at line 603 of file simple_wml.cpp.
References utf8::index().
Referenced by apply_diff(), wesnothd::server::cleanup_game(), wesnothd::server::dummy_player_updates(), wesnothd::game::process_turn(), and wesnothd::server::remove_player().
void simple_wml::node::remove_child | ( | const string_span & | name, |
std::size_t | index | ||
) |
Definition at line 479 of file simple_wml.cpp.
References children_, find_in_map(), utf8::index(), remove_ordered_child(), remove_ordered_child_list(), and set_dirty().
|
private |
Definition at line 527 of file simple_wml.cpp.
References i, and ordered_children_.
Referenced by remove_child().
|
private |
Definition at line 556 of file simple_wml.cpp.
References i, and ordered_children_.
Referenced by remove_child().
node & simple_wml::node::set_attr | ( | const char * | key, |
const char * | value | ||
) |
Definition at line 413 of file simple_wml.cpp.
References attr_, and set_dirty().
Referenced by apply_diff(), server_base::async_send_error(), server_base::async_send_warning(), BOOST_AUTO_TEST_CASE(), wesnothd::game::change_controller_type(), wesnothd::game::handle_controller_choice(), wesnothd::server::handle_player_in_game(), wesnothd::game::handle_random_choice(), wesnothd::game::load_next_scenario(), wesnothd::server::login_client(), wesnothd::game::perform_controller_tweaks(), wesnothd::player::player(), wesnothd::game::process_turn(), wesnothd::game::send_server_message(), wesnothd::game::send_user_list(), simple_wml::document::set_attr(), set_attr_dup(), and wesnothd::game::set_description().
node & simple_wml::node::set_attr_dup | ( | const char * | key, |
const char * | value | ||
) |
Definition at line 429 of file simple_wml.cpp.
References doc_, simple_wml::document::dup_string(), and set_attr().
Referenced by wesnothd::game::add_player(), server_base::async_send_error(), server_base::async_send_warning(), wesnothd::game::change_controller_type(), wesnothd::server::delete_game(), wesnothd::server::dummy_player_updates(), wesnothd::game::handle_controller_choice(), wesnothd::server::handle_player_in_game(), wesnothd::game::handle_random_choice(), wesnothd::server::load_config(), wesnothd::server::login_client(), wesnothd::player::player(), wesnothd::game::process_turn(), wesnothd::game::remove_player(), campaignd::server::send_error(), campaignd::server::send_message(), wesnothd::game::send_observerjoins(), wesnothd::game::send_observerquit(), wesnothd::game::send_taken_side(), wesnothd::game::send_user_list(), simple_wml::document::set_attr_dup(), set_attr_int(), wesnothd::game::take_side(), and wesnothd::game::transfer_side_control().
node & simple_wml::node::set_attr_dup | ( | const char * | key, |
const string_span & | value | ||
) |
Definition at line 434 of file simple_wml.cpp.
References doc_, simple_wml::string_span::duplicate(), set_attr(), and simple_wml::document::take_ownership_of_buffer().
node & simple_wml::node::set_attr_int | ( | const char * | key, |
int | value | ||
) |
Definition at line 441 of file simple_wml.cpp.
References set_attr_dup().
Referenced by wesnothd::game::describe_slots(), wesnothd::server::dummy_player_updates(), wesnothd::game::handle_controller_choice(), wesnothd::game::handle_random_choice(), wesnothd::server::load_config(), wesnothd::make_add_diff(), wesnothd::make_change_diff(), wesnothd::make_delete_diff(), wesnothd::player::player(), and wesnothd::game::update_turn_data().
|
private |
Definition at line 946 of file simple_wml.cpp.
References n.
Referenced by add_child(), add_child_at(), apply_diff(), remove_child(), and set_attr().
void simple_wml::node::set_doc | ( | document * | doc | ) |
Definition at line 910 of file simple_wml.cpp.
References children_, doc_, and i.
Referenced by simple_wml::document::swap().
|
private |
Definition at line 732 of file simple_wml.cpp.
References attr_, simple_wml::string_span::begin(), children_, simple_wml::string_span::empty(), i, output_cache_, and simple_wml::string_span::size().
Referenced by output().
|
private |
Definition at line 195 of file simple_wml.hpp.
Referenced by apply_diff(), copy_into(), has_attr(), nattributes_recursive(), node(), operator[](), output(), output_size(), set_attr(), and shift_buffers().
|
private |
Definition at line 204 of file simple_wml.hpp.
Referenced by add_child(), add_child_at(), apply_diff(), check_ordered_children(), child(), children(), copy_into(), first_child(), get_children(), nattributes_recursive(), nchildren(), no_children(), node(), one_child(), output(), output_size(), remove_child(), set_doc(), shift_buffers(), and ~node().
|
private |
Definition at line 192 of file simple_wml.hpp.
Referenced by add_child(), add_child_at(), apply_diff(), set_attr_dup(), and set_doc().
|
private |
Definition at line 218 of file simple_wml.hpp.
Referenced by add_child(), check_ordered_children(), copy_into(), insert_ordered_child(), insert_ordered_child_list(), node(), output(), output_size(), remove_ordered_child(), and remove_ordered_child_list().
|
private |
Definition at line 227 of file simple_wml.hpp.
Referenced by is_dirty(), node(), output(), output_size(), and shift_buffers().
|
private |
Definition at line 197 of file simple_wml.hpp.