Skip to content

Commit

Permalink
Merge branch 'feature/eof' into 'develop'
Browse files Browse the repository at this point in the history
Removing eof checking

See merge request njoy/tools!10
  • Loading branch information
whaeck committed Jan 30, 2025
2 parents 2562272 + a7687bd commit 6974980
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/tools/disco/Character.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Character : public BaseFixedWidthField< Width > {
value.reserve( Width );

unsigned int position = 0;
while( position < Width && ! ( isNewLine( iter ) || isEndOfFile( iter ) ) ) {
while( position < Width && ! isNewLine( iter ) ) {

++position;
value.push_back( *iter++ );
Expand Down
2 changes: 1 addition & 1 deletion src/tools/disco/Column.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Column : public BaseFixedWidthField< Width > {
static void read( Iterator& iter, const Iterator& end ) {

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

++position;
++iter;
Expand Down
4 changes: 0 additions & 4 deletions src/tools/disco/FreeFormatCharacter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ class FreeFormatCharacter : public BaseField {
iter = std::find_if( iter, end,
[] ( auto&& value )
{ return ! std::isspace( value ); } );
if ( isEndOfFile( iter ) ) {

throw std::runtime_error( "Cannot read valid string: end of file encountered" );
}

auto temp = std::find_if( iter, end,
[] ( auto&& value )
Expand Down
4 changes: 0 additions & 4 deletions src/tools/disco/FreeFormatInteger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ class FreeFormatInteger : public BaseField {
iter = std::find_if( iter, end,
[] ( auto&& value )
{ return ! std::isspace( value ); } );
if ( isEndOfFile( iter ) ) {

throw std::runtime_error( "Cannot read valid integer: end of file encountered" );
}

// we are using fast_float::from_chars instead of std::from_chars since
// not all standard c++ libraries implement the floating point version of
Expand Down
4 changes: 0 additions & 4 deletions src/tools/disco/FreeFormatReal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ class FreeFormatReal : public BaseField {
iter = std::find_if( iter, end,
[] ( auto&& value )
{ return ! std::isspace( value ); } );
if ( isEndOfFile( iter ) ) {

throw std::runtime_error( "Cannot read valid real value: end of file encountered" );
}

// we are using fast_float::from_chars_advanced instead of std::from_chars
// since not all standard c++ libraries implement the floating point version
Expand Down
4 changes: 2 additions & 2 deletions src/tools/disco/Integer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Integer : public BaseFixedWidthField< Width > {
Representation value = 0;

skipSpaces( iter, position );
if ( isNewLine( iter ) || isEndOfFile( iter ) || Width == position || iter >= end ) {
if ( isNewLine( iter ) || Width == position || iter >= end ) {

return value;
}
Expand Down Expand Up @@ -77,7 +77,7 @@ class Integer : public BaseFixedWidthField< Width > {
skipSpaces( iter, position );
if ( Width != position ) {

if ( ! isNewLine( iter ) && ! isEndOfFile( iter ) ) {
if ( ! isNewLine( iter ) ) {

throw std::runtime_error( "cannot parse invalid integer number 3" );
}
Expand Down
4 changes: 2 additions & 2 deletions src/tools/disco/Real.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Real : public BaseFixedWidthField< Width > {
Representation value = 0.0;

skipSpaces( iter, position );
if ( isNewLine( iter ) || isEndOfFile( iter ) || Width == position || iter >= end ) {
if ( isNewLine( iter ) || Width == position || iter >= end ) {

return value;
}
Expand Down Expand Up @@ -71,7 +71,7 @@ class Real : public BaseFixedWidthField< Width > {
skipSpaces( iter, position );
if ( Width != position ) {

if ( ! isNewLine( iter ) && ! isEndOfFile( iter ) ) {
if ( ! isNewLine( iter ) ) {

throw std::runtime_error( "cannot parse invalid real number 3" );
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/disco/Record.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct Record<> {
template< typename Iterator >
static void read( Iterator& iter, const Iterator& end ) {

while ( iter != end && ! ( isNewLine( iter )|| isEndOfFile( iter ) ) ) {
while ( iter != end && ! ( isNewLine( iter ) ) ) {

++iter;
}
Expand Down
9 changes: 0 additions & 9 deletions src/tools/disco/functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,6 @@ bool isWhiteSpace( const Iterator& iter ) {
return std::isspace( *iter );
}

/**
* @brief Return whether or not a character is the end of file character
*/
template < typename Iterator >
constexpr bool isEndOfFile( const Iterator& iter ) {

return std::char_traits< char >::eof() == *iter;
}

} // disco namespace
} // tools namespace
} // njoy namespace
Expand Down

0 comments on commit 6974980

Please sign in to comment.