QtBase
v6.3.1
qmake
generators
xmloutput.h
Go to the documentation of this file.
1
/****************************************************************************
2
**
3
** Copyright (C) 2016 The Qt Company Ltd.
4
** Contact: https://www.qt.io/licensing/
5
**
6
** This file is part of the qmake application of the Qt Toolkit.
7
**
8
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9
** Commercial License Usage
10
** Licensees holding valid commercial Qt licenses may use this file in
11
** accordance with the commercial license agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and The Qt Company. For licensing terms
14
** and conditions see https://www.qt.io/terms-conditions. For further
15
** information use the contact form at https://www.qt.io/contact-us.
16
**
17
** GNU General Public License Usage
18
** Alternatively, this file may be used under the terms of the GNU
19
** General Public License version 3 as published by the Free Software
20
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21
** included in the packaging of this file. Please review the following
22
** information to ensure the GNU General Public License requirements will
23
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24
**
25
** $QT_END_LICENSE$
26
**
27
****************************************************************************/
28
29
#ifndef XMLOUTPUT_H
30
#define XMLOUTPUT_H
31
32
#include <
qtextstream.h
>
33
#include <
qstack.h
>
34
35
QT_BEGIN_NAMESPACE
36
37
class
XmlOutput
38
{
39
public
:
40
enum
ConverstionType
{
41
NoConversion
,
// No change
42
EscapeConversion
,
// Use '\"'
43
XMLConversion
// Use "
44
};
45
enum
XMLFormat
{
46
NoNewLine
,
// No new lines, unless added manually
47
NewLine
// All properties & tags indented on new lines
48
};
49
enum
XMLState
{
50
Bare
,
// Not in tag or attribute
51
Tag
,
// <tagname attribute1="value"
52
Attribute
// attribute2="value">
53
};
54
enum
XMLType
{
55
tNothing
,
// No XML output, and not state change
56
tRaw
,
// Raw text (no formating)
57
tDeclaration
,
// <?xml version="x.x" encoding="xxx"?>
58
tTag
,
// <tagname attribute1="value"
59
tTagValue
,
// <tagname>value</tagname>
60
tValueTag
,
// value</tagname>
61
tCloseTag
,
// Closes an open tag
62
tAttribute
,
// attribute2="value">
63
tAttributeTag
,
// attribute on the same line as a tag
64
tData
,
// Tag data (formating done)
65
tImport
,
// <import "type"="path" />
66
tComment
,
// <!-- Comment -->
67
tCDATA
// <![CDATA[ ... ]]>
68
};
69
70
XmlOutput
(
QTextStream
&
file
,
ConverstionType
type
=
XMLConversion
);
71
~XmlOutput
();
72
73
// Settings
74
void
setIndentString
(
const
QString
&
indentString
);
75
QString
indentString
();
76
void
setIndentLevel
(
int
level
);
77
int
indentLevel
();
78
void
setState
(
XMLState
state
);
79
void
setFormat
(
XMLFormat
newFormat);
80
XMLState
state
();
81
82
83
struct
xml_output
{
84
XMLType
xo_type
;
// Type of struct instance
85
QString
xo_text
;
// Tag/Attribute name/xml version
86
QString
xo_value
;
// Value of attributes/xml encoding
87
88
xml_output
(
XMLType
type
,
const
QString
&
text
,
const
QString
&
value
)
89
:
xo_type
(
type
),
xo_text
(
text
),
xo_value
(
value
) {}
90
xml_output
(
const
xml_output
&xo)
91
:
xo_type
(xo.
xo_type
),
xo_text
(xo.
xo_text
),
xo_value
(xo.
xo_value
) {}
92
};
93
94
// Streams
95
XmlOutput
&
operator<<
(
const
QString
&
o
);
96
XmlOutput
&
operator<<
(
const
xml_output&
o
);
97
98
private
:
99
void
increaseIndent();
100
void
decreaseIndent();
101
void
updateIndent();
102
103
QString
doConversion(
const
QString
&
text
);
104
105
// Output functions
106
void
newTag(
const
QString
&
tag
);
107
void
newTagOpen(
const
QString
&
tag
);
108
void
closeOpen();
109
void
closeTag();
110
void
closeTo(
const
QString
&
tag
);
111
void
closeAll();
112
113
void
addDeclaration(
const
QString
&
version
,
const
QString
&encoding);
114
void
addRaw(
const
QString
&rawText);
115
void
addAttribute(
const
QString
&
attribute
,
const
QString
&
value
);
116
void
addAttributeTag(
const
QString
&
attribute
,
const
QString
&
value
);
117
void
addData(
const
QString
&
data
);
118
119
// Data
120
QTextStream
&xmlFile;
121
QString
indent;
122
123
QString
currentIndent;
124
int
currentLevel;
125
XMLState
currentState;
126
127
XMLFormat
format
;
128
ConverstionType
conversion;
129
QStack<QString>
tagStack;
130
};
131
132
inline
XmlOutput::xml_output
noxml
()
133
{
134
return
XmlOutput::xml_output
(
XmlOutput::tNothing
,
QString
(),
QString
());
135
}
136
137
inline
XmlOutput::xml_output
raw
(
const
QString
&rawText)
138
{
139
return
XmlOutput::xml_output
(
XmlOutput::tRaw
, rawText,
QString
());
140
}
141
142
inline
XmlOutput::xml_output
declaration
(
const
QString
&
version
=
QString
(
"1.0"
),
143
const
QString
&encoding =
QString
())
144
{
145
return
XmlOutput::xml_output
(
XmlOutput::tDeclaration
,
version
, encoding);
146
}
147
148
inline
XmlOutput::xml_output
decl
(
const
QString
&
version
=
QString
(
"1.0"
),
149
const
QString
&encoding =
QString
())
150
{
151
return
declaration
(
version
, encoding);
152
}
153
154
inline
XmlOutput::xml_output
tag
(
const
QString
&
name
)
155
{
156
return
XmlOutput::xml_output
(
XmlOutput::tTag
,
name
,
QString
());
157
}
158
159
160
inline
XmlOutput::xml_output
valueTag
(
const
QString
&
value
)
161
{
162
return
XmlOutput::xml_output
(
XmlOutput::tValueTag
,
value
,
QString
());
163
}
164
165
inline
XmlOutput::xml_output
tagValue
(
const
QString
&tagName,
const
QString
&
value
)
166
{
167
return
XmlOutput::xml_output
(
XmlOutput::tTagValue
, tagName,
value
);
168
}
169
170
inline
XmlOutput::xml_output
import
(
const
QString
&tagName,
const
QString
&
value
)
171
{
172
return
XmlOutput::xml_output
(
XmlOutput::tImport
, tagName,
value
);
173
}
174
175
inline
XmlOutput::xml_output
closetag
()
176
{
177
return
XmlOutput::xml_output
(
XmlOutput::tCloseTag
,
QString
(),
QString
());
178
}
179
180
inline
XmlOutput::xml_output
closetag
(
const
QString
&toTag)
181
{
182
return
XmlOutput::xml_output
(
XmlOutput::tCloseTag
, toTag,
QString
());
183
}
184
185
inline
XmlOutput::xml_output
closeall
()
186
{
187
return
XmlOutput::xml_output
(
XmlOutput::tCloseTag
,
QString
(),
QString
(
"all"
));
188
}
189
190
inline
XmlOutput::xml_output
attribute
(
const
QString
&
name
,
191
const
QString
&
value
)
192
{
193
return
XmlOutput::xml_output
(
XmlOutput::tAttribute
,
name
,
value
);
194
}
195
196
inline
XmlOutput::xml_output
attributeTag
(
const
QString
&
name
,
197
const
QString
&
value
)
198
{
199
return
XmlOutput::xml_output
(
XmlOutput::tAttributeTag
,
name
,
value
);
200
}
201
202
inline
XmlOutput::xml_output
attr
(
const
QString
&
name
,
203
const
QString
&
value
)
204
{
205
return
attribute
(
name
,
value
);
206
}
207
208
inline
XmlOutput::xml_output
attrTag
(
const
QString
&
name
,
209
const
QString
&
value
)
210
{
211
return
attributeTag
(
name
,
value
);
212
}
213
214
inline
XmlOutput::xml_output
data
(
const
QString
&
text
=
QString
())
215
{
216
return
XmlOutput::xml_output
(
XmlOutput::tData
,
text
,
QString
());
217
}
218
219
inline
XmlOutput::xml_output
comment
(
const
QString
&
text
)
220
{
221
return
XmlOutput::xml_output
(
XmlOutput::tComment
,
text
,
QString
());
222
}
223
224
inline
XmlOutput::xml_output
cdata
(
const
QString
&
text
)
225
{
226
return
XmlOutput::xml_output
(
XmlOutput::tCDATA
,
text
,
QString
());
227
}
228
229
QT_END_NAMESPACE
230
231
#endif
// XMLOUTPUT_H
value
#define value
[5]
Definition:
src_corelib_global_qglobal.cpp:107
QByteArray::data
char * data()
Definition:
qopengles2ext.h:206
QStack< QString >
QString
The QString class provides a Unicode character string.
Definition:
qstring.h:388
QTextStream
The QTextStream class provides a convenient interface for reading and writing text.
Definition:
qtextstream.h:62
XmlOutput
Definition:
xmloutput.h:38
XmlOutput::XMLState
XMLState
Definition:
xmloutput.h:49
XmlOutput::Bare
@ Bare
Definition:
xmloutput.h:50
XmlOutput::Attribute
@ Attribute
Definition:
xmloutput.h:52
XmlOutput::Tag
@ Tag
Definition:
xmloutput.h:51
XmlOutput::state
XMLState state()
Definition:
xmloutput.cpp:76
XmlOutput::XMLType
XMLType
Definition:
xmloutput.h:54
XmlOutput::tTagValue
@ tTagValue
Definition:
xmloutput.h:59
XmlOutput::tCloseTag
@ tCloseTag
Definition:
xmloutput.h:61
XmlOutput::tData
@ tData
Definition:
xmloutput.h:64
XmlOutput::tCDATA
@ tCDATA
Definition:
xmloutput.h:67
XmlOutput::tImport
@ tImport
Definition:
xmloutput.h:65
XmlOutput::tComment
@ tComment
Definition:
xmloutput.h:66
XmlOutput::tRaw
@ tRaw
Definition:
xmloutput.h:56
XmlOutput::tAttribute
@ tAttribute
Definition:
xmloutput.h:62
XmlOutput::tDeclaration
@ tDeclaration
Definition:
xmloutput.h:57
XmlOutput::tAttributeTag
@ tAttributeTag
Definition:
xmloutput.h:63
XmlOutput::tNothing
@ tNothing
Definition:
xmloutput.h:55
XmlOutput::tTag
@ tTag
Definition:
xmloutput.h:58
XmlOutput::tValueTag
@ tValueTag
Definition:
xmloutput.h:60
XmlOutput::setState
void setState(XMLState state)
Definition:
xmloutput.cpp:66
XmlOutput::XMLFormat
XMLFormat
Definition:
xmloutput.h:45
XmlOutput::NoNewLine
@ NoNewLine
Definition:
xmloutput.h:46
XmlOutput::NewLine
@ NewLine
Definition:
xmloutput.h:47
XmlOutput::setFormat
void setFormat(XMLFormat newFormat)
Definition:
xmloutput.cpp:71
XmlOutput::indentString
QString indentString()
Definition:
xmloutput.cpp:51
XmlOutput::setIndentLevel
void setIndentLevel(int level)
Definition:
xmloutput.cpp:56
XmlOutput::operator<<
XmlOutput & operator<<(const QString &o)
Definition:
xmloutput.cpp:153
XmlOutput::indentLevel
int indentLevel()
Definition:
xmloutput.cpp:61
XmlOutput::setIndentString
void setIndentString(const QString &indentString)
Definition:
xmloutput.cpp:46
XmlOutput::XmlOutput
XmlOutput(QTextStream &file, ConverstionType type=XMLConversion)
Definition:
xmloutput.cpp:33
XmlOutput::ConverstionType
ConverstionType
Definition:
xmloutput.h:40
XmlOutput::XMLConversion
@ XMLConversion
Definition:
xmloutput.h:43
XmlOutput::EscapeConversion
@ EscapeConversion
Definition:
xmloutput.h:42
XmlOutput::NoConversion
@ NoConversion
Definition:
xmloutput.h:41
XmlOutput::~XmlOutput
~XmlOutput()
Definition:
xmloutput.cpp:40
text
QString text
[meta data]
Definition:
doc_src_properties.cpp:149
version
int const char * version
Definition:
zlib.h:814
QT_BEGIN_NAMESPACE
Definition:
server.cpp:57
QT_END_NAMESPACE
Definition:
qsharedpointer.cpp:1532
QString
#define QString()
Definition:
parse-defines.h:51
value
EGLOutputLayerEXT EGLint EGLAttrib value
Definition:
qeglstreamconvenience_p.h:82
attribute
EGLOutputLayerEXT EGLint attribute
Definition:
qeglstreamconvenience_p.h:82
Tag::text
@ text
type
GLenum type
Definition:
qopengl.h:270
level
GLenum GLuint GLint level
Definition:
qopengles2ext.h:416
data
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
Definition:
qopengles2ext.h:206
name
GLuint name
Definition:
qopengles2ext.h:156
format
GLint GLsizei GLsizei GLenum format
Definition:
qopengles2ext.h:206
qstack.h
qtextstream.h
o
TestClass o
Definition:
src_concurrent_qtconcurrentrun.cpp:133
file
QFile file
[0]
Definition:
src_corelib_io_qfile.cpp:52
XmlOutput::xml_output
Definition:
xmloutput.h:83
XmlOutput::xml_output::xml_output
xml_output(const xml_output &xo)
Definition:
xmloutput.h:90
XmlOutput::xml_output::xml_output
xml_output(XMLType type, const QString &text, const QString &value)
Definition:
xmloutput.h:88
XmlOutput::xml_output::xo_text
QString xo_text
Definition:
xmloutput.h:85
XmlOutput::xml_output::xo_value
QString xo_value
Definition:
xmloutput.h:86
XmlOutput::xml_output::xo_type
XMLType xo_type
Definition:
xmloutput.h:84
closeall
XmlOutput::xml_output closeall()
Definition:
xmloutput.h:185
attribute
XmlOutput::xml_output attribute(const QString &name, const QString &value)
Definition:
xmloutput.h:190
declaration
XmlOutput::xml_output declaration(const QString &version=QString("1.0"), const QString &encoding=QString())
Definition:
xmloutput.h:142
cdata
XmlOutput::xml_output cdata(const QString &text)
Definition:
xmloutput.h:224
tag
XmlOutput::xml_output tag(const QString &name)
Definition:
xmloutput.h:154
closetag
XmlOutput::xml_output closetag()
Definition:
xmloutput.h:175
noxml
XmlOutput::xml_output noxml()
Definition:
xmloutput.h:132
raw
XmlOutput::xml_output raw(const QString &rawText)
Definition:
xmloutput.h:137
attributeTag
XmlOutput::xml_output attributeTag(const QString &name, const QString &value)
Definition:
xmloutput.h:196
tagValue
XmlOutput::xml_output tagValue(const QString &tagName, const QString &value)
Definition:
xmloutput.h:165
decl
XmlOutput::xml_output decl(const QString &version=QString("1.0"), const QString &encoding=QString())
Definition:
xmloutput.h:148
attrTag
XmlOutput::xml_output attrTag(const QString &name, const QString &value)
Definition:
xmloutput.h:208
comment
XmlOutput::xml_output comment(const QString &text)
Definition:
xmloutput.h:219
attr
XmlOutput::xml_output attr(const QString &name, const QString &value)
Definition:
xmloutput.h:202
valueTag
XmlOutput::xml_output valueTag(const QString &value)
Definition:
xmloutput.h:160
Generated by
1.9.1