The Battle for Wesnoth  1.15.0-dev
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
simple_wml::node Class Reference

#include <simple_wml.hpp>

Classes

struct  node_pos
 

Public Types

enum  CACHE_STATUS { REFRESH_CACHE, DO_NOT_MODIFY_CACHE }
 
typedef std::pair< string_span, string_spanattribute
 
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_spanoperator[] (const char *key) const
 
const string_spanattr (const char *key) const
 
bool has_attr (const char *key) const
 
nodeset_attr (const char *key, const char *value)
 
nodeset_attr_dup (const char *key, const char *value)
 
nodeset_attr_dup (const char *key, const string_span &value)
 
nodeset_attr_int (const char *key, int value)
 
nodeadd_child (const char *name)
 
nodeadd_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)
 
nodechild (const char *name)
 
const nodechild (const char *name) const
 
const child_listchildren (const char *name) const
 
const string_spanfirst_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< attributeattribute_list
 
typedef std::pair< string_span, child_listchild_pair
 
typedef std::vector< child_pairchild_map
 

Private Member Functions

 node (const node &)
 
void operator= (const node &)
 
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

documentdoc_
 
attribute_list attr_
 
nodeparent_
 
child_map children_
 
std::vector< node_posordered_children_
 
string_span output_cache_
 

Detailed Description

Definition at line 112 of file simple_wml.hpp.

Member Typedef Documentation

◆ attribute

Definition at line 119 of file simple_wml.hpp.

◆ attribute_list

typedef std::vector<attribute> simple_wml::node::attribute_list
private

Definition at line 187 of file simple_wml.hpp.

◆ child_list

typedef std::vector<node*> simple_wml::node::child_list

Definition at line 120 of file simple_wml.hpp.

◆ child_map

typedef std::vector<child_pair> simple_wml::node::child_map
private

Definition at line 193 of file simple_wml.hpp.

◆ child_pair

Definition at line 192 of file simple_wml.hpp.

Member Enumeration Documentation

◆ CACHE_STATUS

Enumerator
REFRESH_CACHE 
DO_NOT_MODIFY_CACHE 

Definition at line 158 of file simple_wml.hpp.

Constructor & Destructor Documentation

◆ node() [1/3]

simple_wml::node::node ( document doc,
node parent 
)

Definition at line 206 of file simple_wml.cpp.

Referenced by add_child(), add_child_at(), and node().

◆ node() [2/3]

simple_wml::node::node ( document doc,
node parent,
const char **  str,
int  depth = 0 
)

◆ ~node()

simple_wml::node::~node ( )

Definition at line 363 of file simple_wml.cpp.

References a, b, children_, and i.

◆ node() [3/3]

simple_wml::node::node ( const node )
private

Member Function Documentation

◆ add_child()

node & simple_wml::node::add_child ( const char *  name)

◆ add_child_at()

node & simple_wml::node::add_child_at ( const char *  name,
std::size_t  index 
)

◆ apply_diff()

void simple_wml::node::apply_diff ( const node diff)

◆ attr()

const string_span& simple_wml::node::attr ( const char *  key) const
inline

◆ check_ordered_children()

void simple_wml::node::check_ordered_children ( ) const
private

Definition at line 571 of file simple_wml.cpp.

References children_, i, n, and ordered_children_.

Referenced by add_child(), add_child_at(), node(), and output_size().

◆ child() [1/2]

node * simple_wml::node::child ( const char *  name)

◆ child() [2/2]

const node * simple_wml::node::child ( const char *  name) const

Definition at line 618 of file simple_wml.cpp.

References children_, and i.

◆ children()

const node::child_list & simple_wml::node::children ( const char *  name) const

◆ copy_into()

void simple_wml::node::copy_into ( node n) const

◆ find_in_map() [1/2]

node::child_map::const_iterator simple_wml::node::find_in_map ( const child_map m,
const string_span attr 
)
staticprivate

Definition at line 662 of file simple_wml.cpp.

References i.

Referenced by apply_diff(), and remove_child().

◆ find_in_map() [2/2]

node::child_map::iterator simple_wml::node::find_in_map ( child_map m,
const string_span attr 
)
staticprivate

Definition at line 674 of file simple_wml.cpp.

References i.

◆ first_child()

const string_span & simple_wml::node::first_child ( ) const

Definition at line 686 of file simple_wml.cpp.

References children_.

◆ get_children() [1/2]

int simple_wml::node::get_children ( const string_span name)
private

Definition at line 650 of file simple_wml.cpp.

References children_, and i.

Referenced by add_child(), add_child_at(), get_children(), and node().

◆ get_children() [2/2]

int simple_wml::node::get_children ( const char *  name)
private

Definition at line 645 of file simple_wml.cpp.

References get_children().

◆ has_attr()

bool simple_wml::node::has_attr ( const char *  key) const

Definition at line 403 of file simple_wml.cpp.

References attr_.

Referenced by wesnothd::server::handle_player_in_game(), and wesnothd::game::is_legal_command().

◆ insert_ordered_child()

void simple_wml::node::insert_ordered_child ( int  child_map_index,
int  child_list_index 
)
private

Definition at line 503 of file simple_wml.cpp.

References i, and ordered_children_.

Referenced by add_child_at().

◆ insert_ordered_child_list()

void simple_wml::node::insert_ordered_child_list ( int  child_map_index)
private

Definition at line 544 of file simple_wml.cpp.

References i, and ordered_children_.

◆ is_dirty()

bool simple_wml::node::is_dirty ( ) const
inline

◆ nattributes_recursive()

int simple_wml::node::nattributes_recursive ( ) const

Definition at line 918 of file simple_wml.cpp.

References attr_, children_, and i.

◆ nchildren()

int simple_wml::node::nchildren ( ) const

Definition at line 905 of file simple_wml.cpp.

References children_, and i.

◆ no_children()

bool simple_wml::node::no_children ( ) const
inline

Definition at line 165 of file simple_wml.hpp.

Referenced by wesnothd::game::process_turn().

◆ one_child()

bool simple_wml::node::one_child ( ) const
inline

Definition at line 166 of file simple_wml.hpp.

Referenced by wesnothd::game::is_legal_command().

◆ operator=()

void simple_wml::node::operator= ( const node )
private

◆ operator[]()

const string_span & simple_wml::node::operator[] ( const char *  key) const

Definition at line 390 of file simple_wml.cpp.

References attr_.

◆ output()

void simple_wml::node::output ( char *&  buf,
CACHE_STATUS  status = DO_NOT_MODIFY_CACHE 
)

◆ output_size()

int simple_wml::node::output_size ( ) const

◆ remove_child() [1/2]

void simple_wml::node::remove_child ( const char *  name,
std::size_t  index 
)

◆ remove_child() [2/2]

void simple_wml::node::remove_child ( const string_span name,
std::size_t  index 
)

◆ remove_ordered_child()

void simple_wml::node::remove_ordered_child ( int  child_map_index,
int  child_list_index 
)
private

Definition at line 525 of file simple_wml.cpp.

References i, and ordered_children_.

Referenced by remove_child().

◆ remove_ordered_child_list()

void simple_wml::node::remove_ordered_child_list ( int  child_map_index)
private

Definition at line 554 of file simple_wml.cpp.

References i, and ordered_children_.

Referenced by remove_child().

◆ set_attr()

node & simple_wml::node::set_attr ( const char *  key,
const char *  value 
)

◆ set_attr_dup() [1/2]

node & simple_wml::node::set_attr_dup ( const char *  key,
const char *  value 
)

◆ set_attr_dup() [2/2]

node & simple_wml::node::set_attr_dup ( const char *  key,
const string_span value 
)

◆ set_attr_int()

node & simple_wml::node::set_attr_int ( const char *  key,
int  value 
)

◆ set_dirty()

void simple_wml::node::set_dirty ( )
private

Definition at line 930 of file simple_wml.cpp.

References n.

Referenced by add_child(), add_child_at(), apply_diff(), copy_into(), remove_child(), and set_attr().

◆ set_doc()

void simple_wml::node::set_doc ( document doc)

Definition at line 894 of file simple_wml.cpp.

References children_, doc_, and i.

Referenced by simple_wml::document::swap().

◆ shift_buffers()

void simple_wml::node::shift_buffers ( ptrdiff_t  offset)
private

Member Data Documentation

◆ attr_

attribute_list simple_wml::node::attr_
private

◆ children_

child_map simple_wml::node::children_
private

◆ doc_

document* simple_wml::node::doc_
private

Definition at line 185 of file simple_wml.hpp.

Referenced by add_child(), add_child_at(), apply_diff(), copy_into(), set_attr_dup(), and set_doc().

◆ ordered_children_

std::vector<node_pos> simple_wml::node::ordered_children_
private

◆ output_cache_

string_span simple_wml::node::output_cache_
private

Definition at line 220 of file simple_wml.hpp.

Referenced by node(), output(), output_size(), and shift_buffers().

◆ parent_

node* simple_wml::node::parent_
private

Definition at line 190 of file simple_wml.hpp.


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