From b574a79dfe1c9cf34754be858a447bd7cf2fd255 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Thu, 28 Jul 2022 10:57:41 +0200 Subject: [PATCH] Manager+Util: Change enum class type from int to uint8_t (4 -> 1 byte) --- src/dotfile.h | 3 ++- src/package.h | 5 +++-- src/util/argparser.cpp | 3 ++- src/util/argparser.h | 5 +++-- src/util/json/job.h | 9 --------- src/util/json/lexer.h | 3 ++- src/util/json/parser.cpp | 2 +- src/util/json/value.h | 4 ++-- 8 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/dotfile.h b/src/dotfile.h index 6997099..3373444 100644 --- a/src/dotfile.h +++ b/src/dotfile.h @@ -7,6 +7,7 @@ #pragma once #include // size_t +#include // uint8_t #include #include // function #include @@ -19,7 +20,7 @@ public: Dotfile(s); virtual ~Dotfile(); - enum class SyncType { + enum class SyncType : uint8_t { Add, Pull, Push, diff --git a/src/package.h b/src/package.h index 7949ecb..6f6abd4 100644 --- a/src/package.h +++ b/src/package.h @@ -6,6 +6,7 @@ #pragma once +#include // uint8_t #include #include #include @@ -17,13 +18,13 @@ public: Package(s); virtual ~Package(); - enum class Distro { + enum class Distro : uint8_t { Unsupported, Arch, Debian, }; - enum class InstallType { + enum class InstallType : uint8_t { Install, AurInstall, }; diff --git a/src/util/argparser.cpp b/src/util/argparser.cpp index 5649dec..63b9968 100644 --- a/src/util/argparser.cpp +++ b/src/util/argparser.cpp @@ -6,6 +6,7 @@ #include // find_if #include // size_t +#include // uint8_t #include // printf #include // strcmp #include // numeric_limits @@ -169,7 +170,7 @@ bool ArgParser::parseLongOption(std::string_view option, std::string_view next) return false; } - enum class ArgumentProvided { + enum class ArgumentProvided : uint8_t { No, DirectlyAfter, Seperated, diff --git a/src/util/argparser.h b/src/util/argparser.h index 1aff679..1d45053 100644 --- a/src/util/argparser.h +++ b/src/util/argparser.h @@ -7,6 +7,7 @@ #pragma once #include // size_t +#include // uint8_t #include // function #include #include @@ -21,13 +22,13 @@ public: ArgParser(); virtual ~ArgParser(); - enum class Required { + enum class Required : uint8_t { No, Yes, Optional, }; - enum class Error { + enum class Error : uint8_t { None, OptionInvalid, // For short options OptionUnrecognized, // For long options diff --git a/src/util/json/job.h b/src/util/json/job.h index 5c12031..588e3fa 100644 --- a/src/util/json/job.h +++ b/src/util/json/job.h @@ -21,15 +21,6 @@ public: Job(std::string_view input); virtual ~Job(); - enum class Color { - None, - Info, - Warn, - Danger, - Success, - Comment, - }; - Value fire(); void printErrorLine(Token token, const char* message); diff --git a/src/util/json/lexer.h b/src/util/json/lexer.h index f01b892..106b15c 100644 --- a/src/util/json/lexer.h +++ b/src/util/json/lexer.h @@ -10,6 +10,7 @@ // https://www.rfc-editor.org/rfc/pdfrfc/rfc8259.txt.pdf #include // size_t +#include // uint8_t #include #include @@ -20,7 +21,7 @@ namespace Util::JSON { class Job; struct Token { - enum class Type { + enum class Type : uint8_t { None, BraceOpen, // { BraceClose, // } diff --git a/src/util/json/parser.cpp b/src/util/json/parser.cpp index cb7b655..05f3bcd 100644 --- a/src/util/json/parser.cpp +++ b/src/util/json/parser.cpp @@ -144,7 +144,7 @@ Value Parser::consumeNumber() return nullptr; } - enum class State { + enum class State : uint8_t { Int, Fraction, Exponent diff --git a/src/util/json/value.h b/src/util/json/value.h index 52ea1a6..5c8f75d 100644 --- a/src/util/json/value.h +++ b/src/util/json/value.h @@ -7,7 +7,7 @@ #pragma once #include // nullptr_t, size_t -#include // uint32_t +#include // uint8_t, uint32_t #include #include // istream, ostream #include @@ -29,7 +29,7 @@ private: friend class Serializer; public: - enum class Type { + enum class Type : uint8_t { Null, // null (case sensitive!) Bool, // true/false (case sensitive!) Number, // 123