LCOV - code coverage report
Current view: top level - parser/xml - nsSAXAttributes.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 158 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 25 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #include "nsSAXAttributes.h"
       7             : 
       8           0 : NS_IMPL_ISUPPORTS(nsSAXAttributes, nsISAXAttributes, nsISAXMutableAttributes)
       9             : 
      10             : NS_IMETHODIMP
      11           0 : nsSAXAttributes::GetIndexFromName(const nsAString &aURI,
      12             :                                   const nsAString &aLocalName,
      13             :                                   int32_t *aResult)
      14             : {
      15           0 :   int32_t len = mAttrs.Length();
      16             :   int32_t i;
      17           0 :   for (i = 0; i < len; ++i) {
      18           0 :     const SAXAttr &att = mAttrs[i];
      19           0 :     if (att.localName.Equals(aLocalName) && att.uri.Equals(aURI)) {
      20           0 :       *aResult = i;
      21           0 :       return NS_OK;
      22             :     }
      23             :   }
      24           0 :   *aResult = -1;
      25             : 
      26           0 :   return NS_OK;
      27             : }
      28             : 
      29             : NS_IMETHODIMP
      30           0 : nsSAXAttributes::GetIndexFromQName(const nsAString &aQName, int32_t *aResult)
      31             : {
      32           0 :   int32_t len = mAttrs.Length();
      33             :   int32_t i;
      34           0 :   for (i = 0; i < len; ++i) {
      35           0 :     const SAXAttr &att = mAttrs[i];
      36           0 :     if (att.qName.Equals(aQName)) {
      37           0 :       *aResult = i;
      38           0 :       return NS_OK;
      39             :     }
      40             :   }
      41           0 :   *aResult = -1;
      42             : 
      43           0 :   return NS_OK;
      44             : }
      45             : 
      46             : NS_IMETHODIMP
      47           0 : nsSAXAttributes::GetLength(int32_t *aResult)
      48             : {
      49           0 :   *aResult = mAttrs.Length();
      50           0 :   return NS_OK;
      51             : }
      52             : 
      53             : NS_IMETHODIMP
      54           0 : nsSAXAttributes::GetLocalName(uint32_t aIndex, nsAString &aResult)
      55             : {
      56           0 :   uint32_t len = mAttrs.Length();
      57           0 :   if (aIndex >= len) {
      58           0 :     aResult.SetIsVoid(true);
      59             :   } else {
      60           0 :     const SAXAttr &att = mAttrs[aIndex];
      61           0 :     aResult = att.localName;
      62             :   }
      63             : 
      64           0 :   return NS_OK;
      65             : }
      66             : 
      67             : NS_IMETHODIMP
      68           0 : nsSAXAttributes::GetQName(uint32_t aIndex, nsAString &aResult)
      69             : {
      70           0 :   uint32_t len = mAttrs.Length();
      71           0 :   if (aIndex >= len) {
      72           0 :     aResult.SetIsVoid(true);
      73             :   } else {
      74           0 :     const SAXAttr &att = mAttrs[aIndex];
      75           0 :     aResult = att.qName;
      76             :   }
      77             : 
      78           0 :   return NS_OK;
      79             : }
      80             : 
      81             : NS_IMETHODIMP
      82           0 : nsSAXAttributes::GetType(uint32_t aIndex, nsAString &aResult)
      83             : {
      84           0 :   uint32_t len = mAttrs.Length();
      85           0 :   if (aIndex >= len) {
      86           0 :     aResult.SetIsVoid(true);
      87             :   } else {
      88           0 :     const SAXAttr &att = mAttrs[aIndex];
      89           0 :     aResult = att.type;
      90             :   }
      91             : 
      92           0 :   return NS_OK;
      93             : }
      94             : 
      95             : NS_IMETHODIMP
      96           0 : nsSAXAttributes::GetTypeFromName(const nsAString &aURI,
      97             :                                  const nsAString &aLocalName,
      98             :                                  nsAString &aResult)
      99             : {
     100           0 :   int32_t index = -1;
     101           0 :   GetIndexFromName(aURI, aLocalName, &index);
     102           0 :   if (index >= 0) {
     103           0 :     aResult = mAttrs[index].type;
     104             :   } else {
     105           0 :     aResult.SetIsVoid(true);
     106             :   }
     107             : 
     108           0 :   return NS_OK;
     109             : }
     110             : 
     111             : NS_IMETHODIMP
     112           0 : nsSAXAttributes::GetTypeFromQName(const nsAString &aQName, nsAString &aResult)
     113             : {
     114           0 :   int32_t index = -1;
     115           0 :   GetIndexFromQName(aQName, &index);
     116           0 :   if (index >= 0) {
     117           0 :     aResult = mAttrs[index].type;
     118             :   } else {
     119           0 :     aResult.SetIsVoid(true);
     120             :   }
     121             : 
     122           0 :   return NS_OK;
     123             : }
     124             : 
     125             : NS_IMETHODIMP
     126           0 : nsSAXAttributes::GetURI(uint32_t aIndex, nsAString &aResult)
     127             : {
     128           0 :   uint32_t len = mAttrs.Length();
     129           0 :   if (aIndex >= len) {
     130           0 :     aResult.SetIsVoid(true);
     131             :   } else {
     132           0 :     const SAXAttr &att = mAttrs[aIndex];
     133           0 :     aResult = att.uri;
     134             :   }
     135             : 
     136           0 :   return NS_OK;
     137             : }
     138             : 
     139             : NS_IMETHODIMP
     140           0 : nsSAXAttributes::GetValue(uint32_t aIndex, nsAString &aResult)
     141             : {
     142           0 :   uint32_t len = mAttrs.Length();
     143           0 :   if (aIndex >= len) {
     144           0 :     aResult.SetIsVoid(true);
     145             :   } else {
     146           0 :     const SAXAttr &att = mAttrs[aIndex];
     147           0 :     aResult = att.value;
     148             :   }
     149             : 
     150           0 :   return NS_OK;
     151             : }
     152             : 
     153             : NS_IMETHODIMP
     154           0 : nsSAXAttributes::GetValueFromName(const nsAString &aURI,
     155             :                                   const nsAString &aLocalName,
     156             :                                   nsAString &aResult)
     157             : {
     158           0 :   int32_t index = -1;
     159           0 :   GetIndexFromName(aURI, aLocalName, &index);
     160           0 :   if (index >= 0) {
     161           0 :     aResult = mAttrs[index].value;
     162             :   } else {
     163           0 :     aResult.SetIsVoid(true);
     164             :   }
     165             : 
     166           0 :   return NS_OK;
     167             : }
     168             : 
     169             : NS_IMETHODIMP
     170           0 : nsSAXAttributes::GetValueFromQName(const nsAString &aQName,
     171             :                                    nsAString &aResult)
     172             : {
     173           0 :   int32_t index = -1;
     174           0 :   GetIndexFromQName(aQName, &index);
     175           0 :   if (index >= 0) {
     176           0 :     aResult = mAttrs[index].value;
     177             :   } else {
     178           0 :     aResult.SetIsVoid(true);
     179             :   }
     180             : 
     181           0 :   return NS_OK;
     182             : }
     183             : 
     184             : NS_IMETHODIMP
     185           0 : nsSAXAttributes::AddAttribute(const nsAString &aURI,
     186             :                               const nsAString &aLocalName,
     187             :                               const nsAString &aQName,
     188             :                               const nsAString &aType,
     189             :                               const nsAString &aValue)
     190             : {
     191           0 :   SAXAttr *att = mAttrs.AppendElement();
     192           0 :   if (!att) {
     193           0 :     return NS_ERROR_OUT_OF_MEMORY;
     194             :   }
     195             :   
     196           0 :   att->uri = aURI;
     197           0 :   att->localName = aLocalName;
     198           0 :   att->qName = aQName;
     199           0 :   att->type = aType;
     200           0 :   att->value = aValue;
     201             : 
     202           0 :   return NS_OK;
     203             : }
     204             : 
     205             : NS_IMETHODIMP
     206           0 : nsSAXAttributes::Clear()
     207             : {
     208           0 :   mAttrs.Clear();
     209             : 
     210           0 :   return NS_OK;
     211             : }
     212             : 
     213             : NS_IMETHODIMP
     214           0 : nsSAXAttributes::RemoveAttribute(uint32_t aIndex)
     215             : {
     216           0 :   if (aIndex >= mAttrs.Length()) {
     217           0 :     return NS_ERROR_FAILURE;
     218             :   }
     219           0 :   mAttrs.RemoveElementAt(aIndex);
     220             : 
     221           0 :   return NS_OK;
     222             : }
     223             : 
     224             : NS_IMETHODIMP
     225           0 : nsSAXAttributes::SetAttributes(nsISAXAttributes *aAttributes)
     226             : {
     227           0 :   NS_ENSURE_ARG(aAttributes);
     228             : 
     229             :   nsresult rv;
     230             :   int32_t len;
     231           0 :   rv = aAttributes->GetLength(&len);
     232           0 :   NS_ENSURE_SUCCESS(rv, rv);
     233             : 
     234           0 :   mAttrs.Clear();
     235             :   SAXAttr *att;
     236             :   int32_t i;
     237           0 :   for (i = 0; i < len; ++i) {
     238           0 :     att = mAttrs.AppendElement();
     239           0 :     if (!att) {
     240           0 :       return NS_ERROR_OUT_OF_MEMORY;
     241             :     }
     242           0 :     rv = aAttributes->GetURI(i, att->uri);
     243           0 :     NS_ENSURE_SUCCESS(rv, rv);
     244           0 :     rv = aAttributes->GetLocalName(i, att->localName);
     245           0 :     NS_ENSURE_SUCCESS(rv, rv);
     246           0 :     rv = aAttributes->GetQName(i, att->qName);
     247           0 :     NS_ENSURE_SUCCESS(rv, rv);
     248           0 :     rv = aAttributes->GetType(i, att->type);
     249           0 :     NS_ENSURE_SUCCESS(rv, rv);
     250           0 :     rv = aAttributes->GetValue(i, att->value);
     251           0 :     NS_ENSURE_SUCCESS(rv, rv);
     252             :   }
     253             : 
     254           0 :   return NS_OK;
     255             : }
     256             : 
     257             : NS_IMETHODIMP
     258           0 : nsSAXAttributes::SetAttribute(uint32_t aIndex,
     259             :                               const nsAString &aURI,
     260             :                               const nsAString &aLocalName,
     261             :                               const nsAString &aQName,
     262             :                               const nsAString &aType,
     263             :                               const nsAString &aValue)
     264             : {
     265           0 :   if (aIndex >= mAttrs.Length()) {
     266           0 :     return NS_ERROR_FAILURE;
     267             :   }
     268             : 
     269           0 :   SAXAttr &att = mAttrs[aIndex];
     270           0 :   att.uri = aURI;
     271           0 :   att.localName = aLocalName;
     272           0 :   att.qName = aQName;
     273           0 :   att.type = aType;
     274           0 :   att.value = aValue;
     275             : 
     276           0 :   return NS_OK;
     277             : }
     278             : 
     279             : NS_IMETHODIMP
     280           0 : nsSAXAttributes::SetLocalName(uint32_t aIndex, const nsAString &aLocalName)
     281             : {
     282           0 :   if (aIndex >= mAttrs.Length()) {
     283           0 :     return NS_ERROR_FAILURE;
     284             :   }
     285           0 :   mAttrs[aIndex].localName = aLocalName;
     286             : 
     287           0 :   return NS_OK;
     288             : }
     289             : 
     290             : NS_IMETHODIMP
     291           0 : nsSAXAttributes::SetQName(uint32_t aIndex, const nsAString &aQName)
     292             : {
     293           0 :   if (aIndex >= mAttrs.Length()) {
     294           0 :     return NS_ERROR_FAILURE;
     295             :   }
     296           0 :   mAttrs[aIndex].qName = aQName;
     297             : 
     298           0 :   return NS_OK;
     299             : }
     300             : 
     301             : NS_IMETHODIMP
     302           0 : nsSAXAttributes::SetType(uint32_t aIndex, const nsAString &aType)
     303             : {
     304           0 :   if (aIndex >= mAttrs.Length()) {
     305           0 :     return NS_ERROR_FAILURE;
     306             :   }
     307           0 :   mAttrs[aIndex].type = aType;
     308             : 
     309           0 :   return NS_OK;
     310             : }
     311             : 
     312             : NS_IMETHODIMP
     313           0 : nsSAXAttributes::SetURI(uint32_t aIndex, const nsAString &aURI)
     314             : {
     315           0 :   if (aIndex >= mAttrs.Length()) {
     316           0 :     return NS_ERROR_FAILURE;
     317             :   }
     318           0 :   mAttrs[aIndex].uri = aURI;
     319             : 
     320           0 :   return NS_OK;
     321             : }
     322             : 
     323             : NS_IMETHODIMP
     324           0 : nsSAXAttributes::SetValue(uint32_t aIndex, const nsAString &aValue)
     325             : {
     326           0 :   if (aIndex >= mAttrs.Length()) {
     327           0 :     return NS_ERROR_FAILURE;
     328             :   }
     329           0 :   mAttrs[aIndex].value = aValue;
     330             : 
     331           0 :   return NS_OK;
     332             : }

Generated by: LCOV version 1.13