diff --git a/CMakeLists.txt b/CMakeLists.txt index 171f25f5a..a7b6090c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,7 +78,6 @@ target_link_libraries( ENDFtk INTERFACE Log disco - header-utilities range-v3 ) diff --git a/cmake/develop_dependencies.cmake b/cmake/develop_dependencies.cmake index 557e95894..273ec4027 100644 --- a/cmake/develop_dependencies.cmake +++ b/cmake/develop_dependencies.cmake @@ -23,12 +23,6 @@ FetchContent_Declare( disco GIT_SHALLOW TRUE ) -FetchContent_Declare( header-utilities - GIT_REPOSITORY https://github.com/njoy/header-utilities - GIT_TAG origin/master - GIT_SHALLOW TRUE - ) - FetchContent_Declare( range-v3 GIT_REPOSITORY https://github.com/ericniebler/range-v3 GIT_TAG 0.11.0 @@ -46,6 +40,5 @@ FetchContent_Declare( pybind11 FetchContent_MakeAvailable( Log disco - header-utilities range-v3 ) diff --git a/cmake/release_dependencies.cmake b/cmake/release_dependencies.cmake index 49266b6d3..b06bcb460 100644 --- a/cmake/release_dependencies.cmake +++ b/cmake/release_dependencies.cmake @@ -15,11 +15,6 @@ FetchContent_Declare( disco GIT_TAG 2606933a854bb0269c4ec37143e1236797e27838 ) -FetchContent_Declare( header-utilities - GIT_REPOSITORY https://github.com/njoy/header-utilities - GIT_TAG cc2610fee15e255c151e8e22aca1e8b3d1a96b39 - ) - FetchContent_Declare( Log GIT_REPOSITORY https://github.com/njoy/Log GIT_TAG 52962b7796afe37ef1d8f7edb4bf9ecb1b868d15 @@ -47,7 +42,6 @@ set( SPDLOG_BUILD_TESTING CACHE BOOL OFF ) FetchContent_MakeAvailable( disco - header-utilities Log range-v3 spdlog diff --git a/src/ENDFtk/InterpolationRecord/test/InterpolationRecord.test.cpp b/src/ENDFtk/InterpolationRecord/test/InterpolationRecord.test.cpp index 636227c49..1c4278df4 100644 --- a/src/ENDFtk/InterpolationRecord/test/InterpolationRecord.test.cpp +++ b/src/ENDFtk/InterpolationRecord/test/InterpolationRecord.test.cpp @@ -5,20 +5,13 @@ // other includes #include "range/v3/range/operations.hpp" -#include "header-utilities/copy.hpp" // convenience typedefs using namespace njoy::ENDFtk; -std::function< InterpolationRecord() > makeTAB2 = [](){ - auto metadata = std::make_tuple( 1.0, 2.0, 3ul, 4ul ); - auto regionPairs = std::make_tuple( std::vector< long >{ 4, 5, 6 }, - std::vector< long >{ 1, 2, 3 } ); +std::function< InterpolationRecord() > makeTAB2 = [] () { - return InterpolationRecord - ( std::get< 0 >( metadata ), std::get< 1 >( metadata ), - std::get< 2 >( metadata ), std::get< 3 >( metadata ), - njoy::utility::copy( regionPairs ) ); + return InterpolationRecord( 1., 2., 3, 4, { 4, 5, 6 }, { 1, 2, 3 } ); }; #include "ENDFtk/InterpolationRecord/test/ctor.test.hpp" diff --git a/src/ENDFtk/ListRecord/test/ListRecord.test.cpp b/src/ENDFtk/ListRecord/test/ListRecord.test.cpp index 9cd5a5fa5..1dc989839 100644 --- a/src/ENDFtk/ListRecord/test/ListRecord.test.cpp +++ b/src/ENDFtk/ListRecord/test/ListRecord.test.cpp @@ -4,12 +4,12 @@ #include "ENDFtk/ListRecord.hpp" // other includes -#include "header-utilities/copy.hpp" // convenience typedefs using namespace njoy::ENDFtk; -SCENARIO( "ListRecord Tests", "[ENDFtk], [ListRecord]" ){ +SCENARIO( "ListRecord Tests", "[ENDFtk], [ListRecord]" ) { + auto values = std::make_tuple( 1.001000E+3, 9.991673E-1, 0, 0, 10, 5 ); std::vector< double > list{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0}; @@ -20,9 +20,8 @@ SCENARIO( "ListRecord Tests", "[ENDFtk], [ListRecord]" ){ GIVEN( "value construction, the ctor works"){ REQUIRE_NOTHROW( - ListRecord( std::get< 0 >(values), std::get< 1 >(values), - std::get< 2 >(values), std::get< 3 >(values), - std::get< 5 >(values), njoy::utility::copy(list) ) ); + ListRecord( 1.001000E+3, 9.991673E-1, 0, 0, 5, + {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0} ) ); } GIVEN( "iterators and a line number"){ @@ -105,9 +104,8 @@ SCENARIO( "ListRecord Tests", "[ENDFtk], [ListRecord]" ){ auto listRecord0 = ListRecord( it, end, lineNumber, 125, 1, 451 ); const auto& constListRecord0 = listRecord0; auto listRecord1 = - ListRecord( std::get< 0 >(values), std::get< 1 >(values), - std::get< 2 >(values), std::get< 3 >(values), - std::get< 5 >(values), njoy::utility::copy(list) ); + ListRecord( 1.001000E+3, 9.991673E-1, 0, 0, 5, + {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0} ); const auto& constListRecord1 = listRecord1; THEN( "the getter will work" ){ diff --git a/src/ENDFtk/StructureDivision.hpp b/src/ENDFtk/StructureDivision.hpp index 454d2a766..6cf5da0fb 100644 --- a/src/ENDFtk/StructureDivision.hpp +++ b/src/ENDFtk/StructureDivision.hpp @@ -5,14 +5,15 @@ // other includes #include "Log.hpp" -#include "header-utilities/echoErroneousLine.hpp" #include "ENDFtk/record.hpp" namespace njoy { namespace ENDFtk { class StructureDivision { + public: + /* convenience typedefs */ using Base = record::Base< record::Real, record::Real, @@ -32,96 +33,119 @@ namespace ENDFtk { template< typename Iterator > StructureDivision( Iterator& it, const Iterator& end, long& lineNumber ) : - StructureDivision( it, it, end, lineNumber ){} + StructureDivision( it, it, end, lineNumber ) {} template< typename Iterator > StructureDivision ( Iterator begin, Iterator& it, const Iterator& end, long& lineNumber ) - try: base( it, end ), tail( it, end, lineNumber ) { - auto fieldPosition = std::next( begin, 66 ); - if (tail.material() < -1){ + try : base( it, end ), tail( it, end, lineNumber ) { + + if (tail.material() < -1) { + Log::error( "Illegal material number (MAT) encountered" ); - utility::echoErroneousLine( begin, fieldPosition, end, lineNumber - 1 ); + Log::info( "Error parsing line {}: \"{}\"", + lineNumber - 1, + std::string( begin, std::find( begin, end, '\n' ) ) ); Log::info( "Material numbers are greater than or equal to -1" ); Log::info( "Material number: {}", this->tail.material() ); throw std::exception(); } - if (tail.file() < 0){ - std::advance( fieldPosition, 4 ); + if (tail.file() < 0) { + Log::error( "Illegal file number (MF) encountered" ); - utility::echoErroneousLine( begin, fieldPosition, end, lineNumber - 1 ); + Log::info( "Error parsing line {}: \"{}\"", + lineNumber - 1, + std::string( begin, std::find( begin, end, '\n' ) ) ); Log::info( "File numbers are greater than or equal to 0" ); Log::info( "File number: {}", this->tail.file() ); throw std::exception(); } - if (tail.section() < 0){ - std::advance( fieldPosition, 6 ); + if (tail.section() < 0) { + Log::error( "Illegal section number (MT) encountered" ); - utility::echoErroneousLine( begin, fieldPosition, end, lineNumber - 1 ); + Log::info( "Error parsing line {}: \"{}\"", + lineNumber - 1, + std::string( begin, std::find( begin, end, '\n' ) ) ); Log::info( "Section numbers are greater than or equal to 0" ); Log::info( "Section number: {}", this->tail.section() ); throw std::exception(); } - } catch ( int fieldNumber ){ - auto fieldPosition = std::next( begin, 66 ); + } + catch ( int fieldNumber ) { + switch (fieldNumber) { case 6 : + Log::error( "Illegal material number (MAT) encountered" ); - utility::echoErroneousLine( begin, fieldPosition, end, lineNumber ); + Log::info( "Error while parsing line {}:", lineNumber - 1 ); + Log::info( "Line {}:", std::string( begin, std::find( begin, end, '\n' ) ) ); break; case 7 : - std::advance( fieldPosition, 4 ); + Log::error( "Illegal file number (MF) encountered" ); - utility::echoErroneousLine( begin, fieldPosition, end, lineNumber ); + Log::info( "Error while parsing line {}:", lineNumber - 1 ); + Log::info( "Line {}:", std::string( begin, std::find( begin, end, '\n' ) ) ); break; case 8 : - std::advance( fieldPosition, 6 ); + Log::error( "Illegal section number (MT) encountered" ); - utility::echoErroneousLine( begin, fieldPosition, end, lineNumber ); + Log::info( "Error while parsing line {}:", lineNumber - 1 ); + Log::info( "Line {}:", std::string( begin, std::find( begin, end, '\n' ) ) ); break; default: break; } throw std::exception(); - } catch ( std::exception& e ){ + } + catch ( std::exception& e ) { + Log::info( "Error encountered while constructing structure division" ); throw e; } bool isHead() const { + return this->tail.section() and this->tail.file() and this->tail.material(); } bool isSendPermissive() const { + const static Base empty(0.0, 0.0, 0, 0, 0, 0); return ( this->base == empty ) and ( this->tail.section() == 0 ); }; bool isSend() const { + return this->isSendPermissive() and this->tail.file() and ( this->tail.material() > 0 ); } bool isFendPermissive() const { + return this->isSendPermissive() and ( this->tail.file() == 0 ); } bool isFend() const { + return this->isFendPermissive() and ( this->tail.material() > 0 ); } bool isMend() const { + return this->isFendPermissive() and ( this->tail.material() == 0 ); } bool isTend() const { + return this->isFendPermissive() and ( this->tail.material() == -1 ); } template< typename OutputIterator > void print( OutputIterator& it ) const { + if ( this->isHead() ) { + using Format = disco::Record< disco::ENDF, disco::ENDF, disco::Integer< 11 >, disco::Integer< 11 >, disco::Integer< 11 >, disco::Integer< 11 >, @@ -137,6 +161,7 @@ namespace ENDFtk { this->tail.MAT(), this->tail.MF(), this->tail.MT() ); } else { + using Format = disco::Record< disco::Integer< 70 >, disco::Integer< 2 >, disco::Integer< 3 >, @@ -146,14 +171,17 @@ namespace ENDFtk { } }; - inline StructureDivision sectionEndRecord( int MAT, int MF ){ - if ( MAT < 1 ){ + inline StructureDivision sectionEndRecord( int MAT, int MF ) { + + if ( MAT < 1 ) { + Log::error( "Illegal material number (MAT) specified in SEND record" ); Log::info( "SEND records require a material number greater than 0" ); Log::info( "Specified material number: {}", MAT ); throw std::exception(); } - if ( MF < 1 ){ + if ( MF < 1 ) { + Log::error( "Illegal file number (MF) specified in SEND record" ); Log::info( "SEND records require a file number greater than 0" ); Log::info( "Specified file number: {}", MF ); @@ -162,12 +190,15 @@ namespace ENDFtk { return StructureDivision( 0.0, 0.0, 0, 0, 0, 0, MAT, MF, 0 ); } - inline StructureDivision SEND( int MAT, int MF ){ + inline StructureDivision SEND( int MAT, int MF ) { + return sectionEndRecord( MAT, MF ); } - inline StructureDivision fileEndRecord( int MAT ){ - if ( MAT < 1 ){ + inline StructureDivision fileEndRecord( int MAT ) { + + if ( MAT < 1 ) { + Log::error( "Illegal material number (MAT) specified in FEND record" ); Log::info( "FEND records require a material number greater than 0" ); Log::info( "Specified material number: {}", MAT ); @@ -176,19 +207,21 @@ namespace ENDFtk { return StructureDivision( 0.0, 0.0, 0, 0, 0, 0, MAT, 0, 0 ); } - inline StructureDivision FEND( int MAT ){ return fileEndRecord( MAT ); } + inline StructureDivision FEND( int MAT ) { return fileEndRecord( MAT ); } + + inline StructureDivision materialEndRecord() { - inline StructureDivision materialEndRecord(){ return StructureDivision( 0.0, 0.0, 0, 0, 0, 0, 0, 0, 0 ); } - inline StructureDivision MEND(){ return materialEndRecord(); } + inline StructureDivision MEND() { return materialEndRecord(); } + + inline StructureDivision tapeEndRecord() { - inline StructureDivision tapeEndRecord(){ return StructureDivision( 0.0, 0.0, 0, 0, 0, 0, -1, 0, 0 ); } - inline StructureDivision TEND(){ return tapeEndRecord(); } + inline StructureDivision TEND() { return tapeEndRecord(); } } // ENDFtk namespace } // njoy namespace diff --git a/src/ENDFtk/TabulationRecord/test/TabulationRecord.test.cpp b/src/ENDFtk/TabulationRecord/test/TabulationRecord.test.cpp index 6fbcf8a42..a4dd5d1c0 100644 --- a/src/ENDFtk/TabulationRecord/test/TabulationRecord.test.cpp +++ b/src/ENDFtk/TabulationRecord/test/TabulationRecord.test.cpp @@ -6,23 +6,16 @@ // other includes #include "range/v3/algorithm/equal.hpp" #include "range/v3/range/operations.hpp" -#include "header-utilities/copy.hpp" // convenience typedefs using namespace njoy::ENDFtk; -std::function< TabulationRecord() > makeTAB1 = [](){ - auto metadata = std::make_tuple( 1.0, 2.0, 3ul, 4ul ); - auto regionPairs = std::make_tuple( std::vector< long >{ 4, 5, 6 }, - std::vector< long >{ 1, 2, 3 } ); - auto orderedPairs = - std::make_tuple( std::vector< double >{ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 }, - std::vector< double >{ 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 } ); +std::function< TabulationRecord() > makeTAB1 = [] () { - return TabulationRecord - ( std::get< 0 >( metadata ), std::get< 1 >( metadata ), - std::get< 2 >( metadata ), std::get< 3 >( metadata ), - njoy::utility::copy( regionPairs ), njoy::utility::copy( orderedPairs ) ); + return TabulationRecord ( 1., 2., 3, 4, + { 4, 5, 6 }, { 1, 2, 3 }, + { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 }, + { 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 } ); }; #include "ENDFtk/TabulationRecord/test/ctor.test.hpp" diff --git a/src/ENDFtk/TextRecord/test/TextRecord.test.cpp b/src/ENDFtk/TextRecord/test/TextRecord.test.cpp index f2d63bbc7..101ab4383 100644 --- a/src/ENDFtk/TextRecord/test/TextRecord.test.cpp +++ b/src/ENDFtk/TextRecord/test/TextRecord.test.cpp @@ -4,7 +4,6 @@ #include "ENDFtk/TextRecord.hpp" // other includes -#include "header-utilities/copy.hpp" // convenience typedefs using namespace njoy::ENDFtk; @@ -17,7 +16,7 @@ SCENARIO( "TextRecord Tests", "[ENDFtk], [TextRecord]" ){ "The new R-matrix analysis of the N-N system on which the ENDF/B- "; GIVEN( "a string ravlue, the ctor works"){ - REQUIRE_NOTHROW( TextRecord( njoy::utility::copy(text) ) ); + REQUIRE_NOTHROW( TextRecord( std::string(text) ) ); } GIVEN( "iterators and a line number"){ @@ -69,7 +68,7 @@ SCENARIO( "TextRecord Tests", "[ENDFtk], [TextRecord]" ){ auto lineNumber = 0l; auto textRecord0 = TextRecord( it, end, lineNumber, 125, 1, 451 ); const auto& constTextRecord0 = textRecord0; - auto textRecord1 = TextRecord( njoy::utility::copy( text ) ); + auto textRecord1 = TextRecord( std::string( text ) ); const auto& constTextRecord1 = textRecord1; THEN( "the getter will work" ){ diff --git a/src/ENDFtk/record/Base/test/Base.test.cpp b/src/ENDFtk/record/Base/test/Base.test.cpp index 65c48af65..0718f4a8d 100755 --- a/src/ENDFtk/record/Base/test/Base.test.cpp +++ b/src/ENDFtk/record/Base/test/Base.test.cpp @@ -4,7 +4,6 @@ #include "ENDFtk/record/Base.hpp" // other includes -#include "header-utilities/copy.hpp" // convenience typedefs using namespace njoy::ENDFtk; @@ -37,7 +36,7 @@ SCENARIO( "Checking single field record bases" ){ std::string entry( "123456789012345678901234567890123456789012345678901234567890123456" ); - auto base = RecordBase( njoy::utility::copy(entry) ); + auto base = RecordBase( std::string(entry) ); REQUIRE( entry == std::get< 0 >(base.fields) ); } } diff --git a/src/ENDFtk/record/InterpolationBase/test/InterpolationBase.test.cpp b/src/ENDFtk/record/InterpolationBase/test/InterpolationBase.test.cpp index eb1ee506a..47d452b91 100644 --- a/src/ENDFtk/record/InterpolationBase/test/InterpolationBase.test.cpp +++ b/src/ENDFtk/record/InterpolationBase/test/InterpolationBase.test.cpp @@ -5,20 +5,13 @@ // other includes #include "range/v3/range/operations.hpp" -#include "header-utilities/copy.hpp" // convenience typedefs using namespace njoy::ENDFtk::record; -std::function< InterpolationBase() > makeInterpolationBase = [](){ - auto metadata = std::make_tuple( 1.0, 2.0, 3ul, 4ul ); - auto regionPairs = std::make_tuple( std::vector< long >{ 4, 5, 6 }, - std::vector< long >{ 1, 2, 3 } ); +std::function< InterpolationBase() > makeInterpolationBase = [] () { - return InterpolationBase - ( std::get< 0 >( metadata ), std::get< 1 >( metadata ), - std::get< 2 >( metadata ), std::get< 3 >( metadata ), - njoy::utility::copy( regionPairs ) ); + return InterpolationBase( 1., 2., 3, 4, { 4, 5, 6 }, { 1, 2, 3 } ); }; #include "ENDFtk/record/InterpolationBase/test/ctor.test.hpp" diff --git a/src/ENDFtk/section/BaseWithoutMT.hpp b/src/ENDFtk/section/BaseWithoutMT.hpp index 1df14c98c..d6ffd41f7 100644 --- a/src/ENDFtk/section/BaseWithoutMT.hpp +++ b/src/ENDFtk/section/BaseWithoutMT.hpp @@ -4,7 +4,6 @@ // system includes // other includes -#include "header-utilities/echoErroneousLine.hpp" #include "ENDFtk/HeadRecord.hpp" namespace njoy { diff --git a/src/ENDFtk/section/BaseWithoutMT/src/readSEND.hpp b/src/ENDFtk/section/BaseWithoutMT/src/readSEND.hpp index 407dc8c63..8ae3d8914 100644 --- a/src/ENDFtk/section/BaseWithoutMT/src/readSEND.hpp +++ b/src/ENDFtk/section/BaseWithoutMT/src/readSEND.hpp @@ -1,23 +1,30 @@ template< typename Iterator > static void readSEND -( Iterator& it, const Iterator& end, long& lineNumber, int MAT, int MF ){ - try{ +( Iterator& it, const Iterator& end, long& lineNumber, int MAT, int MF ) { + + try { + const auto begin = it; auto division = StructureDivision( it, end, lineNumber ); - if( not division.isSend() ){ + if ( not division.isSend() ) { + Log::error( "Malformatted SEND record." ); - utility::echoErroneousLine( begin, it, end, lineNumber - 1 ); + Log::info( "Error parsing line {}: \"{}\"", + lineNumber - 1, + std::string( begin, std::find( begin, end, '\n' ) ) ); throw std::exception(); } - if( MAT != division.tail.MAT() ){ + if ( MAT != division.tail.MAT() ) { + Log::error( "Incorrect Material number (MAT) in SEND record." ); Log::info( "Expected MAT = {}", MAT ); Log::info( "Encountered MAT = {}", division.tail.MAT() ); throw std::exception(); } - - if( MF != division.tail.MF() ){ + + if ( MF != division.tail.MF() ) { + Log::error( "Incorrect File number (MF) in SEND record" ); Log::info( "Expected MF = {}", MF ); Log::info( "Encountered MF = {}", division.tail.MF() ); diff --git a/src/ENDFtk/tree/Material/test/Material.test.cpp b/src/ENDFtk/tree/Material/test/Material.test.cpp index 9e7c54abe..3bb0c351c 100644 --- a/src/ENDFtk/tree/Material/test/Material.test.cpp +++ b/src/ENDFtk/tree/Material/test/Material.test.cpp @@ -5,7 +5,6 @@ #include "ENDFtk/tree/Material.hpp" // other includes -#include "header-utilities/slurpFileToMemory.hpp" // convenience typedefs using namespace njoy::ENDFtk; diff --git a/src/ENDFtk/tree/Tape/test/Tape.test.cpp b/src/ENDFtk/tree/Tape/test/Tape.test.cpp index deafda89b..9928e8a83 100755 --- a/src/ENDFtk/tree/Tape/test/Tape.test.cpp +++ b/src/ENDFtk/tree/Tape/test/Tape.test.cpp @@ -4,8 +4,6 @@ #include "ENDFtk/tree/Tape.hpp" // other includes -#include "header-utilities/copy.hpp" -#include "header-utilities/slurpFileToMemory.hpp" // convenience typedefs using namespace njoy::ENDFtk;