Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

AttributesImpl.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    AttributesImpl.h
00006  *
00007  *  $Id: AttributesImpl.h,v 1.1.1.1 2003/02/21 18:36:32 chad 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   int operator!= (const ACEXML_Attribute&rhs) const;
00103 
00104 private:
00105   /// @var uri_ Namespace URI of an attribute
00106   ACEXML_Char *uri_;
00107 
00108   /// @var localName_
00109   ACEXML_Char *localName_;
00110   ACEXML_Char *qName_;
00111   ACEXML_Char *type_;
00112   ACEXML_Char *value_;
00113 };
00114 
00115 /**
00116  * @typedef ACE_Array<ACEXML_Attribute> ACEXML_Attribute_Array
00117  */
00118 typedef ACE_Array<ACEXML_Attribute> ACEXML_Attribute_Array;
00119 
00120 /**
00121  * @class ACEXML_AttributesImpl AttributesImpl.h "ACEXML/common/AttributesImpl.h"
00122  *
00123  * @brief ACEXML_AttributesImpl provides the default implementation
00124  * of interface ACEXML_Attributes.
00125  *
00126  * This class provides a default implementation of the SAX2 Attributes
00127  * interface, with the addition of manipulators so that the list can
00128  * be modified or reused.
00129  *
00130  * There are two typical uses of this class:
00131  *
00132  * - to take a persistent snapshot of an Attributes object in a
00133  *   startElement event; or
00134  * - to construct or modify an Attributes object in a SAX2 driver or filter.
00135  *
00136  * This class replaces the now-deprecated SAX1 AttributeListImpl
00137  * class; in addition to supporting the updated Attributes interface
00138  * rather than the deprecated AttributeList interface, it also
00139  * includes a much more efficient implementation using a single array
00140  * rather than a set of Vectors.
00141  *
00142  * @sa ACEXML_Attributes
00143  */
00144 class ACEXML_Export ACEXML_AttributesImpl
00145   : public ACEXML_Attributes
00146 {
00147 public:
00148   /**
00149    * Initialize an AttributesImpl that holds <size> attributes.
00150    */
00151   ACEXML_AttributesImpl (int size = ACEXML_AttributesImpl_Default_Size);
00152   ACEXML_AttributesImpl (const ACEXML_AttributesImpl &attrs);
00153   virtual ~ACEXML_AttributesImpl (void);
00154 
00155   /**
00156    * Add a new attribute using the argument(s) supplied.
00157    * Return -1 if an attribute with the same name already exists.
00158    */
00159   virtual int addAttribute (const ACEXML_Char *uri,
00160                             const ACEXML_Char *localName,
00161                             const ACEXML_Char *qName,
00162                             const ACEXML_Char *type,
00163                             const ACEXML_Char *value);
00164   virtual int addAttribute (const ACEXML_Attribute &att);
00165 
00166   /**
00167    *  Check for duplicate attributes.
00168    */
00169   virtual int isDuplicate (const ACEXML_Char *uri,
00170                               const ACEXML_Char *localName,
00171                               const ACEXML_Char *qName);
00172   /**
00173    * Remove an attribute from the array.  Notice that this
00174    * operation can invalidate previously acquired <index>
00175    * value.  (It will repack the array.)
00176    */
00177   virtual int removeAttribute (size_t index);
00178 
00179 
00180   /**
00181    * Look up the index of an attribute by XML 1.0 qualified name.
00182    * Return -1 if we fail to find a match.
00183    */
00184   virtual int getIndex (const ACEXML_Char *qName);
00185 
00186   /**
00187    * Look up the index of an attribute by Namespace name.
00188    * Return -1 if we fail to find a match.
00189    */
00190   virtual int getIndex (const ACEXML_Char *uri,
00191                         const ACEXML_Char *localPart);
00192 
00193   /**
00194    * Return the number of attributes in the list.
00195    */
00196   virtual size_t getLength (void);
00197 
00198   /**
00199    * Look up an attribute's local name by index.
00200    * Return 0 if index is out of range.
00201    */
00202   virtual const ACEXML_Char *getLocalName (size_t index);
00203 
00204   /**
00205    * Look up an attribute's XML 1.0 qualified name by index.
00206    * Return 0 if index is out of range.
00207    */
00208   virtual const ACEXML_Char *getQName (size_t index);
00209 
00210   /**
00211    * Look up an attribute's type by index.
00212    * Return 0 if index is out of range.
00213    */
00214   virtual const ACEXML_Char *getType (size_t index);
00215 
00216   /**
00217    * Look up an attribute's type by XML 1.0 qualified name.
00218    * Return 0 if we fail to find a match.
00219    */
00220   virtual const ACEXML_Char *getType (const ACEXML_Char *qName);
00221 
00222   /**
00223    * Look up an attribute's type by Namespace name.
00224    * Return 0 if we fail to find a match.
00225    */
00226   virtual const ACEXML_Char *getType (const ACEXML_Char *uri,
00227                                       const ACEXML_Char *localPart);
00228 
00229   /**
00230    * Look up an attribute's Namespace URI by index.
00231    * Return 0 if index is out of range.
00232    */
00233   virtual const ACEXML_Char *getURI (size_t index);
00234 
00235   /**
00236    * Look up an attribute's value by index.
00237    * Return 0 if index is out of range.
00238    */
00239   virtual const ACEXML_Char *getValue (size_t index);
00240 
00241   /**
00242    * Look up an attribute's value by XML 1.0 qualified name.
00243    * Return 0 if we fail to find a match.
00244    */
00245   virtual const ACEXML_Char *getValue (const ACEXML_Char *qName);
00246 
00247   /**
00248    * Look up an attribute's value by Namespace name.
00249    * Return 0 if we fail to find a match.
00250    */
00251   virtual const ACEXML_Char *getValue (const ACEXML_Char *uri,
00252                                        const ACEXML_Char *localPart);
00253 
00254   /**
00255    * Set an attribute at index.  Return -1 if index is out of
00256    * range.
00257    */
00258   virtual int setAttribute (size_t index,
00259                             const ACEXML_Char *uri,
00260                             const ACEXML_Char *localName,
00261                             const ACEXML_Char *qName,
00262                             const ACEXML_Char *type,
00263                             const ACEXML_Char *value);
00264 
00265   /**
00266    * Set the localName of the attribute at <index>.
00267    * return -1 if <index> is out of range.
00268    */
00269   virtual int setLocalName (size_t index,
00270                             const ACEXML_Char *localName);
00271 
00272   /**
00273    * Set the qName of the attribute at <index>.
00274    * return -1 if <index> is out of range.
00275    */
00276   virtual int setQName (size_t index,
00277                         const ACEXML_Char *qName);
00278 
00279   /**
00280    * Set the URI of the attribute at <index>.
00281    * return -1 if <index> is out of range.
00282    */
00283   virtual int setURI (size_t index,
00284                       const ACEXML_Char *uri);
00285 
00286   /**
00287    * Set the type of the attribute at <index>.
00288    * return -1 if <index> is out of range.
00289    */
00290   virtual int setType (size_t index,
00291                        const ACEXML_Char *type);
00292 
00293   /**
00294    * Set the value of the attribute at <index>.
00295    * return -1 if <index> is out of range.
00296    */
00297   virtual int setValue (size_t index,
00298                         const ACEXML_Char *value);
00299 private:
00300   /// Container for all attributes.
00301   ACEXML_Attribute_Array attrs_;
00302 };
00303 
00304 #if defined (__ACEXML_INLINE__)
00305 # include "ACEXML/common/AttributesImpl.i"
00306 #endif /* __ACEXML_INLINE__ */
00307 
00308 #include "ace/post.h"
00309 
00310 #endif /* ACEXML_ATTRIBUTESIMPL_H */

Generated on Mon Jun 16 13:23:19 2003 for ACEXML by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002