mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Factor out a single parseNumber utility function (#1839)
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <stddef.h>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
#define RGBDS_UTIL_HPP
|
||||
|
||||
#include <algorithm>
|
||||
#include <ctype.h>
|
||||
#include <ctype.h> // toupper
|
||||
#include <numeric>
|
||||
#include <optional>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
@@ -13,12 +14,21 @@
|
||||
|
||||
#include "helpers.hpp"
|
||||
|
||||
enum NumberBase {
|
||||
BASE_AUTO = 0,
|
||||
BASE_2 = 2,
|
||||
BASE_8 = 8,
|
||||
BASE_10 = 10,
|
||||
BASE_16 = 16,
|
||||
};
|
||||
|
||||
bool isNewline(int c);
|
||||
bool isBlankSpace(int c);
|
||||
bool isWhitespace(int c);
|
||||
bool isPrintable(int c);
|
||||
bool isLetter(int c);
|
||||
bool isDigit(int c);
|
||||
bool isBinDigit(int c);
|
||||
bool isOctDigit(int c);
|
||||
bool isHexDigit(int c);
|
||||
bool isAlphanumeric(int c);
|
||||
@@ -27,6 +37,8 @@ bool startsIdentifier(int c);
|
||||
bool continuesIdentifier(int c);
|
||||
|
||||
uint8_t parseHexDigit(int c);
|
||||
std::optional<uint64_t> parseNumber(char const *&str, NumberBase base = BASE_AUTO);
|
||||
std::optional<uint64_t> parseWholeNumber(char const *str, NumberBase base = BASE_AUTO);
|
||||
|
||||
char const *printChar(int c);
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#ifndef RGBDS_VERBOSITY_HPP
|
||||
#define RGBDS_VERBOSITY_HPP
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "style.hpp"
|
||||
|
||||
// This macro does not evaluate its arguments unless the condition is true.
|
||||
|
||||
Reference in New Issue
Block a user