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

3
src/util/format/formatter.cpp

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

36
src/util/format/formatter.h

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

Loading…
Cancel
Save