interface to interact with bib-files More...
#include <Parser.hpp>
Public Member Functions | |
Parser (const std::optional< boost::filesystem::path > &ruleFilePath, std::vector< std::string > targetStyles, const bool allowAll=false) | |
Parser (std::optional< std::stringstream > ruleFileContents, std::vector< std::string > targetStyle, const bool allowAll=false) | |
auto | generate (const std::vector< boost::filesystem::path > &inputPaths, const std::optional< std::string > &sorting) const -> std::vector< BibElement > |
auto | generate (const boost::filesystem::path &inputPath, const std::optional< std::string > &sorting) const -> std::vector< BibElement > |
auto | generate (std::string_view inputFileContent, const std::optional< std::string > &sorting, const std::string &filename) const -> std::vector< BibElement > |
Static Private Member Functions | |
static auto | elementsOf (std::string_view input, const std::string &filename) -> std::vector< BibElement > |
static auto | sortElements (std::vector< BibElement > &elements, const std::string &sorting) noexcept -> void |
static auto | filterElements (const std::vector< BibElement > &elements, const std::vector< StyleProperties > &props) noexcept -> std::vector< BibElement > |
Private Attributes | |
std::vector< std::string > | targetStyles |
the target-styles of the generated files More... | |
TranslationTable | translationTable |
translation-Table handler More... | |
bool | allowAll |
flag that allows all styles and fields to get parsed (set when missing translationTable) More... | |
interface to interact with bib-files
Handles interaction with the bib-files and does parsing of it
Definition at line 17 of file Parser.hpp.
Parser::Parser | ( | const std::optional< boost::filesystem::path > & | ruleFilePath, |
std::vector< std::string > | targetStyles, | ||
const bool | allowAll = false |
||
) |
Constructor.
ruleFilePath | optional filepath to the translation-table |
targetStyle | the style name to filter parse-results for |
allowAll | flag to allow every element to get parsed (ignore TranslationTable) |
boost::property_tree::json_parser_error | whenever translationTable is not JSON compliant |
std::invalid_argument | whenever translationTable is no regular file or does not exist |
Definition at line 18 of file Parser.cpp.
References allowAll.
Parser::Parser | ( | std::optional< std::stringstream > | ruleFileContents, |
std::vector< std::string > | targetStyles, | ||
const bool | allowAll = false |
||
) |
Constructor.
ruleFileContents | optional contents of the translation-table |
targetStyle | the style name to filter parse-results for |
allowAll | flag to allow every element to get parsed (ignore TranslationTable) |
boost::property_tree::json_parser_error | whenever translationTable is not JSON compliant |
Definition at line 33 of file Parser.cpp.
References allowAll.
|
staticprivate |
Parse Bib-Elements from a source-file
input | the contents of the source-file |
filename | name or path of the parsed file (for logging errors) |
std::runtime_error | if parsing failed |
Definition at line 113 of file Parser.cpp.
References ParserContext::column, ParserState::handleCharacter(), ParserContext::line, ParserException::state, and ParserException::what().
Referenced by generate().
|
staticprivatenoexcept |
Filters list of elements for only elements that are compliant to one of a list of properties
elements | the list of elements to filter |
props | the list of properties to filter for |
Definition at line 187 of file Parser.cpp.
References BibElement::isCompliantTo().
auto Parser::generate | ( | const boost::filesystem::path & | inputPath, |
const std::optional< std::string > & | sorting | ||
) | const -> std::vector<BibElement> |
Generate bib-elements and Filter them for a Style
inputPath | filepath to a directory of bib-Files or a single bib-File |
sorting | the style name to sort parsing-results for |
std::runtime_error | on parsing error |
std::illegal_argument | if file is invalid |
Definition at line 49 of file Parser.cpp.
auto Parser::generate | ( | const std::vector< boost::filesystem::path > & | inputPaths, |
const std::optional< std::string > & | sorting | ||
) | const -> std::vector<BibElement> |
Generates Elements of multiple input-files
inputPaths | all theinput-paths |
sorting | optional sorting to use |
std::runtime_error | on parsing-error |
std::invalid_argument | if a file is invalid |
Definition at line 164 of file Parser.cpp.
Referenced by main(), and TEST_F().
auto Parser::generate | ( | std::string_view | inputFileContent, |
const std::optional< std::string > & | sorting, | ||
const std::string & | filename | ||
) | const -> std::vector<BibElement> |
Generate bib-elements and Filter them for a Style
inputFileContent | content of a input-file |
sorting | the style name to sort parsing-results for |
filename | name or path of the parsed file (for logging errors) |
std::runtime_error | on parsing error |
Definition at line 87 of file Parser.cpp.
References elementsOf().
|
staticprivatenoexcept |
Sorts a vector of bibElements
elements[out] | the vector of bibElements |
sorting | the attribute to sort for |
Definition at line 145 of file Parser.cpp.
References BibElement::findAttribute(), and Field::value.
|
private |
flag that allows all styles and fields to get parsed (set when missing translationTable)
Definition at line 21 of file Parser.hpp.
Referenced by Parser().
|
private |
the target-styles of the generated files
Definition at line 19 of file Parser.hpp.
|
private |
translation-Table handler
Definition at line 20 of file Parser.hpp.