@@ -17,7 +17,7 @@ typedef SDL_JoystickGUID SDL_GUID; //NOLINT(modernize-use-using), it's used in e
1717}
1818
1919
20- namespace SDL {
20+ namespace sdl {
2121
2222 struct GUID {
2323 public:
@@ -27,43 +27,43 @@ namespace SDL {
2727 ArrayType m_guid;
2828
2929 public:
30- enum class FormatType { Long, Short };
30+ enum class FormatType : u8 { Long, Short };
3131
3232 constexpr GUID () : m_guid{} { }
33- constexpr GUID (const ArrayType& data) : m_guid{ data } { }
33+ explicit constexpr GUID (const ArrayType& data) : m_guid{ data } { }
3434
35- GUID (const SDL_GUID& data);
35+ explicit GUID (const SDL_GUID& data);
3636
3737 [[nodiscard]] static helper::expected<GUID, std::string> from_string (const std::string& value);
3838
3939 [[nodiscard]] bool operator ==(const GUID& other) const ;
4040
4141 [[nodiscard]] std::string to_string (FormatType type = FormatType::Long) const ;
4242 };
43- } // namespace SDL
43+ } // namespace sdl
4444
4545
4646template <>
47- struct fmt ::formatter<SDL ::GUID> : formatter<std::string> {
48- auto format (const SDL ::GUID& guid, format_context& ctx) {
47+ struct fmt ::formatter<sdl ::GUID> : formatter<std::string> {
48+ auto format (const sdl ::GUID& guid, format_context& ctx) {
4949 return formatter<std::string>::format (guid.to_string (), ctx);
5050 }
5151};
5252
53- namespace {
53+ namespace { // NOLINT(cert-dcl59-cpp,google-build-namespaces)
5454
5555 // decode a single_hex_number
56- [[nodiscard]] constexpr const_utils::expected<u8 , std::string> single_hex_number (char n ) {
57- if (n >= ' 0' && n <= ' 9' ) {
58- return const_utils::expected<u8 , std::string>::good_result (static_cast <u8 >(n - ' 0' ));
56+ [[nodiscard]] constexpr const_utils::expected<u8 , std::string> single_hex_number (char input ) {
57+ if (input >= ' 0' && input <= ' 9' ) {
58+ return const_utils::expected<u8 , std::string>::good_result (static_cast <u8 >(input - ' 0' ));
5959 }
6060
61- if (n >= ' A' && n <= ' F' ) {
62- return const_utils::expected<u8 , std::string>::good_result (static_cast <u8 >(n - ' A' + 10 ));
61+ if (input >= ' A' && input <= ' F' ) {
62+ return const_utils::expected<u8 , std::string>::good_result (static_cast <u8 >(input - ' A' + 10 ));
6363 }
6464
65- if (n >= ' a' && n <= ' f' ) {
66- return const_utils::expected<u8 , std::string>::good_result (static_cast <u8 >(n - ' a' + 10 ));
65+ if (input >= ' a' && input <= ' f' ) {
66+ return const_utils::expected<u8 , std::string>::good_result (static_cast <u8 >(input - ' a' + 10 ));
6767 }
6868
6969 return const_utils::expected<u8 , std::string>::error_result (" the input must be a valid hex character" );
@@ -72,22 +72,22 @@ namespace {
7272 // decode a single 2 digit color value in hex
7373 [[nodiscard]] constexpr const_utils::expected<u8 , std::string> single_hex_color_value (const char * input) {
7474
75- const auto first = single_hex_number (input[0 ]);
75+ const auto first = single_hex_number (input[0 ]); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
7676
7777 PROPAGATE (first, u8 , std::string);
7878
79- const auto second = single_hex_number (input[1 ]);
79+ const auto second = single_hex_number (input[1 ]); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
8080
8181 PROPAGATE (second, u8 , std::string);
8282
8383 return const_utils::expected<u8 , std::string>::good_result ((first.value () << 4 ) | second.value ());
8484 }
8585
86- [[nodiscard]] constexpr const_utils::expected<SDL ::GUID, std::string>
86+ [[nodiscard]] constexpr const_utils::expected<sdl ::GUID, std::string>
8787 get_guid_from_string_impl (const char * input, std::size_t size) {
8888
8989 if (size == 0 ) {
90- return const_utils::expected<SDL ::GUID, std::string>::error_result (
90+ return const_utils::expected<sdl ::GUID, std::string>::error_result (
9191 " not enough data to determine the literal type"
9292 );
9393 }
@@ -102,11 +102,11 @@ namespace {
102102 width = 3 ;
103103 } else {
104104
105- return const_utils::expected<SDL ::GUID, std::string>::error_result (" Unrecognized guid literal" );
105+ return const_utils::expected<sdl ::GUID, std::string>::error_result (" Unrecognized guid literal" );
106106 }
107107
108108
109- SDL ::GUID::ArrayType result{};
109+ sdl ::GUID::ArrayType result{};
110110
111111 for (size_t i = 0 ; i < amount; ++i) {
112112 size_t offset = i * (width);
@@ -115,30 +115,30 @@ namespace {
115115 const auto temp_result =
116116 single_hex_color_value (input + offset); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
117117
118- PROPAGATE (temp_result, SDL ::GUID, std::string);
118+ PROPAGATE (temp_result, sdl ::GUID, std::string);
119119
120120 const auto value = temp_result.value ();
121121
122122 result.at (i) = value;
123123 }
124124
125- return const_utils::expected<SDL ::GUID, std::string>::good_result (SDL ::GUID{ result });
125+ return const_utils::expected<sdl ::GUID, std::string>::good_result (sdl ::GUID{ result });
126126 }
127127
128128} // namespace
129129
130130
131131namespace detail {
132132
133- [[nodiscard]] constexpr const_utils::expected<SDL ::GUID, std::string> get_guid_from_string (const std::string& input
133+ [[nodiscard]] constexpr const_utils::expected<sdl ::GUID, std::string> get_guid_from_string (const std::string& input
134134 ) {
135135 return get_guid_from_string_impl (input.c_str (), input.size ());
136136 }
137137
138138} // namespace detail
139139
140140
141- consteval SDL ::GUID operator " " _guid(const char * input, std::size_t size) {
141+ consteval sdl ::GUID operator " " _guid(const char * input, std::size_t size) {
142142 const auto result = get_guid_from_string_impl (input, size);
143143
144144 CONSTEVAL_STATIC_ASSERT (result.has_value (), " incorrect guid literal" );
0 commit comments