mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Factor out a single parseNumber utility function (#1839)
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user