feat(standard-abundances): added raw data accessor
This commit is contained in:
2
Doxyfile
2
Doxyfile
@@ -48,7 +48,7 @@ PROJECT_NAME = fourdst::libcomposition
|
|||||||
# could be handy for archiving the generated documentation or if some version
|
# could be handy for archiving the generated documentation or if some version
|
||||||
# control system is used.
|
# control system is used.
|
||||||
|
|
||||||
PROJECT_NUMBER = v2.4.2
|
PROJECT_NUMBER = v2.4.3
|
||||||
|
|
||||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||||
# for a project that appears at the top of each page and should give viewers a
|
# for a project that appears at the top of each page and should give viewers a
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
# *********************************************************************** #
|
# *********************************************************************** #
|
||||||
project('libcomposition', 'cpp', version: 'v2.4.2', default_options: ['cpp_std=c++23'], meson_version: '>=1.5.0')
|
project('libcomposition', 'cpp', version: 'v2.4.3', default_options: ['cpp_std=c++23'], meson_version: '>=1.5.0')
|
||||||
|
|
||||||
# Add default visibility for all C++ targets
|
# Add default visibility for all C++ targets
|
||||||
add_project_arguments('-fvisibility=default', language: 'cpp')
|
add_project_arguments('-fvisibility=default', language: 'cpp')
|
||||||
|
|||||||
@@ -62,6 +62,12 @@ namespace fourdst::composition::io {
|
|||||||
{IsotopicPercentages::L09, "L09_data"}
|
{IsotopicPercentages::L09, "L09_data"}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Fetch the raw byte array of the standard solar composition data
|
||||||
|
* @return Raw Byte array to be used with ChemicalFileParser
|
||||||
|
*/
|
||||||
|
std::span<const unsigned char> get_raw_standard_solar_composition_data();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class ChemicalFileParser
|
* @class ChemicalFileParser
|
||||||
* @brief An abstract base class for chemical file parsers.
|
* @brief An abstract base class for chemical file parsers.
|
||||||
@@ -104,8 +110,8 @@ namespace fourdst::composition::io {
|
|||||||
* }
|
* }
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
[[nodiscard]] CompositionData parse_compositon_data(const std::vector<char>& data,const std::string& scheme) const ;
|
[[nodiscard]] static CompositionData parse_composition_data(const std::vector<char>& data,const std::string& scheme);
|
||||||
[[nodiscard]] IsotopicPercentage parse_isotopic_percentage(const std::vector<char>& data,const std::string& scheme) const ;
|
[[nodiscard]] static IsotopicPercentage parse_isotopic_percentage(const std::vector<char>& data,const std::string& scheme);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,9 +17,8 @@
|
|||||||
#include <ranges>
|
#include <ranges>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
|
||||||
namespace fourdst:: composition::io {
|
|
||||||
namespace {
|
namespace {
|
||||||
inline void ltrim(std::string &s) {
|
void ltrim(std::string &s) {
|
||||||
s.erase(
|
s.erase(
|
||||||
s.begin(),
|
s.begin(),
|
||||||
std::ranges::find_if(s,
|
std::ranges::find_if(s,
|
||||||
@@ -29,7 +28,7 @@ namespace fourdst:: composition::io {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void rtrim(std::string &s) {
|
void rtrim(std::string &s) {
|
||||||
s.erase(
|
s.erase(
|
||||||
std::find_if(
|
std::find_if(
|
||||||
s.rbegin(),
|
s.rbegin(),
|
||||||
@@ -41,32 +40,33 @@ namespace fourdst:: composition::io {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void trim(std::string &s) {
|
void trim(std::string &s) {
|
||||||
ltrim(s);
|
ltrim(s);
|
||||||
rtrim(s);
|
rtrim(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool to_bool(std::string s) {
|
bool to_bool(std::string s) {
|
||||||
std::transform(s.begin(), s.end(), s.begin(),
|
std::ranges::transform(s, s.begin(),
|
||||||
[](unsigned char c){ return std::tolower(c); });
|
[](const unsigned char c){ return std::tolower(c); });
|
||||||
|
|
||||||
return s == "true";
|
return s == "true";
|
||||||
}
|
}
|
||||||
|
|
||||||
CompositionData ChemicalFileParser::parse_compositon_data(const std::vector<char>& data,const std::string& scheme) const {
|
}
|
||||||
|
|
||||||
|
namespace fourdst:: composition::io {
|
||||||
|
std::span<const unsigned char> get_raw_standard_solar_composition_data() {
|
||||||
|
return StandardMetalFractions;
|
||||||
|
}
|
||||||
|
|
||||||
|
CompositionData ChemicalFileParser::parse_composition_data(const std::vector<char>& data,const std::string& scheme) {
|
||||||
|
|
||||||
// get file and metal_fraction_scheme
|
// get file and metal_fraction_scheme
|
||||||
// Load the file
|
// Load the file
|
||||||
// find the metal_fraction_scheme
|
// find the metal_fraction_scheme
|
||||||
// return abundances
|
// return abundances
|
||||||
|
|
||||||
// LOG_TRACE_L1(m_logger, "Parsing chemical abundance for: {}", scheme);
|
|
||||||
|
|
||||||
bool debug = false;
|
|
||||||
|
|
||||||
std::istringstream stream(std::string(data.begin(), data.end()));
|
std::istringstream stream(std::string(data.begin(), data.end()));
|
||||||
|
|
||||||
// add error message if something goes wrong
|
// add error message if something goes wrong
|
||||||
@@ -141,7 +141,7 @@ namespace fourdst:: composition::io {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IsotopicPercentage ChemicalFileParser::parse_isotopic_percentage(const std::vector<char>& data,const std::string& scheme) const {
|
IsotopicPercentage ChemicalFileParser::parse_isotopic_percentage(const std::vector<char>& data,const std::string& scheme) {
|
||||||
|
|
||||||
// get file and iso_scheme
|
// get file and iso_scheme
|
||||||
// Load the file
|
// Load the file
|
||||||
@@ -149,8 +149,6 @@ namespace fourdst:: composition::io {
|
|||||||
// get iso_comp data
|
// get iso_comp data
|
||||||
// IsotopicPercentage object
|
// IsotopicPercentage object
|
||||||
|
|
||||||
bool debug = false;
|
|
||||||
|
|
||||||
std::istringstream stream(std::string(data.begin(), data.end()));
|
std::istringstream stream(std::string(data.begin(), data.end()));
|
||||||
|
|
||||||
// add error message if something goes wrong
|
// add error message if something goes wrong
|
||||||
@@ -240,7 +238,7 @@ namespace fourdst::composition {
|
|||||||
|
|
||||||
data = std::ranges::to<std::vector<char>>(StandardMetalFractions);
|
data = std::ranges::to<std::vector<char>>(StandardMetalFractions);
|
||||||
|
|
||||||
metals = parser.parse_compositon_data(data,metal_fraction_scheme);
|
metals = parser.parse_composition_data(data,metal_fraction_scheme);
|
||||||
isotopes = parser.parse_isotopic_percentage(data,isotopic_percentage_scheme);
|
isotopes = parser.parse_isotopic_percentage(data,isotopic_percentage_scheme);
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
|
|||||||
Reference in New Issue
Block a user