## Xalan-C++ API Documentation

### The Xalan C++ XSLT Processor Version 1.6

Main Page 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 <xalanc/XPath/XPathDefinitions.hpp>
    00064
    00065
    00066
    00067 #include <xalanc/XalanDOM/XalanDOMString.hpp>
    00068
    00069
    00070
    00071 #include <xalanc/PlatformSupport/DoubleSupport.hpp>
    00072 #include <xalanc/PlatformSupport/FormatterListener.hpp>
    00073 #include <xalanc/PlatformSupport/XalanReferenceCountedObject.hpp>
    00074
    00075
    00076
    00077 #include <xalanc/DOMSupport/DOMServices.hpp>
    00078
    00079
    00080
    00081 #include <xalanc/XPath/NodeRefListBase.hpp>
    00082 #include <xalanc/XPath/XalanXPathException.hpp>
    00083
    00084
    00085
    00086 XALAN_CPP_NAMESPACE_BEGIN
    00087
    00088
    00089
    00090 class MutableNodeRefList;
    00091 class NodeRefListBase;
    00092 class ResultTreeFragBase;
    00093 class XObjectFactory;
    00094 class XObjectTypeCallback;
    00095 class XPathExecutionContext;
    00096
    00097
    00098
    00102 class XALAN_XPATH_EXPORT XObject : protected XalanReferenceCountedObject
    00103 {
    00104 public:
    00105
    00106     friend class XObjectPtr;
    00107
    00111     enum    eObjectType { eTypeNull = 0,
    00112                           eTypeUnknown = 1,
    00113                           eTypeBoolean = 2,
    00114                           eTypeNumber = 3,
    00115                           eTypeString = 4,
    00116                           eTypeNodeSet = 5,
    00117                           eTypeResultTreeFrag = 6,
    00118                           eTypeUserDefined = 7,
    00119                           // These next types are implementation-specific, and
    00120                           // are never returned by getType().
    00121                           eTypeStringReference = 8,
    00122                           eTypeStringAdapter = 9,
    00123                           eTypeStringCached = 10,
    00124                           eTypeXTokenNumberAdapter = 11,
    00125                           eTypeXTokenStringAdapter = 12,
    00126                           eTypeNodeSetNodeProxy = 13,
    00127                           eUnknown
    00128                         };
    00129
    00133     static void
    00134     initialize();
    00135
    00139     static void
    00140     terminate();
    00141
    00147     XObject(eObjectType     theObjectType);
    00148
    00149     XObject(const XObject&  source);
    00150
    00157     virtual XObject*
    00158     clone(void*     theAddress = 0) const = 0;
    00159
    00166     virtual XalanDOMString
    00167     getTypeString() const = 0;
    00168
    00174     virtual double
    00175     num() const;
    00176
    00182     virtual bool
    00183     boolean() const;
    00184
    00190     virtual const XalanDOMString&
    00191     str() const;
    00192
    00193     typedef void (FormatterListener::*MemberFunctionPtr)(const XMLCh* const, const unsigned int);
    00194
    00202     virtual void
    00203     str(
    00204             FormatterListener&  formatterListener,
    00205             MemberFunctionPtr   function) const = 0;
    00206
    00212     virtual double
    00213     stringLength() const = 0;
    00214
    00220     virtual void
    00221     str(XalanDOMString& theBuffer) const;
    00222
    00228     virtual const ResultTreeFragBase&
    00229     rtree() const;
    00230
    00236     virtual const NodeRefListBase&
    00237     nodeset() const;
    00238
    00244     virtual void
    00245     ProcessXObjectTypeCallback(XObjectTypeCallback&     theCallbackObject) = 0;
    00246
    00252     virtual void
    00253     ProcessXObjectTypeCallback(XObjectTypeCallback&     theCallbackObject) const = 0;
    00254
    00262     bool
    00263     equals(
    00264             const XObject&          theRHS,
    00265             XPathExecutionContext&  executionContext) const;
    00266
    00274     bool
    00275     notEquals(
    00276             const XObject&          theRHS,
    00277             XPathExecutionContext&  executionContext) const;
    00278
    00285     bool
    00286     lessThan(
    00287             const XObject&          theRHS,
    00288             XPathExecutionContext&  executionContext) const;
    00289
    00297     bool
    00298     lessThanOrEquals(
    00299             const XObject&          theRHS,
    00300             XPathExecutionContext&  executionContext) const;
    00301
    00308     bool
    00309     greaterThan(
    00310             const XObject&          theRHS,
    00311             XPathExecutionContext&  executionContext) const;
    00312
    00320     bool
    00321     greaterThanOrEquals(
    00322             const XObject&          theRHS,
    00323             XPathExecutionContext&  executionContext) const;
    00324
    00330     eObjectType
    00331     getType() const
    00332     {
    00333         return m_objectType;
    00334     }
    00335
    00341     static bool
    00342     boolean(double  theNumber)
    00343     {
    00344         return !DoubleSupport::isNaN(theNumber) && !DoubleSupport::equal(theNumber, 0.0);
    00345     }
    00346
    00352     static bool
    00353     boolean(const XalanDOMString&   theString)
    00354     {
    00355         return theString.length() == 0 ? false : true;
    00356     }
    00357
    00363     static bool
    00364     boolean(const NodeRefListBase&  theNodeList)
    00365     {
    00366         return theNodeList.getLength() == 0 ? false : true;
    00367     }
    00368
    00374     static const XalanDOMString&
    00375     string(bool     theBool)
    00376     {
    00377         return theBool == true ? s_trueString : s_falseString;
    00378     }
    00379
    00380     static void
    00381     string(
    00382             bool                theBool,
    00383             FormatterListener&  formatterListener,
    00384             MemberFunctionPtr   function)
    00385     {
    00386         if(theBool == true)
    00387         {
    00388             (formatterListener.*function)(s_trueString.c_str(), s_trueString.length());
    00389         }
    00390         else
    00391         {
    00392             (formatterListener.*function)(s_falseString.c_str(), s_falseString.length());
    00393         }
    00394     }
    00395
    00401     static void
    00402     string(
    00403             double              theNumber,
    00404             XalanDOMString&     theString)
    00405     {
    00406         DoubleToDOMString(theNumber, theString);
    00407     }
    00408
    00409     static void
    00410     string(
    00411             double              theNumber,
    00412             FormatterListener&  formatterListener,
    00413             MemberFunctionPtr   function)
    00414     {
    00415         DOMStringHelper::DoubleToCharacters(theNumber, formatterListener, function);
    00416     }
    00417
    00423     static void
    00424     string(
    00425             const XalanNode&    theNode,
    00426             XalanDOMString&     theString)
    00427     {
    00428         DOMServices::getNodeData(theNode, theString);
    00429     }
    00430
    00431     static void
    00432     string(
    00433             const XalanNode&    theNode,
    00434             FormatterListener&  formatterListener,
    00435             MemberFunctionPtr   function)
    00436     {
    00437         DOMServices::getNodeData(theNode, formatterListener, function);
    00438     }
    00439
    00445     static void
    00446     string(
    00447             const NodeRefListBase&  theNodeList,
    00448             XalanDOMString&         theString)
    00449     {
    00450         if (theNodeList.getLength() > 0)
    00451         {
    00452             assert(theNodeList.item(0) != 0);
    00453
    00454             string(*theNodeList.item(0), theString);
    00455         }
    00456     }
    00457
    00458     static void
    00459     string(
    00460             const NodeRefListBase&  theNodeList,
    00461             FormatterListener&      formatterListener,
    00462             MemberFunctionPtr       function)
    00463     {
    00464         if (theNodeList.getLength() > 0)
    00465         {
    00466             assert(theNodeList.item(0) != 0);
    00467
    00468             DOMServices::getNodeData(*theNodeList.item(0), formatterListener, function);
    00469         }
    00470     }
    00471
    00477     static double
    00478     number(bool     theBoolean)
    00479     {
    00480         return theBoolean == true ? 1.0 : 0.0;
    00481     }
    00482
    00483     static double
    00484     number(const XalanDOMString&    theString)
    00485     {
    00486         return DoubleSupport::toDouble(theString);
    00487     }
    00488
    00494     static double
    00495     number(
    00496             XPathExecutionContext&  executionContext,
    00497             const NodeRefListBase&  theNodeList);
    00498
    00504     static double
    00505     number(
    00506             XPathExecutionContext&  executionContext,
    00507             const XalanNode&        theNode);
    00508
    00509
    00510     // All XObject instances are controlled by an instance of an XObjectFactory.
    00511     friend class XObjectFactory;
    00512
    00513     void
    00514     setFactory(XObjectFactory*  theFactory)
    00515     {
    00516         m_factory = theFactory;
    00517     }
    00518
    00519     // Base class for all XObject exceptions...
    00520     class XObjectException : public XalanXPathException
    00521     {
    00522     public:
    00523
    00524         explicit
    00525         XObjectException(
    00526                 const XalanDOMString&   message = XalanDOMString(),
    00527                 const XalanNode*        styleNode = 0,
    00528                 const XalanDOMString&   theType = XalanDOMString(XALAN_STATIC_UCODE_STRING("XObjectException")));
    00529
    00530         virtual
    00531         ~XObjectException();
    00532     };
    00533
    00534     class XObjectInvalidConversionException : public XObjectException
    00535     {
    00536     public:
    00537
    00538         XObjectInvalidConversionException(
    00539                 const XalanDOMString&   fromType,
    00540                 const XalanDOMString&   toType);
    00541
    00542         virtual
    00543         ~XObjectInvalidConversionException();
    00544
    00545         const XalanDOMString&
    00546         getFromType() const
    00547         {
    00548             return m_fromType;
    00549         }
    00550
    00551         const XalanDOMString&
    00552         getToType() const
    00553         {
    00554             return m_toType;
    00555         }
    00556
    00557     private:
    00558
    00559         static const XalanDOMString
    00560         formatErrorString(
    00561                 const XalanDOMString&   fromType,
    00562                 const XalanDOMString&   toType);
    00563
    00564         const XalanDOMString    m_fromType;
    00565
    00566         const XalanDOMString    m_toType;
    00567     };
    00568
    00569 protected:
    00570
    00576     virtual eObjectType
    00577     getRealType() const;
    00578
    00579     virtual void
    00580     referenced();
    00581
    00582     virtual void
    00583     dereferenced();
    00584
    00585     virtual
    00586     ~XObject();
    00587
    00588     static const XalanDOMString     s_nullString;
    00589
    00590 protected:
    00591
    00592     static XalanDOMString   s_falseString;
    00593
    00594     static XalanDOMString   s_trueString;
    00595
    00596 private:
    00597
    00598     // Not implemented...
    00599     XObject&
    00600     operator=(const XObject&);
    00601
    00602     const eObjectType   m_objectType;
    00603
    00604     XObjectFactory*     m_factory;
    00605 };
    00606
    00607
    00608
    00612 class XALAN_XPATH_EXPORT XObjectPtr
    00613 {
    00614 public:
    00615
    00616     friend bool operator==(const XObjectPtr&, const XObjectPtr&);
    00617     friend bool operator<(const XObjectPtr&, const XObjectPtr&);
    00618
    00622     explicit
    00623     XObjectPtr(XObject*     theXObject = 0) :
    00624         m_xobjectPtr(theXObject)
    00625     {
    00626         XalanReferenceCountedObject::addReference(theXObject);
    00627     }
    00628
    00629     XObjectPtr(const XObjectPtr&    theSource) :
    00630         m_xobjectPtr(theSource.m_xobjectPtr)
    00631     {
    00632         XalanReferenceCountedObject::addReference(m_xobjectPtr);
    00633     };
    00634
    00635     XObjectPtr&
    00636 	operator=(const XObjectPtr&        theRHS)
    00637     {
    00638         if (m_xobjectPtr != theRHS.m_xobjectPtr)
    00639         {
    00640             XalanReferenceCountedObject::removeReference(m_xobjectPtr);
    00641
    00642             m_xobjectPtr = theRHS.m_xobjectPtr;
    00643
    00644             XalanReferenceCountedObject::addReference(m_xobjectPtr);
    00645         }
    00646
    00647         return *this;
    00648     }
    00649
    00650     ~XObjectPtr()
    00651     {
    00652         XalanReferenceCountedObject::removeReference(m_xobjectPtr);
    00653     };
    00654
    00655     void
    00656     release()
    00657     {
    00658         XObject* const  xobjectPtr = m_xobjectPtr;
    00659
    00660         m_xobjectPtr = 0;
    00661
    00662         XalanReferenceCountedObject::removeReference(xobjectPtr);
    00663     }
    00664
    00665     bool
    00666     null() const
    00667     {
    00668         return m_xobjectPtr == 0 ? true : false;
    00669     }
    00670
    00671     const XObject&
    00672     operator*() const
    00673     {
    00674         return *m_xobjectPtr;
    00675     };
    00676
    00677     XObject&
    00678     operator*()
    00679     {
    00680         return *m_xobjectPtr;
    00681     };
    00682
    00683     const XObject*
    00684     operator->() const
    00685     {
    00686         return m_xobjectPtr;
    00687     };
    00688
    00689     XObject*
    00690     operator->()
    00691     {
    00692         return m_xobjectPtr;
    00693     };
    00694
    00695     const XObject*
    00696     get() const
    00697     {
    00698         return m_xobjectPtr;
    00699     };
    00700
    00701     XObject*
    00702     get()
    00703     {
    00704         return m_xobjectPtr;
    00705     };
    00706
    00707 private:
    00708
    00709     XObject*    m_xobjectPtr;
    00710 };
    00711
    00712
    00713
    00714 inline bool
    00715 operator==(
    00716             const XObjectPtr&   theLHS,
    00717             const XObjectPtr&   theRHS)
    00718 {
    00719     return theLHS.m_xobjectPtr == theRHS.m_xobjectPtr;
    00720 }
    00721
    00722
    00723
    00724 inline bool
    00725 operator!=(
    00726             const XObjectPtr&   theLHS,
    00727             const XObjectPtr&   theRHS)
    00728 {
    00729     return !(theLHS == theRHS);
    00730 }
    00731
    00732
    00733
    00734 inline bool
    00735 operator<(
    00736             const XObjectPtr&   theLHS,
    00737             const XObjectPtr&   theRHS)
    00738 {
    00739     return theLHS.m_xobjectPtr < theRHS.m_xobjectPtr;
    00740 }
    00741
    00742
    00743
    00744 XALAN_CPP_NAMESPACE_END
    00745
    00746
    00747
    00748 #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.6 Copyright © 2000, 2001, 2002, 2003 The Apache Software Foundation. All Rights Reserved.