LCOV - code coverage report
Current view: directory - content/xslt/src/xpath - txIXPathContext.h (source / functions) Found Hit Coverage
Test: app.info Lines: 9 9 100.0 %
Date: 2012-06-02 Functions: 9 6 66.7 %

       1                 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is TransforMiiX XSLT processor code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Axel Hecht.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2001
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Axel Hecht <axel@pike.org>
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      27                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #ifndef __TX_I_XPATH_CONTEXT
      40                 : #define __TX_I_XPATH_CONTEXT
      41                 : 
      42                 : #include "txCore.h"
      43                 : 
      44                 : class FunctionCall;
      45                 : class nsIAtom;
      46                 : class txAExprResult;
      47                 : class txResultRecycler;
      48                 : class txXPathNode;
      49                 : 
      50                 : /*
      51                 :  * txIParseContext
      52                 :  *
      53                 :  * This interface describes the context needed to create
      54                 :  * XPath Expressions and XSLT Patters.
      55                 :  * (not completely though. key() requires the ProcessorState, which is 
      56                 :  * not part of this interface.)
      57                 :  */
      58                 : 
      59                 : class txIParseContext
      60              42 : {
      61                 : public:
      62              42 :     virtual ~txIParseContext()
      63              42 :     {
      64              84 :     }
      65                 : 
      66                 :     /*
      67                 :      * Return a namespaceID for a given prefix.
      68                 :      */
      69                 :     virtual nsresult resolveNamespacePrefix(nsIAtom* aPrefix, PRInt32& aID) = 0;
      70                 : 
      71                 :     /*
      72                 :      * Create a FunctionCall, needed for extension function calls and
      73                 :      * XSLT. XPath function calls are resolved by the Parser.
      74                 :      */
      75                 :     virtual nsresult resolveFunctionCall(nsIAtom* aName, PRInt32 aID,
      76                 :                                          FunctionCall** aFunction) = 0;
      77                 : 
      78                 :     /**
      79                 :      * Should nametests parsed in this context be case-sensitive
      80                 :      */
      81                 :     virtual bool caseInsensitiveNameTests() = 0;
      82                 : 
      83                 :     /*
      84                 :      * Callback to be used by the Parser if errors are detected.
      85                 :      */
      86                 :     virtual void SetErrorOffset(PRUint32 aOffset) = 0;
      87                 : };
      88                 : 
      89                 : /*
      90                 :  * txIMatchContext
      91                 :  *
      92                 :  * Interface used for matching XSLT Patters.
      93                 :  * This is the part of txIEvalContext (see below), that is independent
      94                 :  * of the context node when evaluating a XPath expression, too.
      95                 :  * When evaluating a XPath expression, |txIMatchContext|s are used
      96                 :  * to transport the information from Step to Step.
      97                 :  */
      98                 : class txIMatchContext
      99              42 : {
     100                 : public:
     101              42 :     virtual ~txIMatchContext()
     102              42 :     {
     103              84 :     }
     104                 : 
     105                 :     /*
     106                 :      * Return the ExprResult associated with the variable with the 
     107                 :      * given namespace and local name.
     108                 :      */
     109                 :     virtual nsresult getVariable(PRInt32 aNamespace, nsIAtom* aLName,
     110                 :                                  txAExprResult*& aResult) = 0;
     111                 : 
     112                 :     /*
     113                 :      * Is whitespace stripping allowed for the given node?
     114                 :      * See http://www.w3.org/TR/xslt#strip
     115                 :      */
     116                 :     virtual bool isStripSpaceAllowed(const txXPathNode& aNode) = 0;
     117                 : 
     118                 :     /**
     119                 :      * Returns a pointer to the private context
     120                 :      */
     121                 :     virtual void* getPrivateContext() = 0;
     122                 : 
     123                 :     virtual txResultRecycler* recycler() = 0;
     124                 : 
     125                 :     /*
     126                 :      * Callback to be used by the expression/pattern if errors are detected.
     127                 :      */
     128                 :     virtual void receiveError(const nsAString& aMsg, nsresult aRes) = 0;
     129                 : };
     130                 : 
     131                 : #define TX_DECL_MATCH_CONTEXT \
     132                 :     nsresult getVariable(PRInt32 aNamespace, nsIAtom* aLName, \
     133                 :                          txAExprResult*& aResult); \
     134                 :     bool isStripSpaceAllowed(const txXPathNode& aNode); \
     135                 :     void* getPrivateContext(); \
     136                 :     txResultRecycler* recycler(); \
     137                 :     void receiveError(const nsAString& aMsg, nsresult aRes)
     138                 : 
     139                 : class txIEvalContext : public txIMatchContext
     140             126 : {
     141                 : public:
     142                 :     /*
     143                 :      * Get the context node.
     144                 :      */
     145                 :     virtual const txXPathNode& getContextNode() = 0;
     146                 : 
     147                 :     /*
     148                 :      * Get the size of the context node set.
     149                 :      */
     150                 :     virtual PRUint32 size() = 0;
     151                 : 
     152                 :     /*
     153                 :      * Get the position of the context node in the context node set,
     154                 :      * starting with 1.
     155                 :      */
     156                 :     virtual PRUint32 position() = 0;
     157                 : };
     158                 : 
     159                 : #define TX_DECL_EVAL_CONTEXT \
     160                 :     TX_DECL_MATCH_CONTEXT; \
     161                 :     const txXPathNode& getContextNode(); \
     162                 :     PRUint32 size(); \
     163                 :     PRUint32 position()
     164                 : 
     165                 : #endif // __TX_I_XPATH_CONTEXT

Generated by: LCOV version 1.7