|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 /* |
|
18 * Licensed to the Apache Software Foundation (ASF) under one or more |
|
19 * contributor license agreements. See the NOTICE file distributed with |
|
20 * this work for additional information regarding copyright ownership. |
|
21 * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
22 * (the "License"); you may not use this file except in compliance with |
|
23 * the License. You may obtain a copy of the License at |
|
24 * |
|
25 * http://www.apache.org/licenses/LICENSE-2.0 |
|
26 * |
|
27 * Unless required by applicable law or agreed to in writing, software |
|
28 * distributed under the License is distributed on an "AS IS" BASIS, |
|
29 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
30 * See the License for the specific language governing permissions and |
|
31 * limitations under the License. |
|
32 */ |
|
33 |
|
34 /* |
|
35 * $Id: XSNamedMap.hpp 568078 2007-08-21 11:43:25Z amassari $ |
|
36 */ |
|
37 |
|
38 |
|
39 #if !defined(XSNAMEDMAP_HPP) |
|
40 #define XSNAMEDMAP_HPP |
|
41 |
|
42 |
|
43 #include <xercesc/util/XMemory.hpp> |
|
44 #include <xercesc/util/RefHash2KeysTableOf.hpp> |
|
45 #include <xercesc/util/RefVectorOf.hpp> |
|
46 |
|
47 XERCES_CPP_NAMESPACE_BEGIN |
|
48 |
|
49 class XMLStringPool; |
|
50 |
|
51 /* |
|
52 * This template provides convenient mappings between name,namespace |
|
53 * pairs and individual components, as well as means to iterate through all the |
|
54 * named components on some object. |
|
55 */ |
|
56 |
|
57 template <class TVal> class XSNamedMap: public XMemory |
|
58 { |
|
59 public: |
|
60 // ----------------------------------------------------------------------- |
|
61 // Constructors and Destructor |
|
62 // ----------------------------------------------------------------------- |
|
63 /** @name Constructors */ |
|
64 //@{ |
|
65 |
|
66 XSNamedMap(const unsigned int maxElems, |
|
67 const unsigned int modulus, |
|
68 XMLStringPool* uriStringPool, |
|
69 const bool adoptElems, |
|
70 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
|
71 ); |
|
72 //@} |
|
73 |
|
74 /** @name Destructor */ |
|
75 //@{ |
|
76 ~XSNamedMap(); |
|
77 |
|
78 //@} |
|
79 |
|
80 // ----------------------------------------------------------------------- |
|
81 // XSNamedMap methods |
|
82 // ----------------------------------------------------------------------- |
|
83 /** @name XSNamedMap methods */ |
|
84 //@{ |
|
85 |
|
86 /** |
|
87 * The number of <code>XSObjects</code> in the <code>XSObjectList</code>. |
|
88 * The range of valid child object indices is 0 to |
|
89 * <code>mapLength-1</code> inclusive. |
|
90 */ |
|
91 unsigned int getLength(); |
|
92 |
|
93 /** |
|
94 * Returns the <code>index</code>th item in the collection. The index |
|
95 * starts at 0. If <code>index</code> is greater than or equal to the |
|
96 * number of objects in the list, this returns <code>null</code>. |
|
97 * @param index index into the collection. |
|
98 * @return The <code>XSObject</code> at the <code>index</code>th |
|
99 * position in the <code>XSObjectList</code>, or <code>null</code> if |
|
100 * that is not a valid index. |
|
101 */ |
|
102 TVal *item(unsigned int index); |
|
103 |
|
104 /** |
|
105 * Retrieves a component specified by local name and namespace URI. |
|
106 * <br>applications must use the value null as the |
|
107 * <code>compNamespace</code> parameter for components whose targetNamespace property |
|
108 * is absent. |
|
109 * @param compNamespace The namespace URI of the component to retrieve. |
|
110 * @param localName The local name of the component to retrieve. |
|
111 * @return A component (of any type) with the specified local |
|
112 * name and namespace URI, or <code>null</code> if they do not |
|
113 * identify any node in this map. |
|
114 */ |
|
115 TVal *itemByName(const XMLCh *compNamespace, |
|
116 const XMLCh *localName); |
|
117 |
|
118 //@} |
|
119 |
|
120 //---------------------------------- |
|
121 /** methods needed by implementation */ |
|
122 |
|
123 //@{ |
|
124 void addElement(TVal* const toAdd, const XMLCh* key1, const XMLCh* key2); |
|
125 //@} |
|
126 |
|
127 |
|
128 private : |
|
129 // ----------------------------------------------------------------------- |
|
130 // Unimplemented constructors and operators |
|
131 // ----------------------------------------------------------------------- |
|
132 XSNamedMap(const XSNamedMap<TVal>&); |
|
133 XSNamedMap<TVal>& operator=(const XSNamedMap<TVal>&); |
|
134 |
|
135 // ----------------------------------------------------------------------- |
|
136 // Data members |
|
137 // |
|
138 // fMemoryManager |
|
139 // manager used to allocate memory needed by this object |
|
140 MemoryManager *const fMemoryManager; |
|
141 XMLStringPool* fURIStringPool; |
|
142 RefVectorOf<TVal>* fVector; |
|
143 RefHash2KeysTableOf<TVal>* fHash; |
|
144 }; |
|
145 |
|
146 |
|
147 |
|
148 XERCES_CPP_NAMESPACE_END |
|
149 |
|
150 #if !defined(XERCES_TMPLSINC) |
|
151 #include <xercesc/framework/psvi/XSNamedMap.c> |
|
152 #endif |
|
153 |
|
154 #endif |