LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/cad/libopencad - caddictionary.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 19 33 57.6 %
Date: 2025-06-28 21:28:23 Functions: 6 10 60.0 %

          Line data    Source code
       1             : /*******************************************************************************
       2             :  *  Project: libopencad
       3             :  *  Purpose: OpenSource CAD formats support library
       4             :  *  Author: Alexandr Borzykh, mush3d at gmail.com
       5             :  *  Author: Dmitry Baryshnikov, bishop.dev@gmail.com
       6             :  *  Language: C++
       7             :  *******************************************************************************
       8             :  *  The MIT License (MIT)
       9             :  *
      10             :  *  Copyright (c) 2016 Alexandr Borzykh
      11             :  *  Copyright (c) 2016 NextGIS, <info@nextgis.com>
      12             :  *
      13             :   * SPDX-License-Identifier: MIT
      14             :  *******************************************************************************/
      15             : 
      16             : #include "caddictionary.h"
      17             : 
      18             : using namespace std;
      19             : //
      20             : // CADDictionaryRecord
      21             : //
      22             : 
      23          32 : CADDictionaryRecord::CADDictionaryRecord() :
      24          32 :     objType(CADObject::UNUSED)
      25             : {
      26          32 : }
      27             : 
      28             : CADDictionaryRecord::~CADDictionaryRecord() = default;
      29             : 
      30           0 : CADObject::ObjectType CADDictionaryRecord::getType() const
      31             : {
      32           0 :     return objType;
      33             : }
      34             : 
      35             : //
      36             : // CADXRecord
      37             : //
      38             : 
      39          24 : CADXRecord::CADXRecord()
      40             : {
      41          24 :     objType = CADObject::XRECORD;
      42          24 : }
      43             : 
      44             : CADXRecord::~CADXRecord() = default;
      45             : 
      46           0 : const string CADXRecord::getRecordData() const
      47             : {
      48           0 :     return sRecordData;
      49             : }
      50             : 
      51          24 : void CADXRecord::setRecordData( const string& data )
      52             : {
      53          24 :     sRecordData = data;
      54          24 : }
      55             : 
      56             : //
      57             : // CADDictionary
      58             : //
      59             : 
      60           8 : CADDictionary::CADDictionary()
      61             : {
      62           8 :     objType = CADObject::DICTIONARY;
      63           8 : }
      64             : 
      65             : CADDictionary::~CADDictionary() = default;
      66             : 
      67           0 : size_t CADDictionary::getRecordsCount()
      68             : {
      69           0 :     return astXRecords.size();
      70             : }
      71             : 
      72           0 : CADDictionaryItem CADDictionary::getRecord( size_t index )
      73             : {
      74           0 :     return astXRecords[index];
      75             : }
      76             : 
      77          24 : void CADDictionary::addRecord( CADDictionaryItem record )
      78             : {
      79          24 :     astXRecords.emplace_back( record );
      80          24 : }
      81             : 
      82           8 : string CADDictionary::getRecordByName(const string& name) const
      83             : {
      84          32 :     for( size_t i = 0; i < astXRecords.size(); ++i )
      85             :     {
      86          24 :         if( astXRecords[i].first.compare(name) == 0 )
      87             :         {
      88           0 :             std::shared_ptr<CADDictionaryRecord> XRecordPtr = astXRecords[i].second;
      89           0 :             if(XRecordPtr == nullptr ||
      90           0 :                XRecordPtr->getType() != CADObject::XRECORD)
      91           0 :                 continue;
      92           0 :             CADXRecord * poXRecord = static_cast<CADXRecord*>(XRecordPtr.get() );
      93           0 :             return poXRecord->getRecordData();
      94             :         }
      95             :     }
      96           8 :     return "";
      97             : }

Generated by: LCOV version 1.14