-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathlazyP21DataSectionReader.cc
More file actions
74 lines (68 loc) · 2.32 KB
/
lazyP21DataSectionReader.cc
File metadata and controls
74 lines (68 loc) · 2.32 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
72
73
#include <assert.h>
#include <set>
#include "cllazyfile/lazyP21DataSectionReader.h"
#include "cllazyfile/lazyInstMgr.h"
lazyP21DataSectionReader::lazyP21DataSectionReader( lazyFileReader * parent, std::ifstream & file,
std::streampos start, sectionID sid ):
lazyDataSectionReader( parent, file, start, sid ) {
findSectionStart();
namedLazyInstance nl;
while( nl = nextInstance(), ( ( nl.loc.begin > 0 ) && ( nl.name != 0 ) ) ) {
parent->getInstMgr()->addLazyInstance( nl );
}
if( sectionReader::_error->severity() <= SEVERITY_WARNING ) {
sectionReader::_error->PrintContents( std::cerr );
if( sectionReader::_error->severity() <= SEVERITY_INPUT_ERROR ) {
_error = true;
return;
}
}
if( !_file.good() ) {
_error = true;
return;
}
if( nl.loc.instance == 0 ) {
//check for ENDSEC;
skipWS();
std::streampos pos = _file.tellg();
if( _file.get() == 'E' && _file.get() == 'N' && _file.get() == 'D'
&& _file.get() == 'S' && _file.get() == 'E' && _file.get() == 'C'
&& ( skipWS(), _file.get() == ';' ) ) {
_sectionEnd = _file.tellg();
} else {
_file.seekg( pos );
char found[26] = { '\0' };
_file.read( found, 25 );
std::cerr << "expected 'ENDSEC;', found " << found << std::endl;
_error = true;
}
}
}
// part of readdata1
//if this changes, probably need to change sectionReader::getType()
const namedLazyInstance lazyP21DataSectionReader::nextInstance() {
std::streampos end = -1;
namedLazyInstance i;
i.refs = 0;
i.loc.section = 0;
i.loc.begin = _file.tellg();
i.loc.instance = readInstanceNumber();
if( ( _file.good() ) && ( i.loc.instance > 0 ) ) {
skipWS();
i.loc.section = _sectionID;
i.name = getDelimitedKeyword( ";( /\\" );
if( _file.good() ) {
end = seekInstanceEnd( & i.refs );
}
}
if( ( i.loc.instance == 0 ) || ( !_file.good() ) || ( end == ( std::streampos ) - 1 ) ) {
//invalid instance, so clear everything
_file.seekg( i.loc.begin );
i.loc.begin = -1;
if( i.refs ) {
delete i.refs;
}
i.name = 0;
}
return i;
}