forked from stepcode/stepcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathattribute.cc
More file actions
59 lines (55 loc) · 1.66 KB
/
attribute.cc
File metadata and controls
59 lines (55 loc) · 1.66 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
/** \file attribute.cc
* 1-Jul-2012
* Test attribute access; uses a tiny schema similar to a subset of IFC2x3
*/
#include <sc_cf.h>
#include <STEPfile.h>
#include <sdai.h>
#include <STEPattribute.h>
#include <ExpDict.h>
#include <Registry.h>
#include <errordesc.h>
#include <algorithm>
#include <string>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <sc_getopt.h>
#include "schema.h"
int main( int argc, char * argv[] ) {
Registry registry( SchemaInit );
InstMgr instance_list;
STEPfile sfile( registry, instance_list, "", false );
bool foundMatch = false;
const char * attrname = "description";
if( argc != 2 ) {
exit( EXIT_FAILURE );
}
sfile.ReadExchangeFile( argv[1] );
if( sfile.Error().severity() <= SEVERITY_INCOMPLETE ) {
sfile.Error().PrintContents( cout );
exit( EXIT_FAILURE );
}
const SdaiWindow * wind = dynamic_cast< SdaiWindow * >( instance_list.GetApplication_instance( "window" ) );
int i = 0;
if( wind ) {
STEPattributeList attrlist = wind->attributes;
for( ; i < attrlist.list_length(); i++ ) {
cout << "attr " << i << ": " << attrlist[i].Name() << endl;
if( 0 == strcmp( attrname, attrlist[i].Name() ) ) {
foundMatch = true;
cout << "attribute " << '"' << attrname << '"' << " found at " << i << endl;
}
}
}
if( !i ) {
cout << "no attrs found" << endl;
exit( EXIT_FAILURE );
}
if( !foundMatch ) {
cout << "attribute " << '"' << attrname << '"' << " not found" << endl;
exit( EXIT_FAILURE );
} else {
exit( EXIT_SUCCESS );
}
}