Skip to content

Commit 6974980

Browse files
committed
Merge branch 'feature/eof' into 'develop'
Removing eof checking See merge request njoy/tools!10
2 parents 2562272 + a7687bd commit 6974980

File tree

9 files changed

+7
-28
lines changed

9 files changed

+7
-28
lines changed

src/tools/disco/Character.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Character : public BaseFixedWidthField< Width > {
4848
value.reserve( Width );
4949

5050
unsigned int position = 0;
51-
while( position < Width && ! ( isNewLine( iter ) || isEndOfFile( iter ) ) ) {
51+
while( position < Width && ! isNewLine( iter ) ) {
5252

5353
++position;
5454
value.push_back( *iter++ );

src/tools/disco/Column.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Column : public BaseFixedWidthField< Width > {
4040
static void read( Iterator& iter, const Iterator& end ) {
4141

4242
unsigned int position = 0;
43-
while( position < Width && ! ( isNewLine( iter ) || isEndOfFile( iter ) || iter >= end ) ) {
43+
while( position < Width && ! ( isNewLine( iter ) || iter >= end ) ) {
4444

4545
++position;
4646
++iter;

src/tools/disco/FreeFormatCharacter.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ class FreeFormatCharacter : public BaseField {
3535
iter = std::find_if( iter, end,
3636
[] ( auto&& value )
3737
{ return ! std::isspace( value ); } );
38-
if ( isEndOfFile( iter ) ) {
39-
40-
throw std::runtime_error( "Cannot read valid string: end of file encountered" );
41-
}
4238

4339
auto temp = std::find_if( iter, end,
4440
[] ( auto&& value )

src/tools/disco/FreeFormatInteger.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ class FreeFormatInteger : public BaseField {
4141
iter = std::find_if( iter, end,
4242
[] ( auto&& value )
4343
{ return ! std::isspace( value ); } );
44-
if ( isEndOfFile( iter ) ) {
45-
46-
throw std::runtime_error( "Cannot read valid integer: end of file encountered" );
47-
}
4844

4945
// we are using fast_float::from_chars instead of std::from_chars since
5046
// not all standard c++ libraries implement the floating point version of

src/tools/disco/FreeFormatReal.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ class FreeFormatReal : public BaseField {
4141
iter = std::find_if( iter, end,
4242
[] ( auto&& value )
4343
{ return ! std::isspace( value ); } );
44-
if ( isEndOfFile( iter ) ) {
45-
46-
throw std::runtime_error( "Cannot read valid real value: end of file encountered" );
47-
}
4844

4945
// we are using fast_float::from_chars_advanced instead of std::from_chars
5046
// since not all standard c++ libraries implement the floating point version

src/tools/disco/Integer.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Integer : public BaseFixedWidthField< Width > {
4848
Representation value = 0;
4949

5050
skipSpaces( iter, position );
51-
if ( isNewLine( iter ) || isEndOfFile( iter ) || Width == position || iter >= end ) {
51+
if ( isNewLine( iter ) || Width == position || iter >= end ) {
5252

5353
return value;
5454
}
@@ -77,7 +77,7 @@ class Integer : public BaseFixedWidthField< Width > {
7777
skipSpaces( iter, position );
7878
if ( Width != position ) {
7979

80-
if ( ! isNewLine( iter ) && ! isEndOfFile( iter ) ) {
80+
if ( ! isNewLine( iter ) ) {
8181

8282
throw std::runtime_error( "cannot parse invalid integer number 3" );
8383
}

src/tools/disco/Real.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Real : public BaseFixedWidthField< Width > {
4040
Representation value = 0.0;
4141

4242
skipSpaces( iter, position );
43-
if ( isNewLine( iter ) || isEndOfFile( iter ) || Width == position || iter >= end ) {
43+
if ( isNewLine( iter ) || Width == position || iter >= end ) {
4444

4545
return value;
4646
}
@@ -71,7 +71,7 @@ class Real : public BaseFixedWidthField< Width > {
7171
skipSpaces( iter, position );
7272
if ( Width != position ) {
7373

74-
if ( ! isNewLine( iter ) && ! isEndOfFile( iter ) ) {
74+
if ( ! isNewLine( iter ) ) {
7575

7676
throw std::runtime_error( "cannot parse invalid real number 3" );
7777
}

src/tools/disco/Record.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct Record<> {
2222
template< typename Iterator >
2323
static void read( Iterator& iter, const Iterator& end ) {
2424

25-
while ( iter != end && ! ( isNewLine( iter )|| isEndOfFile( iter ) ) ) {
25+
while ( iter != end && ! ( isNewLine( iter ) ) ) {
2626

2727
++iter;
2828
}

src/tools/disco/functions.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,6 @@ bool isWhiteSpace( const Iterator& iter ) {
6969
return std::isspace( *iter );
7070
}
7171

72-
/**
73-
* @brief Return whether or not a character is the end of file character
74-
*/
75-
template < typename Iterator >
76-
constexpr bool isEndOfFile( const Iterator& iter ) {
77-
78-
return std::char_traits< char >::eof() == *iter;
79-
}
80-
8172
} // disco namespace
8273
} // tools namespace
8374
} // njoy namespace

0 commit comments

Comments
 (0)