XercesAttGroupInfo.hpp
上传用户:huihehuasu
上传日期:2007-01-10
资源大小:6948k
文件大小:8k
源码类别:

xml/soap/webservice

开发平台:

C/C++

  1. /*
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 2001 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  *
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  *
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  *
  26.  * 4. The names "Xerces" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written
  29.  *    permission, please contact apache@apache.org.
  30.  *
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation, and was
  51.  * originally based on software copyright (c) 2001, International
  52.  * Business Machines, Inc., http://www.ibm.com .  For more information
  53.  * on the Apache Software Foundation, please see
  54.  * <http://www.apache.org/>.
  55.  */
  56. /*
  57.  * $Id: XercesAttGroupInfo.hpp,v 1.4 2001/11/20 20:21:49 knoaman Exp $
  58.  */
  59. #if !defined(XERCESATTGROUPINFO_HPP)
  60. #define XERCESATTGROUPINFO_HPP
  61. /**
  62.   * The class act as a place holder to store attributeGroup information.
  63.   *
  64.   * The class is intended for internal use.
  65.   */
  66. // ---------------------------------------------------------------------------
  67. //  Includes
  68. // ---------------------------------------------------------------------------
  69. #include <util/RefVectorOf.hpp>
  70. #include <validators/schema/SchemaAttDef.hpp>
  71. class VALIDATORS_EXPORT XercesAttGroupInfo
  72. {
  73. public:
  74.     // -----------------------------------------------------------------------
  75.     //  Public Constructors/Destructor
  76.     // -----------------------------------------------------------------------
  77.     XercesAttGroupInfo();
  78. ~XercesAttGroupInfo();
  79. // -----------------------------------------------------------------------
  80.     //  Getter methods
  81.     // -----------------------------------------------------------------------
  82.     bool                containsTypeWithId() const;
  83.     unsigned int        attributeCount() const;
  84.     unsigned int        anyAttributeCount() const; 
  85.     SchemaAttDef*       attributeAt(const unsigned int index);
  86.     const SchemaAttDef* attributeAt(const unsigned int index) const;
  87.     SchemaAttDef*       anyAttributeAt(const unsigned int index);
  88.     const SchemaAttDef* anyAttributeAt(const unsigned int index) const;
  89.     SchemaAttDef*       getCompleteWildCard() const;
  90.     const SchemaAttDef* getAttDef(const XMLCh* const baseName,
  91.                                   const int uriId) const;
  92.     
  93. // -----------------------------------------------------------------------
  94.     //  Setter methods
  95.     // -----------------------------------------------------------------------
  96.     void setTypeWithId(const bool other);
  97.     void addAttDef(SchemaAttDef* const toAdd, const bool toClone = false);
  98.     void addAnyAttDef(SchemaAttDef* const toAdd, const bool toClone = false);
  99.     void setCompleteWildCard(SchemaAttDef* const toSet);
  100. // -----------------------------------------------------------------------
  101.     //  Query methods
  102.     // -----------------------------------------------------------------------
  103.     bool containsAttribute(const XMLCh* const name, const unsigned int uri);
  104. private:
  105.     // -----------------------------------------------------------------------
  106.     //  Unimplemented contstructors and operators
  107.     // -----------------------------------------------------------------------
  108.     XercesAttGroupInfo(const XercesAttGroupInfo& elemInfo);
  109.     XercesAttGroupInfo& operator= (const XercesAttGroupInfo& other);
  110.     // -----------------------------------------------------------------------
  111.     //  Private data members
  112.     // -----------------------------------------------------------------------
  113.     bool                       fTypeWithId;
  114.     RefVectorOf<SchemaAttDef>* fAttributes;
  115.     RefVectorOf<SchemaAttDef>* fAnyAttributes;
  116.     SchemaAttDef*              fCompleteWildCard;
  117. };
  118. // ---------------------------------------------------------------------------
  119. //  XercesAttGroupInfo: Getter methods
  120. // ---------------------------------------------------------------------------
  121. inline bool XercesAttGroupInfo::containsTypeWithId() const {
  122.     return fTypeWithId;
  123. }
  124. inline unsigned int XercesAttGroupInfo::attributeCount() const {
  125.     if (fAttributes) {
  126.         return fAttributes->size();
  127.     }
  128.     return 0;
  129. }
  130. inline unsigned int XercesAttGroupInfo::anyAttributeCount() const {
  131.     if (fAnyAttributes) {
  132.         return fAnyAttributes->size();
  133.     }
  134.     return 0;
  135. }
  136. inline SchemaAttDef*
  137. XercesAttGroupInfo::attributeAt(const unsigned int index) {
  138.     if (fAttributes) {
  139.         return fAttributes->elementAt(index);
  140.     }
  141.     return 0;
  142. }
  143. inline const SchemaAttDef* 
  144. XercesAttGroupInfo::attributeAt(const unsigned int index) const {
  145.     if (fAttributes) {
  146.         return fAttributes->elementAt(index);
  147.     }
  148.     return 0;
  149. }
  150. inline SchemaAttDef*
  151. XercesAttGroupInfo::anyAttributeAt(const unsigned int index) {
  152.     if (fAnyAttributes) {
  153.         return fAnyAttributes->elementAt(index);
  154.     }
  155.     return 0;
  156. }
  157. inline const SchemaAttDef* 
  158. XercesAttGroupInfo::anyAttributeAt(const unsigned int index) const {
  159.     if (fAnyAttributes) {
  160.         return fAnyAttributes->elementAt(index);
  161.     }
  162.     return 0;
  163. }
  164. inline SchemaAttDef*
  165. XercesAttGroupInfo::getCompleteWildCard() const {
  166.     return fCompleteWildCard;
  167. }
  168. // ---------------------------------------------------------------------------
  169. //  XercesAttGroupInfo: Setter methods
  170. // ---------------------------------------------------------------------------
  171. inline void XercesAttGroupInfo::setTypeWithId(const bool other) {
  172.     fTypeWithId = other;
  173. }
  174. inline void XercesAttGroupInfo::addAttDef(SchemaAttDef* const toAdd,
  175.                                              const bool toClone) {
  176.     if (!fAttributes) {
  177.         fAttributes = new RefVectorOf<SchemaAttDef>(4);
  178.     }
  179.     if (toClone) {
  180.         fAttributes->addElement(new SchemaAttDef(toAdd));
  181.     }
  182.     else {
  183.         fAttributes->addElement(toAdd);
  184.     }
  185. }
  186. inline void XercesAttGroupInfo::addAnyAttDef(SchemaAttDef* const toAdd,
  187.                                              const bool toClone) {
  188.     if (!fAnyAttributes) {   
  189.         fAnyAttributes = new RefVectorOf<SchemaAttDef>(2);
  190.     }
  191.     if (toClone) {
  192.         fAnyAttributes->addElement(new SchemaAttDef(toAdd));
  193.     }
  194.     else {
  195.         fAnyAttributes->addElement(toAdd);
  196.     }
  197. }
  198. inline void
  199. XercesAttGroupInfo::setCompleteWildCard(SchemaAttDef* const toSet) {
  200.     if (fCompleteWildCard) {
  201.         delete fCompleteWildCard;
  202.     }
  203.     fCompleteWildCard = toSet;
  204. }
  205. #endif
  206. /**
  207.   * End of file XercesAttGroupInfo.hpp
  208.   */