-
Notifications
You must be signed in to change notification settings - Fork 9
/
xml_parameter_reader.h
138 lines (120 loc) · 4.25 KB
/
xml_parameter_reader.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// ---------------------------------------------------------------------
//
// 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 XMLPARAMETERREADER_H
#define XMLPARAMETERREADER_H
#include <QIcon>
#include <QXmlStreamReader>
#include <QTreeWidget>
#include <QTreeWidgetItem>
namespace dealii
{
/*! @addtogroup ParameterGui
*@{
*/
namespace ParameterGui
{
/**
* The XMLParameterReader class provides an interface to parse parameters from XML files to a QTreeWidget.
* This class makes extensive use of the QXmlStreamReader class, which implements the basic functionalities
* for parsing 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 XMLParameterReader
{
public:
/**
* Constructor.
* The parameter values will be stored in @p tree_widget.
*/
XMLParameterReader (QTreeWidget *tree_widget);
/**
* This function reads the parameters from @p device into the <tt>tree_widget</tt>.
* We use the QXmlStreamReader class for this.
* There must be a start element
* <code><ParameterHandler></code>
* and an end element <code></ParameterHandler></code>
* otherwise an exception is thrown.
*/
bool read_xml_file (QIODevice *device);
/**
* This function returns an error message.
*/
QString error_string () const;
private:
/**
* This function implements a loop over the XML file
* and parses XML elements. It calls @ref read_subsection_element
* till the <code></ParameterHandler></code> element is found
* or the end of the file is reached. In this case, an exception is thrown.
*/
void parse_parameters ();
/**
* This functions parses a <tt>subsection</tt>.
* and adds it as a child to @p parent.
* If the next element is <code><value></code>,
* this functions calls @ref read_parameter_element
* otherwise the function itself recursively.
*/
void read_subsection_element (QTreeWidgetItem *parent);
/**
* This function parses a <tt>parameter</tt> and
* and adds it as a child to @p parent.
* A <tt>parameter</tt> description consists of five elements:
* @code
* <value>value</value>
* <default_value>default_value</default_value>
* <documentation>documentation</documentation>
* <pattern>pattern</pattern>
* <pattern_description>[pattern_description]</pattern_description>
* @endcode
* If a <tt>parameter</tt> description is incomplete, an exception
* is thrown.
*/
void read_parameter_element (QTreeWidgetItem *parent);
/**
* Reimplemented from the @ref ParameterHandler class.
* Unmangle a string @p s into its original form.
*/
QString demangle (const QString &s);
/**
* This helper function creates a new child of @p item in the tree.
*/
QTreeWidgetItem *create_child_item(QTreeWidgetItem *item);
/**
* The QXmlStreamReader object for reading XML elements.
*/
QXmlStreamReader xml;
/**
* A pointer to the tree structure.
*/
QTreeWidget *tree_widget;
/**
* An icon for subsections in the tree structure.
*/
QIcon subsection_icon;
/**
* An icon for parameters in the tree structure.
*/
QIcon parameter_icon;
};
}
/**@}*/
}
#endif