source: calamares/trunk/fuentes/src/libcalamares/utils/YamlUtils.h @ 7538

Last change on this file since 7538 was 7538, checked in by kbut, 17 months ago

sync with github

File size: 2.2 KB
Line 
1/* === This file is part of Calamares - <https://github.com/calamares> ===
2 *
3 *   Copyright 2014, Teo Mrnjavac <teo@kde.org>
4 *   Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
5 *
6 *   Calamares is free software: you can redistribute it and/or modify
7 *   it under the terms of the GNU General Public License as published by
8 *   the Free Software Foundation, either version 3 of the License, or
9 *   (at your option) any later version.
10 *
11 *   Calamares is distributed in the hope that it will be useful,
12 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *   GNU General Public License for more details.
15 *
16 *   You should have received a copy of the GNU General Public License
17 *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef YAMLUTILS_H
21#define YAMLUTILS_H
22
23#include <QStringList>
24#include <QVariant>
25
26class QByteArray;
27class QFileInfo;
28
29namespace YAML
30{
31class Node;
32class Exception;
33}
34
35void operator>>( const YAML::Node& node, QStringList& v );
36
37namespace CalamaresUtils
38{
39/**
40 * Loads a given @p filename and returns the YAML data
41 * as a QVariantMap. If filename doesn't exist, or is
42 * malformed in some way, returns an empty map and sets
43 * @p *ok to false. Otherwise sets @p *ok to true.
44 */
45QVariantMap loadYaml( const QString& filename, bool* ok = nullptr );
46/** Convenience overload. */
47QVariantMap loadYaml( const QFileInfo&, bool* ok = nullptr );
48
49QVariant yamlToVariant( const YAML::Node& node );
50QVariant yamlScalarToVariant( const YAML::Node& scalarNode );
51QVariant yamlSequenceToVariant( const YAML::Node& sequenceNode );
52QVariant yamlMapToVariant( const YAML::Node& mapNode );
53
54/**
55 * Given an exception from the YAML parser library, explain
56 * what is going on in terms of the data passed to the parser.
57 * Uses @p label when labeling the data source (e.g. "netinstall data")
58 */
59void explainYamlException( const YAML::Exception& e, const QByteArray& data, const char *label );
60void explainYamlException( const YAML::Exception& e, const QByteArray& data, const QString& label );
61void explainYamlException( const YAML::Exception& e, const QByteArray& data );
62
63} //ns
64
65#endif // YAMLUTILS_H
Note: See TracBrowser for help on using the repository browser.