bump product version to 6.3.0.0.beta1
[LibreOffice.git] / configmgr / source / setnode.cxx
blobeac56f70f476e0bd1a2e883bda7866337d0fd19c
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 #include <sal/config.h>
22 #include <algorithm>
23 #include <functional>
24 #include <vector>
26 #include <rtl/ref.hxx>
27 #include <rtl/ustring.hxx>
29 #include "data.hxx"
30 #include "node.hxx"
31 #include "nodemap.hxx"
32 #include "setnode.hxx"
34 namespace configmgr {
36 SetNode::SetNode(
37 int layer, OUString const & defaultTemplateName,
38 OUString const & templateName):
39 Node(layer), defaultTemplateName_(defaultTemplateName),
40 templateName_(templateName), mandatory_(Data::NO_LAYER)
43 rtl::Reference< Node > SetNode::clone(bool keepTemplateName) const {
44 return new SetNode(*this, keepTemplateName);
47 NodeMap & SetNode::getMembers() {
48 return members_;
51 OUString SetNode::getTemplateName() const {
52 return templateName_;
55 void SetNode::setMandatory(int layer) {
56 mandatory_ = layer;
59 int SetNode::getMandatory() const {
60 return mandatory_;
64 bool SetNode::isValidTemplate(OUString const & templateName) const {
65 return Data::equalTemplateNames(templateName, defaultTemplateName_) ||
66 std::any_of(
67 additionalTemplateNames_.begin(),
68 additionalTemplateNames_.end(),
69 [&templateName](OUString const & longName) { return Data::equalTemplateNames(templateName, longName); } );
72 SetNode::SetNode(SetNode const & other, bool keepTemplateName):
73 Node(other), defaultTemplateName_(other.defaultTemplateName_),
74 additionalTemplateNames_(other.additionalTemplateNames_),
75 mandatory_(other.mandatory_)
77 other.members_.cloneInto(&members_);
78 if (keepTemplateName) {
79 templateName_ = other.templateName_;
83 SetNode::~SetNode() {}
85 Node::Kind SetNode::kind() const {
86 return KIND_SET;
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */