LibreOffice Module configmgr (master) 1
setnode.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <sal/config.h>
21
22#include <algorithm>
23
24#include <rtl/ref.hxx>
25#include <rtl/ustring.hxx>
26#include <utility>
27
28#include "data.hxx"
29#include "node.hxx"
30#include "nodemap.hxx"
31#include "setnode.hxx"
32
33namespace configmgr {
34
36 int layer, OUString defaultTemplateName,
37 OUString templateName):
38 Node(layer), defaultTemplateName_(std::move(defaultTemplateName)),
39 templateName_(std::move(templateName)), mandatory_(Data::NO_LAYER)
40{}
41
42rtl::Reference< Node > SetNode::clone(bool keepTemplateName) const {
43 return new SetNode(*this, keepTemplateName);
44}
45
47 return members_;
48}
49
50OUString SetNode::getTemplateName() const {
51 return templateName_;
52}
53
54void SetNode::setMandatory(int layer) {
55 mandatory_ = layer;
56}
57
59 return mandatory_;
60}
61
62
63bool SetNode::isValidTemplate(OUString const & templateName) const {
64 return Data::equalTemplateNames(templateName, defaultTemplateName_) ||
65 std::any_of(
68 [&templateName](OUString const & longName) { return Data::equalTemplateNames(templateName, longName); } );
69}
70
71SetNode::SetNode(SetNode const & other, bool keepTemplateName):
72 Node(other), defaultTemplateName_(other.defaultTemplateName_),
73 additionalTemplateNames_(other.additionalTemplateNames_),
74 mandatory_(other.mandatory_)
75{
77 if (keepTemplateName) {
79 }
80}
81
83
85 return KIND_SET;
86}
87
88}
89
90/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void cloneInto(NodeMap *target) const
Definition: nodemap.cxx:31
virtual rtl::Reference< Node > clone(bool keepTemplateName) const override
Definition: setnode.cxx:42
virtual ~SetNode() override
Definition: setnode.cxx:82
SetNode(int layer, OUString defaultTemplateName, OUString templateName)
Definition: setnode.cxx:35
virtual int getMandatory() const override
Definition: setnode.cxx:58
bool isValidTemplate(OUString const &templateName) const
Definition: setnode.cxx:63
virtual OUString getTemplateName() const override
Definition: setnode.cxx:50
std::vector< OUString > additionalTemplateNames_
Definition: setnode.hxx:64
virtual void setMandatory(int layer) override
Definition: setnode.cxx:54
OUString defaultTemplateName_
Definition: setnode.hxx:63
virtual NodeMap & getMembers() override
Definition: setnode.cxx:46
virtual Kind kind() const override
Definition: setnode.cxx:84
OUString templateName_
Definition: setnode.hxx:66
NodeMap members_
Definition: setnode.hxx:65
static bool equalTemplateNames(OUString const &shortName, OUString const &longName)
Definition: data.cxx:165