xmllite: Implement attribute iteration methods.
This commit is contained in:
parent
13f126498b
commit
f6e6b835b6
@ -113,6 +113,7 @@ typedef struct _xmlreader
|
|||||||
DtdProcessing dtdmode;
|
DtdProcessing dtdmode;
|
||||||
UINT line, pos; /* reader position in XML stream */
|
UINT line, pos; /* reader position in XML stream */
|
||||||
struct list attrs; /* attributes list for current node */
|
struct list attrs; /* attributes list for current node */
|
||||||
|
struct attribute *attr; /* current attribute */
|
||||||
UINT attr_count;
|
UINT attr_count;
|
||||||
} xmlreader;
|
} xmlreader;
|
||||||
|
|
||||||
@ -942,14 +943,32 @@ static HRESULT WINAPI xmlreader_GetNodeType(IXmlReader* iface, XmlNodeType *node
|
|||||||
|
|
||||||
static HRESULT WINAPI xmlreader_MoveToFirstAttribute(IXmlReader* iface)
|
static HRESULT WINAPI xmlreader_MoveToFirstAttribute(IXmlReader* iface)
|
||||||
{
|
{
|
||||||
FIXME("(%p): stub\n", iface);
|
xmlreader *This = impl_from_IXmlReader(iface);
|
||||||
return E_NOTIMPL;
|
|
||||||
|
TRACE("(%p)\n", This);
|
||||||
|
|
||||||
|
if (!This->attr_count) return S_FALSE;
|
||||||
|
This->attr = LIST_ENTRY(list_head(&This->attrs), struct attribute, entry);
|
||||||
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI xmlreader_MoveToNextAttribute(IXmlReader* iface)
|
static HRESULT WINAPI xmlreader_MoveToNextAttribute(IXmlReader* iface)
|
||||||
{
|
{
|
||||||
FIXME("(%p): stub\n", iface);
|
xmlreader *This = impl_from_IXmlReader(iface);
|
||||||
return E_NOTIMPL;
|
const struct list *next;
|
||||||
|
|
||||||
|
TRACE("(%p)\n", This);
|
||||||
|
|
||||||
|
if (!This->attr_count) return S_FALSE;
|
||||||
|
|
||||||
|
if (!This->attr)
|
||||||
|
return IXmlReader_MoveToFirstAttribute(iface);
|
||||||
|
|
||||||
|
next = list_next(&This->attrs, &This->attr->entry);
|
||||||
|
if (next)
|
||||||
|
This->attr = LIST_ENTRY(next, struct attribute, entry);
|
||||||
|
|
||||||
|
return next ? S_OK : S_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI xmlreader_MoveToAttributeByName(IXmlReader* iface,
|
static HRESULT WINAPI xmlreader_MoveToAttributeByName(IXmlReader* iface,
|
||||||
@ -962,8 +981,13 @@ static HRESULT WINAPI xmlreader_MoveToAttributeByName(IXmlReader* iface,
|
|||||||
|
|
||||||
static HRESULT WINAPI xmlreader_MoveToElement(IXmlReader* iface)
|
static HRESULT WINAPI xmlreader_MoveToElement(IXmlReader* iface)
|
||||||
{
|
{
|
||||||
FIXME("(%p): stub\n", iface);
|
xmlreader *This = impl_from_IXmlReader(iface);
|
||||||
return E_NOTIMPL;
|
|
||||||
|
TRACE("(%p)\n", This);
|
||||||
|
|
||||||
|
if (!This->attr_count) return S_FALSE;
|
||||||
|
This->attr = NULL;
|
||||||
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI xmlreader_GetQualifiedName(IXmlReader* iface, LPCWSTR *qualifiedName,
|
static HRESULT WINAPI xmlreader_GetQualifiedName(IXmlReader* iface, LPCWSTR *qualifiedName,
|
||||||
@ -1202,6 +1226,7 @@ HRESULT WINAPI CreateXmlReader(REFIID riid, void **obj, IMalloc *imalloc)
|
|||||||
reader->nodetype = XmlNodeType_None;
|
reader->nodetype = XmlNodeType_None;
|
||||||
list_init(&reader->attrs);
|
list_init(&reader->attrs);
|
||||||
reader->attr_count = 0;
|
reader->attr_count = 0;
|
||||||
|
reader->attr = NULL;
|
||||||
|
|
||||||
*obj = &reader->IXmlReader_iface;
|
*obj = &reader->IXmlReader_iface;
|
||||||
|
|
||||||
|
@ -591,6 +591,7 @@ static void test_read_xmldeclaration(void)
|
|||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
XmlNodeType type;
|
XmlNodeType type;
|
||||||
UINT count = 0;
|
UINT count = 0;
|
||||||
|
const WCHAR *val;
|
||||||
|
|
||||||
hr = pCreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL);
|
hr = pCreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL);
|
||||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||||
@ -611,6 +612,16 @@ static void test_read_xmldeclaration(void)
|
|||||||
ok(hr == S_OK, "got %08x\n", hr);
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
ok(count == 0, "got %d\n", count);
|
ok(count == 0, "got %d\n", count);
|
||||||
|
|
||||||
|
/* try to move without attributes */
|
||||||
|
hr = IXmlReader_MoveToElement(reader);
|
||||||
|
ok(hr == S_FALSE, "got %08x\n", hr);
|
||||||
|
|
||||||
|
hr = IXmlReader_MoveToNextAttribute(reader);
|
||||||
|
ok(hr == S_FALSE, "got %08x\n", hr);
|
||||||
|
|
||||||
|
hr = IXmlReader_MoveToFirstAttribute(reader);
|
||||||
|
ok(hr == S_FALSE, "got %08x\n", hr);
|
||||||
|
|
||||||
ok_pos(reader, 0, 0, -1, -1, FALSE);
|
ok_pos(reader, 0, 0, -1, -1, FALSE);
|
||||||
|
|
||||||
type = -1;
|
type = -1;
|
||||||
@ -622,13 +633,27 @@ static void test_read_xmldeclaration(void)
|
|||||||
ok_pos(reader, 1, 3, -1, 55, TRUE);
|
ok_pos(reader, 1, 3, -1, 55, TRUE);
|
||||||
test_read_state(reader, XmlReadState_Interactive, -1, 0);
|
test_read_state(reader, XmlReadState_Interactive, -1, 0);
|
||||||
|
|
||||||
|
hr = IXmlReader_GetValue(reader, &val, NULL);
|
||||||
|
todo_wine
|
||||||
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
|
if (hr == S_OK)
|
||||||
|
ok(*val == 0, "got %s\n", wine_dbgstr_w(val));
|
||||||
|
|
||||||
/* check attributes */
|
/* check attributes */
|
||||||
hr = IXmlReader_MoveToNextAttribute(reader);
|
hr = IXmlReader_MoveToNextAttribute(reader);
|
||||||
todo_wine ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
ok_pos(reader, 1, 7, -1, 55, TRUE);
|
ok_pos(reader, 1, 7, -1, 55, TRUE);
|
||||||
|
|
||||||
|
/* try to move from last attribute */
|
||||||
|
hr = IXmlReader_MoveToNextAttribute(reader);
|
||||||
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
|
hr = IXmlReader_MoveToNextAttribute(reader);
|
||||||
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
|
hr = IXmlReader_MoveToNextAttribute(reader);
|
||||||
|
ok(hr == S_FALSE, "got %08x\n", hr);
|
||||||
|
|
||||||
hr = IXmlReader_MoveToFirstAttribute(reader);
|
hr = IXmlReader_MoveToFirstAttribute(reader);
|
||||||
todo_wine ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
ok_pos(reader, 1, 7, -1, 55, TRUE);
|
ok_pos(reader, 1, 7, -1, 55, TRUE);
|
||||||
|
|
||||||
hr = IXmlReader_GetAttributeCount(reader, NULL);
|
hr = IXmlReader_GetAttributeCount(reader, NULL);
|
||||||
@ -644,6 +669,9 @@ todo_wine {
|
|||||||
ok(count == 1, "Expected 1, got %d\n", count);
|
ok(count == 1, "Expected 1, got %d\n", count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hr = IXmlReader_MoveToElement(reader);
|
||||||
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
|
|
||||||
IStream_Release(stream);
|
IStream_Release(stream);
|
||||||
IXmlReader_Release(reader);
|
IXmlReader_Release(reader);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user