00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 #if !defined(ATTDEF_HPP)
00022 #define ATTDEF_HPP
00023 
00024 #include <xercesc/util/PlatformUtils.hpp>
00025 #include <xercesc/util/XMLString.hpp>
00026 #include <xercesc/util/XMemory.hpp>
00027 #include <xercesc/internal/XSerializable.hpp>
00028 
00029 XERCES_CPP_NAMESPACE_BEGIN
00030 
00031 class XMLAttr;
00032 
00051 class  XMLAttDef : public XSerializable, public XMemory
00052 {
00053 public:
00054     
00055     
00056     
00057     
00058     
00059     
00060     
00061     
00062     
00063     
00064     
00065     
00066     
00067     
00068     
00069     
00070     enum AttTypes
00071     {
00072         CData               = 0
00073         , ID                = 1
00074         , IDRef             = 2
00075         , IDRefs            = 3
00076         , Entity            = 4
00077         , Entities          = 5
00078         , NmToken           = 6
00079         , NmTokens          = 7
00080         , Notation          = 8
00081         , Enumeration       = 9
00082         , Simple            = 10
00083         , Any_Any           = 11
00084         , Any_Other         = 12
00085         , Any_List          = 13
00086 
00087         , AttTypes_Count
00088         , AttTypes_Min      = 0
00089         , AttTypes_Max      = 13
00090         , AttTypes_Unknown  = -1
00091     };
00092 
00093     enum DefAttTypes
00094     {
00095         Default                  = 0
00096         , Fixed                  = 1
00097         , Required               = 2
00098         , Required_And_Fixed     = 3
00099         , Implied                = 4
00100         , ProcessContents_Skip   = 5
00101         , ProcessContents_Lax    = 6
00102         , ProcessContents_Strict = 7
00103         , Prohibited             = 8
00104 
00105         , DefAttTypes_Count
00106         , DefAttTypes_Min   = 0
00107         , DefAttTypes_Max   = 8
00108         , DefAttTypes_Unknown = -1
00109     };
00110 
00111     enum CreateReasons
00112     {
00113         NoReason
00114         , JustFaultIn
00115     };
00116 
00117     
00118     
00119     
00120     static const unsigned int fgInvalidAttrId;
00121 
00122 
00123     
00124     
00125     
00126 
00129 
00140     static const XMLCh* getAttTypeString(const AttTypes attrType
00141         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00142 
00153     static const XMLCh* getDefAttTypeString(const DefAttTypes attrType
00154         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00155 
00157 
00158 
00159     
00160     
00161     
00162 
00165 
00169     virtual ~XMLAttDef();
00171 
00172 
00173     
00174     
00175     
00176 
00179 
00188     virtual const XMLCh* getFullName() const = 0;
00189 
00194     virtual void reset() = 0;
00195 
00197 
00198 
00199     
00200     
00201     
00202 
00205 
00214     DefAttTypes getDefaultType() const;
00215 
00225     const XMLCh* getEnumeration() const;
00226 
00235     unsigned int getId() const;
00236 
00251     bool getProvided() const;
00252 
00262     AttTypes getType() const;
00263 
00273     const XMLCh* getValue() const;
00274 
00283     CreateReasons getCreateReason() const;
00284 
00292     bool isExternal() const;
00293 
00301     MemoryManager* getMemoryManager() const;
00302 
00303 
00308     virtual const XMLCh* getDOMTypeInfoUri() const = 0;
00309 
00314     virtual const XMLCh* getDOMTypeInfoName() const = 0;
00315 
00317 
00318 
00319     
00320     
00321     
00322 
00325 
00334     void setDefaultType(const XMLAttDef::DefAttTypes newValue);
00335 
00344     void setId(const unsigned int newId);
00345 
00355     void setProvided(const bool newValue);
00356 
00364     void setType(const XMLAttDef::AttTypes newValue);
00365 
00376     void setValue(const XMLCh* const newValue);
00377 
00388     void setEnumeration(const XMLCh* const newValue);
00389 
00397     void setCreateReason(const CreateReasons newReason);
00398 
00404     void setExternalAttDeclaration(const bool aValue);
00405 
00407 
00408     
00409 
00410 
00411     DECL_XSERIALIZABLE(XMLAttDef)
00412 
00413 protected :
00414     
00415     
00416     
00417     XMLAttDef
00418     (
00419         const   AttTypes       type = CData
00420         , const DefAttTypes    defType= Implied
00421         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00422     );
00423     XMLAttDef
00424     (
00425         const   XMLCh* const        attValue
00426         , const AttTypes            type
00427         , const DefAttTypes         defType
00428         , const XMLCh* const        enumValues = 0
00429         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00430     );
00431 
00432 
00433 private :
00434     
00435     
00436     
00437     XMLAttDef(const XMLAttDef&);
00438     XMLAttDef& operator=(const XMLAttDef&);
00439 
00440 
00441     
00442     
00443     
00444     void cleanUp();
00445 
00446 
00447     
00448     
00449     
00450     
00451     
00452     
00453     
00454     
00455     
00456     
00457     
00458     
00459     
00460     
00461     
00462     
00463     
00464     
00465     
00466     
00467     
00468     
00469     
00470     
00471     
00472     
00473     
00474     
00475     
00476     
00477     
00478     
00479     
00480     
00481     
00482     
00483     DefAttTypes     fDefaultType;
00484     AttTypes        fType;
00485     CreateReasons   fCreateReason;
00486     bool            fProvided;
00487     bool            fExternalAttribute;
00488     unsigned int    fId;
00489     XMLCh*          fValue;
00490     XMLCh*          fEnumeration;
00491     MemoryManager*  fMemoryManager;
00492 };
00493 
00494 
00495 
00496 
00497 
00498 inline XMLAttDef::DefAttTypes XMLAttDef::getDefaultType() const
00499 {
00500     return fDefaultType;
00501 }
00502 
00503 inline const XMLCh* XMLAttDef::getEnumeration() const
00504 {
00505     return fEnumeration;
00506 }
00507 
00508 inline unsigned int XMLAttDef::getId() const
00509 {
00510     return fId;
00511 }
00512 
00513 inline bool XMLAttDef::getProvided() const
00514 {
00515     return fProvided;
00516 }
00517 
00518 inline XMLAttDef::AttTypes XMLAttDef::getType() const
00519 {
00520     return fType;
00521 }
00522 
00523 inline const XMLCh* XMLAttDef::getValue() const
00524 {
00525     return fValue;
00526 }
00527 
00528 inline XMLAttDef::CreateReasons XMLAttDef::getCreateReason() const
00529 {
00530     return fCreateReason;
00531 }
00532 
00533 inline bool XMLAttDef::isExternal() const
00534 {
00535     return fExternalAttribute;
00536 }
00537 
00538 inline MemoryManager* XMLAttDef::getMemoryManager() const
00539 {
00540     return fMemoryManager;
00541 }
00542 
00543 
00544 
00545 
00546 inline void XMLAttDef::setDefaultType(const XMLAttDef::DefAttTypes newValue)
00547 {
00548     fDefaultType = newValue;
00549 }
00550 
00551 inline void XMLAttDef::setEnumeration(const XMLCh* const newValue)
00552 {
00553     if (fEnumeration)
00554         fMemoryManager->deallocate(fEnumeration);
00555 
00556     fEnumeration = XMLString::replicate(newValue, fMemoryManager);
00557 }
00558 
00559 inline void XMLAttDef::setId(const unsigned int newId)
00560 {
00561     fId = newId;
00562 }
00563 
00564 inline void XMLAttDef::setProvided(const bool newValue)
00565 {
00566     fProvided = newValue;
00567 }
00568 
00569 inline void XMLAttDef::setType(const XMLAttDef::AttTypes newValue)
00570 {
00571     fType = newValue;
00572 }
00573 
00574 inline void XMLAttDef::setValue(const XMLCh* const newValue)
00575 {
00576     if (fValue)
00577        fMemoryManager->deallocate(fValue);
00578 
00579     fValue = XMLString::replicate(newValue, fMemoryManager);
00580 }
00581 
00582 inline void
00583 XMLAttDef::setCreateReason(const XMLAttDef::CreateReasons newReason)
00584 {
00585     fCreateReason = newReason;
00586 }
00587 
00588 inline void XMLAttDef::setExternalAttDeclaration(const bool aValue)
00589 {
00590     fExternalAttribute = aValue;
00591 }
00592 
00593 XERCES_CPP_NAMESPACE_END
00594 
00595 #endif