Xerces-C++ 3.2.0

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 932889 2010-04-11 13:10:10Z 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
XMLAttr::setType
void setType(const XMLAttDef::AttTypes newType)
This method will update the attribute type of the object.
Definition: XMLAttr.hpp:489
XMemory
This class makes it possible to override the C++ memory management by adding new/delete operators to ...
Definition: XMemory.hpp:40
XMLPlatformUtils::fgMemoryManager
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition: PlatformUtils.hpp:121
XMLAttr::getSpecified
bool getSpecified() const
This method will get the specified flag, which indicates whether the attribute was explicitly specifi...
Definition: XMLAttr.hpp:435
XMLAttr::getType
XMLAttDef::AttTypes getType() const
This method will get the type of the attribute.
Definition: XMLAttr.hpp:440
XMLAttr::getName
const XMLCh * getName() const
This method gets a const pointer to the name of the attribute.
Definition: XMLAttr.hpp:425
XMLPARSER_EXPORT
#define XMLPARSER_EXPORT
Definition: XercesDefs.hpp:163
XMLAttr
This class defines the information about an attribute that will come out of the scanner during parsin...
Definition: XMLAttr.hpp:53
XMLAttr::getAttName
QName * getAttName() const
This method returns the attribute name in a QName format.
Definition: XMLAttr.hpp:420
XMLAttDef::CData
Definition: XMLAttDef.hpp:73
XMLAttr::getPrefix
const XMLCh * getPrefix() const
This method will get a const pointer to the prefix string of this attribute.
Definition: XMLAttr.hpp:430
XMLAttr::set
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
PlatformUtils.hpp
MemoryManager
Configurable memory manager.
Definition: MemoryManager.hpp:39
XMLCh
uint16_t XMLCh
Definition: Xerces_autoconf_config.hpp:118
QName
Definition: QName.hpp:34
XERCES_CPP_NAMESPACE_BEGIN
#define XERCES_CPP_NAMESPACE_BEGIN
Definition: XercesDefs.hpp:112
XMLAttDef.hpp
XMLAttDef::AttTypes
AttTypes
Definition: XMLAttDef.hpp:71
XMLAttr::setSpecified
void setSpecified(const bool newValue)
This method will update the specified state of the object.
Definition: XMLAttr.hpp:494
XMLSize_t
size_t XMLSize_t
Definition: Xerces_autoconf_config.hpp:110
XMLAttr::getURIId
unsigned int getURIId() const
This method will get the id of the URI that this attribute&#39;s prefix mapped to.
Definition: XMLAttr.hpp:450
XERCES_CPP_NAMESPACE_END
#define XERCES_CPP_NAMESPACE_END
Definition: XercesDefs.hpp:113
QName.hpp
XMLAttr::getValue
const XMLCh * getValue() const
This method will get the value of the attribute.
Definition: XMLAttr.hpp:445
XMLAttr::~XMLAttr
~XMLAttr()
Definition: XMLAttr.hpp:411