secureswitools/swisistools/source/xmlparser/xerces/include/xercesc/framework/XMLRefInfo.hpp
changeset 0 ba25891c3a9e
child 1 c42dffbd5b4f
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 /*
       
    18  * Licensed to the Apache Software Foundation (ASF) under one or more
       
    19  * contributor license agreements.  See the NOTICE file distributed with
       
    20  * this work for additional information regarding copyright ownership.
       
    21  * The ASF licenses this file to You under the Apache License, Version 2.0
       
    22  * (the "License"); you may not use this file except in compliance with
       
    23  * the License.  You may obtain a copy of the License at
       
    24  * 
       
    25  *      http://www.apache.org/licenses/LICENSE-2.0
       
    26  * 
       
    27  * Unless required by applicable law or agreed to in writing, software
       
    28  * distributed under the License is distributed on an "AS IS" BASIS,
       
    29  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    30  * See the License for the specific language governing permissions and
       
    31  * limitations under the License.
       
    32  */
       
    33 
       
    34 /*
       
    35  * $Id: XMLRefInfo.hpp 568078 2007-08-21 11:43:25Z amassari $
       
    36  */
       
    37 
       
    38 
       
    39 #if !defined(XMLIDREFINFO_HPP)
       
    40 #define XMLIDREFINFO_HPP
       
    41 
       
    42 #include <xercesc/util/XMemory.hpp>
       
    43 #include <xercesc/util/PlatformUtils.hpp>
       
    44 #include <xercesc/util/XMLString.hpp>
       
    45 
       
    46 #include <xercesc/internal/XSerializable.hpp>
       
    47 
       
    48 XERCES_CPP_NAMESPACE_BEGIN
       
    49 
       
    50 /**
       
    51  *  This class provides a simple means to track ID Ref usage. Since id/idref
       
    52  *  semamatics are part of XML 1.0, any validator will likely to be able to
       
    53  *  track them. Instances of this class represent a reference and two markers,
       
    54  *  one for its being declared and another for its being used. When the
       
    55  *  document is done, one can look at each instance and, if used but not
       
    56  *  declared, its an error.
       
    57  *
       
    58  *  The getKey() method allows it to support keyed collection semantics. It
       
    59  *  returns the referenced name, so these objects will be stored via the hash
       
    60  *  of the name. This name will either be a standard QName if namespaces are
       
    61  *  not enabled/supported by the validator, or it will be in the form
       
    62  *  {url}name if namespace processing is enabled.
       
    63  */
       
    64 class XMLPARSER_EXPORT XMLRefInfo : public XSerializable, public XMemory
       
    65 {
       
    66 public :
       
    67     // -----------------------------------------------------------------------
       
    68     //  Constructors and Destructor
       
    69     // -----------------------------------------------------------------------
       
    70 
       
    71     /** @name Constructor */
       
    72     //@{
       
    73     XMLRefInfo
       
    74     (
       
    75         const   XMLCh* const   refName
       
    76         , const bool           fDeclared = false
       
    77         , const bool           fUsed = false
       
    78         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
       
    79     );
       
    80     //@}
       
    81 
       
    82     /** @name Destructor */
       
    83     //@{
       
    84     ~XMLRefInfo();
       
    85     //@}
       
    86 
       
    87 
       
    88     // -----------------------------------------------------------------------
       
    89     //  Getter methods
       
    90     // -----------------------------------------------------------------------
       
    91     bool getDeclared() const;
       
    92     const XMLCh* getRefName() const;
       
    93     bool getUsed() const;
       
    94 
       
    95 
       
    96     // -----------------------------------------------------------------------
       
    97     //  Setter methods
       
    98     // -----------------------------------------------------------------------
       
    99     void setDeclared(const bool newValue);
       
   100     void setUsed(const bool newValue);
       
   101 
       
   102     /***
       
   103      * Support for Serialization/De-serialization
       
   104      ***/
       
   105     DECL_XSERIALIZABLE(XMLRefInfo)
       
   106 
       
   107     XMLRefInfo
       
   108     (
       
   109       MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
       
   110     );
       
   111 
       
   112 private :
       
   113     // -----------------------------------------------------------------------
       
   114     //  Unimplemented constructors and operators
       
   115     // -----------------------------------------------------------------------
       
   116     XMLRefInfo(const XMLRefInfo&);
       
   117     XMLRefInfo& operator=(XMLRefInfo&);
       
   118 
       
   119 
       
   120     // -----------------------------------------------------------------------
       
   121     //  Private data members
       
   122     //
       
   123     //  fDeclared
       
   124     //      The name was declared somewhere as an ID attribute.
       
   125     //
       
   126     //  fRefName
       
   127     //      The name of the ref that this object represents. This is not a
       
   128     //      name of the attribute, but of the value of an ID or IDREF attr
       
   129     //      in content.
       
   130     //
       
   131     //  fUsed
       
   132     //      The name was used somewhere in an IDREF/IDREFS attribute. If this
       
   133     //      is true, but fDeclared is false, then the ref does not refer to
       
   134     //      a declared ID.
       
   135     // -----------------------------------------------------------------------
       
   136     bool        fDeclared;
       
   137     bool        fUsed;
       
   138     XMLCh*      fRefName;
       
   139     MemoryManager* fMemoryManager;
       
   140 };
       
   141 
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 //  XMLRefInfo: Constructors and Destructor
       
   145 // ---------------------------------------------------------------------------
       
   146 inline XMLRefInfo::XMLRefInfo( const XMLCh* const   refName
       
   147                              , const bool           declared
       
   148                              , const bool           used
       
   149                              , MemoryManager* const manager) :
       
   150     fDeclared(declared)
       
   151     , fUsed(used)
       
   152     , fRefName(0)
       
   153     , fMemoryManager(manager)
       
   154 {
       
   155     fRefName = XMLString::replicate(refName, fMemoryManager);
       
   156 }
       
   157 
       
   158 inline XMLRefInfo::~XMLRefInfo()
       
   159 {
       
   160     fMemoryManager->deallocate(fRefName);
       
   161 }
       
   162 
       
   163 
       
   164 // ---------------------------------------------------------------------------
       
   165 //  XMLRefInfo: Getter methods
       
   166 // ---------------------------------------------------------------------------
       
   167 inline bool XMLRefInfo::getDeclared() const
       
   168 {
       
   169     return fDeclared;
       
   170 }
       
   171 
       
   172 inline const XMLCh* XMLRefInfo::getRefName() const
       
   173 {
       
   174     return fRefName;
       
   175 }
       
   176 
       
   177 inline bool XMLRefInfo::getUsed() const
       
   178 {
       
   179     return fUsed;
       
   180 }
       
   181 
       
   182 
       
   183 // ---------------------------------------------------------------------------
       
   184 //  XMLRefInfo: Setter methods
       
   185 // ---------------------------------------------------------------------------
       
   186 inline void XMLRefInfo::setDeclared(const bool newValue)
       
   187 {
       
   188     fDeclared = newValue;
       
   189 }
       
   190 
       
   191 inline void XMLRefInfo::setUsed(const bool newValue)
       
   192 {
       
   193     fUsed = newValue;
       
   194 }
       
   195 
       
   196 XERCES_CPP_NAMESPACE_END
       
   197 
       
   198 #endif