3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program Helper Library
5 * -------------------------------------------
7 * Copyright 2014 The Android Open Source Project
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 * \brief Test log library
24 *//*--------------------------------------------------------------------*/
32 typedef struct qpXmlWriter_s qpXmlWriter;
34 typedef enum qpXmlAttributeType_e
36 QP_XML_ATTRIBUTE_STRING = 0,
38 QP_XML_ATTRIBUTE_BOOL,
43 typedef struct qpXmlAttribute_s
46 qpXmlAttributeType type;
47 const char* stringValue;
52 DE_INLINE qpXmlAttribute qpSetStringAttrib (const char* name, const char* value)
54 qpXmlAttribute attrib;
56 attrib.type = QP_XML_ATTRIBUTE_STRING;
57 attrib.stringValue = value;
58 attrib.intValue = -678;
59 attrib.boolValue = (deBool)0xFFFFFFFFu;
63 DE_INLINE qpXmlAttribute qpSetIntAttrib (const char* name, int value)
65 qpXmlAttribute attrib;
67 attrib.type = QP_XML_ATTRIBUTE_INT;
68 attrib.stringValue = "<intAttrib>";
69 attrib.intValue = value;
70 attrib.boolValue = (deBool)0xFFFFFFFFu;
74 DE_INLINE qpXmlAttribute qpSetBoolAttrib (const char* name, deBool value)
76 qpXmlAttribute attrib;
78 attrib.type = QP_XML_ATTRIBUTE_BOOL;
79 attrib.stringValue = "<boolAttrib>";
80 attrib.intValue = -679;
81 attrib.boolValue = value;
84 /*--------------------------------------------------------------------*//*!
85 * \brief Create a file based XML Writer instance
86 * \param fileName Name of the file
87 * \param useCompression Set to DE_TRUE to use compression, if supported by implementation
88 * \param flushAfterWrite Set to DE_TRUE to call fflush after writing each XML token
89 * \return qpXmlWriter instance, or DE_NULL if cannot create file
90 *//*--------------------------------------------------------------------*/
91 qpXmlWriter* qpXmlWriter_createFileWriter (FILE* outFile, deBool useCompression, deBool flushAfterWrite);
93 /*--------------------------------------------------------------------*//*!
94 * \brief XML Writer instance
95 * \param a qpXmlWriter instance
96 *//*--------------------------------------------------------------------*/
97 void qpXmlWriter_destroy (qpXmlWriter* writer);
99 /*--------------------------------------------------------------------*//*!
100 * \brief XML Writer instance
101 * \param a qpXmlWriter instance
102 *//*--------------------------------------------------------------------*/
103 void qpXmlWriter_flush (qpXmlWriter* writer);
105 /*--------------------------------------------------------------------*//*!
106 * \brief Start XML document
107 * \param writer qpXmlWriter instance
108 * \return true on success, false on error
109 *//*--------------------------------------------------------------------*/
110 deBool qpXmlWriter_startDocument (qpXmlWriter* writer);
112 /*--------------------------------------------------------------------*//*!
113 * \brief End XML document
114 * \param writer qpXmlWriter instance
115 * \return true on success, false on error
116 *//*--------------------------------------------------------------------*/
117 deBool qpXmlWriter_endDocument (qpXmlWriter* writer);
119 /*--------------------------------------------------------------------*//*!
120 * \brief Start XML element
121 * \param writer qpXmlWriter instance
122 * \param elementName Name of the element
123 * \return true on success, false on error
124 *//*--------------------------------------------------------------------*/
125 deBool qpXmlWriter_startElement (qpXmlWriter* writer, const char* elementName, int numAttribs, const qpXmlAttribute* attribs);
127 /*--------------------------------------------------------------------*//*!
128 * \brief End XML element
129 * \param writer qpXmlWriter instance
130 * \param elementName Name of the element
131 * \return true on success, false on error
132 *//*--------------------------------------------------------------------*/
133 deBool qpXmlWriter_endElement (qpXmlWriter* writer, const char* elementName);
135 /*--------------------------------------------------------------------*//*!
136 * \brief Write raw string into XML document
137 * \param writer qpXmlWriter instance
138 * \param content String to be written
139 * \return true on success, false on error
140 *//*--------------------------------------------------------------------*/
141 deBool qpXmlWriter_writeString (qpXmlWriter* writer, const char* content);
143 /*--------------------------------------------------------------------*//*!
144 * \brief Write base64 encoded data into XML document
145 * \param writer qpXmlWriter instance
146 * \param data Pointer to data to be written
147 * \param numBytes Length of data in bytes
148 * \return true on success, false on error
149 *//*--------------------------------------------------------------------*/
150 deBool qpXmlWriter_writeBase64 (qpXmlWriter* writer, const deUint8* data, size_t numBytes);
152 /*--------------------------------------------------------------------*//*!
153 * \brief Convenience function for writing XML element
154 * \param writer qpXmlWriter instance
155 * \param elementName Name of the element
156 * \param elementContent Contents of the element
157 * \return true on success, false on error
158 *//*--------------------------------------------------------------------*/
159 deBool qpXmlWriter_writeStringElement (qpXmlWriter* writer, const char* elementName, const char* elementContent);
163 #endif /* _QPXMLWRITER_H */