Browse Source

Util: Use char literals instead of numbers in enums

master
Riyyi 2 years ago
parent
commit
3e2819cf93
  1. 12
      src/util/format/builder.h
  2. 3
      src/util/format/formatter.cpp
  3. 36
      src/util/format/formatter.h

12
src/util/format/builder.h

@ -17,16 +17,16 @@ class Builder {
public: public:
enum class Align : uint8_t { enum class Align : uint8_t {
None, None,
Left = 60, // '<' Left = '<',
Right = 62, // '>' Right = '>',
Center = 94, // '^' Center = '^',
}; };
enum class Sign : uint8_t { enum class Sign : uint8_t {
None, None,
Negative = 45, // '-' Negative = '-',
Both = 43, // '+' Both = '+',
Space = 32, // ' ' Space = ' ',
}; };
explicit Builder(std::stringstream& builder) explicit Builder(std::stringstream& builder)

3
src/util/format/formatter.cpp

@ -4,8 +4,7 @@
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
#include <cstddef> // size_t #include <cstdint> // uint8_t
#include <cstdint> // int32_t, uint32_t, int64_t,
#include <cstring> // strlen #include <cstring> // strlen
#include <string> #include <string>
#include <string_view> #include <string_view>

36
src/util/format/formatter.h

@ -23,29 +23,29 @@
namespace Util::Format { namespace Util::Format {
enum class PresentationType : uint8_t { enum class PresentationType : uint8_t {
None, // Defaults are any of: 'dgcsp', depending on the type None,
// Interger // Interger
Binary = 98, // 'b' Binary = 'b',
BinaryUppercase = 66, // 'B' BinaryUppercase = 'B',
Decimal = 100, // 'd' Decimal = 'd',
Octal = 111, // 'o' Octal = 'o',
Hex = 120, // 'x' Hex = 'x',
HexUppercase = 88, // 'X' HexUppercase = 'X',
// Floating-point // Floating-point
Hexfloat = 97, // 'a' Hexfloat = 'a',
HexfloatUppercase = 65, // 'A' HexfloatUppercase = 'A',
Exponent = 101, // 'e' Exponent = 'e',
ExponentUppercase = 69, // 'E' ExponentUppercase = 'E',
FixedPoint = 102, // 'f' FixedPoint = 'f',
FixedPointUppercase = 70, // 'F' FixedPointUppercase = 'F',
General = 103, // 'g' General = 'g',
GeneralUppercase = 71, // 'G' GeneralUppercase = 'G',
// Character // Character
Character = 99, // 'c' Character = 'c',
// String // String
String = 115, // 's' String = 's',
// Pointer // Pointer
Pointer = 112, // 'p' Pointer = 'p',
}; };
struct Specifier { struct Specifier {

Loading…
Cancel
Save