ReactOS  r76032
XMLStorage::XMLPos Struct Reference

iterator for XML trees More...

#include <xmlstorage.h>

Inheritance diagram for XMLStorage::XMLPos:
Collaboration diagram for XMLStorage::XMLPos:

Public Member Functions

 XMLPos (XMLNode *root)
 
 XMLPos (const XMLPos &other)
 
 XMLPos (XMLNode *node, const XS_String &name)
 
 XMLPos (XMLNode *node, const XS_String &name, const XS_String &attr_name, const XS_String &attr_value)
 
 XMLPos (const XMLPos &other, const XS_String &name)
 
 XMLPos (const XMLPos &other, const XS_String &name, const XS_String &attr_name, const XS_String &attr_value)
 
XMLNodecur ()
 access to current node More...
 
const XMLNodecur () const
 
 operator const XMLNode * () const
 automatic access to current node More...
 
 operator XMLNode * ()
 
const XMLNodeoperator-> () const
 
XMLNodeoperator-> ()
 
const XMLNodeoperator* () const
 
XMLNodeoperator* ()
 
XS_String get (const XS_String &attr_name, LPCXSSTR def=XS_EMPTY_STR) const
 attribute access More...
 
void put (const XS_String &attr_name, const XS_String &value)
 attribute setting More...
 
template<typename T >
XS_String get (const T &attr_name) const
 index operator attribute access More...
 
XS_Stringoperator[] (const XS_String &attr_name)
 
const XS_Stringoperator[] (const XS_String &attr_name) const
 
void add_down (XMLNode *child)
 insert children when building tree More...
 
bool back ()
 go back to previous position More...
 
bool go_down ()
 go down to first child More...
 
bool go_down (const XS_String &child_name, int n=0)
 search for child and go down More...
 
bool iterate (const XS_String &child_name, size_t &cnt)
 iterate to the next matching child More...
 
bool go (const XPath &xpath)
 move to the position defined by xpath in XML tree More...
 
bool create_relative (const XPath &xpath)
 create child nodes using XPath notation and move to the deepest child More...
 
void create (const XS_String &name)
 create node and move to it More...
 
void create_node_content (const XS_String &node_name, const XS_String &content)
 create node with string content More...
 
void smart_create (const XS_String &child_name)
 create node if not already existing and move to it More...
 
void smart_create (const XS_String &child_name, const XS_String &attr_name, const XS_String &attr_value)
 search matching child node identified by key name and an attribute value More...
 
int count (const XPath &xpath) const
 count the nodes matching the given relative XPath expression More...
 
int filter (const XPath &xpath, XMLNode &target) const
 create a new node tree using the given XPath filter expression More...
 
bool delete_this ()
 delete current node and go back to previous position More...
 
void remove_children (const XS_String &name)
 remove all children named 'name' More...
 
void erase (const XS_String &attr_name)
 remove the attribute 'attr_name' from the current node More...
 
XS_Stringstr ()
 
const XS_Stringstr () const
 
void set_property (const XS_String &key, int value, const XS_String &name=XS_PROPERTY)
 
void set_property (const XS_String &key, double value, const XS_String &name=XS_PROPERTY)
 
void set_property (const XS_String &key, const XS_String &value, const XS_String &name=XS_PROPERTY)
 
void set_property (const XS_String &key, const struct XMLBool &value, const XS_String &name=XS_PROPERTY)
 
void set_property (const XS_String &key, const char *value, const XS_String &name=XS_PROPERTY)
 

Protected Member Functions

void go_to (XMLNode *child)
 go to specified node More...
 

Protected Attributes

XMLNode_root
 
XMLNode_cur
 
std::stack< XMLNode * > _stack
 

Friends

struct const_XMLPos
 

Detailed Description

iterator for XML trees

Definition at line 1493 of file xmlstorage.h.

Constructor & Destructor Documentation

XMLStorage::XMLPos::XMLPos ( XMLNode root)
inline

Definition at line 1495 of file xmlstorage.h.

1496  : _root(root),
1497  _cur(root)
1498  {
1499  }
XMLStorage::XMLPos::XMLPos ( const XMLPos other)
inline

Definition at line 1501 of file xmlstorage.h.

1502  : _root(other._root),
1503  _cur(other._cur)
1504  { // don't copy _stack
1505  }
int other
Definition: msacm.c:1364
XMLStorage::XMLPos::XMLPos ( XMLNode node,
const XS_String name 
)
inline

Definition at line 1507 of file xmlstorage.h.

1508  : _root(node),
1509  _cur(node)
1510  {
1511  smart_create(name);
1512  }
Definition: graphics.c:176
void smart_create(const XS_String &child_name)
create node if not already existing and move to it
Definition: xmlstorage.h:1657
Definition: name.c:23
XMLStorage::XMLPos::XMLPos ( XMLNode node,
const XS_String name,
const XS_String attr_name,
const XS_String attr_value 
)
inline

Definition at line 1514 of file xmlstorage.h.

1515  : _root(node),
1516  _cur(node)
1517  {
1518  smart_create(name, attr_name, attr_value);
1519  }
Definition: graphics.c:176
void smart_create(const XS_String &child_name)
create node if not already existing and move to it
Definition: xmlstorage.h:1657
Definition: name.c:23
XMLStorage::XMLPos::XMLPos ( const XMLPos other,
const XS_String name 
)
inline

Definition at line 1521 of file xmlstorage.h.

1522  : _root(other._root),
1523  _cur(other._cur)
1524  {
1525  smart_create(name);
1526  }
int other
Definition: msacm.c:1364
void smart_create(const XS_String &child_name)
create node if not already existing and move to it
Definition: xmlstorage.h:1657
Definition: name.c:23
XMLStorage::XMLPos::XMLPos ( const XMLPos other,
const XS_String name,
const XS_String attr_name,
const XS_String attr_value 
)
inline

Definition at line 1528 of file xmlstorage.h.

1529  : _root(other._root),
1530  _cur(other._cur)
1531  {
1532  smart_create(name, attr_name, attr_value);
1533  }
int other
Definition: msacm.c:1364
void smart_create(const XS_String &child_name)
create node if not already existing and move to it
Definition: xmlstorage.h:1657
Definition: name.c:23

Member Function Documentation

void XMLStorage::XMLPos::add_down ( XMLNode child)
inline

insert children when building tree

Definition at line 1574 of file xmlstorage.h.

Referenced by create(), and smart_create().

1575  {
1576  _cur->add_child(child);
1577  go_to(child);
1578  }
void add_child(XMLNode *child)
add a new child node
Definition: xmlstorage.h:1067
static HWND child
Definition: cursoricon.c:298
void go_to(XMLNode *child)
go to specified node
Definition: xmlstorage.h:1786
bool XMLStorage::XMLPos::back ( )
inline

go back to previous position

Definition at line 1581 of file xmlstorage.h.

Referenced by set_property().

1582  {
1583  if (!_stack.empty()) {
1584  _cur = _stack.top();
1585  _stack.pop();
1586  return true;
1587  } else
1588  return false;
1589  }
std::stack< XMLNode * > _stack
Definition: xmlstorage.h:1783
int XMLStorage::XMLPos::count ( const XPath xpath) const
inline

count the nodes matching the given relative XPath expression

Definition at line 1682 of file xmlstorage.h.

1683  {
1684  return _cur->count(xpath);
1685  }
int count(const XPath &xpath) const
count the nodes matching the given relative XPath expression
Definition: xmlstorage.h:1244
void XMLStorage::XMLPos::create ( const XS_String name)
inline

create node and move to it

Definition at line 1643 of file xmlstorage.h.

Referenced by XMLStorage::XMLMessage::XMLMessage().

1644  {
1645  add_down(new XMLNode(name));
1646  }
void add_down(XMLNode *child)
insert children when building tree
Definition: xmlstorage.h:1574
Definition: name.c:23
void XMLStorage::XMLPos::create_node_content ( const XS_String node_name,
const XS_String content 
)
inline

create node with string content

Definition at line 1649 of file xmlstorage.h.

1650  {
1651  XMLNode* pNode = new XMLNode(node_name);
1652  pNode->set_content(content);
1653  _cur->add_child(pNode);
1654  }
void add_child(XMLNode *child)
add a new child node
Definition: xmlstorage.h:1067
content
Definition: atl_ax.c:977
bool XMLStorage::XMLPos::create_relative ( const XPath xpath)
inline

create child nodes using XPath notation and move to the deepest child

Definition at line 1632 of file xmlstorage.h.

Referenced by ExplorerGlobals::get_cfg().

1633  {
1634  XMLNode* node = _cur->create_relative(xpath);
1635  if (!node)
1636  return false; // invalid path specified
1637 
1638  go_to(node);
1639  return true;
1640  }
Definition: graphics.c:176
void go_to(XMLNode *child)
go to specified node
Definition: xmlstorage.h:1786
XMLNode * create_relative(const XPath &xpath)
relative XPath create function
Definition: xmlstorage.cpp:279
XMLNode& XMLStorage::XMLPos::cur ( )
inline

access to current node

Definition at line 1536 of file xmlstorage.h.

1537  {
1538  return *_cur;
1539  }
const XMLNode& XMLStorage::XMLPos::cur ( ) const
inline

Definition at line 1541 of file xmlstorage.h.

1542  {
1543  return *_cur;
1544  }
bool XMLStorage::XMLPos::delete_this ( )
inline

delete current node and go back to previous position

Definition at line 1740 of file xmlstorage.h.

1741  {
1742  if (!_stack.empty()) {
1743  XMLNode* pLast = _stack.top();
1744 
1745  if (pLast->_children.remove(_cur)) {
1746  _cur = _stack.top();
1747  return true;
1748  }
1749  }
1750 
1751  return false;
1752  }
std::stack< XMLNode * > _stack
Definition: xmlstorage.h:1783
void XMLStorage::XMLPos::erase ( const XS_String attr_name)
inline

remove the attribute 'attr_name' from the current node

Definition at line 1761 of file xmlstorage.h.

1762  {
1763  _cur->erase(attr_name);
1764  }
void erase(const XS_String &attr_name)
remove the attribute 'attr_name'
Definition: xmlstorage.h:1106
int XMLStorage::XMLPos::filter ( const XPath xpath,
XMLNode target 
) const
inline

create a new node tree using the given XPath filter expression

Definition at line 1688 of file xmlstorage.h.

1689  {
1690  return _cur->filter(xpath, target);
1691  }
bool filter(const XPath &xpath, XMLNode &target) const
copy matching tree nodes using the given XPath filter expression
Definition: xmlstorage.cpp:321
XS_String XMLStorage::XMLPos::get ( const XS_String attr_name,
LPCXSSTR  def = XS_EMPTY_STR 
) const
inline

attribute access

Definition at line 1557 of file xmlstorage.h.

1558  {
1559  return _cur->get(attr_name, def);
1560  }
XS_String get(const T &attr_name, LPCXSSTR def=XS_EMPTY_STR) const
read only access to an attribute
Definition: xmlstorage.h:1095
template<typename T >
XS_String XMLStorage::XMLPos::get ( const T attr_name) const
inline

index operator attribute access

Definition at line 1569 of file xmlstorage.h.

1569 {return (*_cur)[attr_name];}
bool XMLStorage::XMLPos::go ( const XPath xpath)

move to the position defined by xpath in XML tree

Definition at line 114 of file xmlstorage.cpp.

115 {
116  XMLNode* node = xpath._absolute? _root: _cur;
117 
118  node = node->find_relative(xpath);
119 
120  if (node) {
121  go_to(node);
122  return true;
123  } else
124  return false;
125 }
Definition: graphics.c:176
void go_to(XMLNode *child)
go to specified node
Definition: xmlstorage.h:1786
const XMLNode * find_relative(const XPath &xpath) const
XPath find function (const)
Definition: xmlstorage.cpp:251
bool XMLStorage::XMLPos::go_down ( )
inline

go down to first child

Definition at line 1592 of file xmlstorage.h.

1593  {
1594  XMLNode* node = _cur->get_first_child();
1595 
1596  if (node) {
1597  go_to(node);
1598  return true;
1599  } else
1600  return false;
1601  }
Definition: graphics.c:176
XMLNode * get_first_child() const
Definition: xmlstorage.h:1261
void go_to(XMLNode *child)
go to specified node
Definition: xmlstorage.h:1786
bool XMLStorage::XMLPos::go_down ( const XS_String child_name,
int  n = 0 
)
inline

search for child and go down

Definition at line 1604 of file xmlstorage.h.

1605  {
1606  XMLNode* node = XPathElement(child_name, n).find(_cur);
1607 
1608  if (node) {
1609  go_to(node);
1610  return true;
1611  } else
1612  return false;
1613  }
Definition: graphics.c:176
GLuint n
Definition: s_context.h:57
void go_to(XMLNode *child)
go to specified node
Definition: xmlstorage.h:1786
void XMLStorage::XMLPos::go_to ( XMLNode child)
inlineprotected

go to specified node

Definition at line 1786 of file xmlstorage.h.

Referenced by add_down(), create_relative(), go(), go_down(), iterate(), and smart_create().

1787  {
1788  _stack.push(_cur);
1789  _cur = child;
1790  }
static HWND child
Definition: cursoricon.c:298
std::stack< XMLNode * > _stack
Definition: xmlstorage.h:1783
bool XMLStorage::XMLPos::iterate ( const XS_String child_name,
size_t cnt 
)
inline

iterate to the next matching child

Definition at line 1616 of file xmlstorage.h.

1617  {
1618  XMLNode* node = XPathElement(child_name, cnt).find(_cur);
1619 
1620  if (node) {
1621  go_to(node);
1622  ++cnt;
1623  return true;
1624  } else
1625  return false;
1626  }
Definition: graphics.c:176
void go_to(XMLNode *child)
go to specified node
Definition: xmlstorage.h:1786

automatic access to current node

Definition at line 1547 of file xmlstorage.h.

1547 {return _cur;}

Definition at line 1548 of file xmlstorage.h.

1548 {return _cur;}

Definition at line 1553 of file xmlstorage.h.

1553 {return *_cur;}

Definition at line 1554 of file xmlstorage.h.

1554 {return *_cur;}

Definition at line 1550 of file xmlstorage.h.

1550 {return _cur;}

Definition at line 1551 of file xmlstorage.h.

1551 {return _cur;}

Definition at line 1570 of file xmlstorage.h.

1570 {return (*_cur)[attr_name];}
const XS_String& XMLStorage::XMLPos::operator[] ( const XS_String attr_name) const
inline

Definition at line 1571 of file xmlstorage.h.

1571 {return (*_cur)[attr_name];}
void XMLStorage::XMLPos::put ( const XS_String attr_name,
const XS_String value 
)
inline

attribute setting

Definition at line 1563 of file xmlstorage.h.

Referenced by set_property().

1564  {
1565  _cur->put(attr_name, value);
1566  }
Definition: get.c:139
void put(const XS_String &attr_name, const XS_String &value)
write access to an attribute
Definition: xmlstorage.h:1083
void XMLStorage::XMLPos::remove_children ( const XS_String name)
inline

remove all children named 'name'

Definition at line 1755 of file xmlstorage.h.

1756  {
1758  }
Definition: name.c:23
void remove_children(const XS_String &name)
remove all children named 'name'
Definition: xmlstorage.h:1073
void XMLStorage::XMLPos::set_property ( const XS_String key,
int  value,
const XS_String name = XS_PROPERTY 
)
inline

Definition at line 2274 of file xmlstorage.h.

Referenced by set_property().

2275 {
2277  XMLIntRef(_cur, XS_VALUE) = value;
2278  back();
2279 }
const XS_String XS_KEY
Definition: xmlstorage.cpp:61
bool back()
go back to previous position
Definition: xmlstorage.h:1581
void smart_create(const XS_String &child_name)
create node if not already existing and move to it
Definition: xmlstorage.h:1657
const XS_String XS_VALUE
Definition: xmlstorage.cpp:62
GLsizei const GLfloat * value
Definition: glext.h:6069
Definition: name.c:23
Definition: path.c:42
void XMLStorage::XMLPos::set_property ( const XS_String key,
double  value,
const XS_String name = XS_PROPERTY 
)
inline

Definition at line 2281 of file xmlstorage.h.

2282 {
2284  XMLDoubleRef(_cur, XS_VALUE) = value;
2285  back();
2286 }
const XS_String XS_KEY
Definition: xmlstorage.cpp:61
bool back()
go back to previous position
Definition: xmlstorage.h:1581
void smart_create(const XS_String &child_name)
create node if not already existing and move to it
Definition: xmlstorage.h:1657
const XS_String XS_VALUE
Definition: xmlstorage.cpp:62
GLsizei const GLfloat * value
Definition: glext.h:6069
Definition: name.c:23
Definition: path.c:42
void XMLStorage::XMLPos::set_property ( const XS_String key,
const XS_String value,
const XS_String name = XS_PROPERTY 
)
inline

Definition at line 2288 of file xmlstorage.h.

2289 {
2291  put(XS_VALUE, value);
2292  back();
2293 }
Definition: get.c:139
const XS_String XS_KEY
Definition: xmlstorage.cpp:61
bool back()
go back to previous position
Definition: xmlstorage.h:1581
void smart_create(const XS_String &child_name)
create node if not already existing and move to it
Definition: xmlstorage.h:1657
const XS_String XS_VALUE
Definition: xmlstorage.cpp:62
Definition: name.c:23
void put(const XS_String &attr_name, const XS_String &value)
attribute setting
Definition: xmlstorage.h:1563
Definition: path.c:42
void XMLStorage::XMLPos::set_property ( const XS_String key,
const struct XMLBool value,
const XS_String name = XS_PROPERTY 
)
void XMLStorage::XMLPos::set_property ( const XS_String key,
const char value,
const XS_String name = XS_PROPERTY 
)
inline

Definition at line 1775 of file xmlstorage.h.

1776  {set_property(key, XS_String(value), name);}
Definition: get.c:139
Definition: name.c:23
void set_property(const XS_String &key, int value, const XS_String &name=XS_PROPERTY)
Definition: xmlstorage.h:2274
Definition: path.c:42
void XMLStorage::XMLPos::smart_create ( const XS_String child_name)
inline

create node if not already existing and move to it

Definition at line 1657 of file xmlstorage.h.

Referenced by ExplorerGlobals::get_cfg(), set_property(), and XMLPos().

1658  {
1659  XMLNode* node = XPathElement(child_name).find(_cur);
1660 
1661  if (node)
1662  go_to(node);
1663  else
1664  add_down(new XMLNode(child_name));
1665  }
Definition: graphics.c:176
void go_to(XMLNode *child)
go to specified node
Definition: xmlstorage.h:1786
void add_down(XMLNode *child)
insert children when building tree
Definition: xmlstorage.h:1574
void XMLStorage::XMLPos::smart_create ( const XS_String child_name,
const XS_String attr_name,
const XS_String attr_value 
)
inline

search matching child node identified by key name and an attribute value

Definition at line 1668 of file xmlstorage.h.

1669  {
1670  XMLNode* node = XPathElement(child_name, 0, attr_name, attr_value).find(_cur);
1671 
1672  if (node)
1673  go_to(node);
1674  else {
1675  node = new XMLNode(child_name);
1676  add_down(node);
1677  (*node)[attr_name] = attr_value;
1678  }
1679  }
Definition: graphics.c:176
void go_to(XMLNode *child)
go to specified node
Definition: xmlstorage.h:1786
void add_down(XMLNode *child)
insert children when building tree
Definition: xmlstorage.h:1574
XS_String& XMLStorage::XMLPos::str ( )
inline

Definition at line 1766 of file xmlstorage.h.

1766 {return *_cur;}
const XS_String& XMLStorage::XMLPos::str ( ) const
inline

Definition at line 1767 of file xmlstorage.h.

1767 {return *_cur;}

Friends And Related Function Documentation

friend struct const_XMLPos
friend

Definition at line 1779 of file xmlstorage.h.

Member Data Documentation

XMLNode* XMLStorage::XMLPos::_root
protected

Definition at line 1781 of file xmlstorage.h.

std::stack<XMLNode*> XMLStorage::XMLPos::_stack
protected

Definition at line 1783 of file xmlstorage.h.

Referenced by back(), delete_this(), and go_to().


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