Skip to content

Commit 48f3456

Browse files
committed
now reads files successfully; still doesn't create SDAI instances
1 parent 5004c6d commit 48f3456

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

src/cllazyfile/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ include_directories(
1010
${SCL_SOURCE_DIR}/src/cldai
1111
${SCL_SOURCE_DIR}/src/clstepcore
1212
${SCL_SOURCE_DIR}/src/clutils
13+
${SCL_SOURCE_DIR}/src/base
1314
)
1415

1516

src/cllazyfile/lazyP21DataSectionReader.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ const namedLazyInstance lazyP21DataSectionReader::nextInstance() {
2424
// std::cerr << "inst id start: " << _file.tellg() << std::endl;
2525
// _file >> i.loc.instance;
2626
// std::cerr << "inst start: " << _file.tellg() << std::endl;
27-
assert( _file.good() );
27+
if( !_file.good() ) {
28+
i.loc.end = i.loc.begin;
29+
return i;
30+
}
2831
_file >> std::ws;
2932
char c = _file.get();
3033
if( c != '=' ) {

src/cllazyfile/main.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#include "lazyInstMgr.h"
2-
// g++ main.cc -I. -o main
2+
#include <sc_benchmark.h>
33

44
int main (int argc, char ** argv ) {
5+
benchmark stats( "p21 lazy load test" );
6+
57
std::string n;
68
if( argc == 2 ) {
79
n = argv[1];
@@ -10,4 +12,11 @@ int main (int argc, char ** argv ) {
1012
}
1113
lazyInstMgr mgr;
1214
mgr.openFile( n );
15+
instanceTypeMMap_range r,s;
16+
r = mgr.getInstances("POSITIVE_LENGTH_MEASURE");
17+
s = mgr.getInstances("VERTEX_POINT");
18+
//count those
19+
20+
stats.stop();
21+
stats.out();
1322
}

src/cllazyfile/sectionReader.cc

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ std::streampos sectionReader::findString( const std::string& str, bool semicolon
5050
if( resetPos ) {
5151
_file.seekg(current);
5252
}
53-
assert( _file.is_open() && _file.good() );
54-
return found;
53+
if( _file.is_open() && _file.good() ) {
54+
return found;
55+
} else {
56+
return -1;
57+
}
5558
}
5659

5760
//NOTE different behavior than const char * GetKeyword( istream & in, const char * delims, ErrorDescriptor & err ) in read_func.cc
@@ -93,24 +96,28 @@ instanceID sectionReader::readInstanceNumber() {
9396
std::streampos hash,eq;
9497
char c;
9598
instanceID id = -1;
99+
// std::string s;
96100

97101
hash = findString( "#" );
98102
eq = findString( "=" );
99-
std::cerr << "id from " << hash << " to " << eq << std::endl;
103+
// std::cerr << "id from " << hash << " to " << eq << std::endl;
100104
_file.seekg( hash );
101105
do {
102106
//check chars in between
103107
_file.get( c );
108+
// s.append(1,c);
109+
// std::cout << c;
104110
if( !isdigit( c ) && ( c != ' ' ) && ( c != '\t' ) && ( c != '\n' ) ) {
105111
hash = findString( "#" );
106112
if( hash > eq ) {
107113
eq = findString( "=" );
108114
_file.seekg( hash );
109115
}
110-
std::cerr << "id from " << hash << " to " << eq << std::endl;
116+
// std::cerr << "id from " << hash << " to " << eq << std::endl;
111117
_file >> ws;
118+
// s.clear();
112119
}
113-
} while( _file.tellg() < eq && _file.good() );
120+
} while( _file.tellg() < ( eq - 1L ) && _file.good() );
114121
if( _file.good() ) {
115122
_file.seekg( hash );
116123
_file >> id;

0 commit comments

Comments
 (0)