LCOV - code coverage report
Current view: top level - inc/tables/typeTable/types/userTypes - enumType.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 21 0
Test Date: 2025-04-18 15:53:49 Functions: 0.0 % 5 0

            Line data    Source code
       1              : #ifndef ENUM_TYPE_H
       2              : #define ENUM_TYPE_H
       3              : 
       4              : #include "../type.h"
       5              : #include <sstream>
       6              : #include <string>
       7              : #include <vector>
       8              : 
       9              : namespace nicole {
      10              : 
      11              : class EnumType final : public Type {
      12              : private:
      13              :   std::string name_;
      14              :   std::vector<std::string> values_;
      15              : 
      16              : public:
      17              :   EnumType(const std::string &name,
      18              :            const std::vector<std::string> &values) noexcept
      19            0 :       : name_(name), values_(values) {}
      20              : 
      21            0 :   [[nodiscard]] const std::string &name() const noexcept { return name_; }
      22              : 
      23            0 :   [[nodiscard]] const std::vector<std::string> &values() const noexcept {
      24            0 :     return values_;
      25            0 :   }
      26              : 
      27              :   [[nodiscard]] bool
      28            0 :   hasIdentifier(const std::string &identifier) const noexcept {
      29            0 :     return std::find(values_.begin(), values_.end(), identifier) !=
      30            0 :            values_.end();
      31            0 :   }
      32              : 
      33            0 :   [[nodiscard]] std::string toString() const noexcept override {
      34            0 :     std::ostringstream oss;
      35            0 :     oss << "enum " << name_ << " { ";
      36            0 :     for (size_t i = 0; i < values_.size(); ++i) {
      37            0 :       oss << values_[i];
      38            0 :       if (i != values_.size() - 1) {
      39            0 :         oss << ", ";
      40            0 :       }
      41            0 :     }
      42            0 :     oss << " }";
      43            0 :     return oss.str();
      44            0 :   }
      45              : };
      46              : 
      47              : } // namespace nicole
      48              : 
      49              : #endif
        

Generated by: LCOV version 2.0-1