ReactOS 0.4.15-dev-8191-gbc6c731
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
 
const XMLNodecur () const
 
 operator const XMLNode * () const
 automatic access to current node
 
 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
 
void put (const XS_String &attr_name, const XS_String &value)
 attribute setting
 
template<typename T >
XS_String get (const T &attr_name) const
 index operator attribute access
 
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
 
bool back ()
 go back to previous position
 
bool go_down ()
 go down to first child
 
bool go_down (const XS_String &child_name, int n=0)
 search for child and go down
 
bool iterate (const XS_String &child_name, size_t &cnt)
 iterate to the next matching child
 
bool go (const XPath &xpath)
 move to the position defined by xpath in XML tree
 
bool create_relative (const XPath &xpath)
 create child nodes using XPath notation and move to the deepest child
 
void create (const XS_String &name)
 create node and move to it
 
void create_node_content (const XS_String &node_name, const XS_String &content)
 create node with string content
 
void smart_create (const XS_String &child_name)
 create node if not already existing and move to it
 
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
 
int count (const XPath &xpath) const
 count the nodes matching the given relative XPath expression
 
int filter (const XPath &xpath, XMLNode &target) const
 create a new node tree using the given XPath filter expression
 
bool delete_this ()
 delete current node and go back to previous position
 
void remove_children (const XS_String &name)
 remove all children named 'name'
 
void erase (const XS_String &attr_name)
 remove the attribute 'attr_name' from the current node
 
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
 

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

◆ XMLPos() [1/6]

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

Definition at line 1495 of file xmlstorage.h.

1496 : _root(root),
1497 _cur(root)
1498 {
1499 }

◆ XMLPos() [2/6]

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:1376

◆ XMLPos() [3/6]

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 {
1512 }
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:39
Definition: dlist.c:348

◆ XMLPos() [4/6]

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 }

◆ XMLPos() [5/6]

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 {
1526 }

◆ XMLPos() [6/6]

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 }

Member Function Documentation

◆ add_down()

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

insert children when building tree

Definition at line 1574 of file xmlstorage.h.

1575 {
1577 go_to(child);
1578 }
static HWND child
Definition: cursoricon.c:298
void add_child(XMLNode *child)
add a new child node
Definition: xmlstorage.h:1067
void go_to(XMLNode *child)
go to specified node
Definition: xmlstorage.h:1786

Referenced by create(), smart_create(), and XMLStorage::XMLReaderBase::StartElementHandler().

◆ back()

bool XMLStorage::XMLPos::back ( )
inline

go back to previous position

Definition at line 1581 of file xmlstorage.h.

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

Referenced by XMLStorage::XMLReaderBase::EndElementHandler(), and set_property().

◆ count()

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

◆ create()

void XMLStorage::XMLPos::create ( const XS_String name)
inline

create node and move to it

Definition at line 1643 of file xmlstorage.h.

1644 {
1645 add_down(new XMLNode(name));
1646 }
void add_down(XMLNode *child)
insert children when building tree
Definition: xmlstorage.h:1574

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

◆ create_node_content()

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 }
content
Definition: atl_ax.c:994

◆ create_relative()

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.

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 }
XMLNode * create_relative(const XPath &xpath)
relative XPath create function
Definition: xmlstorage.cpp:279

Referenced by ExplorerGlobals::get_cfg().

◆ cur() [1/2]

XMLNode & XMLStorage::XMLPos::cur ( )
inline

access to current node

Definition at line 1536 of file xmlstorage.h.

1537 {
1538 return *_cur;
1539 }

◆ cur() [2/2]

const XMLNode & XMLStorage::XMLPos::cur ( ) const
inline

Definition at line 1541 of file xmlstorage.h.

1542 {
1543 return *_cur;
1544 }

◆ delete_this()

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 }

◆ erase()

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

◆ filter()

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 }
GLenum target
Definition: glext.h:7315
bool filter(const XPath &xpath, XMLNode &target) const
copy matching tree nodes using the given XPath filter expression
Definition: xmlstorage.cpp:321

◆ get() [1/2]

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];}

◆ get() [2/2]

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

◆ go()

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}

◆ go_down() [1/2]

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 }
XMLNode * get_first_child() const
Definition: xmlstorage.h:1261

◆ go_down() [2/2]

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 }
GLdouble n
Definition: glext.h:7729

◆ go_to()

void XMLStorage::XMLPos::go_to ( XMLNode child)
inlineprotected

go to specified node

Definition at line 1786 of file xmlstorage.h.

1787 {
1788 _stack.push(_cur);
1789 _cur = child;
1790 }

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

◆ iterate()

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 }

◆ operator const XMLNode *()

XMLStorage::XMLPos::operator const XMLNode * ( ) const
inline

automatic access to current node

Definition at line 1547 of file xmlstorage.h.

1547{return _cur;}

◆ operator XMLNode *()

XMLStorage::XMLPos::operator XMLNode * ( )
inline

Definition at line 1548 of file xmlstorage.h.

1548{return _cur;}

◆ operator*() [1/2]

XMLNode & XMLStorage::XMLPos::operator* ( )
inline

Definition at line 1554 of file xmlstorage.h.

1554{return *_cur;}

◆ operator*() [2/2]

const XMLNode & XMLStorage::XMLPos::operator* ( ) const
inline

Definition at line 1553 of file xmlstorage.h.

1553{return *_cur;}

◆ operator->() [1/2]

XMLNode * XMLStorage::XMLPos::operator-> ( )
inline

Definition at line 1551 of file xmlstorage.h.

1551{return _cur;}

◆ operator->() [2/2]

const XMLNode * XMLStorage::XMLPos::operator-> ( ) const
inline

Definition at line 1550 of file xmlstorage.h.

1550{return _cur;}

◆ operator[]() [1/2]

XS_String & XMLStorage::XMLPos::operator[] ( const XS_String attr_name)
inline

Definition at line 1570 of file xmlstorage.h.

1570{return (*_cur)[attr_name];}

◆ operator[]() [2/2]

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];}

◆ put()

void XMLStorage::XMLPos::put ( const XS_String attr_name,
const XS_String value 
)
inline

attribute setting

Definition at line 1563 of file xmlstorage.h.

1564 {
1565 _cur->put(attr_name, value);
1566 }
void put(const XS_String &attr_name, const XS_String &value)
write access to an attribute
Definition: xmlstorage.h:1083
Definition: pdh_main.c:94

◆ remove_children()

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 }
void remove_children(const XS_String &name)
remove all children named 'name'
Definition: xmlstorage.h:1073

◆ set_property() [1/5]

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);}
void set_property(const XS_String &key, int value, const XS_String &name=XS_PROPERTY)
Definition: xmlstorage.h:2274
Definition: copy.c:22

◆ set_property() [2/5]

void XMLStorage::XMLPos::set_property ( const XS_String key,
const struct XMLBool value,
const XS_String name = XS_PROPERTY 
)

◆ set_property() [3/5]

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}
#define put(ret, state, sp, n)
Definition: match.c:105
const XS_String XS_VALUE
Definition: xmlstorage.cpp:62
const XS_String XS_KEY
Definition: xmlstorage.cpp:61
bool back()
go back to previous position
Definition: xmlstorage.h:1581

◆ set_property() [4/5]

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}

◆ set_property() [5/5]

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.

2275{
2277 XMLIntRef(_cur, XS_VALUE) = value;
2278 back();
2279}

Referenced by set_property().

◆ smart_create() [1/2]

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.

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 }

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

◆ smart_create() [2/2]

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 }

◆ str() [1/2]

XS_String & XMLStorage::XMLPos::str ( )
inline

Definition at line 1766 of file xmlstorage.h.

1766{return *_cur;}

◆ str() [2/2]

const XS_String & XMLStorage::XMLPos::str ( ) const
inline

Definition at line 1767 of file xmlstorage.h.

1767{return *_cur;}

Friends And Related Function Documentation

◆ const_XMLPos

friend struct const_XMLPos
friend

Definition at line 1779 of file xmlstorage.h.

Member Data Documentation

◆ _cur

◆ _root

XMLNode* XMLStorage::XMLPos::_root
protected

Definition at line 1781 of file xmlstorage.h.

Referenced by go().

◆ _stack

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: