• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ParadoxGameConverters / commonItems / 12846535547

18 Jan 2025 06:41PM UTC coverage: 75.846% (-1.7%) from 77.556%
12846535547

Pull #274

github

web-flow
Merge 8b9494010 into b007cb890
Pull Request #274: Eliminate warnings

279 of 358 new or added lines in 13 files covered. (77.93%)

38 existing lines in 2 files now uncovered.

1837 of 2422 relevant lines covered (75.85%)

240.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

25.0
/Parser.h
1
#ifndef PARSER_H
2
#define PARSER_H
3

4

5
#include <filesystem>
6
#include <functional>
7
#include <map>
8
#include <optional>
9
#include <regex>
10
#include <set>
11

12

13

14
// A parser for reading Paradox Script.
15

16
namespace commonItems
17
{
18
using parsingFunction = std::function<void(const std::string&, std::istream&)>;
19
using parsingFunctionStreamOnly = std::function<void(std::istream&)>;
20
void absorbBOM(std::istream& theStream);
21

22
class parser
23
{
24
  public:
25
        parser() = default;
×
NEW
26
        virtual ~parser() = default;
×
27
        parser(const parser&) = default;
28
        parser(parser&&) noexcept = default;
11✔
29
        parser& operator=(const parser&) = default;
30
        parser& operator=(parser&&) = default;
×
31

32
        void registerKeyword(const std::string& keyword, const parsingFunctionStreamOnly& function);
33
        void registerKeyword(const std::string& keyword,
34
                 const parsingFunction& function); // for the few keywords that need to be returned
35
        void registerRegex(const std::string& keyword, const parsingFunction& function);
36
        void IgnoreUnregisteredItems();
37
        void IgnoreAndLogUnregisteredItems();
38
        void IgnoreAndStoreUnregisteredItems(std::set<std::string>& ignored_tokens);
39

40
        void clearRegisteredKeywords() noexcept;
41

42
        void parseStream(std::istream& theStream);
43
        void parseFile(std::filesystem::path filename);
44
        [[deprecated("Use std::filesystem::path version")]] void parseFile(std::string_view filename);
45

46
        std::optional<std::string> getNextToken(std::istream& theStream);
47
        static std::optional<std::string> getNextTokenWithoutMatching(std::istream& theStream);
48
        // as a function object, parse the stream.
49
        virtual void operator()(std::istream& theStream);
50

51
  private:
52
        inline bool tryToMatchAgainstKeywords(const std::string& toReturn, const std::string& strippedLexeme, bool isLexemeQuoted, std::istream& theStream);
53
        inline bool tryToMatchAgainstRegexes(const std::string& toReturn, const std::string& strippedLexeme, bool isLexemeQuoted, std::istream& theStream);
54

55
        std::map<std::string, parsingFunctionStreamOnly> registeredKeywordStringsStreamOnly;
56
        std::map<std::string, parsingFunction> registeredKeywordStrings;
57
        std::vector<std::pair<std::regex, parsingFunction>> generatedRegexes;
58
};
59
} // namespace commonItems
60
#endif // PARSER_H
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc