LCOV - code coverage report
Current view: directory - content/xul/templates/src - nsXULTemplateResultSetRDF.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 39 0 0.0 %
Date: 2012-06-02 Functions: 5 0 0.0 %

       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 mozilla.org code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is Neil Deakin
      18                 :  * Portions created by the Initial Developer are Copyright (C) 2005
      19                 :  * the Initial Developer. All Rights Reserved.
      20                 :  *
      21                 :  * Contributor(s):
      22                 :  *
      23                 :  * Alternatively, the contents of this file may be used under the terms of
      24                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      25                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      26                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      27                 :  * of those above. If you wish to allow use of your version of this file only
      28                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      29                 :  * use your version of this file under the terms of the MPL, indicate your
      30                 :  * decision by deleting the provisions above and replace them with the notice
      31                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      32                 :  * the provisions above, a recipient may use your version of this file under
      33                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      34                 :  *
      35                 :  * ***** END LICENSE BLOCK ***** */
      36                 : 
      37                 : #include "nsXULTemplateResultSetRDF.h"
      38                 : #include "nsXULTemplateQueryProcessorRDF.h"
      39                 : 
      40               0 : NS_IMPL_ISUPPORTS1(nsXULTemplateResultSetRDF, nsISimpleEnumerator)
      41                 : 
      42                 : NS_IMETHODIMP
      43               0 : nsXULTemplateResultSetRDF::HasMoreElements(bool *aResult)
      44                 : {
      45               0 :     *aResult = true;
      46                 : 
      47               0 :     nsCOMPtr<nsIRDFNode> node;
      48                 : 
      49               0 :     if (! mInstantiations || ! mQuery) {
      50               0 :         *aResult = false;
      51               0 :         return NS_OK;
      52                 :     }
      53                 : 
      54               0 :     if (mCheckedNext) {
      55               0 :         if (!mCurrent || mCurrent == &(mInstantiations->mHead))
      56               0 :             *aResult = false;
      57               0 :         return NS_OK;
      58                 :     }
      59                 : 
      60               0 :     mCheckedNext = true;
      61                 :                 
      62               0 :     do {
      63               0 :         if (mCurrent) {
      64               0 :             mCurrent = mCurrent->mNext;
      65               0 :             if (mCurrent == &(mInstantiations->mHead)) {
      66               0 :                 *aResult = false;
      67               0 :                 return NS_OK;
      68                 :             }
      69                 :         }
      70                 :         else {
      71               0 :             *aResult = ! mInstantiations->Empty();
      72               0 :             if (*aResult)
      73               0 :                 mCurrent = mInstantiations->mHead.mNext;
      74                 :         }
      75                 : 
      76                 :         // get the value of the member variable. If it is not set, skip
      77                 :         // the result and move on to the next result
      78               0 :         if (mCurrent) {
      79                 :             mCurrent->mInstantiation.mAssignments.
      80               0 :                 GetAssignmentFor(mQuery->mMemberVariable, getter_AddRefs(node));
      81                 :         }
      82                 : 
      83                 :         // only resources may be used as results
      84               0 :         mResource = do_QueryInterface(node);
      85               0 :     } while (! mResource);
      86                 : 
      87               0 :     return NS_OK;
      88                 : }
      89                 : 
      90                 : NS_IMETHODIMP
      91               0 : nsXULTemplateResultSetRDF::GetNext(nsISupports **aResult)
      92                 : {
      93               0 :     if (!aResult)
      94               0 :         return NS_ERROR_NULL_POINTER;
      95                 : 
      96               0 :     if (!mCurrent || !mCheckedNext)
      97               0 :         return NS_ERROR_FAILURE;
      98                 : 
      99                 :     nsRefPtr<nsXULTemplateResultRDF> nextresult =
     100               0 :         new nsXULTemplateResultRDF(mQuery, mCurrent->mInstantiation, mResource);
     101               0 :     if (!nextresult)
     102               0 :         return NS_ERROR_OUT_OF_MEMORY;
     103                 : 
     104                 :     // add the supporting memory elements to the processor's map. These are
     105                 :     // used to remove the results when an assertion is removed from the graph
     106               0 :     mProcessor->AddMemoryElements(mCurrent->mInstantiation, nextresult);
     107                 : 
     108               0 :     mCheckedNext = false;
     109                 : 
     110               0 :     *aResult = nextresult;
     111               0 :     NS_ADDREF(*aResult);
     112                 : 
     113               0 :     return NS_OK;
     114                 : }

Generated by: LCOV version 1.7