Coverage Report

Created: 2026-09-26 08:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gdal/ogr/ogrsf_frmts/kml/kmlnode.h
Line
Count
Source
1
/******************************************************************************
2
 *
3
 * Project:  KML Driver
4
 * Purpose:  Class for building up the node structure of the kml file.
5
 * Author:   Jens Oberender, j.obi@troja.net
6
 *
7
 ******************************************************************************
8
 * Copyright (c) 2007, Jens Oberender
9
 * Copyright (c) 2009-2012, Even Rouault <even dot rouault at spatialys.com>
10
 *
11
 * SPDX-License-Identifier: MIT
12
 ****************************************************************************/
13
#ifndef OGR_KMLNODE_H_INCLUDED
14
#define OGR_KMLNODE_H_INCLUDED
15
16
#ifdef HAVE_EXPAT
17
18
#include "kml.h"
19
#include "kmlutility.h"
20
// std
21
#include <iostream>
22
#include <limits>
23
#include <string>
24
#include <vector>
25
26
std::string Nodetype2String(Nodetype const &type);
27
28
class KMLNode
29
{
30
    CPL_DISALLOW_COPY_ASSIGN(KMLNode)
31
  public:
32
    KMLNode();
33
    ~KMLNode();
34
35
    void print(unsigned int what = 3);
36
    int classify(KML *poKML, int nRecLevel = 0);
37
    void eliminateEmpty(KML *poKML);
38
    bool hasOnlyEmpty() const;
39
40
    void setType(Nodetype type);
41
    Nodetype getType() const;
42
43
    void setName(std::string const &name);
44
    const std::string &getName() const;
45
46
    void setLevel(std::size_t level);
47
    std::size_t getLevel() const;
48
49
    void addAttribute(Attribute *poAttr);
50
51
    void setParent(KMLNode *poNode);
52
    KMLNode *getParent() const;
53
54
    void addChildren(KMLNode *poNode);
55
    std::size_t countChildren() const;
56
57
    KMLNode *getChild(std::size_t index) const;
58
59
    void addContent(std::string const &text);
60
    void appendContent(std::string const &text);
61
    const std::string &getContent(std::size_t index) const;
62
    void deleteContent(std::size_t index);
63
    std::size_t numContent() const;
64
65
    void setLayerNumber(int nNum);
66
    int getLayerNumber() const;
67
68
    std::string getNameElement() const;
69
    std::string getDescriptionElement() const;
70
71
    std::size_t getNumFeatures();
72
    Feature *getFeature(std::size_t nNum, int &nLastAsked, int &nLastCount);
73
74
    OGRGeometry *getGeometry(Nodetype eType = Unknown);
75
76
    bool is25D() const
77
110
    {
78
110
        return b25D_;
79
110
    }
80
81
    typedef std::vector<Attribute *> kml_attributes_t;
82
83
    const kml_attributes_t &getAttributes() const
84
764
    {
85
764
        return voAttributes_;
86
764
    }
87
88
  private:
89
    typedef std::vector<KMLNode *> kml_nodes_t;
90
    kml_nodes_t *pvpoChildren_ = nullptr;
91
92
    typedef std::vector<std::string> kml_content_t;
93
    kml_content_t *pvsContent_ = nullptr;
94
95
    kml_attributes_t voAttributes_{};
96
97
    KMLNode *poParent_ = nullptr;
98
    std::size_t nLevel_ = 0;
99
    std::string sName_{};
100
101
    Nodetype eType_ = Unknown;
102
    bool b25D_ = false;
103
104
    int nLayerNumber_ = -1;
105
    size_t nNumFeatures_ = std::numeric_limits<size_t>::max();
106
107
    void unregisterLayerIfMatchingThisNode(KML *poKML);
108
};
109
110
#endif  // HAVE_EXPAT
111
112
#endif /* OGR_KMLNODE_H_INCLUDED */