LCOV - code coverage report
Current view: top level - frmts/iso8211 - ddfrecordindex.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 3 3 100.0 %
Date: 2026-05-07 23:23:29 Functions: 2 2 100.0 %

          Line data    Source code
       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        2680 : 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      728662 :     int GetCount() const
      60             :     {
      61      728662 :         return static_cast<int>(asRecords.size());
      62             :     }
      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

Generated by: LCOV version 1.14