webservices: Add support for writing WS_STRING and WS_XML_STRING values.
Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
3950998778
commit
864559db02
|
@ -577,10 +577,13 @@ static void test_WsWriteType(void)
|
||||||
|
|
||||||
static void test_basic_type(void)
|
static void test_basic_type(void)
|
||||||
{
|
{
|
||||||
|
static WCHAR testW[] = {'t','e','s','t',0};
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
WS_XML_WRITER *writer;
|
WS_XML_WRITER *writer;
|
||||||
WS_XML_STRING localname = {1, (BYTE *)"t"}, ns = {0, NULL};
|
WS_XML_STRING localname = {1, (BYTE *)"t"}, ns = {0, NULL}, xmlstr;
|
||||||
GUID guid;
|
GUID guid;
|
||||||
|
WCHAR *str;
|
||||||
|
WS_STRING string;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
static const struct
|
static const struct
|
||||||
{
|
{
|
||||||
|
@ -687,6 +690,53 @@ static void test_basic_type(void)
|
||||||
ok( hr == S_OK, "got %08x\n", hr );
|
ok( hr == S_OK, "got %08x\n", hr );
|
||||||
check_output( writer, "<t>00000000-0000-0000-0000-000000000000</t>", __LINE__ );
|
check_output( writer, "<t>00000000-0000-0000-0000-000000000000</t>", __LINE__ );
|
||||||
|
|
||||||
|
hr = set_output( writer );
|
||||||
|
ok( hr == S_OK, "got %08x\n", hr );
|
||||||
|
|
||||||
|
hr = WsWriteStartElement( writer, NULL, &localname, &ns, NULL );
|
||||||
|
ok( hr == S_OK, "got %08x\n", hr );
|
||||||
|
|
||||||
|
string.chars = testW;
|
||||||
|
string.length = 4;
|
||||||
|
hr = WsWriteType( writer, WS_ELEMENT_TYPE_MAPPING, WS_STRING_TYPE, NULL, WS_WRITE_REQUIRED_VALUE,
|
||||||
|
&string, sizeof(string), NULL );
|
||||||
|
ok( hr == S_OK, "got %08x\n", hr );
|
||||||
|
|
||||||
|
hr = WsWriteEndElement( writer, NULL );
|
||||||
|
ok( hr == S_OK, "got %08x\n", hr );
|
||||||
|
check_output( writer, "<t>test</t>", __LINE__ );
|
||||||
|
|
||||||
|
hr = set_output( writer );
|
||||||
|
ok( hr == S_OK, "got %08x\n", hr );
|
||||||
|
|
||||||
|
hr = WsWriteStartElement( writer, NULL, &localname, &ns, NULL );
|
||||||
|
ok( hr == S_OK, "got %08x\n", hr );
|
||||||
|
|
||||||
|
str = testW;
|
||||||
|
hr = WsWriteType( writer, WS_ELEMENT_TYPE_MAPPING, WS_WSZ_TYPE, NULL, WS_WRITE_REQUIRED_POINTER,
|
||||||
|
&str, sizeof(str), NULL );
|
||||||
|
ok( hr == S_OK, "got %08x\n", hr );
|
||||||
|
|
||||||
|
hr = WsWriteEndElement( writer, NULL );
|
||||||
|
ok( hr == S_OK, "got %08x\n", hr );
|
||||||
|
check_output( writer, "<t>test</t>", __LINE__ );
|
||||||
|
|
||||||
|
hr = set_output( writer );
|
||||||
|
ok( hr == S_OK, "got %08x\n", hr );
|
||||||
|
|
||||||
|
hr = WsWriteStartElement( writer, NULL, &localname, &ns, NULL );
|
||||||
|
ok( hr == S_OK, "got %08x\n", hr );
|
||||||
|
|
||||||
|
xmlstr.bytes = (BYTE *)"test";
|
||||||
|
xmlstr.length = 4;
|
||||||
|
hr = WsWriteType( writer, WS_ELEMENT_TYPE_MAPPING, WS_XML_STRING_TYPE, NULL, WS_WRITE_REQUIRED_VALUE,
|
||||||
|
&xmlstr, sizeof(xmlstr), NULL );
|
||||||
|
ok( hr == S_OK, "got %08x\n", hr );
|
||||||
|
|
||||||
|
hr = WsWriteEndElement( writer, NULL );
|
||||||
|
ok( hr == S_OK, "got %08x\n", hr );
|
||||||
|
check_output( writer, "<t>test</t>", __LINE__ );
|
||||||
|
|
||||||
WsFreeWriter( writer );
|
WsFreeWriter( writer );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1516,6 +1516,22 @@ static HRESULT write_type_guid( struct writer *writer, WS_TYPE_MAPPING mapping,
|
||||||
return write_type_text( writer, mapping, &utf8.text );
|
return write_type_text( writer, mapping, &utf8.text );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HRESULT write_type_string( struct writer *writer, WS_TYPE_MAPPING mapping,
|
||||||
|
const WS_STRING_DESCRIPTION *desc, const WS_STRING *value )
|
||||||
|
{
|
||||||
|
WS_XML_UTF16_TEXT utf16;
|
||||||
|
|
||||||
|
if (desc)
|
||||||
|
{
|
||||||
|
FIXME( "description not supported\n" );
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
|
utf16.text.textType = WS_XML_TEXT_TYPE_UTF16;
|
||||||
|
utf16.bytes = (BYTE *)value->chars;
|
||||||
|
utf16.byteCount = value->length * sizeof(WCHAR);
|
||||||
|
return write_type_text( writer, mapping, &utf16.text );
|
||||||
|
}
|
||||||
|
|
||||||
static HRESULT write_type_wsz( struct writer *writer, WS_TYPE_MAPPING mapping,
|
static HRESULT write_type_wsz( struct writer *writer, WS_TYPE_MAPPING mapping,
|
||||||
const WS_WSZ_DESCRIPTION *desc, const WCHAR *value )
|
const WS_WSZ_DESCRIPTION *desc, const WCHAR *value )
|
||||||
{
|
{
|
||||||
|
@ -1532,6 +1548,22 @@ static HRESULT write_type_wsz( struct writer *writer, WS_TYPE_MAPPING mapping,
|
||||||
return write_type_text( writer, mapping, &utf16.text );
|
return write_type_text( writer, mapping, &utf16.text );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HRESULT write_type_xml_string( struct writer *writer, WS_TYPE_MAPPING mapping,
|
||||||
|
const WS_XML_STRING_DESCRIPTION *desc, const WS_XML_STRING *value )
|
||||||
|
{
|
||||||
|
WS_XML_UTF8_TEXT utf8;
|
||||||
|
|
||||||
|
if (desc)
|
||||||
|
{
|
||||||
|
FIXME( "description not supported\n" );
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
|
utf8.text.textType = WS_XML_TEXT_TYPE_UTF8;
|
||||||
|
utf8.value.bytes = value->bytes;
|
||||||
|
utf8.value.length = value->length;
|
||||||
|
return write_type_text( writer, mapping, &utf8.text );
|
||||||
|
}
|
||||||
|
|
||||||
static HRESULT write_type( struct writer *, WS_TYPE_MAPPING, WS_TYPE, const void *, WS_WRITE_OPTION,
|
static HRESULT write_type( struct writer *, WS_TYPE_MAPPING, WS_TYPE, const void *, WS_WRITE_OPTION,
|
||||||
const void *, ULONG );
|
const void *, ULONG );
|
||||||
|
|
||||||
|
@ -1744,6 +1776,13 @@ static HRESULT write_type( struct writer *writer, WS_TYPE_MAPPING mapping, WS_TY
|
||||||
if ((hr = get_value_ptr( option, value, size, (const void **)&ptr )) != S_OK) return hr;
|
if ((hr = get_value_ptr( option, value, size, (const void **)&ptr )) != S_OK) return hr;
|
||||||
return write_type_guid( writer, mapping, desc, ptr );
|
return write_type_guid( writer, mapping, desc, ptr );
|
||||||
}
|
}
|
||||||
|
case WS_STRING_TYPE:
|
||||||
|
{
|
||||||
|
const WS_STRING *ptr;
|
||||||
|
if (!option) option = WS_WRITE_REQUIRED_VALUE;
|
||||||
|
if ((hr = get_value_ptr( option, value, size, (const void **)&ptr )) != S_OK) return hr;
|
||||||
|
return write_type_string( writer, mapping, desc, ptr );
|
||||||
|
}
|
||||||
case WS_WSZ_TYPE:
|
case WS_WSZ_TYPE:
|
||||||
{
|
{
|
||||||
const WCHAR *ptr;
|
const WCHAR *ptr;
|
||||||
|
@ -1754,6 +1793,13 @@ static HRESULT write_type( struct writer *writer, WS_TYPE_MAPPING mapping, WS_TY
|
||||||
if ((hr = get_value_ptr( option, value, size, (const void **)&ptr )) != S_OK) return hr;
|
if ((hr = get_value_ptr( option, value, size, (const void **)&ptr )) != S_OK) return hr;
|
||||||
return write_type_wsz( writer, mapping, desc, ptr );
|
return write_type_wsz( writer, mapping, desc, ptr );
|
||||||
}
|
}
|
||||||
|
case WS_XML_STRING_TYPE:
|
||||||
|
{
|
||||||
|
const WS_XML_STRING *ptr;
|
||||||
|
if (!option) option = WS_WRITE_REQUIRED_VALUE;
|
||||||
|
if ((hr = get_value_ptr( option, value, size, (const void **)&ptr )) != S_OK) return hr;
|
||||||
|
return write_type_xml_string( writer, mapping, desc, ptr );
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
FIXME( "type %u not supported\n", type );
|
FIXME( "type %u not supported\n", type );
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
|
|
Loading…
Reference in New Issue