LCOV - code coverage report
Current view: top level - inc/lexicalAnalysis - regexWrapper.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 7 7
Test Date: 2025-04-18 15:53:49 Functions: 100.0 % 4 4

            Line data    Source code
       1              : #ifndef REGEX_NC_H
       2              : #define REGEX_NC_H
       3              : 
       4              : #include <regex>
       5              : #include <string>
       6              : 
       7              : namespace nicole {
       8              : 
       9              : // Regex doesn´t store a raw string of the pattern so a wrapper is need like the
      10              : // one used in boost library
      11              : class RegexWrapper final {
      12              : private:
      13              :   /* data */
      14              :   std::string rawPattern_;
      15              :   std::regex pattern_;
      16              : 
      17              : public:
      18              :   explicit RegexWrapper(const std::string &rawPattern) noexcept
      19         1764 :       : rawPattern_{rawPattern},
      20         1764 :         pattern_{rawPattern, std::regex_constants::optimize} {};
      21              : 
      22         7254 :   [[nodiscard]] const std::string &str() const noexcept { return rawPattern_; }
      23              : 
      24       402273 :   [[nodiscard]] const std::regex &pattern() const noexcept { return pattern_; }
      25              : 
      26          135 :   [[nodiscard]] bool match(const std::string &str) const noexcept {
      27          135 :     return std::regex_match(str, pattern_);
      28          135 :   }
      29              : };
      30              : 
      31              : } // namespace nicole
      32              : 
      33              : #endif
        

Generated by: LCOV version 2.0-1