Skip to content

Commit f1e20af

Browse files
committed
Continuing development. Framework is incomplete.
IN 2017/06/14
1 parent 01d972e commit f1e20af

2 files changed

Lines changed: 51 additions & 16 deletions

File tree

‎intecplot.cpp‎

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ inTec_Zone::inTec_Zone( inTec_File* file_ )
4444
#ifdef _DEBUG_
4545
printf(" i Zone object instantiated\n");
4646
#endif
47+
istate = 0;
4748
ipos = 0;
4849
ipos_data = 0;
4950
InitKeywords();
@@ -98,9 +99,6 @@ void inTec_Zone::InitKeywords()
9899
// keywords["PASSIVEVARLIST"] = "";
99100
// keywords["AUXDATA"] = "";
100101
// keywords[""] = "";
101-
102-
103-
104102
}
105103

106104

@@ -139,6 +137,15 @@ int inTec_Zone::SetDataPositionInFile( long ipos_data_ )
139137
}
140138
}
141139

140+
int inTec_Zone::SetState_Reading( void )
141+
{
142+
if( istate == 0 ) {
143+
istate = 1;
144+
return(0);
145+
}
146+
147+
return(1);
148+
}
142149

143150
int inTec_Zone::ParseKeywords( char *buf )
144151
{
@@ -485,6 +492,20 @@ int inTec_Zone::CheckCharForNum( char c ) const
485492
}
486493
}
487494

495+
int inTec_Zone::ParseData( char *buf )
496+
{
497+
#ifdef _DEBUG_
498+
printf(" i Parsing zone data \n");
499+
#endif
500+
#ifdef _DEBUG_
501+
printf(" STRING: --->|%s|<---\n", buf );
502+
#endif
503+
504+
505+
506+
return(0);
507+
}
508+
488509

489510
//
490511
// the file object methods
@@ -908,7 +929,7 @@ int inTec_File::ParseComponent_Zone()
908929
size_t ibuf_size=0;
909930

910931
int idone_zone = 0; // flag for present zone component termination
911-
int igot_descr = 0; // flag for whether we have a description of the zone
932+
int igot_head = 0; // flag for whether we have a description of the zone
912933
while( !feof( fp ) && idone_zone <= 1 ) {
913934
int ic;
914935

@@ -924,6 +945,8 @@ int inTec_File::ParseComponent_Zone()
924945
ic = inUtils_ReadTextline( &ibuf_size, &buf, fp );
925946
// check error code
926947

948+
++iline;
949+
927950
// sanitize the line
928951
inUtils_TrimLeadingSpaceTextline( buf );
929952
size_t isize=0;
@@ -939,20 +962,19 @@ int inTec_File::ParseComponent_Zone()
939962
printf("FOUND iret=%d idone_zone=%d \n", iret,idone_zone);//HACK
940963
// check if we have jumped to a new component under certain conditions...
941964
if( iret > 0 ) { // we found a component
965+
942966
// only allow "stray" comment components to pass through
943967
if( iret == Comment ) {
944968
#ifdef _DEBUG_
945969
printf(" --- Found comment (inside Zone component) \n");
946970
#endif
947-
++iline;
948-
949971
// we will not be parsing this line
950972
iparse_line = 0;
951973
// store comment in strings
952974
buf[ strlen(buf) ] = '\n';
953975
strings[ iline ] = buf;
954976
#ifdef _DEBUG_
955-
printf(" i Added to strings line %ld \n", iline );
977+
printf(" i Added comment to strings line %ld \n", iline );
956978
#endif
957979
// show the line
958980
printf(" [%ld] %s", iline, buf );
@@ -978,21 +1000,25 @@ printf("FOUND iret=%d idone_zone=%d \n", iret,idone_zone);//HACK
9781000

9791001
// parse the line only if we are still parsing the current zone field
9801002
if( iparse_line == 1 ) {
981-
++iline;
982-
983-
///// we need to keep parsing pieces as they cone
984-
if( igot_descr == 0 ) {
1003+
if( igot_head == 0 ) {
9851004
#ifdef _DEBUG_
9861005
printf(" --- Looking for Zone keywords \n");
9871006
#endif
9881007
int np = zone->ParseKeywords( buf );
1008+
if( np >= 0 ) {
9891009
#ifdef _DEBUG_
990-
if( np >= 0 ) printf(" --- Parsed %d item(s) \n",np);
1010+
printf(" --- Parsed %d item(s) \n",np);
1011+
#endif
1012+
buf[ strlen(buf) ] = '\n';
1013+
strings[ iline ] = buf;
1014+
#ifdef _DEBUG2_
1015+
printf(" i Added to strings line %ld \n", iline );
9911016
#endif
1017+
}
9921018
if( np == -100 ) { // special return value!
9931019
// we have parsed through possibly multiple "zone" lines...
9941020
// ...and encountered data
995-
igot_descr = 1;
1021+
igot_head = 1;
9961022

9971023
// rewind this line
9981024
iret = fseek( fp, ipos, SEEK_SET );
@@ -1007,22 +1033,28 @@ printf("FOUND iret=%d idone_zone=%d \n", iret,idone_zone);//HACK
10071033
// set the data position for this zone
10081034
zone->SetDataPositionInFile( ipos );
10091035
// (here we must put the zone in data-reading particular state)
1036+
if( zone->SetState_Reading() != 0 ) {
1037+
// respond to the possibility of the zone being mis-used...
1038+
1039+
}
10101040

10111041
} else if( np < 0 ) {
10121042
// an error in parsing keywords was trapped
10131043
// (This section will have to be changed based on how we want to
10141044
// handle bad keywords, etc.)
10151045
}
1016-
} else {
1046+
} else { // we have parsed the header completely; now parsing data
10171047
#ifdef _DEBUG_
10181048
printf(" --- Collecting Zone data \n");
10191049
#endif
10201050
// push the buffer to the zone for data extraction
10211051
// (we must have set the zone to a data-reading state earlier)
1052+
zone->ParseData( buf );
1053+
// possibly respond to errors returned by the zone...
10221054

10231055
}
10241056

1025-
}
1057+
} // (end of iparse_line=1)
10261058
}
10271059

10281060
// drop the buffer
@@ -1034,7 +1066,7 @@ printf("FOUND iret=%d idone_zone=%d \n", iret,idone_zone);//HACK
10341066
printf("HACK dropping the zone object\n");
10351067
#endif
10361068
delete zone; //HACK
1037-
printf("EXITING....\n");exit(0);//HACK
1069+
//printf("EXITING....\n");exit(0);//HACK
10381070

10391071
#ifdef _DEBUG_
10401072
printf(" i *** Skipping parsing of ZONE component *** \n");

‎intecplot.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@ class inTec_Zone {
3232
int SetDataPositionInFile( long ipos_data_ );
3333
int ParseKeywords( char *buf );
3434
int HandleKeyword( char *buf );
35+
int SetState_Reading( void );
36+
int ParseData( char *buf );
3537

3638
protected:
3739
void InitKeywords();
40+
int istate;
3841

3942
private:
4043
inTec_File *file;

0 commit comments

Comments
 (0)