ReactOS  r76032
XMLStorage::XPathElement Struct Reference

#include <xmlstorage.h>

Collaboration diagram for XMLStorage::XPathElement:

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)
 
const charparse (const char *path)
 
XMLNodefind (XMLNode *node) const
 
const XMLNodeconst_find (const XMLNode *node) const
 
bool matches (const XMLNode &node, int &n) const
 

Public Attributes

XS_String _child_name
 
int _child_idx
 
XS_String _attr_name
 
XS_String _attr_value
 

Detailed Description

Definition at line 814 of file xmlstorage.h.

Constructor & Destructor Documentation

XMLStorage::XPathElement::XPathElement ( )
inline

Definition at line 816 of file xmlstorage.h.

816 : _child_idx(-1) {}
XMLStorage::XPathElement::XPathElement ( const XS_String child_name,
int  child_idx = -1 
)
inline

Definition at line 818 of file xmlstorage.h.

819  : _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 821 of file xmlstorage.h.

822  : _child_name(child_name), _child_idx(child_idx),
823  _attr_name(attr_name), _attr_value(attr_value)
824  {
825  }

Member Function Documentation

const XMLNode * XMLStorage::XPathElement::const_find ( const XMLNode node) const

Definition at line 195 of file xmlstorage.cpp.

Referenced by XMLStorage::const_XMLPos::go_down(), and XMLStorage::const_XMLPos::iterate().

196 {
197  int n = 0;
198 
199  for(XMLNode::Children::const_iterator it=node->_children.begin(); it!=node->_children.end(); ++it)
200  if (matches(**it, n))
201  return *it;
202 
203  return NULL;
204 }
Definition: graphics.c:176
GLuint n
Definition: s_context.h:57
smooth NULL
Definition: ftsmooth.c:557
bool matches(const XMLNode &node, int &n) const
Definition: xmlstorage.cpp:206
XMLNode * XMLStorage::XPathElement::find ( XMLNode node) const

Definition at line 184 of file xmlstorage.cpp.

Referenced by XMLStorage::XMLPos::go_down(), XMLStorage::XMLPos::iterate(), and XMLStorage::XMLPos::smart_create().

185 {
186  int n = 0;
187 
188  for(XMLNode::Children::const_iterator it=node->_children.begin(); it!=node->_children.end(); ++it)
189  if (matches(**it, n))
190  return *it;
191 
192  return NULL;
193 }
Definition: graphics.c:176
GLuint n
Definition: s_context.h:57
smooth NULL
Definition: ftsmooth.c:557
bool matches(const XMLNode &node, int &n) const
Definition: xmlstorage.cpp:206
bool XMLStorage::XPathElement::matches ( const XMLNode node,
int n 
) const

Definition at line 206 of file xmlstorage.cpp.

Referenced by const_find(), XMLStorage::XMLNode::count(), XMLStorage::XMLNode::filter(), and find().

207 {
208  if (node != _child_name)
209  if (_child_name != XS_TEXT("*")) // use asterisk as wildcard
210  return false;
211 
212  if (!_attr_name.empty())
213  if (node.get(_attr_name) != _attr_value)
214  return false;
215 
216  if (_child_idx == -1)
217  return true;
218  else if (n++ == _child_idx)
219  return true;
220  else
221  return false;
222 }
Definition: graphics.c:176
GLuint n
Definition: s_context.h:57
#define XS_TEXT(x)
Definition: xmlstorage.h:237
const char * XMLStorage::XPathElement::parse ( const char path)

Definition at line 142 of file xmlstorage.cpp.

Referenced by XMLStorage::XPath::init().

143 {
144  const char* slash = strchr(path, '/');
145  if (slash == path)
146  return NULL;
147 
148  size_t l = slash? slash-path: strlen(path);
149  std::string comp(path, l);
150  path += l;
151 
152  // look for [n] and [@attr_name="attr_value"] expressions in path components
153  const char* bracket = strchr(comp.c_str(), '[');
154  l = bracket? bracket-comp.c_str(): comp.length();
155  _child_name.assign(comp.c_str(), l);
156 
157  int n = 0;
158  if (bracket) {
159  std::string expr = unescape(bracket, '[', ']');
160  const char* p = expr.c_str();
161 
162  n = atoi(p); // read index number
163 
164  if (n)
165  _child_idx = n - 1; // convert into zero based index
166 
167  const char* at = strchr(p, '@');
168 
169  if (at) {
170  p = at + 1;
171  const char* equal = strchr(p, '=');
172 
173  // read attribute name and value
174  if (equal) {
175  _attr_name = unescape(p, equal-p);
176  _attr_value = unescape(equal+1);
177  }
178  }
179  }
180 
181  return path;
182 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLsizei const GLchar ** path
Definition: glext.h:7234
static std::string unescape(const char *s, char b, char e)
remove escape characters from zero terminated string
Definition: xmlstorage.cpp:67
#define equal(x, y)
Definition: reader.cc:56
Definition: query.h:74
GLuint n
Definition: s_context.h:57
smooth NULL
Definition: ftsmooth.c:557
r l[0]
Definition: byte_order.h:167
static int bracket
Definition: adnsresfilter.c:59
void assign(const XS_String &s)
Definition: xmlstorage.h:338
char string[160]
Definition: util.h:11
Definition: services.c:311
char * strchr(const char *String, int ch)
Definition: utclib.c:501
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
GLfloat GLfloat p
Definition: glext.h:8902

Member Data Documentation

XS_String XMLStorage::XPathElement::_attr_name

Definition at line 830 of file xmlstorage.h.

Referenced by matches(), and parse().

XS_String XMLStorage::XPathElement::_attr_value

Definition at line 831 of file xmlstorage.h.

Referenced by matches(), and parse().

int XMLStorage::XPathElement::_child_idx

Definition at line 828 of file xmlstorage.h.

Referenced by matches(), and parse().

XS_String XMLStorage::XPathElement::_child_name

Definition at line 827 of file xmlstorage.h.

Referenced by matches(), and parse().


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