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 
27 #include "data.hxx"
28 #include "node.hxx"
29 #include "nodemap.hxx"
30 #include "setnode.hxx"
31 
32 namespace configmgr {
33 
35  int layer, OUString const & defaultTemplateName,
36  OUString const & templateName):
37  Node(layer), defaultTemplateName_(defaultTemplateName),
38  templateName_(templateName), mandatory_(Data::NO_LAYER)
39 {}
40 
41 rtl::Reference< Node > SetNode::clone(bool keepTemplateName) const {
42  return new SetNode(*this, keepTemplateName);
43 }
44 
46  return members_;
47 }
48 
49 OUString SetNode::getTemplateName() const {
50  return templateName_;
51 }
52 
53 void SetNode::setMandatory(int layer) {
54  mandatory_ = layer;
55 }
56 
57 int SetNode::getMandatory() const {
58  return mandatory_;
59 }
60 
61 
62 bool SetNode::isValidTemplate(OUString const & templateName) const {
63  return Data::equalTemplateNames(templateName, defaultTemplateName_) ||
64  std::any_of(
67  [&templateName](OUString const & longName) { return Data::equalTemplateNames(templateName, longName); } );
68 }
69 
70 SetNode::SetNode(SetNode const & other, bool keepTemplateName):
71  Node(other), defaultTemplateName_(other.defaultTemplateName_),
72  additionalTemplateNames_(other.additionalTemplateNames_),
73  mandatory_(other.mandatory_)
74 {
75  other.members_.cloneInto(&members_);
76  if (keepTemplateName) {
78  }
79 }
80 
82 
84  return KIND_SET;
85 }
86 
87 }
88 
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual NodeMap & getMembers() override
Definition: setnode.cxx:45
void cloneInto(NodeMap *target) const
Definition: nodemap.cxx:31
virtual ~SetNode() override
Definition: setnode.cxx:81
virtual void setMandatory(int layer) override
Definition: setnode.cxx:53
NodeMap members_
Definition: setnode.hxx:65
virtual Kind kind() const override
Definition: setnode.cxx:83
OUString defaultTemplateName_
Definition: setnode.hxx:63
bool isValidTemplate(OUString const &templateName) const
Definition: setnode.cxx:62
virtual int getMandatory() const override
Definition: setnode.cxx:57
virtual rtl::Reference< Node > clone(bool keepTemplateName) const override
Definition: setnode.cxx:41
SetNode(int layer, OUString const &defaultTemplateName, OUString const &templateName)
Definition: setnode.cxx:34
virtual OUString getTemplateName() const override
Definition: setnode.cxx:49
static bool equalTemplateNames(OUString const &shortName, OUString const &longName)
Definition: data.cxx:161
std::vector< OUString > additionalTemplateNames_
Definition: setnode.hxx:64
OUString templateName_
Definition: setnode.hxx:66