Xerces-C++ 3.2.5
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$
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_XMLATTR_HPP)
23#define XERCESC_INCLUDE_GUARD_XMLATTR_HPP
24
28#include <xercesc/validators/datatype/DatatypeValidator.hpp>
29
31
54{
55public:
56 // -----------------------------------------------------------------------
57 // Constructors and Destructor
58 // -----------------------------------------------------------------------
61
70
104 (
105 const unsigned int uriId
106 , const XMLCh* const attrName
107 , const XMLCh* const attrPrefix
108 , const XMLCh* const attrValue
110 , const bool specified = true
112 , DatatypeValidator * datatypeValidator = 0
113 , const bool isSchema = false
114 );
115
145 (
146 const unsigned int uriId
147 , const XMLCh* const rawName
148 , const XMLCh* const attrValue
150 , const bool specified = true
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
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
298 , DatatypeValidator * datatypeValidator = 0
299 , const bool isSchema = false
300 );
301
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
364private :
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;
402 XMLSize_t fValueBufSz;
403 XMLCh* fValue;
404 QName* fAttName;
405 MemoryManager* fMemoryManager;
406};
407
408// ---------------------------------------------------------------------------
409// XMLAttr: Constructors and Destructor
410// ---------------------------------------------------------------------------
412{
413 cleanUp();
414}
415
416
417// ---------------------------------------------------------------------------
418// XMLAttr: Getter methods
419// ---------------------------------------------------------------------------
421{
422 return fAttName;
423}
424
425inline const XMLCh* XMLAttr::getName() const
426{
427 return fAttName->getLocalPart();
428}
429
430inline const XMLCh* XMLAttr::getPrefix() const
431{
432 return fAttName->getPrefix();
433}
434
435inline bool XMLAttr::getSpecified() const
436{
437 return fSpecified;
438}
439
441{
442 return fType;
443}
444
445inline const XMLCh* XMLAttr::getValue() const
446{
447 return fValue;
448}
449
450inline unsigned int XMLAttr::getURIId() const
451{
452 return fAttName->getURI();
453}
454
455// ---------------------------------------------------------------------------
456// XMLAttr: Setter methods
457// ---------------------------------------------------------------------------
458inline 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
474inline 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
489inline void XMLAttr::setType(const XMLAttDef::AttTypes newValue)
490{
491 fType = newValue;
492}
493
494inline void XMLAttr::setSpecified(const bool newValue)
495{
496 fSpecified = newValue;
497}
498
500
501#endif
#define XMLPARSER_EXPORT
Definition XercesDefs.hpp:163
#define XERCES_CPP_NAMESPACE_BEGIN
Definition XercesDefs.hpp:112
#define XERCES_CPP_NAMESPACE_END
Definition XercesDefs.hpp:113
uint16_t XMLCh
Definition Xerces_autoconf_config.hpp:120
size_t XMLSize_t
Definition Xerces_autoconf_config.hpp:112
Configurable memory manager.
Definition MemoryManager.hpp:40
Definition QName.hpp:35
const XMLCh * getLocalPart() const
Definition QName.hpp:177
void setName(const XMLCh *const prefix, const XMLCh *const localPart, const unsigned int uriId)
unsigned int getURI() const
Definition QName.hpp:187
const XMLCh * getPrefix() const
Definition QName.hpp:167
AttTypes
Definition XMLAttDef.hpp:72
@ CData
Definition XMLAttDef.hpp:73
This class defines the information about an attribute that will come out of the scanner during parsin...
Definition XMLAttr.hpp:54
const XMLCh * getName() const
This method gets a const pointer to the name of the attribute.
Definition XMLAttr.hpp:425
XMLAttr(const unsigned int uriId, const XMLCh *const rawName, const XMLCh *const attrValue, const XMLAttDef::AttTypes type=XMLAttDef::CData, const bool specified=true, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager, DatatypeValidator *datatypeValidator=0, const bool isSchema=false)
This is the primary constructor which takes all of the information required to construct a complete a...
const XMLCh * getValue() const
This method will get the value of the attribute.
Definition XMLAttr.hpp:445
void setType(const XMLAttDef::AttTypes newType)
This method will update the attribute type of the object.
Definition XMLAttr.hpp:489
unsigned int getURIId() const
This method will get the id of the URI that this attribute's prefix mapped to.
Definition XMLAttr.hpp:450
const XMLCh * getPrefix() const
This method will get a const pointer to the prefix string of this attribute.
Definition XMLAttr.hpp:430
XMLAttDef::AttTypes getType() const
This method will get the type of the attribute.
Definition XMLAttr.hpp:440
void set(const unsigned int uriId, const XMLCh *const attrName, const XMLCh *const attrPrefix, const XMLCh *const attrValue, const XMLAttDef::AttTypes type=XMLAttDef::CData, DatatypeValidator *datatypeValidator=0, const bool isSchema=false)
This method is called to set up a default constructed object after the fact, or to reuse a previously...
Definition XMLAttr.hpp:458
void setName(const unsigned int uriId, const XMLCh *const attrName, const XMLCh *const attrPrefix)
This method will update just the name related fields of the attribute object.
const XMLCh * getQName() const
This method will get the QName of this attribute, which will be the prefix if any,...
void setSpecified(const bool newValue)
This method will update the specified state of the object.
Definition XMLAttr.hpp:494
~XMLAttr()
Definition XMLAttr.hpp:411
void setURIId(const unsigned int uriId)
This method will set the URI id field of this attribute.
XMLAttr(MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
The default constructor just setsup an empty attribute to be filled in the later.
void setValue(const XMLCh *const newValue)
This method will update the value field of the attribute.
QName * getAttName() const
This method returns the attribute name in a QName format.
Definition XMLAttr.hpp:420
XMLAttr(const unsigned int uriId, const XMLCh *const attrName, const XMLCh *const attrPrefix, const XMLCh *const attrValue, const XMLAttDef::AttTypes type=XMLAttDef::CData, const bool specified=true, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager, DatatypeValidator *datatypeValidator=0, const bool isSchema=false)
This is the primary constructor which takes all of the information required to construct a complete a...
bool getSpecified() const
This method will get the specified flag, which indicates whether the attribute was explicitly specifi...
Definition XMLAttr.hpp:435
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition PlatformUtils.hpp:121
This class makes it possible to override the C++ memory management by adding new/delete operators to ...
Definition XMemory.hpp:41