13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _QPXMLWRITER_H
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _QPXMLWRITER_H
33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program Helper Library
53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * -------------------------------------------
63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project
83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License");
103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License.
113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at
123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *      http://www.apache.org/licenses/LICENSE-2.0
143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software
163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS,
173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and
193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License.
203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*!
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Test log library
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deDefs.h"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <stdio.h>
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
303c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDE_BEGIN_EXTERN_C
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef struct qpXmlWriter_s	qpXmlWriter;
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef enum qpXmlAttributeType_e
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	QP_XML_ATTRIBUTE_STRING = 0,
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	QP_XML_ATTRIBUTE_INT,
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	QP_XML_ATTRIBUTE_BOOL,
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	QP_XML_ATTRIBUTE_LAST
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} qpXmlAttributeType;
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef struct qpXmlAttribute_s
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char*			name;
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	qpXmlAttributeType	type;
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char*			stringValue;
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int					intValue;
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deBool				boolValue;
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} qpXmlAttribute;
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
523c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDE_INLINE qpXmlAttribute qpSetStringAttrib (const char* name, const char* value)
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	qpXmlAttribute attrib;
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attrib.name			= name;
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attrib.type			= QP_XML_ATTRIBUTE_STRING;
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attrib.stringValue	= value;
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attrib.intValue		= -678;
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attrib.boolValue	= (deBool)0xFFFFFFFFu;
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return attrib;
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
633c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDE_INLINE qpXmlAttribute qpSetIntAttrib (const char* name, int value)
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	qpXmlAttribute attrib;
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attrib.name			= name;
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attrib.type			= QP_XML_ATTRIBUTE_INT;
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attrib.stringValue	= "<intAttrib>";
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attrib.intValue		= value;
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attrib.boolValue	= (deBool)0xFFFFFFFFu;
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return attrib;
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
743c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDE_INLINE qpXmlAttribute qpSetBoolAttrib (const char* name, deBool value)
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	qpXmlAttribute attrib;
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attrib.name			= name;
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attrib.type			= QP_XML_ATTRIBUTE_BOOL;
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attrib.stringValue	= "<boolAttrib>";
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attrib.intValue		= -679;
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	attrib.boolValue	= value;
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return attrib;
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Create a file based XML Writer instance
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \param fileName Name of the file
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \param useCompression Set to DE_TRUE to use compression, if supported by implementation
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \return qpXmlWriter instance, or DE_NULL if cannot create file
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
903c827367444ee418f129b2c238299f49d3264554Jarkko PoyryqpXmlWriter*	qpXmlWriter_createFileWriter (FILE* outFile, deBool useCompression);
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief XML Writer instance
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \param a	qpXmlWriter instance
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			qpXmlWriter_destroy (qpXmlWriter* writer);
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief XML Writer instance
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \param a	qpXmlWriter instance
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			qpXmlWriter_flush (qpXmlWriter* writer);
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Start XML document
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \param writer qpXmlWriter instance
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \return true on success, false on error
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
1093c827367444ee418f129b2c238299f49d3264554Jarkko PoyrydeBool			qpXmlWriter_startDocument (qpXmlWriter* writer);
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief End XML document
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \param writer qpXmlWriter instance
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \return true on success, false on error
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
1163c827367444ee418f129b2c238299f49d3264554Jarkko PoyrydeBool			qpXmlWriter_endDocument (qpXmlWriter* writer);
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Start XML element
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \param writer qpXmlWriter instance
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \param elementName Name of the element
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \return true on success, false on error
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
1243c827367444ee418f129b2c238299f49d3264554Jarkko PoyrydeBool			qpXmlWriter_startElement (qpXmlWriter* writer, const char* elementName, int numAttribs, const qpXmlAttribute* attribs);
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief End XML element
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \param writer qpXmlWriter instance
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \param elementName Name of the element
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \return true on success, false on error
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
1323c827367444ee418f129b2c238299f49d3264554Jarkko PoyrydeBool			qpXmlWriter_endElement (qpXmlWriter* writer, const char* elementName);
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Write raw string into XML document
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \param writer qpXmlWriter instance
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \param content String to be written
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \return true on success, false on error
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
1403c827367444ee418f129b2c238299f49d3264554Jarkko PoyrydeBool			qpXmlWriter_writeString (qpXmlWriter* writer, const char* content);
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Write base64 encoded data into XML document
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \param writer	qpXmlWriter instance
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \param data		Pointer to data to be written
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \param numBytes	Length of data in bytes
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \return true on success, false on error
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
1493c827367444ee418f129b2c238299f49d3264554Jarkko PoyrydeBool			qpXmlWriter_writeBase64 (qpXmlWriter* writer, const deUint8* data, int numBytes);
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Convenience function for writing XML element
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \param writer qpXmlWriter instance
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \param elementName Name of the element
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \param elementContent Contents of the element
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \return true on success, false on error
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
1583c827367444ee418f129b2c238299f49d3264554Jarkko PoyrydeBool			qpXmlWriter_writeStringElement (qpXmlWriter* writer, const char* elementName, const char* elementContent);
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1603c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDE_END_EXTERN_C
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif /* _QPXMLWRITER_H */
163