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: 2025-01-18 12:42:00 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        3175 : void GMLReadState::Reset()
      31             : {
      32        3175 :     m_poFeature = nullptr;
      33        3175 :     m_poParentState = nullptr;
      34             : 
      35        3175 :     osPath.clear();
      36        3175 :     m_nPathLength = 0;
      37        3175 : }
      38             : 
      39             : /************************************************************************/
      40             : /*                              PushPath()                              */
      41             : /************************************************************************/
      42             : 
      43       15869 : void GMLReadState::PushPath(const char *pszElement, int nLen)
      44             : 
      45             : {
      46       15869 :     if (m_nPathLength > 0)
      47        5510 :         osPath.append(1, '|');
      48       15869 :     if (m_nPathLength < static_cast<int>(aosPathComponents.size()))
      49             :     {
      50       14324 :         if (nLen >= 0)
      51             :         {
      52       13934 :             aosPathComponents[m_nPathLength].assign(pszElement, nLen);
      53       13934 :             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        1545 :         aosPathComponents.push_back(pszElement);
      64        1545 :         osPath.append(pszElement);
      65             :     }
      66       15869 :     m_nPathLength++;
      67       15869 : }
      68             : 
      69             : /************************************************************************/
      70             : /*                              PopPath()                               */
      71             : /************************************************************************/
      72             : 
      73       15784 : void GMLReadState::PopPath()
      74             : 
      75             : {
      76       15784 :     CPLAssert(m_nPathLength > 0);
      77             : 
      78       31568 :     osPath.resize(osPath.size() - (aosPathComponents[m_nPathLength - 1].size() +
      79       15784 :                                    ((m_nPathLength > 1) ? 1 : 0)));
      80       15784 :     m_nPathLength--;
      81       15784 : }

Generated by: LCOV version 1.14