From 588a88455b6509a18ec5766a1387091a13935721 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Wed, 28 Feb 2024 11:31:28 +0100 Subject: [PATCH] CalcState: add toString() method --- library/include/mobilisis/calculate_price.h | 45 +++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/library/include/mobilisis/calculate_price.h b/library/include/mobilisis/calculate_price.h index a5afc67..5f05225 100644 --- a/library/include/mobilisis/calculate_price.h +++ b/library/include/mobilisis/calculate_price.h @@ -84,6 +84,51 @@ struct CALCULATE_LIBRARY_API CalcState { return (m_status == State::SUCCESS); } + QString toString() { + QString s; + switch (m_status) { + case State::SUCCESS: + s = "SUCCESS"; + break; + case State::ERROR_PARSING_ZONE_NR: + s = "ERROR_PARSING_ZONE_NR"; + break; + case State::ERROR_LOADING_TARIFF: + s = "ERROR_LOADING_TARIFF"; + break; + case State::ERROR_PARSING_TARIFF: + s = "ERROR_PARSING_TARIFF"; + break; + case State::NEGATIVE_PARING_TIME: + s = "NEGATIVE_PARKING_TIME"; + break; + case State::ABOVE_MAX_PARKING_TIME: + s = "ABOVE_MAX_PARKING_TIME"; + break; + case State::WRONG_PARAM_VALUES: + s = "WRONG_PARAM_VALUES"; + break; + case State::BELOW_MIN_PARKING_TIME: + s = "BELOW_MIN_PARKING_TIME"; + break; + case State::BELOW_MIN_PARKING_PRICE: + s = "BELOW_MIN_PARKING_PRICE"; + break; + case State::OVERPAID: + s = "OVERPAID"; + break; + case State::INVALID_START_DATE: + s = "INVALID_START_DATE"; + break; + case State::WRONG_ISO_TIME_FORMAT: + s = "WRONG_ISO_TIME_FORMAT"; + break; + case State::OUTSIDE_ALLOWED_PARKING_TIME: + s = "OUTSIDE_ALLOWED_PARKING_TIME"; + } + return s + ":" + m_desc; + } + explicit operator QString () const noexcept { QString s; switch (m_status) {