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