Coverage Report

Created: 2026-08-14 09:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gdal/ogr/ogrsf_frmts/cad/libopencad/caddictionary.cpp
Line
Count
Source
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
CADDictionaryRecord::CADDictionaryRecord() :
24
0
    objType(CADObject::UNUSED)
25
0
{
26
0
}
27
28
0
CADDictionaryRecord::~CADDictionaryRecord() = default;
29
30
CADObject::ObjectType CADDictionaryRecord::getType() const
31
0
{
32
0
    return objType;
33
0
}
34
35
//
36
// CADXRecord
37
//
38
39
CADXRecord::CADXRecord()
40
0
{
41
0
    objType = CADObject::XRECORD;
42
0
}
43
44
0
CADXRecord::~CADXRecord() = default;
45
46
const string CADXRecord::getRecordData() const
47
0
{
48
0
    return sRecordData;
49
0
}
50
51
void CADXRecord::setRecordData( const string& data )
52
0
{
53
0
    sRecordData = data;
54
0
}
55
56
//
57
// CADDictionary
58
//
59
60
CADDictionary::CADDictionary()
61
0
{
62
0
    objType = CADObject::DICTIONARY;
63
0
}
64
65
0
CADDictionary::~CADDictionary() = default;
66
67
size_t CADDictionary::getRecordsCount()
68
0
{
69
0
    return astXRecords.size();
70
0
}
71
72
CADDictionaryItem CADDictionary::getRecord( size_t index )
73
0
{
74
0
    return astXRecords[index];
75
0
}
76
77
void CADDictionary::addRecord( CADDictionaryItem record )
78
0
{
79
0
    astXRecords.emplace_back( record );
80
0
}
81
82
string CADDictionary::getRecordByName(const string& name) const
83
0
{
84
0
    for( size_t i = 0; i < astXRecords.size(); ++i )
85
0
    {
86
0
        if( astXRecords[i].first.compare(name) == 0 )
87
0
        {
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
0
        }
95
0
    }
96
0
    return "";
97
0
}