-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from njoy/develop
tools v0.3.0
- Loading branch information
Showing
245 changed files
with
23,401 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
// disco | ||
#include "tools/disco.hpp" | ||
|
||
// the logging tool | ||
#include "tools/Log.hpp" | ||
|
||
// an overload struct to collect lambdas for std::visit | ||
#include "tools/overload.hpp" | ||
|
||
// a partial C++-17 implementation of the C++-20 ranges standard | ||
#include "tools/std20.hpp" | ||
|
||
// custom views | ||
#include "tools/views.hpp" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include "tools/disco/functions.hpp" | ||
#include "tools/disco/BaseField.hpp" | ||
#include "tools/disco/FreeFormatCharacter.hpp" | ||
#include "tools/disco/FreeFormatInteger.hpp" | ||
#include "tools/disco/FreeFormatReal.hpp" | ||
#include "tools/disco/BaseFixedWidthField.hpp" | ||
#include "tools/disco/Column.hpp" | ||
#include "tools/disco/Character.hpp" | ||
#include "tools/disco/Integer.hpp" | ||
#include "tools/disco/Real.hpp" | ||
#include "tools/disco/FixedPoint.hpp" | ||
#include "tools/disco/Scientific.hpp" | ||
#include "tools/disco/ENDF.hpp" | ||
#include "tools/disco/Record.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#ifndef NJOY_TOOLS_DISCO_BASEFIELD | ||
#define NJOY_TOOLS_DISCO_BASEFIELD | ||
|
||
// system includes | ||
#include <cctype> | ||
|
||
// other includes | ||
#include "tools/disco/functions.hpp" | ||
|
||
namespace njoy { | ||
namespace tools { | ||
namespace disco { | ||
|
||
/** | ||
* @brief A base class for reading data fields (either fixed width or free | ||
* format). | ||
*/ | ||
class BaseField { | ||
|
||
/* fields */ | ||
|
||
protected: | ||
|
||
/* auxiliary functions */ | ||
|
||
/** | ||
* @brief Skip the '+' character | ||
* | ||
* Note: when a plus sign is encountered, the position is incremented. | ||
* In the case of a fixed width field, this may put the position over | ||
* the width so this must be checked prior to calling this function. | ||
* | ||
* @param[in,out] iter an iterator to a character in a range | ||
* @param[in,out] position the current position in the field | ||
*/ | ||
template < typename Iterator > | ||
static void skipPlusSign( Iterator& iter, unsigned int& position ) { | ||
|
||
if ( *iter == '+' ) { | ||
|
||
++iter; | ||
++position; | ||
} | ||
} | ||
}; | ||
|
||
} // disco namespace | ||
} // tools namespace | ||
} // njoy namespace | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// include Catch2 | ||
#include <catch2/catch_test_macros.hpp> | ||
|
||
// what we are testing | ||
#include "tools/disco/BaseField.hpp" | ||
|
||
// other includes | ||
|
||
// convenience typedefs | ||
using namespace njoy::tools::disco; | ||
|
||
class TestBaseField : protected BaseField { | ||
|
||
public: | ||
|
||
using BaseField::skipPlusSign; | ||
}; | ||
|
||
SCENARIO( "BaseField" ) { | ||
|
||
std::string string = " a\t\n\r\n\f"; | ||
string += char{ std::char_traits<char>::eof() }; | ||
auto iter = string.begin(); | ||
unsigned int position = 0; | ||
|
||
string = "+abc"; | ||
position = 0; | ||
iter = string.begin(); | ||
TestBaseField::skipPlusSign( iter, position ); | ||
CHECK( iter == string.begin() + 1 ); | ||
CHECK( position == 1 ); | ||
|
||
string = "abc"; | ||
position = 0; | ||
iter = string.begin(); | ||
TestBaseField::skipPlusSign( iter, position ); | ||
CHECK( iter == string.begin() ); | ||
CHECK( position == 0 ); | ||
} // SCENARIO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_cpp_test( disco.BaseField BaseField.test.cpp ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#ifndef NJOY_TOOLS_DISCO_BASEFIXEDWIDTHFIELD | ||
#define NJOY_TOOLS_DISCO_BASEFIXEDWIDTHFIELD | ||
|
||
// system includes | ||
#include <cctype> | ||
|
||
// other includes | ||
#include "tools/disco/BaseField.hpp" | ||
|
||
namespace njoy { | ||
namespace tools { | ||
namespace disco { | ||
|
||
/** | ||
* @brief A base class for reading fixed width data fields | ||
*/ | ||
template < unsigned int Width > | ||
class BaseFixedWidthField : public BaseField { | ||
|
||
/* fields */ | ||
|
||
protected: | ||
|
||
using BaseField::skipPlusSign; | ||
|
||
/** | ||
* @brief Skip over spaces until the end of the field or until | ||
* a non-space character is encountered | ||
* | ||
* @param[in,out] iter an iterator to a character in a range | ||
* @param[in,out] position the current position in the field | ||
*/ | ||
template < typename Iterator > | ||
static void skipSpaces( Iterator& iter, unsigned int& position ) { | ||
|
||
while( position < Width && isSpace( iter ) ) { | ||
|
||
++position; | ||
++iter; | ||
} | ||
} | ||
}; | ||
|
||
} // disco namespace | ||
} // tools namespace | ||
} // njoy namespace | ||
|
||
#endif |
Oops, something went wrong.