Line data Source code
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 : #ifndef ARY_IDL_NNFINDER_HXX
21 : #define ARY_IDL_NNFINDER_HXX
22 :
23 : // USED SERVICES
24 : #include "is_ce.hxx"
25 :
26 :
27 :
28 :
29 : namespace ary
30 : {
31 : namespace idl
32 : {
33 :
34 :
35 : /** Gives context info for tree search functions.
36 :
37 : @collab ->ary::Search_SubTree<>()
38 : @collab ->ary::Search_SubTree_UpTillRoot<>()
39 : */
40 3700 : class Find_ModuleNode
41 : {
42 : public:
43 : typedef Ce_id id_type;
44 : typedef StringVector::const_iterator name_iterator;
45 :
46 : // LIFECYCLE
47 3700 : Find_ModuleNode(
48 : const Ce_Storage & i_rStorage,
49 : name_iterator it_begin,
50 : name_iterator it_end,
51 : const String & i_sName )
52 : : rStorage(i_rStorage),
53 : itBegin(it_begin),
54 : itEnd(it_end),
55 3700 : sName2Search(i_sName) { if (itBegin != itEnd ? (*itBegin).empty() : false) ++itBegin; }
56 : // OPERATIONS
57 33356 : const Module * operator()(
58 : id_type i_id ) const
59 33356 : { return i_id.IsValid()
60 21388 : ? & ary_cast<Module>(rStorage[i_id])
61 54744 : : 0; }
62 :
63 13355 : name_iterator Begin() const { return itBegin; }
64 33670 : name_iterator End() const { return itEnd; }
65 3702 : const String & Name2Search() const { return sName2Search; }
66 :
67 : private:
68 : // DATA
69 : const Ce_Storage & rStorage;
70 : name_iterator itBegin;
71 : name_iterator itEnd;
72 : String sName2Search;
73 : };
74 :
75 :
76 :
77 :
78 : class Types_forSetCe_Id
79 : {
80 : public:
81 : typedef Ce_id element_type;
82 : typedef Ce_Storage find_type;
83 :
84 : // KORR_FUTURE: Check, if this sorting is right or the ary standard
85 : // sorting should be used.
86 : struct sort_type
87 : {
88 : sort_type(
89 : const find_type & i_rFinder )
90 : : rFinder(i_rFinder) {}
91 : bool operator()(
92 : const element_type &
93 : i_r1,
94 : const element_type &
95 : i_r2 ) const
96 : {
97 : return rFinder[i_r1].LocalName()
98 : < rFinder[i_r2].LocalName();
99 : }
100 :
101 : private:
102 : const find_type & rFinder;
103 :
104 : };
105 : };
106 :
107 :
108 : } // namespace idl
109 : } // namespace ary
110 : #endif
111 :
112 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|