#include <xmlstorage.h>

Public Types | |
| typedef XS_StringMap | MAPATTR |
Public Member Functions | |
| XPathElement () | |
| XPathElement (const XS_String &child_name, int child_idx=-1) | |
| XPathElement (const XS_String &child_name, int child_idx, const XS_String &attr_name, const XS_String &attr_value) | |
| LPCXSSTR | parse (LPCXSSTR path) |
| XMLNode * | find (XMLNode *node) const |
| const XMLNode * | const_find (const XMLNode *node) const |
| bool | matches (const XMLNode &node, int &n) const |
Public Attributes | |
| XS_String | _child_name |
| int | _child_idx |
| MAPATTR | _mAttrAndAttr |
Definition at line 1336 of file xmlstorage.h.
Definition at line 1354 of file xmlstorage.h.
| XMLStorage::XPathElement::XPathElement | ( | ) | [inline] |
Definition at line 1338 of file xmlstorage.h.
: _child_idx(-1) {}
| XMLStorage::XPathElement::XPathElement | ( | const XS_String & | child_name, |
| int | child_idx = -1 |
||
| ) | [inline] |
Definition at line 1340 of file xmlstorage.h.
: _child_name(child_name), _child_idx(child_idx) { }
| XMLStorage::XPathElement::XPathElement | ( | const XS_String & | child_name, |
| int | child_idx, | ||
| const XS_String & | attr_name, | ||
| const XS_String & | attr_value | ||
| ) | [inline] |
Definition at line 1345 of file xmlstorage.h.
References _mAttrAndAttr.
: _child_name(child_name), _child_idx(child_idx) { _mAttrAndAttr[attr_name] = attr_value; }
Definition at line 214 of file xmlstorage.cpp.
References XMLStorage::XMLNode::_children, and matches().
Referenced by XMLStorage::const_XMLPos::go_down(), and XMLStorage::const_XMLPos::iterate().
{
int n = 0;
for(XMLNode::Children::const_iterator it=node->_children.begin(); it!=node->_children.end(); ++it)
if (matches(**it, n))
return *it;
return NULL;
}


Definition at line 203 of file xmlstorage.cpp.
References XMLStorage::XMLNode::_children, and matches().
Referenced by XMLStorage::XMLPos::go_down(), XMLStorage::XMLPos::iterate(), and XMLStorage::XMLPos::smart_create().
{
int n = 0;
for(XMLNode::Children::const_iterator it=node->_children.begin(); it!=node->_children.end(); ++it)
if (matches(**it, n))
return *it;
return NULL;
}


| bool XMLStorage::XPathElement::matches | ( | const XMLNode & | node, |
| int & | n | ||
| ) | const |
Definition at line 225 of file xmlstorage.cpp.
References _child_idx, _child_name, _mAttrAndAttr, XMLStorage::XS_StringMap::begin(), XMLStorage::XS_StringMap::end(), XMLStorage::XMLNode::get(), and XS_TEXT.
Referenced by const_find(), XMLStorage::XMLNode::count(), XMLStorage::XMLNode::filter(), XMLStorage::XMLStreamReader::find(), and find().
{
if (node != _child_name)
if (_child_name != XS_TEXT("*")) // use asterisk as wildcard
return false;
for(MAPATTR::const_iterator b=_mAttrAndAttr.begin(), e=_mAttrAndAttr.end(); b!=e; ++b)
if (node.get(b->first) != b->second)
return false;
if (_child_idx == -1)
return true;
else if (n++ == _child_idx)
return true;
else
return false;
}


| LPCXSSTR XMLStorage::XPathElement::parse | ( | LPCXSSTR | path ) |
Definition at line 141 of file xmlstorage.cpp.
References _child_idx, _child_name, _mAttrAndAttr, _tcslen, _tcsnicmp, _ttoi, XMLStorage::XS_String::assign(), and LPCXSSTR.
Referenced by XMLStorage::XPath::init().
{
LPCXSSTR slash = _tcschr(path, '/');
if (slash == path)
return NULL;
// parse relative path
size_t l = slash? slash-path: _tcslen(path);
XS_String comp(path, l);
path += l;
// look for [n] and [@attr_name="attr_value"] expressions in path components
LPCXSSTR bracket = _tcschr(comp.c_str(), _T('['));
l = bracket? bracket-comp.c_str(): comp.length();
_child_name.assign(comp.c_str(), l);
if (bracket) {
XS_String expr = unescape(bracket, _T('['), _T(']'));
LPCXSSTR p = expr.c_str();
while(_istspace((_TUCHAR)*p)) ++p;
if (isdigit(*p)) {
int n = _ttoi(p); // read index number
if (n)
_child_idx = n - 1; // convert into zero based index
} else {
while(*p == '@') {
LPCXSSTR equal = _tcschr(++p, '=');
if (equal) {
// look for delimiters
LPCXSSTR del1 = equal+1;
LPCXSSTR del2 = *del1==_T('\'')||*del1==_T('"')? _tcschr(del1+1, *del1): NULL;
// read attribute name and value
const XS_String& attrName = unescape(p, equal-p);
const XS_String& attrValue = del2? unescape(del1, ++del2-del1): unescape(del1);
_mAttrAndAttr[attrName] = attrValue;
if (!del2)
break;
p = del2 + 1;
while(isspace((unsigned char)*p)) ++p;
// handle [@attr1="value1" and @attr2="value2"] expressions
// handle expressions like [@name="1.2" and @profil="IPE" and @date="2006_07"]
if (!_tcsnicmp(p, _T("and "), 4))
p += 4;
}
while(_istspace((_TUCHAR)*p)) ++p;
}
}
}
return path;
}


Definition at line 1352 of file xmlstorage.h.
Definition at line 1351 of file xmlstorage.h.
Referenced by XMLStorage::XMLStreamReader::find(), matches(), and parse().
Definition at line 1355 of file xmlstorage.h.
Referenced by matches(), parse(), and XPathElement().
|
ROS Explorer Source Code Documentation
generated on 02.01.2013 by
|