Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2021 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 :
23 : #pragma once
24 :
25 : #include "serialization/xmlstreamreader.h"
26 :
27 : #include "draw/types/color.h"
28 : #include "draw/types/geometry.h"
29 :
30 : #include "../types/types.h"
31 :
32 : namespace mu::engraving {
33 : class XmlReader : public muse::XmlStreamReader
34 : {
35 : public:
36 :
37 116 : XmlReader() = default;
38 2231 : XmlReader(const muse::ByteArray& d)
39 2231 : : XmlStreamReader(d) {}
40 1621 : XmlReader(muse::io::IODevice* d)
41 1621 : : XmlStreamReader(d) {}
42 :
43 : #ifndef NO_QT_SUPPORT
44 0 : XmlReader(const QByteArray& d)
45 0 : : XmlStreamReader(d) {}
46 : #endif
47 :
48 : XmlReader(const XmlReader&) = delete;
49 : XmlReader& operator=(const XmlReader&) = delete;
50 :
51 : ~XmlReader();
52 :
53 : void unknown();
54 :
55 7799 : bool readBool() { return XmlStreamReader::readInt(); }
56 53515 : double readDouble(bool* ok = nullptr) { return XmlStreamReader::readDouble(ok); }
57 : double readDouble(double min, double max);
58 :
59 : PointF readPoint();
60 : SizeF readSize();
61 : ScaleF readScale();
62 : RectF readRect();
63 : Color readColor();
64 : Fraction readFraction();
65 : String readXml();
66 :
67 1742 : void setDocName(const String& s) { m_docName = s; }
68 232 : String docName() const { return m_docName; }
69 :
70 : // for reading old files (< 3.01)
71 116 : void setByteOffsetAdjustment(int64_t val) { m_byteOffsetAdjustment = val; }
72 :
73 : private:
74 :
75 : void htmlToString(int level, String*);
76 :
77 : String m_docName; // used for error reporting
78 : int64_t m_byteOffsetAdjustment = 0;
79 : };
80 : }
|