source: NonGTP/Xerces/xerces/include/xercesc/framework/psvi/XSAnnotation.hpp @ 358

Revision 358, 6.3 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
1/*
2 * Copyright 2003,2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * $Log: XSAnnotation.hpp,v $
19 * Revision 1.11  2004/09/08 13:56:07  peiyongz
20 * Apache License Version 2.0
21 *
22 * Revision 1.10  2004/09/02 19:08:09  cargilld
23 * Fix API Doc warning message
24 *
25 * Revision 1.9  2004/04/02 16:51:05  peiyongz
26 * Better error report support
27 *
28 * Revision 1.8  2003/12/01 23:23:26  neilg
29 * fix for bug 25118; thanks to Jeroen Witmond
30 *
31 * Revision 1.7  2003/11/28 14:55:11  neilg
32 * fix for compilation error on HPUX
33 *
34 * Revision 1.6  2003/11/27 21:29:05  neilg
35 * implement writeAnnotation; thanks to Dave Cargill
36 *
37 * Revision 1.5  2003/11/14 22:47:53  neilg
38 * fix bogus log message from previous commit...
39 *
40 * Revision 1.4  2003/11/14 22:33:30  neilg
41 * Second phase of schema component model implementation. 
42 * Implement XSModel, XSNamespaceItem, and the plumbing necessary
43 * to connect them to the other components.
44 * Thanks to David Cargill.
45 *
46 * Revision 1.3  2003/11/11 22:48:13  knoaman
47 * Serialization of XSAnnotation.
48 *
49 * Revision 1.2  2003/11/06 19:28:11  knoaman
50 * PSVI support for annotations.
51 *
52 * Revision 1.1  2003/09/16 14:33:36  neilg
53 * PSVI/schema component model classes, with Makefile/configuration changes necessary to build them
54 *
55 */
56
57#if !defined(XSANNOTATION_HPP)
58#define XSANNOTATION_HPP
59
60#include <xercesc/framework/psvi/XSObject.hpp>
61#include <xercesc/internal/XSerializable.hpp>
62
63XERCES_CPP_NAMESPACE_BEGIN
64
65/**
66 * This class describes all properties of a Schema Annotation
67 * component.
68 * This is *always* owned by the validator /parser object from which
69 * it is obtained. 
70 */
71
72// forward declarations
73class DOMNode;
74class ContentHandler;
75
76class XMLPARSER_EXPORT XSAnnotation : public XSerializable, public XSObject
77{
78public:
79
80    // TargetType
81    enum ANNOTATION_TARGET {
82            /**
83             * The object type is <code>org.w3c.dom.Element</code>.
84             */
85            W3C_DOM_ELEMENT           = 1,
86            /**
87             * The object type is <code>org.w3c.dom.Document</code>.
88             */
89            W3C_DOM_DOCUMENT          = 2
90    };
91
92    //  Constructors and Destructor
93    // -----------------------------------------------------------------------
94    /** @name Constructors */
95    //@{
96
97    /**
98      * The default constructor
99      *
100      * @param  contents    The string that is to be the content of this XSAnnotation
101      * @param  manager     The configurable memory manager
102      */
103    XSAnnotation
104    (
105        const XMLCh* const contents
106        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
107    );
108
109    //@};
110
111    /** @name Destructor */
112    //@{
113    ~XSAnnotation();
114    //@}
115
116    //---------------------
117    /** @name XSAnnotation methods */
118
119    //@{
120
121    /**
122     * Write contents of the annotation to the specified DOM object. In-scope
123     * namespace declarations for <code>annotation</code> element are added as
124     * attribute nodes of the serialized <code>annotation</code>.
125     * @param node  A target pointer to the annotation target object, i.e.
126     * either <code>DOMDocument</code> or <code>DOMElement</code> cast as
127     * <code>DOMNode</code>.
128     * @param targetType  A target type.   
129     */
130 
131    void writeAnnotation(DOMNode* node, ANNOTATION_TARGET targetType); 
132
133    /**
134     * Write contents of the annotation to the specified object.
135     * The corresponding events for all in-scope namespace declarations are
136     * sent via the specified document handler.
137     * @param handler  A target pointer to the annotation target object, i.e.
138     *   <code>ContentHandler</code>.
139     */   
140    void writeAnnotation(ContentHandler* handler);
141
142    /**
143     * A text representation of annotation.
144     */
145    const XMLCh *getAnnotationString() const;
146    XMLCh *getAnnotationString();
147
148    //@}
149
150    //----------------------------------
151    /** methods needed by implementation */
152    //@{
153    void            setNext(XSAnnotation* const nextAnnotation);
154    XSAnnotation*   getNext();
155    //@}
156
157    //-----------------------------
158    /** Getter */
159    //@{
160    inline void           getLineCol(int& line, int& col)  const;
161    inline const XMLCh*   getSystemId()                    const;   
162    //@}
163
164    //-----------------------------
165    /** Setter */
166    //@{
167    inline void           setLineCol(int line, int col);
168           void           setSystemId(const XMLCh* const systemId);   
169    //@}
170
171    /***
172     * Support for Serialization/De-serialization
173     ***/
174    DECL_XSERIALIZABLE(XSAnnotation)
175    XSAnnotation(MemoryManager* const manager);
176
177private:
178
179    // -----------------------------------------------------------------------
180    //  Unimplemented constructors and operators
181    // -----------------------------------------------------------------------
182    XSAnnotation(const XSAnnotation&);
183    XSAnnotation & operator=(const XSAnnotation &);
184
185protected:
186
187    // -----------------------------------------------------------------------
188    //  data members
189    // -----------------------------------------------------------------------
190    XMLCh*        fContents;
191    XSAnnotation* fNext;
192
193private:
194
195    XMLCh*        fSystemId;
196    int           fLine;
197    int           fCol;
198
199};
200
201inline const XMLCh *XSAnnotation::getAnnotationString() const
202{
203    return fContents;
204}
205
206inline XMLCh *XSAnnotation::getAnnotationString()
207{
208    return fContents;
209}
210
211inline void XSAnnotation::getLineCol(int& line, int& col) const
212{
213    line = fLine;
214    col  = fCol;
215}
216
217inline const XMLCh* XSAnnotation::getSystemId() const
218{
219    return fSystemId;
220}
221
222inline void XSAnnotation::setLineCol(int line, int col)
223{
224    fLine = line;
225    fCol  = col;
226}
227
228XERCES_CPP_NAMESPACE_END
229
230#endif
Note: See TracBrowser for help on using the repository browser.