Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.4

Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

XObject.hpp

Go to the documentation of this file.
00001 /*
00002  * The Apache Software License, Version 1.1
00003  *
00004  *
00005  * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
00006  * reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions
00010  * are met:
00011  *
00012  * 1. Redistributions of source code must retain the above copyright
00013  *    notice, this list of conditions and the following disclaimer. 
00014  *
00015  * 2. Redistributions in binary form must reproduce the above copyright
00016  *    notice, this list of conditions and the following disclaimer in
00017  *    the documentation and/or other materials provided with the
00018  *    distribution.
00019  *
00020  * 3. The end-user documentation included with the redistribution,
00021  *    if any, must include the following acknowledgment:  
00022  *       "This product includes software developed by the
00023  *        Apache Software Foundation (http://www.apache.org/)."
00024  *    Alternately, this acknowledgment may appear in the software itself,
00025  *    if and wherever such third-party acknowledgments normally appear.
00026  *
00027  * 4. The names "Xalan" and "Apache Software Foundation" must
00028  *    not be used to endorse or promote products derived from this
00029  *    software without prior written permission. For written 
00030  *    permission, please contact apache@apache.org.
00031  *
00032  * 5. Products derived from this software may not be called "Apache",
00033  *    nor may "Apache" appear in their name, without prior written
00034  *    permission of the Apache Software Foundation.
00035  *
00036  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
00037  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00038  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00039  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
00040  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00041  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00042  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
00043  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00044  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00045  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00046  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00047  * SUCH DAMAGE.
00048  * ====================================================================
00049  *
00050  * This software consists of voluntary contributions made by many
00051  * individuals on behalf of the Apache Software Foundation and was
00052  * originally based on software copyright (c) 1999, International
00053  * Business Machines, Inc., http://www.ibm.com.  For more
00054  * information on the Apache Software Foundation, please see
00055  * <http://www.apache.org/>.
00056  */
00057 #if !defined(XOBJECT_HEADER_GUARD_1357924680)
00058 #define XOBJECT_HEADER_GUARD_1357924680
00059 
00060 
00061 
00062 // Base include file.  Must be first.
00063 #include <XPath/XPathDefinitions.hpp>
00064 
00065 
00066 
00067 #include <XalanDOM/XalanDOMString.hpp>
00068 
00069 
00070 
00071 #include <PlatformSupport/FormatterListener.hpp>
00072 #include <PlatformSupport/XalanReferenceCountedObject.hpp>
00073 
00074 
00075 
00076 #include <XPath/XalanXPathException.hpp>
00077 
00078 
00079 
00080 class MutableNodeRefList;
00081 class NodeRefListBase;
00082 class ResultTreeFragBase;
00083 class XObjectFactory;
00084 class XObjectTypeCallback;
00085 class XPathExecutionContext;
00086 
00087 
00088 
00092 class XALAN_XPATH_EXPORT XObject : protected XalanReferenceCountedObject
00093 {
00094 public:
00095 
00096     friend class XObjectPtr;
00097 
00101     enum    eObjectType { eTypeNull = 0,
00102                           eTypeUnknown = 1,
00103                           eTypeBoolean = 2,
00104                           eTypeNumber = 3,
00105                           eTypeString = 4,
00106                           eTypeNodeSet = 5,
00107                           eTypeResultTreeFrag = 6,
00108                           eTypeUserDefined = 7,
00109                           // These next types are implementation-specific, and
00110                           // are never returned by getType().
00111                           eTypeStringReference = 8,
00112                           eTypeStringAdapter = 9,
00113                           eTypeStringCached = 10,
00114                           eTypeXTokenNumberAdapter = 11,
00115                           eTypeXTokenStringAdapter = 12,
00116                           eUnknown
00117                         };
00118 
00124     XObject(eObjectType     theObjectType);
00125 
00126     XObject(const XObject&  source);
00127 
00134     virtual XObject*
00135     clone(void*     theAddress = 0) const = 0;
00136 
00143     virtual XalanDOMString
00144     getTypeString() const = 0;
00145 
00151     virtual double
00152     num() const;
00153 
00159     virtual bool
00160     boolean() const;
00161 
00167     virtual const XalanDOMString&
00168     str() const;
00169 
00170     typedef void (FormatterListener::*MemberFunctionPtr)(const XMLCh* const, const unsigned int);
00171 
00179     virtual void
00180     str(
00181             FormatterListener&  formatterListener,
00182             MemberFunctionPtr   function) const = 0;
00183 
00189     virtual void
00190     str(XalanDOMString& theBuffer) const;
00191 
00197     virtual const ResultTreeFragBase&
00198     rtree() const;
00199 
00205     virtual const NodeRefListBase&
00206     nodeset() const;
00207 
00213     virtual void
00214     ProcessXObjectTypeCallback(XObjectTypeCallback&     theCallbackObject) = 0;
00215 
00221     virtual void
00222     ProcessXObjectTypeCallback(XObjectTypeCallback&     theCallbackObject) const = 0;
00223 
00231     bool
00232     equals(
00233             const XObject&          theRHS,
00234             XPathExecutionContext&  executionContext) const;
00235 
00243     bool
00244     notEquals(
00245             const XObject&          theRHS,
00246             XPathExecutionContext&  executionContext) const;
00247 
00254     bool
00255     lessThan(
00256             const XObject&          theRHS,
00257             XPathExecutionContext&  executionContext) const;
00258 
00266     bool
00267     lessThanOrEquals(
00268             const XObject&          theRHS,
00269             XPathExecutionContext&  executionContext) const;
00270 
00277     bool
00278     greaterThan(
00279             const XObject&          theRHS,
00280             XPathExecutionContext&  executionContext) const;
00281 
00289     bool
00290     greaterThanOrEquals(
00291             const XObject&          theRHS,
00292             XPathExecutionContext&  executionContext) const;
00293 
00299     eObjectType
00300     getType() const
00301     {
00302         return m_objectType;
00303     }
00304 
00305     // All XObject instances are controlled by an instance of an XObjectFactory.
00306     friend class XObjectFactory;
00307 
00308     void
00309     setFactory(XObjectFactory*  theFactory)
00310     {
00311         m_factory = theFactory;
00312     }
00313 
00314     // Base class for all XObject exceptions...
00315     class XObjectException : public XalanXPathException
00316     {
00317     public:
00318 
00319         explicit
00320         XObjectException(
00321                 const XalanDOMString&   message = XalanDOMString(),
00322                 const XalanNode*        styleNode = 0,
00323                 const XalanDOMString&   theType = XalanDOMString(XALAN_STATIC_UCODE_STRING("XObjectException")));
00324 
00325         virtual
00326         ~XObjectException();
00327     };
00328 
00329     class XObjectInvalidConversionException : public XObjectException
00330     {
00331     public:
00332 
00333         XObjectInvalidConversionException(
00334                 const XalanDOMString&   fromType,
00335                 const XalanDOMString&   toType);
00336 
00337         virtual
00338         ~XObjectInvalidConversionException();
00339 
00340         const XalanDOMString&
00341         getFromType() const
00342         {
00343             return m_fromType;
00344         }
00345 
00346         const XalanDOMString&
00347         getToType() const
00348         {
00349             return m_toType;
00350         }
00351 
00352     private:
00353 
00354         static const XalanDOMString
00355         formatErrorString(
00356                 const XalanDOMString&   fromType,
00357                 const XalanDOMString&   toType);
00358 
00359         const XalanDOMString    m_fromType;
00360 
00361         const XalanDOMString    m_toType;
00362     };
00363 
00364 protected:
00365 
00371     virtual eObjectType
00372     getRealType() const;
00373 
00374     virtual void 
00375     referenced();
00376 
00377     virtual void 
00378     dereferenced();
00379 
00380     virtual
00381     ~XObject();
00382 
00383     static const XalanDOMString     s_nullString;
00384 
00385 private:
00386 
00387     // Not implemented...
00388     XObject&
00389     operator=(const XObject&);
00390 
00391     const eObjectType   m_objectType;
00392 
00393     XObjectFactory*     m_factory;
00394 };
00395 
00396 
00397 
00401 class XALAN_XPATH_EXPORT XObjectPtr
00402 {
00403 public:
00404 
00405     friend bool operator==(const XObjectPtr&, const XObjectPtr&);
00406     friend bool operator<(const XObjectPtr&, const XObjectPtr&);
00407 
00411     explicit
00412     XObjectPtr(XObject*     theXObject = 0) :
00413         m_xobjectPtr(theXObject)
00414     {
00415         XalanReferenceCountedObject::addReference(theXObject);
00416     }
00417     
00418     XObjectPtr(const XObjectPtr&    theSource) :
00419         m_xobjectPtr(theSource.m_xobjectPtr)
00420     { 
00421         XalanReferenceCountedObject::addReference(m_xobjectPtr);
00422     };
00423 
00424     XObjectPtr&
00425     operator=(const XObjectPtr&     theRHS)
00426     { 
00427         if (m_xobjectPtr != theRHS.m_xobjectPtr)
00428         {
00429             XalanReferenceCountedObject::removeReference(m_xobjectPtr);
00430 
00431             m_xobjectPtr = theRHS.m_xobjectPtr;
00432 
00433             XalanReferenceCountedObject::addReference(m_xobjectPtr);
00434         }
00435 
00436         return *this;
00437     }
00438 
00439     ~XObjectPtr()
00440     {
00441         XalanReferenceCountedObject::removeReference(m_xobjectPtr);
00442     };  
00443 
00444     bool
00445     null() const
00446     {
00447         return m_xobjectPtr == 0 ? true : false;
00448     }
00449 
00450     const XObject&
00451     operator*() const
00452     {
00453         return *m_xobjectPtr;
00454     };
00455 
00456     XObject&
00457     operator*() 
00458     {
00459         return *m_xobjectPtr;
00460     };
00461 
00462     const XObject*
00463     operator->() const
00464     {
00465         return m_xobjectPtr;
00466     };
00467 
00468     XObject*
00469     operator->()
00470     {
00471         return m_xobjectPtr;
00472     };
00473 
00474     const XObject*
00475     get() const
00476     {
00477         return m_xobjectPtr;
00478     };
00479 
00480     XObject*
00481     get()
00482     {
00483         return m_xobjectPtr;
00484     };
00485 
00486 private:
00487 
00488     XObject*    m_xobjectPtr;   
00489 };
00490 
00491 
00492 
00493 inline bool
00494 operator==(
00495             const XObjectPtr&   theLHS,
00496             const XObjectPtr&   theRHS)
00497 {
00498     return theLHS.m_xobjectPtr == theRHS.m_xobjectPtr;
00499 }
00500 
00501 
00502 
00503 inline bool
00504 operator!=(
00505             const XObjectPtr&   theLHS,
00506             const XObjectPtr&   theRHS)
00507 {
00508     return !(theLHS == theRHS);
00509 }
00510 
00511 
00512 
00513 inline bool
00514 operator<(
00515             const XObjectPtr&   theLHS,
00516             const XObjectPtr&   theRHS)
00517 {
00518     return theLHS.m_xobjectPtr < theRHS.m_xobjectPtr;
00519 }
00520 
00521 
00522 
00523 #endif  // XOBJECT_HEADER_GUARD_1357924680

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

Xalan-C++ XSLT Processor Version 1.4
Copyright © 2000, 2001, 2002 The Apache Software Foundation. All Rights Reserved.