LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/gml - gmlreadstate.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 25 25 100.0 %
Date: 2024-11-21 22:18:42 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /**********************************************************************
       2             :  *
       3             :  * Project:  GML Reader
       4             :  * Purpose:  Implementation of GMLReadState class.
       5             :  * Author:   Frank Warmerdam, warmerdam@pobox.com
       6             :  *
       7             :  **********************************************************************
       8             :  * Copyright (c) 2002, Frank Warmerdam
       9             :  * Copyright (c) 2011, Even Rouault <even dot rouault at spatialys.com>
      10             :  *
      11             :  * SPDX-License-Identifier: MIT
      12             :  ****************************************************************************/
      13             : 
      14             : #include "cpl_port.h"
      15             : #include "gmlreaderp.h"
      16             : 
      17             : #include <cstddef>
      18             : #include <memory>
      19             : #include <string>
      20             : #include <vector>
      21             : 
      22             : #include "cpl_conv.h"
      23             : #include "cpl_error.h"
      24             : #include "cpl_string.h"
      25             : 
      26             : /************************************************************************/
      27             : /*                              Reset()                                 */
      28             : /************************************************************************/
      29             : 
      30        2996 : void GMLReadState::Reset()
      31             : {
      32        2996 :     m_poFeature = nullptr;
      33        2996 :     m_poParentState = nullptr;
      34             : 
      35        2996 :     osPath.clear();
      36        2996 :     m_nPathLength = 0;
      37        2996 : }
      38             : 
      39             : /************************************************************************/
      40             : /*                              PushPath()                              */
      41             : /************************************************************************/
      42             : 
      43       14952 : void GMLReadState::PushPath(const char *pszElement, int nLen)
      44             : 
      45             : {
      46       14952 :     if (m_nPathLength > 0)
      47        5285 :         osPath.append(1, '|');
      48       14952 :     if (m_nPathLength < static_cast<int>(aosPathComponents.size()))
      49             :     {
      50       13493 :         if (nLen >= 0)
      51             :         {
      52       13103 :             aosPathComponents[m_nPathLength].assign(pszElement, nLen);
      53       13103 :             osPath.append(pszElement, nLen);
      54             :         }
      55             :         else
      56             :         {
      57         390 :             aosPathComponents[m_nPathLength].assign(pszElement);
      58         390 :             osPath.append(pszElement);
      59             :         }
      60             :     }
      61             :     else
      62             :     {
      63        1459 :         aosPathComponents.push_back(pszElement);
      64        1459 :         osPath.append(pszElement);
      65             :     }
      66       14952 :     m_nPathLength++;
      67       14952 : }
      68             : 
      69             : /************************************************************************/
      70             : /*                              PopPath()                               */
      71             : /************************************************************************/
      72             : 
      73       14867 : void GMLReadState::PopPath()
      74             : 
      75             : {
      76       14867 :     CPLAssert(m_nPathLength > 0);
      77             : 
      78       29734 :     osPath.resize(osPath.size() - (aosPathComponents[m_nPathLength - 1].size() +
      79       14867 :                                    ((m_nPathLength > 1) ? 1 : 0)));
      80       14867 :     m_nPathLength--;
      81       14867 : }

Generated by: LCOV version 1.14