Fix GNU C++ version check
[LibreOffice.git] / configmgr / source / xcuparser.hxx
blob680b294bd6b3ac3c96bc3c92105ca2d986f306a8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #include <sal/config.h>
24 #include <set>
25 #include <stack>
26 #include <string_view>
28 #include <rtl/ref.hxx>
29 #include <rtl/ustring.hxx>
30 #include <utility>
31 #include <xmlreader/xmlreader.hxx>
33 #include "additions.hxx"
34 #include "node.hxx"
35 #include "nodemap.hxx"
36 #include "parser.hxx"
37 #include "type.hxx"
38 #include "valueparser.hxx"
40 namespace xmlreader { struct Span; }
42 namespace configmgr {
44 class GroupNode;
45 class LocalizedPropertyNode;
46 class Modifications;
47 class Partial;
48 class PropertyNode;
49 class SetNode;
50 struct Data;
52 class XcuParser: public Parser {
53 public:
54 XcuParser(
55 int layer, Data & data, Partial const * partial,
56 Modifications * broadcastModifications, Additions * additions);
58 private:
59 virtual ~XcuParser() override;
61 virtual xmlreader::XmlReader::Text getTextMode() override;
63 virtual bool startElement(
64 xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name,
65 std::set< OUString > const * existingDependencies) override;
67 virtual void endElement(xmlreader::XmlReader const & reader) override;
69 virtual void characters(xmlreader::Span const & span) override;
71 enum Operation {
72 OPERATION_MODIFY, OPERATION_REPLACE, OPERATION_FUSE, OPERATION_REMOVE };
74 static Operation parseOperation(xmlreader::Span const & text);
76 bool isAlreadyFinalized(int finalizedLayer) const;
78 void handleComponentData(xmlreader::XmlReader & reader);
80 void handleItem(xmlreader::XmlReader & reader);
82 void handlePropValue(xmlreader::XmlReader & reader, PropertyNode * prop);
84 void handleLocpropValue(
85 xmlreader::XmlReader & reader, LocalizedPropertyNode * locprop);
87 void handleGroupProp(xmlreader::XmlReader & reader, GroupNode * group);
89 void handleUnknownGroupProp(
90 xmlreader::XmlReader const & reader, GroupNode const * group,
91 OUString const & name, Type type, Operation operation,
92 bool finalized);
94 void handlePlainGroupProp(
95 xmlreader::XmlReader const & reader, GroupNode * group,
96 NodeMap::iterator const & propertyIndex, std::u16string_view name,
97 Type type, Operation operation, bool finalized);
99 void handleLocalizedGroupProp(
100 xmlreader::XmlReader const & reader, LocalizedPropertyNode * property,
101 OUString const & name, Type type, Operation operation,
102 bool finalized);
104 void handleGroupNode(
105 xmlreader::XmlReader & reader, rtl::Reference< Node > const & group);
107 void handleSetNode(xmlreader::XmlReader & reader, SetNode * set);
109 void recordModification(bool addition);
111 struct State {
112 rtl::Reference< Node > node; // empty if ignore or <items>
113 OUString name; // empty and ignored if !insert
114 bool ignore;
115 bool insert;
116 bool pop;
118 static State Ignore(bool thePop) { return State(thePop); }
120 static State Modify(rtl::Reference< Node > const & theNode)
121 { return State(theNode); }
123 static State Insert(
124 rtl::Reference< Node > const & theNode, OUString const & theName)
125 { return State(theNode, theName); }
127 private:
128 explicit State(bool thePop): ignore(true), insert(false), pop(thePop) {}
130 explicit State(rtl::Reference< Node > theNode):
131 node(std::move(theNode)), ignore(false), insert(false), pop(true)
134 State(
135 rtl::Reference< Node > theNode, OUString theName):
136 node(std::move(theNode)), name(std::move(theName)), ignore(false), insert(true), pop(true)
140 ValueParser valueParser_;
141 Data & data_;
142 Partial const * partial_;
143 Modifications * broadcastModifications_;
144 Additions * additions_;
145 bool recordModifications_;
146 bool trackPath_;
147 OUString componentName_;
148 std::stack< State > state_;
149 std::vector<OUString> path_;
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */