Coverage Report

Created: 2026-06-30 08:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gdal/frmts/iso8211/ddfrecordindex.h
Line
Count
Source
1
/******************************************************************************
2
 *
3
 * Project:  ISO 8211 Access
4
 * Purpose:  Implements DDFRecordIndex class. This class is used to cache
5
 *           ISO8211 records for spatial objects so they can be efficiently
6
 *           assembled later as features.
7
 * Author:   Frank Warmerdam, warmerdam@pobox.com
8
 *
9
 ******************************************************************************
10
 * Copyright (c) 1999, 2001, Frank Warmerdam
11
 *
12
 * SPDX-License-Identifier: MIT
13
 ****************************************************************************/
14
15
#ifndef DDFRECORDINDEX_H_INCLUDED
16
#define DDFRECORDINDEX_H_INCLUDED
17
18
#include "iso8211.h"
19
20
#include <map>
21
22
/************************************************************************/
23
/*                            DDFRecordIndex                            */
24
/*                                                                      */
25
/*      Maintain an index of DDF records based on an integer key.       */
26
/************************************************************************/
27
28
struct DDFIndexedRecord
29
{
30
    int nKey = 0;
31
    std::unique_ptr<DDFRecord> poRecord{};
32
    const void *pClientData = nullptr;
33
};
34
35
class CPL_DLL DDFRecordIndex
36
{
37
    mutable bool bSorted = false;
38
    mutable std::vector<DDFIndexedRecord> asRecords{};
39
    std::map<int, DDFRecord *> oMapKeyToRecord{};
40
41
    void Sort() const;
42
43
    DDFRecordIndex(const DDFRecordIndex &) = delete;
44
    DDFRecordIndex &operator=(const DDFRecordIndex &) = delete;
45
    DDFRecordIndex(DDFRecordIndex &&) = delete;
46
    DDFRecordIndex &operator=(DDFRecordIndex &&) = delete;
47
48
  public:
49
    DDFRecordIndex();
50
    ~DDFRecordIndex();
51
52
    void AddRecord(int nKey, std::unique_ptr<DDFRecord> poRecord);
53
    bool RemoveRecord(int nKey);
54
55
    DDFRecord *FindRecord(int nKey) const;
56
57
    void Clear();
58
59
    int GetCount() const
60
76.5k
    {
61
76.5k
        return static_cast<int>(asRecords.size());
62
76.5k
    }
63
64
    const DDFRecord *GetByIndex(int i) const;
65
    const void *GetClientInfoByIndex(int i) const;
66
    void SetClientInfoByIndex(int i, const void *pClientInfo);
67
};
68
69
#endif