/* File: Enums.h Description: Declares enumerations and utility functions for user types, payment modes, payment status, service job status, and state management in the Vehicle Service Management System. Provides string conversion and parsing functions for each enum type. Author: Trenser Date: 19-May-2026 */ #pragma once #include namespace util { enum class UserType : int { ADMIN, TECHNICIAN, CUSTOMER }; enum class PaymentMode : int { ONLINE, OFFLINE, NOTSET }; enum class PaymentStatus : int { PENDING, COMPLETED, PAID }; enum class ServiceJobStatus : int { PENDING, STARTED, COMPLETED, IN_PROGRESS, CANCELLED }; enum class State : int { ACTIVE, INACTIVE }; /* Function: getUserTypeString Description: Converts a UserType enum value to its corresponding string representation. Parameters: - type: UserType enum value. Returns: - std::string representing the UserType. */ inline std::string getUserTypeString(UserType type) { switch (type) { case UserType::ADMIN: return "ADMIN"; case UserType::TECHNICIAN: return "TECHNICIAN"; case UserType::CUSTOMER: return "CUSTOMER"; } throw std::invalid_argument("Invalid UserType"); } /* Function: getUserType Description: Converts a string value to its corresponding UserType enum. Parameters: - value: std::string representing the UserType. Returns: - UserType enum value. Throws: - std::invalid_argument if the string does not match a valid UserType. */ inline UserType getUserType(const std::string& value) { if (value == "ADMIN") { return UserType::ADMIN; } if (value == "TECHNICIAN") { return UserType::TECHNICIAN; } if (value == "CUSTOMER") { return UserType::CUSTOMER; } throw std::invalid_argument("Invalid UserType string"); } /* Function: getPaymentModeString Description: Converts a PaymentMode enum value to its corresponding string representation. Parameters: - mode: PaymentMode enum value. Returns: - std::string representing the PaymentMode. */ inline std::string getPaymentModeString(PaymentMode mode) { switch (mode) { case PaymentMode::ONLINE: return "ONLINE"; case PaymentMode::OFFLINE: return "OFFLINE"; case PaymentMode::NOTSET: return "NOTSET"; } throw std::invalid_argument("Invalid PaymentMode"); } /* Function: getPaymentMode Description: Converts a string value to its corresponding PaymentMode enum. Parameters: - value: std::string representing the PaymentMode. Returns: - PaymentMode enum value. Throws: - std::invalid_argument if the string does not match a valid PaymentMode. */ inline PaymentMode getPaymentMode(const std::string& value) { if (value == "ONLINE") { return PaymentMode::ONLINE; } if (value == "OFFLINE") { return PaymentMode::OFFLINE; } if (value == "NOTSET") { return PaymentMode::NOTSET; } throw std::invalid_argument("Invalid PaymentMode string"); } /* Function: getPaymentStatusString Description: Converts a PaymentStatus enum value to its corresponding string representation. Parameters: - status: PaymentStatus enum value. Returns: - std::string representing the PaymentStatus. */ inline std::string getPaymentStatusString(PaymentStatus status) { switch (status) { case PaymentStatus::PENDING: return "PENDING"; case PaymentStatus::COMPLETED: return "COMPLETED"; case PaymentStatus::PAID: return "PAID"; } throw std::invalid_argument("Invalid PaymentStatus"); } /* Function: getPaymentStatus Description: Converts a string value to its corresponding PaymentStatus enum. Parameters: - value: std::string representing the PaymentStatus. Returns: - PaymentStatus enum value. Throws: - std::invalid_argument if the string does not match a valid PaymentStatus. */ inline PaymentStatus getPaymentStatus(const std::string& value) { if (value == "PENDING") { return PaymentStatus::PENDING; } if (value == "COMPLETED") { return PaymentStatus::COMPLETED; } throw std::invalid_argument("Invalid PaymentStatus string"); } /* Function: getServiceJobStatusString Description: Converts a ServiceJobStatus enum value to its corresponding string representation. Parameters: - status: ServiceJobStatus enum value. Returns: - std::string representing the ServiceJobStatus. */ inline std::string getServiceJobStatusString(ServiceJobStatus status) { switch (status) { case ServiceJobStatus::PENDING: return "PENDING"; case ServiceJobStatus::STARTED: return "STARTED"; case ServiceJobStatus::COMPLETED: return "COMPLETED"; case ServiceJobStatus::CANCELLED: return "CANCELLED"; case ServiceJobStatus::IN_PROGRESS: return "IN_PROGRESS"; } throw std::invalid_argument("Invalid ServiceJobStatus"); } /* Function: getServiceJobStatus Description: Converts a string value to its corresponding ServiceJobStatus enum. Parameters: - value: std::string representing the ServiceJobStatus. Returns: - ServiceJobStatus enum value. Throws: - std::invalid_argument if the string does not match a valid ServiceJobStatus. */ inline ServiceJobStatus getServiceJobStatus(const std::string& value) { if (value == "STARTED") { return ServiceJobStatus::STARTED; } if (value == "COMPLETED") { return ServiceJobStatus::COMPLETED; } if (value == "PENDING") { return ServiceJobStatus::PENDING; } if (value == "CANCELLED") { return ServiceJobStatus::CANCELLED; } if (value == "IN_PROGRESS") { return ServiceJobStatus::IN_PROGRESS; } throw std::invalid_argument("Invalid ServiceJobStatus string"); } /* Function: getStateString Description: Converts a State enum value to its corresponding string representation. Parameters: - status: State enum value. Returns: - std::string representing the State. */ inline std::string getStateString(State status) { switch (status) { case State::ACTIVE: return "ACTIVE"; case State::INACTIVE: return "INACTIVE"; } throw std::invalid_argument("Invalid State"); } /* Function: getState Description: Converts a string value to its corresponding State enum. Parameters: - value: std::string representing the State. Returns: - State enum value. Throws: - std::invalid_argument if the string does not match a valid State. */ inline State getState(const std::string& value) { if (value == "ACTIVE") { return State::ACTIVE; } if (value == "INACTIVE") { return State::INACTIVE; } throw std::invalid_argument("Invalid State string"); } }