## 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

# XPathFactory.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(XPATHFACTORY_HEADER_GUARD_1357924680)
    00058 #define XPATHFACTORY_HEADER_GUARD_1357924680
    00059
    00060
    00061
    00062 // Base include file.  Must be first.
    00063 #include <xalanc/XPath/XPathDefinitions.hpp>
    00064
    00065
    00066
    00067 #include <cassert>
    00068 #include <functional>
    00069
    00070
    00071
    00072 XALAN_CPP_NAMESPACE_BEGIN
    00073
    00074
    00075
    00076 class XPath;
    00077
    00078
    00079
    00080 class XALAN_XPATH_EXPORT XPathFactory
    00081 {
    00082 public:
    00083
    00084     explicit
    00085     XPathFactory();
    00086
    00087     virtual
    00088     ~XPathFactory();
    00089
    00096     bool
    00097     returnObject(const XPath*   theXPath)
    00098     {
    00099         return doReturnObject(theXPath);
    00100     }
    00101
    00106     virtual void
    00107     reset() = 0;
    00108
    00114     virtual XPath*
    00115     create() = 0;
    00116
    00122 #if defined(XALAN_NO_STD_NAMESPACE)
    00123     struct DeleteXPathFunctor : public unary_function<const XPath*, void>
    00124 #else
    00125     struct DeleteXPathFunctor : public std::unary_function<const XPath*, void>
    00126 #endif
    00127     {
    00128     public:
    00129
    00130         DeleteXPathFunctor(
    00131             XPathFactory&       theFactoryInstance,
    00132             bool                fInReset = false) :
    00133             m_factoryInstance(theFactoryInstance),
    00134             m_fInReset(fInReset)
    00135         {
    00136         }
    00137
    00138         result_type
    00139         operator()(argument_type    theXPath) const
    00140         {
    00141             if (m_fInReset == true)
    00142             {
    00143                 m_factoryInstance.doReturnObject(theXPath,
    00144                                                  true);
    00145             }
    00146             else
    00147             {
    00148                 m_factoryInstance.returnObject(theXPath);
    00149             }
    00150         }
    00151
    00152     private:
    00153
    00154         XPathFactory&       m_factoryInstance;
    00155
    00156         const bool          m_fInReset;
    00157     };
    00158
    00159     friend struct DeleteXPathFunctor;
    00160
    00161 protected:
    00162
    00163     virtual bool
    00164     doReturnObject(
    00165             const XPath*    theXPath,
    00166             bool            fInReset = false) = 0;
    00167 };
    00168
    00169
    00170
    00174 class XPathGuard
    00175 {
    00176 public:
    00177
    00184     XPathGuard(
    00185             XPathFactory&   theFactory,
    00186             const XPath*    theXPath) :
    00187         m_factory(&theFactory),
    00188         m_object(theXPath)
    00189     {
    00190     }
    00191
    00192     // Note that copy construction transfers ownership, just
    00193     // as std::auto_ptr.
    00194     XPathGuard(XPathGuard&  theRHS)
    00195     {
    00196         // Release the current object...
    00197         release();
    00198
    00199         // Copy the factory and object pointers...
    00200         m_factory = theRHS.m_factory;
    00201         m_object = theRHS.m_object;
    00202
    00203         // The source object no longer points to
    00204         // the object...
    00205         theRHS.m_factory = 0;
    00206         theRHS.m_object = 0;
    00207     }
    00208
    00209     ~XPathGuard()
    00210     {
    00211         reset();
    00212     }
    00213
    00219     const XPath*
    00220     operator->() const
    00221     {
    00222         assert(m_object != 0);
    00223
    00224         return m_object;
    00225     }
    00226
    00232     const XPath*
    00233     get() const
    00234     {
    00235         return m_object;
    00236     }
    00237
    00241     void
    00242     reset()
    00243     {
    00244         if (m_object != 0)
    00245         {
    00246             assert(m_factory != 0);
    00247
    00248             m_factory->returnObject(m_object);
    00249
    00250             m_object = 0;
    00251         }
    00252
    00253         m_factory = 0;
    00254     }
    00255
    00261     const XPath*
    00262     release()
    00263     {
    00264         const XPath* const  theTemp = m_object;
    00265
    00266         m_object = 0;
    00267
    00268         return theTemp;
    00269     }
    00270
    00271 private:
    00272
    00273     XPathGuard&
    00274     operator=(const XPathGuard&);
    00275
    00276     bool
    00277     operator==(const XPathGuard&) const;
    00278
    00279
    00280     // Data members...
    00281     XPathFactory*   m_factory;
    00282     const XPath*    m_object;
    00283 };
    00284
    00285
    00286
    00287 XALAN_CPP_NAMESPACE_END
    00288
    00289
    00290
    00291 #endif  // XPATHFACTORY_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.