00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #if !defined(XMLATTR_HPP)
00023 #define XMLATTR_HPP
00024
00025 #include <xercesc/util/PlatformUtils.hpp>
00026 #include <xercesc/util/QName.hpp>
00027 #include <xercesc/framework/XMLAttDef.hpp>
00028 #include <xercesc/validators/datatype/DatatypeValidator.hpp>
00029
00030 XERCES_CPP_NAMESPACE_BEGIN
00031
00053 class XMLAttr : public XMemory
00054 {
00055 public:
00056
00057
00058
00061
00069 XMLAttr(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00070
00103 XMLAttr
00104 (
00105 const unsigned int uriId
00106 , const XMLCh* const attrName
00107 , const XMLCh* const attrPrefix
00108 , const XMLCh* const attrValue
00109 , const XMLAttDef::AttTypes type = XMLAttDef::CData
00110 , const bool specified = true
00111 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00112 , DatatypeValidator * datatypeValidator = 0
00113 , const bool isSchema = false
00114 );
00115
00144 XMLAttr
00145 (
00146 const unsigned int uriId
00147 , const XMLCh* const rawName
00148 , const XMLCh* const attrValue
00149 , const XMLAttDef::AttTypes type = XMLAttDef::CData
00150 , const bool specified = true
00151 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00152 , DatatypeValidator * datatypeValidator = 0
00153 , const bool isSchema = false
00154 );
00155
00157
00160 ~XMLAttr();
00162
00163
00164
00165
00166
00167
00170
00174 QName* getAttName() const;
00175
00180 const XMLCh* getName() const;
00181
00186 const XMLCh* getPrefix() const;
00187
00193 const XMLCh* getQName() const;
00194
00199 bool getSpecified() const;
00200
00205 XMLAttDef::AttTypes getType() const;
00206
00212 const XMLCh* getValue() const;
00213
00218 unsigned int getURIId() const;
00219
00224 const XMLCh* getValidatingTypeURI() const;
00225
00230 const XMLCh* getValidatingTypeName() const;
00231
00233
00234
00235
00236
00237
00238
00241
00270 void set
00271 (
00272 const unsigned int uriId
00273 , const XMLCh* const attrName
00274 , const XMLCh* const attrPrefix
00275 , const XMLCh* const attrValue
00276 , const XMLAttDef::AttTypes type = XMLAttDef::CData
00277 , DatatypeValidator * datatypeValidator = 0
00278 , const bool isSchema = false
00279 );
00280
00304 void set
00305 (
00306 const unsigned int uriId
00307 , const XMLCh* const attrRawName
00308 , const XMLCh* const attrValue
00309 , const XMLAttDef::AttTypes type = XMLAttDef::CData
00310 , DatatypeValidator * datatypeValidator = 0
00311 , const bool isSchema = false
00312 );
00313
00328 void setName
00329 (
00330 const unsigned int uriId
00331 , const XMLCh* const attrName
00332 , const XMLCh* const attrPrefix
00333 );
00334
00342 void setSpecified(const bool newValue);
00343
00352 void setType(const XMLAttDef::AttTypes newType);
00353
00361 void setValue(const XMLCh* const newValue);
00362
00370 void setURIId(const unsigned int uriId);
00371
00379 void setDatatypeValidator(DatatypeValidator * datatypeValidator);
00380
00388 void setSchemaValidated(const bool isSchema);
00389
00391
00392
00393
00394 private :
00395
00396
00397
00398 XMLAttr(const XMLAttr&);
00399 XMLAttr& operator=(const XMLAttr&);
00400
00401
00402
00403
00404
00405 void cleanUp();
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437 bool fSpecified;
00438 XMLAttDef::AttTypes fType;
00439 unsigned int fValueBufSz;
00440 XMLCh* fValue;
00441 QName* fAttName;
00442 MemoryManager* fMemoryManager;
00443 DatatypeValidator * fDatatypeValidator;
00444 bool fIsSchemaValidated;
00445 };
00446
00447
00448
00449
00450 inline XMLAttr::~XMLAttr()
00451 {
00452 cleanUp();
00453 }
00454
00455
00456
00457
00458
00459 inline QName* XMLAttr::getAttName() const
00460 {
00461 return fAttName;
00462 }
00463
00464 inline const XMLCh* XMLAttr::getName() const
00465 {
00466 return fAttName->getLocalPart();
00467 }
00468
00469 inline const XMLCh* XMLAttr::getPrefix() const
00470 {
00471 return fAttName->getPrefix();
00472 }
00473
00474 inline bool XMLAttr::getSpecified() const
00475 {
00476 return fSpecified;
00477 }
00478
00479 inline XMLAttDef::AttTypes XMLAttr::getType() const
00480 {
00481 return fType;
00482 }
00483
00484 inline const XMLCh* XMLAttr::getValue() const
00485 {
00486 return fValue;
00487 }
00488
00489 inline unsigned int XMLAttr::getURIId() const
00490 {
00491 return fAttName->getURI();
00492 }
00493
00494 inline const XMLCh* XMLAttr::getValidatingTypeName() const
00495 {
00496 if(fIsSchemaValidated)
00497 {
00498 if(!fDatatypeValidator || fDatatypeValidator->getAnonymous())
00499 return 0;
00500 return fDatatypeValidator->getTypeLocalName();
00501 }
00502 else
00503 {
00504 return XMLAttDef::getAttTypeString(fType, fMemoryManager);
00505 }
00506 }
00507
00508 inline const XMLCh* XMLAttr::getValidatingTypeURI() const
00509 {
00510 if(fIsSchemaValidated)
00511 {
00512 if(!fDatatypeValidator || fDatatypeValidator->getAnonymous())
00513 return 0;
00514 return fDatatypeValidator->getTypeUri();
00515 }
00516 else
00517 {
00518 return 0;
00519 }
00520 }
00521
00522
00523
00524
00525 inline void XMLAttr::set(const unsigned int uriId
00526 , const XMLCh* const attrName
00527 , const XMLCh* const attrPrefix
00528 , const XMLCh* const attrValue
00529 , const XMLAttDef::AttTypes type
00530 , DatatypeValidator * datatypeValidator
00531 , const bool isSchema )
00532 {
00533
00534 fAttName->setName(attrPrefix, attrName, uriId);
00535 setValue(attrValue);
00536
00537
00538 fType = type;
00539
00540
00541 fIsSchemaValidated = isSchema;
00542 fDatatypeValidator = datatypeValidator;
00543 }
00544
00545 inline void XMLAttr::set(const unsigned int uriId
00546 , const XMLCh* const attrRawName
00547 , const XMLCh* const attrValue
00548 , const XMLAttDef::AttTypes type
00549 , DatatypeValidator * datatypeValidator
00550 , const bool isSchema )
00551 {
00552
00553 fAttName->setName(attrRawName, uriId);
00554 setValue(attrValue);
00555
00556
00557 fType = type;
00558
00559
00560 fIsSchemaValidated = isSchema;
00561 fDatatypeValidator = datatypeValidator;
00562 }
00563
00564 inline void XMLAttr::setType(const XMLAttDef::AttTypes newValue)
00565 {
00566 fType = newValue;
00567 }
00568
00569 inline void XMLAttr::setSpecified(const bool newValue)
00570 {
00571 fSpecified = newValue;
00572 }
00573
00574 inline void XMLAttr::setDatatypeValidator(DatatypeValidator *datatypeValidator)
00575 {
00576 fDatatypeValidator = datatypeValidator;
00577 }
00578
00579 inline void XMLAttr::setSchemaValidated(const bool isSchema)
00580 {
00581 fIsSchemaValidated = isSchema;
00582 }
00583
00584 XERCES_CPP_NAMESPACE_END
00585
00586 #endif