1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-13 03:14:38 +00:00

Update ZAPD (#1569)

* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "094e79734"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "094e79734"
git-subrepo:
  version:  "0.4.6"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "110b9eb"

* Add EnumData.xml where some names are now externalized

* Remove legacy typedefs for zapd, no longer needed!
This commit is contained in:
Dragorn421 2023-10-25 03:36:10 +02:00 committed by GitHub
parent 503f6d86d5
commit 4e55168eaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
97 changed files with 4225 additions and 2328 deletions

View file

@ -106,9 +106,35 @@ public:
return std::all_of(str.begin(), str.end(), ::isdigit);
}
static bool HasOnlyHexDigits(const std::string& str)
static bool IsValidHex(std::string_view str)
{
return std::all_of(str.begin(), str.end(), ::isxdigit);
if (str.length() < 3)
{
return false;
}
if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X'))
{
return std::all_of(str.begin() + 2, str.end(), ::isxdigit);
}
return false;
}
static bool IsValidOffset(std::string_view str)
{
if (str.length() == 1)
{
// 0 is a valid offset
return isdigit(str[0]);
}
return IsValidHex(str);
}
static bool IsValidHex(const std::string& str)
{
return IsValidHex(std::string_view(str.c_str()));
}
static std::string ToUpper(const std::string& str)
@ -123,4 +149,66 @@ public:
return std::equal(a.begin(), a.end(), b.begin(), b.end(),
[](char a, char b) { return tolower(a) == tolower(b); });
}
/**
* Converts a std::string formatted in camelCase into one in SCREAMING_SNAKE_CASE. Since this
* will mostly be used on symbols that start with either 'g' or 's', an option is included to
* skip these.
*/
static std::string camelCaseTo_SCREAMING_SNAKE_CASE(const std::string& in, bool skipSP)
{
std::string out = "";
const char* ptr = in.c_str();
char ch = *ptr;
// Switch checks for 'g'/'s'/'\0', looks at next character if skipSP enabled and string is
// nonempty.
switch (ch)
{
case 'g':
case 's':
if (skipSP)
{
// Print it anyway if the next character is lowercase, e.g. "gameplay_keep_...".
if (!isupper(ptr[1]))
{
out.push_back(toupper(ch));
}
if ((ch = *++ptr) == '\0')
{
case '\0':
// This is reached either by the if or the case label, avoiding duplication.
return out;
}
}
[[fallthrough]];
default:
if (islower(ch))
{
out.push_back(toupper(ch));
}
else
{
out.push_back(ch);
}
break;
}
while ((ch = *++ptr) != '\0')
{
if (islower(ch))
{
out.push_back(toupper(ch));
}
else
{
if (isupper(ch) && !(isupper(ptr[1]) && isupper(ptr[-1])))
{
out.push_back('_');
}
out.push_back(ch);
}
}
return out;
}
};