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

xml/soap/webservice

开发平台:

C/C++

  1. /*
  2.  * The Apache Software License, Version 1.1
  3.  * 
  4.  * Copyright (c) 1999-2000 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) 1999, 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.  * $Log: XMLRefInfo.hpp,v $
  58.  * Revision 1.5  2000/07/07 22:23:38  jpolast
  59.  * remove useless getKey() functions.
  60.  *
  61.  * Revision 1.4  2000/02/24 20:00:23  abagchi
  62.  * Swat for removing Log from API docs
  63.  *
  64.  * Revision 1.3  2000/02/15 01:21:31  roddey
  65.  * Some initial documentation improvements. More to come...
  66.  *
  67.  * Revision 1.2  2000/02/06 07:47:49  rahulj
  68.  * Year 2K copyright swat.
  69.  *
  70.  * Revision 1.1.1.1  1999/11/09 01:08:37  twl
  71.  * Initial checkin
  72.  *
  73.  * Revision 1.2  1999/11/08 20:44:40  rahul
  74.  * Swat for adding in Product name and CVS comment log variable.
  75.  *
  76.  */
  77. #if !defined(XMLIDREFINFO_HPP)
  78. #define XMLIDREFINFO_HPP
  79. /**
  80.  *  This class provides a simple means to track ID Ref usage. Since id/idref
  81.  *  semamatics are part of XML 1.0, any validator will likely to be able to
  82.  *  track them. Instances of this class represent a reference and two markers,
  83.  *  one for its being declared and another for its being used. When the
  84.  *  document is done, one can look at each instance and, if used but not
  85.  *  declared, its an error.
  86.  *
  87.  *  The getKey() method allows it to support keyed collection semantics. It
  88.  *  returns the referenced name, so these objects will be stored via the hash
  89.  *  of the name. This name will either be a standard QName if namespaces are
  90.  *  not enabled/supported by the validator, or it will be in the form
  91.  *  {url}name if namespace processing is enabled.
  92.  */
  93. class XMLPARSER_EXPORT XMLRefInfo
  94. {
  95. public :
  96.     // -----------------------------------------------------------------------
  97.     //  Constructors and Destructor
  98.     // -----------------------------------------------------------------------
  99.     /** @name Constructor */
  100.     //@{
  101.     XMLRefInfo
  102.     (
  103.         const   XMLCh* const    refName
  104.         , const bool            fDeclared = false
  105.         , const bool            fUsed = false
  106.     );
  107.     //@}
  108.     /** @name Destructor */
  109.     //@{
  110.     ~XMLRefInfo();
  111.     //@}
  112.     // -----------------------------------------------------------------------
  113.     //  Getter methods
  114.     // -----------------------------------------------------------------------
  115.     bool getDeclared() const;
  116.     const XMLCh* getRefName() const;
  117.     bool getUsed() const;
  118.     // -----------------------------------------------------------------------
  119.     //  Setter methods
  120.     // -----------------------------------------------------------------------
  121.     void setDeclared(const bool newValue);
  122.     void setUsed(const bool newValue);
  123. private :
  124.     // -----------------------------------------------------------------------
  125.     //  Unimplemented constructors and operators
  126.     // -----------------------------------------------------------------------
  127.     XMLRefInfo();
  128.     XMLRefInfo(const XMLRefInfo&);
  129.     void operator=(XMLRefInfo&);
  130.     // -----------------------------------------------------------------------
  131.     //  Private data members
  132.     //
  133.     //  fDeclared
  134.     //      The name was declared somewhere as an ID attribute.
  135.     //
  136.     //  fRefName
  137.     //      The name of the ref that this object represents. This is not a
  138.     //      name of the attribute, but of the value of an ID or IDREF attr
  139.     //      in content.
  140.     //
  141.     //  fUsed
  142.     //      The name was used somewhere in an IDREF/IDREFS attribute. If this
  143.     //      is true, but fDeclared is false, then the ref does not refer to
  144.     //      a declared ID.
  145.     // -----------------------------------------------------------------------
  146.     bool        fDeclared;
  147.     XMLCh*      fRefName;
  148.     bool        fUsed;
  149. };
  150. // ---------------------------------------------------------------------------
  151. //  XMLRefInfo: Constructors and Destructor
  152. // ---------------------------------------------------------------------------
  153. inline XMLRefInfo::XMLRefInfo(  const   XMLCh* const    refName
  154.                                 , const bool            declared
  155.                                 , const bool            used) :
  156.     fDeclared(declared)
  157.     , fRefName(XMLString::replicate(refName))
  158.     , fUsed(used)
  159. {
  160. }
  161. inline XMLRefInfo::~XMLRefInfo()
  162. {
  163.     delete [] fRefName;
  164. }
  165. // ---------------------------------------------------------------------------
  166. //  XMLRefInfo: Getter methods
  167. // ---------------------------------------------------------------------------
  168. inline bool XMLRefInfo::getDeclared() const
  169. {
  170.     return fDeclared;
  171. }
  172. inline const XMLCh* XMLRefInfo::getRefName() const
  173. {
  174.     return fRefName;
  175. }
  176. inline bool XMLRefInfo::getUsed() const
  177. {
  178.     return fUsed;
  179. }
  180. // ---------------------------------------------------------------------------
  181. //  XMLRefInfo: Setter methods
  182. // ---------------------------------------------------------------------------
  183. inline void XMLRefInfo::setDeclared(const bool newValue)
  184. {
  185.     fDeclared = newValue;
  186. }
  187. inline void XMLRefInfo::setUsed(const bool newValue)
  188. {
  189.     fUsed = newValue;
  190. }
  191. #endif