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: 21 35 60.0 %
Date: 2024-05-03 15:49:35 Functions: 7 12 58.3 %

          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             :  *  Permission is hereby granted, free of charge, to any person obtaining a copy
      14             :  *  of this software and associated documentation files (the "Software"), to deal
      15             :  *  in the Software without restriction, including without limitation the rights
      16             :  *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      17             :  *  copies of the Software, and to permit persons to whom the Software is
      18             :  *  furnished to do so, subject to the following conditions:
      19             :  *
      20             :  *  The above copyright notice and this permission notice shall be included in all
      21             :  *  copies or substantial portions of the Software.
      22             :  *
      23             :  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      24             :  *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      25             :  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      26             :  *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      27             :  *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      28             :  *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
      29             :  *  SOFTWARE.
      30             :  *******************************************************************************/
      31             : 
      32             : #include "caddictionary.h"
      33             : 
      34             : using namespace std;
      35             : //
      36             : // CADDictionaryRecord
      37             : //
      38             : 
      39          32 : CADDictionaryRecord::CADDictionaryRecord() :
      40          32 :     objType(CADObject::UNUSED)
      41             : {
      42          32 : }
      43             : 
      44           0 : CADObject::ObjectType CADDictionaryRecord::getType() const
      45             : {
      46           0 :     return objType;
      47             : }
      48             : 
      49             : //
      50             : // CADXRecord
      51             : //
      52             : 
      53          24 : CADXRecord::CADXRecord()
      54             : {
      55          24 :     objType = CADObject::XRECORD;
      56          24 : }
      57             : 
      58           0 : const string CADXRecord::getRecordData() const
      59             : {
      60           0 :     return sRecordData;
      61             : }
      62             : 
      63          24 : void CADXRecord::setRecordData( const string& data )
      64             : {
      65          24 :     sRecordData = data;
      66          24 : }
      67             : 
      68             : //
      69             : // CADDictionary
      70             : //
      71             : 
      72           8 : CADDictionary::CADDictionary()
      73             : {
      74           8 :     objType = CADObject::DICTIONARY;
      75           8 : }
      76             : 
      77           8 : CADDictionary::~CADDictionary()
      78             : {
      79           8 : }
      80             : 
      81           0 : size_t CADDictionary::getRecordsCount()
      82             : {
      83           0 :     return astXRecords.size();
      84             : }
      85             : 
      86           0 : CADDictionaryItem CADDictionary::getRecord( size_t index )
      87             : {
      88           0 :     return astXRecords[index];
      89             : }
      90             : 
      91          24 : void CADDictionary::addRecord( CADDictionaryItem record )
      92             : {
      93          24 :     astXRecords.emplace_back( record );
      94          24 : }
      95             : 
      96           8 : string CADDictionary::getRecordByName(const string& name) const
      97             : {
      98          32 :     for( size_t i = 0; i < astXRecords.size(); ++i )
      99             :     {
     100          24 :         if( astXRecords[i].first.compare(name) == 0 )
     101             :         {
     102           0 :             std::shared_ptr<CADDictionaryRecord> XRecordPtr = astXRecords[i].second;
     103           0 :             if(XRecordPtr == nullptr ||
     104           0 :                XRecordPtr->getType() != CADObject::XRECORD)
     105           0 :                 continue;
     106           0 :             CADXRecord * poXRecord = static_cast<CADXRecord*>(XRecordPtr.get() );
     107           0 :             return poXRecord->getRecordData();
     108             :         }
     109             :     }
     110           8 :     return "";
     111             : }

Generated by: LCOV version 1.14