btool
A parser/converter/transpiler for .bib files
Parser.hpp
Go to the documentation of this file.
1 #ifndef BIBPARSER_PARSER_HPP
2 #define BIBPARSER_PARSER_HPP
3 
4 #include <TranslationTable.hpp>
5 #include <StyleProperties.hpp>
6 #include <BibElement.hpp>
7 #include <boost/filesystem.hpp>
8 #include <Field.hpp>
9 #include <vector>
10 #include <string>
11 #include <stdexcept>
12 
17 class
18 Parser {
19  std::vector<std::string> targetStyles;
21  bool allowAll;
22 
23  public:
24  Parser(
25  const std::optional<boost::filesystem::path> &ruleFilePath,
26  std::vector<std::string> targetStyles,
27  const bool allowAll = false
28  );
29 
30  Parser(
31  std::optional<std::stringstream> ruleFileContents,
32  std::vector<std::string> targetStyle,
33  const bool allowAll = false
34  );
35 
36  [[nodiscard]] auto generate(
37  const std::vector<boost::filesystem::path> &inputPaths,
38  const std::optional<std::string> &sorting
39  ) const -> std::vector<BibElement>;
40 
41  [[nodiscard]] auto generate(
42  const boost::filesystem::path &inputPath,
43  const std::optional<std::string> &sorting
44  ) const -> std::vector<BibElement>;
45 
46  [[nodiscard]] auto generate(
47  std::string_view inputFileContent,
48  const std::optional<std::string> &sorting,
49  const std::string &filename
50  ) const -> std::vector<BibElement>;
51 
52  private:
53 
54  static auto elementsOf(
55  std::string_view input,
56  const std::string &filename
57  ) -> std::vector<BibElement>;
58 
59  static auto sortElements(
60  std::vector<BibElement> &elements,
61  const std::string &sorting
62  ) noexcept -> void;
63 
64  static auto filterElements(
65  const std::vector<BibElement> &elements,
66  const std::vector<StyleProperties> &props
67  ) noexcept -> std::vector<BibElement>;
68 };
69 
70 #endif
Parser
interface to interact with bib-files
Definition: Parser.hpp:18
Field.hpp
TranslationTable.hpp
Parser::allowAll
bool allowAll
flag that allows all styles and fields to get parsed (set when missing translationTable)
Definition: Parser.hpp:21
TranslationTable
api to interact with translation-table resource
Definition: TranslationTable.hpp:16
Parser::targetStyles
std::vector< std::string > targetStyles
the target-styles of the generated files
Definition: Parser.hpp:19
StyleProperties.hpp
BibElement.hpp
Parser::translationTable
TranslationTable translationTable
translation-Table handler
Definition: Parser.hpp:20