yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
hex.h
Go to the documentation of this file.
1#ifndef YAZE_UTIL_HEX_H
2#define YAZE_UTIL_HEX_H
3
4#include <cstdint>
5#include <string>
6
7#include "absl/strings/string_view.h"
8
9namespace yaze {
10namespace util {
11
14 bool uppercase = true;
15};
16
17std::string HexByte(uint8_t byte, HexStringParams params = {});
18std::string HexWord(uint16_t word, HexStringParams params = {});
19std::string HexLong(uint32_t dword, HexStringParams params = {});
20std::string HexLongLong(uint64_t qword, HexStringParams params = {});
21
22// Strict hexadecimal parsing shared by the CLI, core manifest loading, and the
23// editor. The whole string must be a hexadecimal number, so a value that only
24// starts with digits is rejected instead of silently truncating:
25//
26// "0x1E8000" -> 0x1E8000 "0x1E80zz" -> rejected
27// " 0x1E8000 " -> 0x1E8000 "1E 80" -> rejected
28// "$1E8000" -> 0x1E8000 "" / "0x" -> rejected
29// "0X1E8000" -> 0x1E8000 "-1" -> rejected
30//
31// Surrounding ASCII whitespace is ignored. A value that does not fit the
32// requested type is rejected rather than wrapped or truncated. Returns false
33// and leaves *out untouched when the string does not parse.
34bool ParseHexString(absl::string_view str, uint64_t* out);
35bool ParseHexString(absl::string_view str, uint32_t* out);
36bool ParseHexString(absl::string_view str, int* out);
37
38} // namespace util
39} // namespace yaze
40
41#endif
std::string HexWord(uint16_t word, HexStringParams params)
Definition hex.cc:44
std::string HexByte(uint8_t byte, HexStringParams params)
Definition hex.cc:33
std::string HexLongLong(uint64_t qword, HexStringParams params)
Definition hex.cc:66
bool ParseHexString(absl::string_view str, uint64_t *out)
Definition hex.cc:133
std::string HexLong(uint32_t dword, HexStringParams params)
Definition hex.cc:55
enum yaze::util::HexStringParams::Prefix prefix