Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:14:51

0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  *
0009  *      http://www.apache.org/licenses/LICENSE-2.0
0010  *
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 /*
0019  * $Id$
0020  */
0021 
0022 #if !defined(XERCESC_INCLUDE_GUARD_XSANNOTATION_HPP)
0023 #define XERCESC_INCLUDE_GUARD_XSANNOTATION_HPP
0024 
0025 #include <xercesc/framework/psvi/XSObject.hpp>
0026 #include <xercesc/internal/XSerializable.hpp>
0027 
0028 XERCES_CPP_NAMESPACE_BEGIN
0029 
0030 /**
0031  * This class describes all properties of a Schema Annotation
0032  * component.
0033  * This is *always* owned by the validator /parser object from which
0034  * it is obtained.
0035  */
0036 
0037 // forward declarations
0038 class DOMNode;
0039 class ContentHandler;
0040 
0041 class XMLPARSER_EXPORT XSAnnotation : public XSerializable, public XSObject
0042 {
0043 public:
0044 
0045     // TargetType
0046     enum ANNOTATION_TARGET {
0047         /**
0048          * The object type is <code>org.w3c.dom.Element</code>.
0049          */
0050         W3C_DOM_ELEMENT           = 1,
0051         /**
0052          * The object type is <code>org.w3c.dom.Document</code>.
0053          */
0054         W3C_DOM_DOCUMENT          = 2
0055     };
0056 
0057     //  Constructors and Destructor
0058     // -----------------------------------------------------------------------
0059     /** @name Constructors */
0060     //@{
0061 
0062     /**
0063       * The default constructor
0064       *
0065       * @param  contents    The string that is to be the content of this XSAnnotation
0066       * @param  manager     The configurable memory manager
0067       */
0068     XSAnnotation
0069     (
0070         const XMLCh* const contents
0071         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
0072     );
0073 
0074     //@};
0075 
0076     /** @name Destructor */
0077     //@{
0078     ~XSAnnotation();
0079     //@}
0080 
0081     //---------------------
0082     /** @name XSAnnotation methods */
0083 
0084     //@{
0085 
0086     /**
0087      * Write contents of the annotation to the specified DOM object. In-scope
0088      * namespace declarations for <code>annotation</code> element are added as
0089      * attribute nodes of the serialized <code>annotation</code>.
0090      * @param node  A target pointer to the annotation target object, i.e.
0091      * either <code>DOMDocument</code> or <code>DOMElement</code> cast as
0092      * <code>DOMNode</code>.
0093      * @param targetType  A target type.
0094      */
0095 
0096     void writeAnnotation(DOMNode* node, ANNOTATION_TARGET targetType);
0097 
0098     /**
0099      * Write contents of the annotation to the specified object.
0100      * The corresponding events for all in-scope namespace declarations are
0101      * sent via the specified document handler.
0102      * @param handler  A target pointer to the annotation target object, i.e.
0103      *   <code>ContentHandler</code>.
0104      */
0105     void writeAnnotation(ContentHandler* handler);
0106 
0107     /**
0108      * A text representation of annotation.
0109      */
0110     const XMLCh *getAnnotationString() const;
0111     XMLCh *getAnnotationString();
0112 
0113     //@}
0114 
0115     //----------------------------------
0116     /** methods needed by implementation */
0117     //@{
0118     void            setNext(XSAnnotation* const nextAnnotation);
0119     XSAnnotation*   getNext();
0120     //@}
0121 
0122     //-----------------------------
0123     /** Getter */
0124     //@{
0125     inline void           getLineCol(XMLFileLoc& line, XMLFileLoc& col)  const;
0126     inline const XMLCh*   getSystemId()                    const;
0127     //@}
0128 
0129     //-----------------------------
0130     /** Setter */
0131     //@{
0132     inline void           setLineCol(XMLFileLoc line, XMLFileLoc col);
0133            void           setSystemId(const XMLCh* const systemId);
0134     //@}
0135 
0136     /***
0137      * Support for Serialization/De-serialization
0138      ***/
0139     DECL_XSERIALIZABLE(XSAnnotation)
0140     XSAnnotation(MemoryManager* const manager);
0141 
0142 private:
0143 
0144     // -----------------------------------------------------------------------
0145     //  Unimplemented constructors and operators
0146     // -----------------------------------------------------------------------
0147     XSAnnotation(const XSAnnotation&);
0148     XSAnnotation & operator=(const XSAnnotation &);
0149 
0150 protected:
0151 
0152     // -----------------------------------------------------------------------
0153     //  data members
0154     // -----------------------------------------------------------------------
0155     XMLCh*        fContents;
0156     XSAnnotation* fNext;
0157 
0158 private:
0159 
0160     XMLCh*        fSystemId;
0161     XMLFileLoc    fLine;
0162     XMLFileLoc    fCol;
0163 
0164 };
0165 
0166 inline const XMLCh *XSAnnotation::getAnnotationString() const
0167 {
0168     return fContents;
0169 }
0170 
0171 inline XMLCh *XSAnnotation::getAnnotationString()
0172 {
0173     return fContents;
0174 }
0175 
0176 inline void XSAnnotation::getLineCol(XMLFileLoc& line, XMLFileLoc& col) const
0177 {
0178     line = fLine;
0179     col  = fCol;
0180 }
0181 
0182 inline const XMLCh* XSAnnotation::getSystemId() const
0183 {
0184     return fSystemId;
0185 }
0186 
0187 inline void XSAnnotation::setLineCol(XMLFileLoc line, XMLFileLoc col)
0188 {
0189     fLine = line;
0190     fCol  = col;
0191 }
0192 
0193 XERCES_CPP_NAMESPACE_END
0194 
0195 #endif