1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include <toolkit/out_node.hxx>
24 // NOT FULLY DEFINED SERVICES
40 { return p1
->Name() < p2
->Name(); }
43 struct Less_NodePtr C_Less_NodePtr
;
46 Node
C_aNullNode(Node::null_object
);
49 } // namepace anonymous
52 //********************** Node ***************************//
64 Node::Node( E_NullObject
)
74 const String
& i_name
,
80 nDepth(i_parent
.Depth()+1),
87 for ( NodeList::iterator it
= aChildren
.begin();
88 it
!= aChildren
.end();
95 Node
& Node::Provide_Child( const String
& i_name
)
97 Node
* ret
= find_Child(i_name
);
100 return add_Child(i_name
);
108 // Intentionally 'i_maxDepth != 0', so max_Depth == -1 sets no limit:
112 pParent
->Get_Path(o_result
, i_maxDepth
-1);
113 o_result
<< sName
<< '/';
117 void Node::Get_Chain(
118 StringVector
& o_result
,
124 // This is called also for the toplevel Node,
125 // but there happens nothing:
128 pParent
->Get_Chain(o_result
, i_maxDepth
-1);
129 o_result
.push_back(sName
);
134 Node
* Node::find_Child( const String
& i_name
)
137 aSearch
.sName
= i_name
;
139 NodeList::const_iterator
140 ret
= std::lower_bound( aChildren
.begin(),
144 if ( ret
!= aChildren
.end() ? (*ret
)->Name() == i_name
: false )
150 Node
& Node::add_Child( const String
& i_name
)
152 DYN Node
* pNew
= new Node(i_name
,*this);
153 aChildren
.insert( std::lower_bound( aChildren
.begin(),
161 Node
& Node::provide_Child(
162 StringVector::const_iterator i_next
,
163 StringVector::const_iterator i_end
168 return Provide_Child(*i_next
).provide_Child(i_next
+1,i_end
);
180 } // namespace output
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */