source: icXML/icXML-devel/src/xercesc/framework/XMLRefInfo.hpp @ 2722

Last change on this file since 2722 was 2722, checked in by cameron, 6 years ago

Original Xerces files with import mods for icxercesc

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