-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathSTEPattributeList.cc
More file actions
71 lines (58 loc) · 1.74 KB
/
STEPattributeList.cc
File metadata and controls
71 lines (58 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* NIST STEP Core Class Library
* clstepcore/STEPattributeList.cc
* April 1997
* K. C. Morris
* David Sauder
* Development of this software was funded by the United States Government,
* and is not subject to copyright.
*/
#include "clstepcore/STEPattributeList.h"
#include "clstepcore/STEPattribute.h"
AttrListNode::AttrListNode( STEPattribute * a ) {
attr = a;
}
AttrListNode::~AttrListNode() {
}
STEPattributeList::STEPattributeList() {
}
STEPattributeList::~STEPattributeList() {
}
STEPattribute & STEPattributeList::operator []( int n ) {
int x = 0;
AttrListNode * a = ( AttrListNode * )head;
int cnt = EntryCount();
if( n < cnt ) {
while( a && ( x < n ) ) {
a = ( AttrListNode * )( a->next );
x++;
}
}
if( a ) {
return *( a->attr );
}
// else - error case: return a static error object to avoid undefined behavior
// The error object allows calling code to detect the error condition
static STEPattribute errorAttr;
cerr << "\nERROR in STEP Core library: " << __FILE__ << ":"
<< __LINE__ << "\n" << _POC_ << "\n\n";
errorAttr.Error().AppendToDetailMsg( "STEPattributeList::operator[] - index out of bounds" );
errorAttr.Error().severity( SEVERITY_BUG );
return errorAttr;
}
int STEPattributeList::list_length() {
return EntryCount();
}
void STEPattributeList::push( STEPattribute * a ) {
AttrListNode * a2 = ( AttrListNode * )head;
// if the attribute already exists in the list, don't push it
while( a2 ) {
if( *a == *( a2 -> attr ) ) {
return;
}
a2 = ( AttrListNode * )( a2->next );
}
a->incrRefCount();
AttrListNode * saln = new AttrListNode( a );
AppendNode( saln );
}