Xalan-C++ API Reference  1.12.0
AttributesImpl.hpp
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 #if !defined(ATTRIBUTESIMPL_HEADER_GUARD_1357924680)
19 #define ATTRIBUTESIMPL_HEADER_GUARD_1357924680
20 
21 
22 
23 // Base include file. Must be first.
25 
26 
27 
29 
30 
31 
32 #include <xercesc/sax2/Attributes.hpp>
33 
34 
35 
36 namespace XALAN_CPP_NAMESPACE {
37 
38 
39 
41 
42 
43 
44 typedef xercesc::Attributes AttributesType;
45 
46 
47 
49 {
50 public:
51 
52  explicit
53  AttributesImpl(MemoryManager& theManager XALAN_DEFAULT_MEMMGR);
54 
55  virtual
56  ~AttributesImpl();
57 
58  AttributesImpl(const AttributesImpl& theSource,
59  MemoryManager& theManager);
60 
61  AttributesImpl(const AttributesType& theSource,
62  MemoryManager& theManager);
63 
65  operator=(const AttributesImpl& theRHS);
66 
68  operator=(const AttributesType& theRHS);
69 
70  // These are inherited from Attributes
71  virtual XalanSize_t
72  getLength() const;
73 
74  virtual const XMLCh*
75  getURI(const XalanSize_t index) const;
76 
77  virtual const XMLCh*
78  getLocalName(const XalanSize_t index) const;
79 
80  virtual const XMLCh*
81  getQName(const XalanSize_t index) const;
82 
83  virtual const XMLCh*
84  getType(const XalanSize_t index) const;
85 
86  virtual const XMLCh*
87  getValue(const XalanSize_t index) const;
88 
89  virtual bool
90  getIndex(
91  const XMLCh* const uri,
92  const XMLCh* const localPart,
93  XalanSize_t& index) const;
94 
95  virtual int
96  getIndex(
97  const XMLCh* const uri,
98  const XMLCh* const localPart) const;
99 
100  virtual bool
101  getIndex(
102  const XMLCh* const qName,
103  XalanSize_t& index) const;
104 
105  virtual int
106  getIndex(const XMLCh* const qname) const;
107 
108  virtual const XMLCh*
109  getType(const XMLCh* const qname) const;
110 
111  virtual const XMLCh*
112  getType(
113  const XMLCh* const uri,
114  const XMLCh* const localName) const;
115 
116  virtual const XMLCh*
117  getValue(const XMLCh* const qname) const;
118 
119  virtual const XMLCh*
120  getValue(
121  const XMLCh* const uri,
122  const XMLCh* const localName) const;
123 
124  MemoryManager&
126  {
127  return m_attributesVector.getMemoryManager();
128  }
129 
130  // The mutators are new to this class.
131 
132  /**
133  * Remove all attributes from the list
134  */
135  virtual void
136  clear();
137 
138  /**
139  * Adds an attribute to the attribute list. Does not check for
140  * duplicates.
141  *
142  * @param qname attribute qname
143  * @param type attribute type, "CDATA," for example
144  * @param value attribute value
145  */
146  void
148  const XMLCh* qname,
149  const XMLCh* type,
150  const XMLCh* value)
151  {
152  const XMLCh theDummy = 0;
153 
154  addAttribute(&theDummy, &theDummy, qname, type, value);
155  }
156 
157  /**
158  * Adds an attribute to the attribute list. Does not check for
159  * duplicates.
160  *
161  * @param uri attribute namespace URI
162  * @param localName attribute local name
163  * @param qname attribute qname
164  * @param type attribute type, "CDATA," for example
165  * @param value attribute value
166  */
167  void
168  addAttribute(
169  const XMLCh* uri,
170  const XMLCh* localName,
171  const XMLCh* qname,
172  const XMLCh* type,
173  const XMLCh* value);
174 
175  /**
176  * Removes an attribute from the attribute list
177  *
178  * @param qname attribute qname
179  */
180  virtual bool
181  removeAttribute(const XMLCh* qname);
182 
183  /**
184  * Swap the contents of two instances. This must _never_
185  * throw an exception.
186  *
187  * @param thOther The instance with which to swap.
188  */
189  void
190  swap(AttributesImpl& theOther)
191  {
192  m_attributesVector.swap(theOther.m_attributesVector);
193  }
194 
195  /**
196  * Reserve room for the given number of
197  * attributes.
198  *
199  * @param theCount The number to reserve
200  */
201  void
202  reserve(XalanSize_t theCount)
203  {
204  m_attributesVector.reserve(theCount);
205  }
206 
207  // This vector will hold the entries.
209 
210 private:
211 
212  // This is not implemented.
213  bool
214  operator==(const AttributesImpl&) const;
215 
216  // Default vector allocation size.
217  enum
218  {
219  eDefaultVectorSize = 5
220  };
221 
223  getNewEntry(
224  const XMLCh* qname,
225  const XMLCh* type,
226  const XMLCh* value,
227  const XMLCh* uri = 0,
228  const XMLCh* localName = 0);
229 
230  // Helper function to delete entries...
231  static void
232  deleteEntries(AttributesVectorType& theVector);
233 
234  AttributesVectorType m_attributesVector;
235 
236  AttributesVectorType m_cacheVector;
237 };
238 
239 
240 
241 }
242 
243 
244 
245 #endif // ATTRIBUTESIMPL_HEADER_GUARD_1357924680
XALAN_CPP_NAMESPACE
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Definition: XalanVersion.hpp:76
xalanc::clear
void clear(XalanDOMString &theString)
Remove all elements from target string.
Definition: DOMStringHelper.hpp:2475
xalanc::XalanVector< AttributeVectorEntryExtended * >
xalanc::AttributeVectorEntryExtended
Definition: AttributeVectorEntryExtended.hpp:36
xalanc::AttributesImpl::swap
void swap(AttributesImpl &theOther)
Swap the contents of two instances.
Definition: AttributesImpl.hpp:190
XALAN_DEFAULT_MEMMGR
#define XALAN_DEFAULT_MEMMGR
Definition: XalanMemoryManagement.hpp:516
XalanVector.hpp
xalanc::operator==
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1118
XALAN_PLATFORMSUPPORT_EXPORT
#define XALAN_PLATFORMSUPPORT_EXPORT
Definition: PlatformSupportDefinitions.hpp:35
PlatformSupportDefinitions.hpp
xalanc::AttributesImpl::reserve
void reserve(XalanSize_t theCount)
Reserve room for the given number of attributes.
Definition: AttributesImpl.hpp:202
xalanc::AttributesImpl::getMemoryManager
MemoryManager & getMemoryManager()
Definition: AttributesImpl.hpp:125
xalanc::AttributesImpl::AttributesVectorType
XalanVector< AttributeVectorEntryExtended * > AttributesVectorType
Definition: AttributesImpl.hpp:208
xalanc::AttributesImpl::addAttribute
void addAttribute(const XMLCh *qname, const XMLCh *type, const XMLCh *value)
Adds an attribute to the attribute list.
Definition: AttributesImpl.hpp:147
xalanc::AttributesImpl
Definition: AttributesImpl.hpp:48
xalanc::AttributesType
xercesc::Attributes AttributesType
Definition: AttributesImpl.hpp:40