11#include <qx/core/qx-abstracterror.h>
18class RefCategoryConfig;
23 QStringList candidates;
30 QList<QList<int>> votes;
33class QX_ERROR_TYPE(RefBallotBoxError,
"Star::RefBallotBoxError", 1150)
35 friend class RefBallotBox;
53 static inline const QString MAIN_ERR_MSG = u
"Error reading the ballot box."_s;
54 static inline const QHash<Type, QString> ERR_STRINGS{
56 {InvalidRowCount, u
"The ballot box has less than the minimum required row count (headings + 2 voters)."_s},
57 {InvalidColumnCount, u
"The ballot box has a different number of columns than specified by the category configuration (%1 vs %2)."_s},
58 {InvalidDate, u
"The format of a submission date was invalid."_s},
59 {Empty, u
"The provided file contains no ballots."_s},
60 {BlankValue, u
"A field expected to have a value was blank (r: %1, c: %2)."_s},
61 {InvalidVote, u
"A vote value was not a valid unsigned integer between 0 and 5 (r: %1, c: %2)."_s},
62 {DuplicateCandidate, u
"The ballot box contained duplicate candidates within the same category."_s},
63 {IoError, u
"IO Error: %1"_s}
73 RefBallotBoxError(Type t = NoError);
75 template<
typename... Strings>
76 requires (std::same_as<Strings, QString> && ...)
77 RefBallotBoxError(Type t, Strings... args) :
80 mString = mString.arg(args...);
83 template<
typename... Ints>
84 requires (std::integral<Ints> && ...)
85 RefBallotBoxError(Type t, Ints... args) :
88 auto sub = [
this](
auto integer) { mString = mString.arg(integer); };
96 QString string()
const;
99 Qx::Severity deriveSeverity()
const override;
100 quint32 deriveValue()
const override;
101 QString derivePrimary()
const override;
102 QString deriveSecondary()
const override;
113 QList<RefCategory> mCategories;
114 QList<RefBallot> mBallots;
122 const QList<RefCategory>& categories()
const;
123 const QList<RefBallot>& ballots()
const;
126class RefBallotBox::Reader
131 static const int STATIC_FIELD_COUNT = 2;
132 static const int SUBMISSION_DATE_INDEX = 0;
133 static const int MEMBER_NAME_INDEX = 1;
137 RefBallotBox* mTargetBox;
139 const RefCategoryConfig* mCategoryConfig;
140 qsizetype mExpectedFieldCount;
144 Reader(RefBallotBox* targetBox,
const QString& filePath,
const RefCategoryConfig* categoryConfig);
148 RefBallotBoxError parseCategories(
const QList<QVariant>& headingsRow);
149 RefBallotBoxError parseBallot(
const QList<QVariant>& ballotRow, qsizetype ballotNum);
152 RefBallotBoxError readInto();
The Star namespace is the main namespace through which all functionality of the STAR++ library is acc...
Definition calculator.cpp:21