-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathp21HeaderSectionReader.cc
More file actions
66 lines (56 loc) · 2.13 KB
/
p21HeaderSectionReader.cc
File metadata and controls
66 lines (56 loc) · 2.13 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
#include <assert.h>
#include <string.h>
#include "cllazyfile/p21HeaderSectionReader.h"
#include "cllazyfile/headerSectionReader.h"
#include "cllazyfile/sectionReader.h"
#include "cllazyfile/lazyInstMgr.h"
#include "cllazyfile/judyL2Array.h"
void p21HeaderSectionReader::findSectionStart() {
_sectionStart = findNormalString( "HEADER", true );
assert( _file.is_open() && _file.good() );
}
p21HeaderSectionReader::p21HeaderSectionReader( lazyFileReader * parent, std::ifstream & file,
std::streampos start, sectionID sid ):
headerSectionReader( parent, file, start, sid ) {
findSectionStart();
findSectionEnd();
_file.seekg( _sectionStart );
namedLazyInstance nl;
while( nl = nextInstance(), ( nl.loc.begin > 0 ) ) {
std::streampos pos = _file.tellg();
_headerInstances->insert( nl.loc.instance, getRealInstance( _lazyFile->getInstMgr()->getHeaderRegistry(), nl.loc.begin, nl.loc.instance, nl.name, "", true ) );
_file.seekg( pos ); //reset stream position for next call to nextInstance()
}
_file.seekg( _sectionEnd );
}
// part of readdata1
const namedLazyInstance p21HeaderSectionReader::nextInstance() {
namedLazyInstance i;
static instanceID nextFreeInstance = 4; // 1-3 are reserved per 10303-21
i.refs = 0;
i.loc.begin = _file.tellg();
i.loc.section = _sectionID;
skipWS();
if( i.loc.begin <= 0 ) {
i.name = 0;
} else {
i.name = getDelimitedKeyword( ";( /\\" );
if( 0 == strcmp( "FILE_DESCRIPTION", i.name ) ) {
i.loc.instance = 1;
} else if( 0 == strcmp( "FILE_NAME", i.name ) ) {
i.loc.instance = 2;
} else if( 0 == strcmp( "FILE_SCHEMA", i.name ) ) {
i.loc.instance = 3;
} else {
i.loc.instance = nextFreeInstance++;
}
assert( strlen( i.name ) > 0 );
std::streampos end = seekInstanceEnd( 0 ); //no references in file header
if( ( (signed long int)end == -1 ) || ( end >= _sectionEnd ) ) {
//invalid instance, so clear everything
i.loc.begin = -1;
i.name = 0;
}
}
return i;
}