Xerces-C++ 3.1.3

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

XMLAttr.hpp
Go to the documentation of this file.
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 /*
19 * $Id: XMLAttr.hpp 932887 2010-04-11 13:04:59Z borisk $
20 */
21
22 #if !defined(XERCESC_INCLUDE_GUARD_XMLATTR_HPP)
23 #define XERCESC_INCLUDE_GUARD_XMLATTR_HPP
24
25 #include <xercesc/util/PlatformUtils.hpp>
26 #include <xercesc/util/QName.hpp>
27 #include <xercesc/framework/XMLAttDef.hpp>
28 #include <xercesc/validators/datatype/DatatypeValidator.hpp>
29
30 XERCES_CPP_NAMESPACE_BEGIN
31
53 class XMLPARSER_EXPORT XMLAttr : public XMemory
54 {
55 public:
56 // -----------------------------------------------------------------------
57 // Constructors and Destructor
58 // -----------------------------------------------------------------------
61
69 XMLAttr(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
70
103 XMLAttr
104 (
105 const unsigned int uriId
106 , const XMLCh* const attrName
107 , const XMLCh* const attrPrefix
108 , const XMLCh* const attrValue
109 , const XMLAttDef::AttTypes type = XMLAttDef::CData
110 , const bool specified = true
111 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
112 , DatatypeValidator * datatypeValidator = 0
113 , const bool isSchema = false
114 );
115
144 XMLAttr
145 (
146 const unsigned int uriId
147 , const XMLCh* const rawName
148 , const XMLCh* const attrValue
149 , const XMLAttDef::AttTypes type = XMLAttDef::CData
150 , const bool specified = true
151 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
152 , DatatypeValidator * datatypeValidator = 0
153 , const bool isSchema = false
154 );
155
157
160 ~XMLAttr();
162
163
164 // -----------------------------------------------------------------------
165 // Getter methods
166 // -----------------------------------------------------------------------
167
170
174 QName* getAttName() const;
175
180 const XMLCh* getName() const;
181
186 const XMLCh* getPrefix() const;
187
193 const XMLCh* getQName() const;
194
199 bool getSpecified() const;
200
205 XMLAttDef::AttTypes getType() const;
206
212 const XMLCh* getValue() const;
213
218 unsigned int getURIId() const;
219
221
222
223 // -----------------------------------------------------------------------
224 // Setter methods
225 // -----------------------------------------------------------------------
226
229
258 void set
259 (
260 const unsigned int uriId
261 , const XMLCh* const attrName
262 , const XMLCh* const attrPrefix
263 , const XMLCh* const attrValue
264 , const XMLAttDef::AttTypes type = XMLAttDef::CData
265 , DatatypeValidator * datatypeValidator = 0
266 , const bool isSchema = false
267 );
268
292 void set
293 (
294 const unsigned int uriId
295 , const XMLCh* const attrRawName
296 , const XMLCh* const attrValue
297 , const XMLAttDef::AttTypes type = XMLAttDef::CData
298 , DatatypeValidator * datatypeValidator = 0
299 , const bool isSchema = false
300 );
301
316 void setName
317 (
318 const unsigned int uriId
319 , const XMLCh* const attrName
320 , const XMLCh* const attrPrefix
321 );
322
330 void setSpecified(const bool newValue);
331
340 void setType(const XMLAttDef::AttTypes newType);
341
349 void setValue(const XMLCh* const newValue);
350
358 void setURIId(const unsigned int uriId);
359
361
362
363
364 private :
365 // -----------------------------------------------------------------------
366 // Unimplemented constructors and operators
367 // -----------------------------------------------------------------------
368 XMLAttr(const XMLAttr&);
369 XMLAttr& operator=(const XMLAttr&);
370
371
372 // -----------------------------------------------------------------------
373 // Private, helper methods
374 // -----------------------------------------------------------------------
375 void cleanUp();
376
377
378 // -----------------------------------------------------------------------
379 // Private instance variables
380 //
381 // fAttName
382 // The Attribute Name;
383 //
384 // fSpecified
385 // True if this attribute appeared in the element; else, false if
386 // it was defaulted from an AttDef.
387 //
388 // fType
389 // The attribute type enum value for this attribute. Indicates what
390 // type of attribute it was.
391 //
392 // fValue
393 // fValueBufSz
394 // The attribute value that was given in the attribute instance, and
395 // its current buffer size (minus one, where the null is.)
396 //
397 // fMemoryManager
398 // The memory manager used for dynamic memory allocation/deallocation
399 // -----------------------------------------------------------------------
400 bool fSpecified;
401 XMLAttDef::AttTypes fType;
402 XMLSize_t fValueBufSz;
403 XMLCh* fValue;
404 QName* fAttName;
405 MemoryManager* fMemoryManager;
406 };
407
408 // ---------------------------------------------------------------------------
409 // XMLAttr: Constructors and Destructor
410 // ---------------------------------------------------------------------------
411 inline XMLAttr::~XMLAttr()
412 {
413 cleanUp();
414 }
415
416
417 // ---------------------------------------------------------------------------
418 // XMLAttr: Getter methods
419 // ---------------------------------------------------------------------------
420 inline QName* XMLAttr::getAttName() const
421 {
422 return fAttName;
423 }
424
425 inline const XMLCh* XMLAttr::getName() const
426 {
427 return fAttName->getLocalPart();
428 }
429
430 inline const XMLCh* XMLAttr::getPrefix() const
431 {
432 return fAttName->getPrefix();
433 }
434
435 inline bool XMLAttr::getSpecified() const
436 {
437 return fSpecified;
438 }
439
440 inline XMLAttDef::AttTypes XMLAttr::getType() const
441 {
442 return fType;
443 }
444
445 inline const XMLCh* XMLAttr::getValue() const
446 {
447 return fValue;
448 }
449
450 inline unsigned int XMLAttr::getURIId() const
451 {
452 return fAttName->getURI();
453 }
454
455 // ---------------------------------------------------------------------------
456 // XMLAttr: Setter methods
457 // ---------------------------------------------------------------------------
458 inline void XMLAttr::set(const unsigned int uriId
459 , const XMLCh* const attrName
460 , const XMLCh* const attrPrefix
461 , const XMLCh* const attrValue
462 , const XMLAttDef::AttTypes type
463 , DatatypeValidator * /*datatypeValidator */
464 , const bool /*isSchema*/ )
465 {
466 // Set the name info and the value via their respective calls
467 fAttName->setName(attrPrefix, attrName, uriId);
468 setValue(attrValue);
469
470 // And store the type
471 fType = type;
472 }
473
474 inline void XMLAttr::set(const unsigned int uriId
475 , const XMLCh* const attrRawName
476 , const XMLCh* const attrValue
477 , const XMLAttDef::AttTypes type
478 , DatatypeValidator * /*datatypeValidator */
479 , const bool /*isSchema*/ )
480 {
481 // Set the name info and the value via their respective calls
482 fAttName->setName(attrRawName, uriId);
483 setValue(attrValue);
484
485 // And store the type
486 fType = type;
487 }
488
489 inline void XMLAttr::setType(const XMLAttDef::AttTypes newValue)
490 {
491 fType = newValue;
492 }
493
494 inline void XMLAttr::setSpecified(const bool newValue)
495 {
496 fSpecified = newValue;
497 }
498
499 XERCES_CPP_NAMESPACE_END
500
501 #endif