The Battle for Wesnoth  1.19.5+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  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_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 &)=delete
 
nodeoperator= (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

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

Detailed Description

Definition at line 113 of file simple_wml.hpp.

Member Typedef Documentation

◆ attribute_list

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

Definition at line 192 of file simple_wml.hpp.

◆ child_list

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

Definition at line 125 of file simple_wml.hpp.

◆ child_map

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

Definition at line 198 of file simple_wml.hpp.

◆ child_pair

Definition at line 197 of file simple_wml.hpp.

Member Enumeration Documentation

◆ CACHE_STATUS

Enumerator
REFRESH_CACHE 
DO_NOT_MODIFY_CACHE 

Definition at line 163 of file simple_wml.hpp.

Constructor & Destructor Documentation

◆ node() [1/3]

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

Definition at line 208 of file simple_wml.cpp.

Referenced by add_child(), 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 365 of file simple_wml.cpp.

References children_, and i.

◆ node() [3/3]

simple_wml::node::node ( const node )
privatedelete

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 573 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 620 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::iterator simple_wml::node::find_in_map ( child_map m,
const string_span attr 
)
staticprivate

Definition at line 676 of file simple_wml.cpp.

References attr(), and i.

◆ find_in_map() [2/2]

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

Definition at line 664 of file simple_wml.cpp.

References attr(), and i.

Referenced by apply_diff(), and remove_child().

◆ first_child()

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

Definition at line 688 of file simple_wml.cpp.

References children_.

◆ get_children() [1/2]

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

Definition at line 647 of file simple_wml.cpp.

References get_children().

◆ get_children() [2/2]

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

Definition at line 652 of file simple_wml.cpp.

References children_, and i.

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

◆ has_attr()

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().

◆ insert_ordered_child()

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

Definition at line 505 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 546 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 926 of file simple_wml.cpp.

References attr_, children_, and i.

◆ nchildren()

int simple_wml::node::nchildren ( ) const

Definition at line 913 of file simple_wml.cpp.

References children_, and i.

◆ no_children()

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

Definition at line 170 of file simple_wml.hpp.

References children_.

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

◆ one_child()

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

Definition at line 171 of file simple_wml.hpp.

References children_.

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

◆ operator=()

node& simple_wml::node::operator= ( const node )
privatedelete

◆ operator[]()

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

Definition at line 392 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 527 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 556 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 938 of file simple_wml.cpp.

References n.

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

◆ set_doc()

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

Definition at line 902 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 190 of file simple_wml.hpp.

Referenced by add_child(), add_child_at(), apply_diff(), 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 225 of file simple_wml.hpp.

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

◆ parent_

node* simple_wml::node::parent_
private

Definition at line 195 of file simple_wml.hpp.


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