-
Notifications
You must be signed in to change notification settings - Fork 9
/
xml_parameter_writer.h
104 lines (92 loc) · 3.33 KB
/
xml_parameter_writer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// ---------------------------------------------------------------------
//
// Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
//
// This file is part of the deal.II library.
//
// The deal.II library is free software; you can use it, redistribute
// it, and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// The full text of the license can be found in the file LICENSE at
// the top level of the deal.II distribution.
//
// ---------------------------------------------------------------------
#ifndef XMLPARAMETERWRITER_H
#define XMLPARAMETERWRITER_H
#include <QXmlStreamWriter>
#include <QTreeWidget>
#include <QTreeWidgetItem>
namespace dealii
{
/*! @addtogroup ParameterGui
*@{
*/
namespace ParameterGui
{
/**
* The XMLParameterWriter class provides an interface to write parameters stored in a QTreeWidget to a file in XML format.
* This class makes extensive use of the QXmlStreamWriter class, which implements the basic functionalities for writing
* XML files.
*
* @note This class is used in the graphical user interface for the @ref ParameterHandler class.
* It is not compiled into the deal.II libraries and can not be used by applications using deal.II.
*
* @ingroup ParameterGui
* @author Martin Steigemann, Wolfgang Bangerth, 2010
*/
class XMLParameterWriter
{
public:
/**
* Constructor.
* Parameter values from @p tree_widget will be written.
*/
XMLParameterWriter (QTreeWidget *tree_widget);
/**
* This function writes the parameter values stored in <tt>tree_widget</tt>
* to @p device in XML format. We use the QXmlStreamWriter class
* for this. The root element is
* <code><ParameterHandler></code>
*/
bool write_xml_file (QIODevice *device);
private:
/**
* This function writes a given @p item of <tt>tree_widget</tt>
* to a file in XML format. For this the QXmlStreamWriter class is used.
* If the @p item is a parameter, the elements that describes this parameter
* are written:
* @code
* <value>value</value>
* <default_value>default_value</default_value>
* <documentation>documentation</documentation>
* <pattern>pattern</pattern>
* <pattern_description>[pattern_description]</pattern_description>
* @endcode
* If the @p item is a subsection, a start element <code>this_subsection</code> is written
* and <tt>write_item</tt> is called recursively to write the next <tt>item</tt>.
*/
void write_item (QTreeWidgetItem *item);
/**
* Reimplemented from the @ref ParameterHandler class.
* Mangle a string @p s so that it
* doesn't contain any special
* characters or spaces.
*/
QString mangle (const QString &s);
/**
* An QXmlStreamWriter object
* which implements the functionalities
* we need for writing parameters to XML files.
*/
QXmlStreamWriter xml;
/**
* A pointer to the QTreeWidget structure
* which stores the parameters.
*/
QTreeWidget *tree_widget;
};
}
/**@}*/
}
#endif