AttributesImpl.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    AttributesImpl.h
00006  *
00007  *  AttributesImpl.h,v 1.8 2004/10/21 17:33:56 elliott_c Exp
00008  *
00009  *  @author Nanbor Wang <nanbor@cs.wustl.edu>
00010  */
00011 //=============================================================================
00012 
00013 
00014 #ifndef ACEXML_ATTRIBUTESIMPL_H
00015 #define ACEXML_ATTRIBUTESIMPL_H
00016 
00017 #include /**/ "ace/pre.h"
00018 #include "ACEXML/common/ACEXML_Export.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 #pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #include "ACEXML/common/Attributes.h"
00025 #include "ace/Containers_T.h"
00026 
00027 #if !defined ACEXML_AttributesImpl_Default_Size
00028 #define ACEXML_AttributesImpl_Default_Size 20
00029 #endif /* ACEXML_AttributesImpl_Default_Size */
00030 
00031 class ACEXML_AttributesImpl;
00032 
00033 /**
00034  * @class ACEXML_Attribute AttributesImpl.h "ACEXML/common/AttributesImpl.h"
00035  *
00036  * @brief ACEXML_Attribute defines the data structure of an attribute
00037  *
00038  * @sa ACEXML_AttributesImpl
00039  */
00040 class ACEXML_Export ACEXML_Attribute
00041 {
00042 public:
00043   friend class ACEXML_AttributesImpl;
00044 
00045   /// Default constructor.
00046   ACEXML_Attribute (void);
00047 
00048   /// Copy constructor.
00049   ACEXML_Attribute (const ACEXML_Attribute &attr);
00050 
00051   /// Initialize all constructor.
00052   ACEXML_Attribute (const ACEXML_Char *uri,
00053                     const ACEXML_Char *localName,
00054                     const ACEXML_Char *qName,
00055                     const ACEXML_Char *type,
00056                     const ACEXML_Char *value);
00057 
00058   /// Destructor.
00059   ~ACEXML_Attribute (void);
00060 
00061   /// Set all members.
00062   void setAttribute (const ACEXML_Char *uri,
00063                      const ACEXML_Char *localName,
00064                      const ACEXML_Char *qName,
00065                      const ACEXML_Char *type,
00066                      const ACEXML_Char *value);
00067 
00068   /// Get \a uri_.
00069   const ACEXML_Char *uri (void) const;
00070 
00071   /// Set \a uri_.
00072   void uri (const ACEXML_Char *uri);
00073 
00074   /// Get \a localName_.
00075   const ACEXML_Char *localName (void) const;
00076 
00077   /// Set \a localName_.
00078   void localName (const ACEXML_Char *localName);
00079 
00080   /// Get \a qName_.
00081   const ACEXML_Char *qName (void) const;
00082 
00083   /// Set \a qName_.
00084   void qName (const ACEXML_Char *qName);
00085 
00086   /// Get \a type_.
00087   const ACEXML_Char *type (void) const;
00088 
00089   /// Set \a type_.
00090   void type (const ACEXML_Char *type);
00091 
00092   /// Get \a value_.
00093   const ACEXML_Char *value (void) const;
00094 
00095   /// Set \a value_.
00096   void value (const ACEXML_Char *value);
00097 
00098   /// Assignment operator.
00099   ACEXML_Attribute &operator= (const ACEXML_Attribute &rhs);
00100 
00101   /// Comparison operator.
00102   bool operator!= (const ACEXML_Attribute&rhs) const;
00103 
00104 private:
00105   /// Namespace URI of an attribute
00106   ACEXML_Char *uri_;
00107 
00108   ACEXML_Char *localName_;
00109   ACEXML_Char *qName_;
00110   ACEXML_Char *type_;
00111   ACEXML_Char *value_;
00112 };
00113 
00114 /**
00115  * @typedef ACE_Array<ACEXML_Attribute> ACEXML_Attribute_Array
00116  */
00117 typedef ACE_Array<ACEXML_Attribute> ACEXML_Attribute_Array;
00118 
00119 /**
00120  * @class ACEXML_AttributesImpl AttributesImpl.h "ACEXML/common/AttributesImpl.h"
00121  *
00122  * @brief ACEXML_AttributesImpl provides the default implementation
00123  * of interface ACEXML_Attributes.
00124  *
00125  * This class provides a default implementation of the SAX2 Attributes
00126  * interface, with the addition of manipulators so that the list can
00127  * be modified or reused.
00128  *
00129  * There are two typical uses of this class:
00130  *
00131  * - to take a persistent snapshot of an Attributes object in a
00132  *   startElement event; or
00133  * - to construct or modify an Attributes object in a SAX2 driver or filter.
00134  *
00135  * This class replaces the now-deprecated SAX1 AttributeListImpl
00136  * class; in addition to supporting the updated Attributes interface
00137  * rather than the deprecated AttributeList interface, it also
00138  * includes a much more efficient implementation using a single array
00139  * rather than a set of Vectors.
00140  *
00141  * @sa ACEXML_Attributes
00142  */
00143 class ACEXML_Export ACEXML_AttributesImpl
00144   : public ACEXML_Attributes
00145 {
00146 public:
00147   /**
00148    * Initialize an AttributesImpl that holds <size> attributes.
00149    */
00150   ACEXML_AttributesImpl (int size = ACEXML_AttributesImpl_Default_Size);
00151   ACEXML_AttributesImpl (const ACEXML_AttributesImpl &attrs);
00152   virtual ~ACEXML_AttributesImpl (void);
00153 
00154   /**
00155    * Add a new attribute using the argument(s) supplied.
00156    * Return -1 if an attribute with the same name already exists.
00157    */
00158   virtual int addAttribute (const ACEXML_Char *uri,
00159                             const ACEXML_Char *localName,
00160                             const ACEXML_Char *qName,
00161                             const ACEXML_Char *type,
00162                             const ACEXML_Char *value);
00163   virtual int addAttribute (const ACEXML_Attribute &att);
00164 
00165   /**
00166    *  Check for duplicate attributes.
00167    */
00168   virtual int isDuplicate (const ACEXML_Char *uri,
00169                               const ACEXML_Char *localName,
00170                               const ACEXML_Char *qName);
00171   /**
00172    * Remove an attribute from the array.  Notice that this
00173    * operation can invalidate previously acquired <index>
00174    * value.  (It will repack the array.)
00175    */
00176   virtual int removeAttribute (size_t index);
00177 
00178 
00179   /**
00180    * Look up the index of an attribute by XML 1.0 qualified name.
00181    * Return -1 if we fail to find a match.
00182    */
00183   virtual int getIndex (const ACEXML_Char *qName);
00184 
00185   /**
00186    * Look up the index of an attribute by Namespace name.
00187    * Return -1 if we fail to find a match.
00188    */
00189   virtual int getIndex (const ACEXML_Char *uri,
00190                         const ACEXML_Char *localPart);
00191 
00192   /**
00193    * Return the number of attributes in the list.
00194    */
00195   virtual size_t getLength (void);
00196 
00197   /**
00198    * Look up an attribute's local name by index.
00199    * Return 0 if index is out of range.
00200    */
00201   virtual const ACEXML_Char *getLocalName (size_t index);
00202 
00203   /**
00204    * Look up an attribute's XML 1.0 qualified name by index.
00205    * Return 0 if index is out of range.
00206    */
00207   virtual const ACEXML_Char *getQName (size_t index);
00208 
00209   /**
00210    * Look up an attribute's type by index.
00211    * Return 0 if index is out of range.
00212    */
00213   virtual const ACEXML_Char *getType (size_t index);
00214 
00215   /**
00216    * Look up an attribute's type by XML 1.0 qualified name.
00217    * Return 0 if we fail to find a match.
00218    */
00219   virtual const ACEXML_Char *getType (const ACEXML_Char *qName);
00220 
00221   /**
00222    * Look up an attribute's type by Namespace name.
00223    * Return 0 if we fail to find a match.
00224    */
00225   virtual const ACEXML_Char *getType (const ACEXML_Char *uri,
00226                                       const ACEXML_Char *localPart);
00227 
00228   /**
00229    * Look up an attribute's Namespace URI by index.
00230    * Return 0 if index is out of range.
00231    */
00232   virtual const ACEXML_Char *getURI (size_t index);
00233 
00234   /**
00235    * Look up an attribute's value by index.
00236    * Return 0 if index is out of range.
00237    */
00238   virtual const ACEXML_Char *getValue (size_t index);
00239 
00240   /**
00241    * Look up an attribute's value by XML 1.0 qualified name.
00242    * Return 0 if we fail to find a match.
00243    */
00244   virtual const ACEXML_Char *getValue (const ACEXML_Char *qName);
00245 
00246   /**
00247    * Look up an attribute's value by Namespace name.
00248    * Return 0 if we fail to find a match.
00249    */
00250   virtual const ACEXML_Char *getValue (const ACEXML_Char *uri,
00251                                        const ACEXML_Char *localPart);
00252 
00253   /**
00254    * Set an attribute at index.  Return -1 if index is out of
00255    * range.
00256    */
00257   virtual int setAttribute (size_t index,
00258                             const ACEXML_Char *uri,
00259                             const ACEXML_Char *localName,
00260                             const ACEXML_Char *qName,
00261                             const ACEXML_Char *type,
00262                             const ACEXML_Char *value);
00263 
00264   /**
00265    * Set the localName of the attribute at <index>.
00266    * return -1 if <index> is out of range.
00267    */
00268   virtual int setLocalName (size_t index,
00269                             const ACEXML_Char *localName);
00270 
00271   /**
00272    * Set the qName of the attribute at <index>.
00273    * return -1 if <index> is out of range.
00274    */
00275   virtual int setQName (size_t index,
00276                         const ACEXML_Char *qName);
00277 
00278   /**
00279    * Set the URI of the attribute at <index>.
00280    * return -1 if <index> is out of range.
00281    */
00282   virtual int setURI (size_t index,
00283                       const ACEXML_Char *uri);
00284 
00285   /**
00286    * Set the type of the attribute at <index>.
00287    * return -1 if <index> is out of range.
00288    */
00289   virtual int setType (size_t index,
00290                        const ACEXML_Char *type);
00291 
00292   /**
00293    * Set the value of the attribute at <index>.
00294    * return -1 if <index> is out of range.
00295    */
00296   virtual int setValue (size_t index,
00297                         const ACEXML_Char *value);
00298 private:
00299   /// Container for all attributes.
00300   ACEXML_Attribute_Array attrs_;
00301 };
00302 
00303 #if defined (__ACEXML_INLINE__)
00304 # include "ACEXML/common/AttributesImpl.i"
00305 #endif /* __ACEXML_INLINE__ */
00306 
00307 #include /**/ "ace/post.h"
00308 
00309 #endif /* ACEXML_ATTRIBUTESIMPL_H */

Generated on Thu Nov 9 11:45:35 2006 for ACEXML by doxygen 1.3.6