1#ifndef CATEGORYCONFIG_P_H
2#define CATEGORYCONFIG_P_H
9#include <qx/io/qx-textstreamreader.h>
15struct RefCategoryHeader
21class QX_ERROR_TYPE(RefCategoryConfigError,
"Star::RefCategoryConfigError", 1152)
23 friend class RefCategoryConfig;
45 static inline const QString MAIN_ERR_MSG = u
"Error reading the category configuration."_s;
46 static inline const QHash<Type, QString> ERR_STRINGS{
48 {DoesNotExist, u
"The specified file does not exist."_s},
49 {Empty, u
"The provided file is empty."_s},
50 {IoError, u
"IO Error: %1"_s},
51 {InvalidIni, u
"The provided file is not a valid INI format file (Line: %1)."_s},
52 {InvalidLayout, u
"The provided file does not follow the expected layout (Line: %1)."_s},
53 {InvalidValueType, u
"Category configuration contains a value that is not an unsigned integer (Line: %1)."_s},
54 {InvalidCategoryCount, u
"A category specified a candidate count less than 2 (Line: %1)."_s},
55 {DuplicateCategory, u
"The provided file contains duplicate categories (Line: %1)."_s},
56 {InvalidGeneralKey, u
"Unrecognized General key (Line: %1)."_s},
57 {InvalidSeatCount, u
"The provided file specified a seat count less than 1 (Line: %1)."_s},
58 {NoCategories, u
"The provided file contains no categories."_s},
59 {NoSeats, u
"The provided file didn't specify a seat count."_s}
69 RefCategoryConfigError(Type t = NoError);
71 template<
typename... Strings>
72 requires (std::same_as<Strings, QString> && ...)
73 RefCategoryConfigError(Type t, Strings... args) :
74 RefCategoryConfigError(t)
76 mString = mString.arg(args...);
79 template<
typename... Ints>
80 requires (std::integral<Ints> && ...)
81 RefCategoryConfigError(Type t, Ints... args) :
82 RefCategoryConfigError(t)
84 auto sub = [
this](
auto integer) { mString = mString.arg(integer); };
92 QString string()
const;
95 Qx::Severity deriveSeverity()
const override;
96 quint32 deriveValue()
const override;
97 QString derivePrimary()
const override;
98 QString deriveSecondary()
const override;
101class RefCategoryConfig
109 static inline const QString SECTION_HEADING_CATEGORIES = QStringLiteral(
"[Categories]");
110 static inline const QString SECTION_HEADING_GENERAL = QStringLiteral(
"[General]");
111 static inline const QString KEY_GENERAL_SEATS = QStringLiteral(
"Seats");
115 QList<RefCategoryHeader> mHeaders;
117 uint mTotalCandidates;
125 uint totalCandidates()
const;
127 const QList<RefCategoryHeader>& headers()
const;
130class RefCategoryConfig::Reader
134 enum Section { None, Categories, General };
138 RefCategoryConfig* mTargetConfig;
139 Qx::TextStreamReader mIniReader;
143 Reader(RefCategoryConfig* targetConfig,
const QString& filePath);
147 RefCategoryConfigError readInto();
The Star namespace is the main namespace through which all functionality of the STAR++ library is acc...
Definition calculator.cpp:21