[ox] Cleanup String/StringView conversions, MallocaPtr

This commit is contained in:
2023-11-23 01:34:16 -06:00
parent 5b91ad25c2
commit a84a829769
17 changed files with 66 additions and 48 deletions

View File

@@ -37,32 +37,32 @@ ClArgs::ClArgs(int argc, const char **args) noexcept {
}
}
bool ClArgs::getBool(ox::CRStringView arg, bool defaultValue) const noexcept {
bool ClArgs::getBool(ox::CRString arg, bool defaultValue) const noexcept {
auto [value, err] = m_ints.at(arg);
return !err ? *value : defaultValue;
}
String ClArgs::getString(ox::CRStringView arg, const char *defaultValue) const noexcept {
String ClArgs::getString(ox::CRString arg, const char *defaultValue) const noexcept {
auto [value, err] = m_strings.at(arg);
return !err ? *value : defaultValue;
}
int ClArgs::getInt(ox::CRStringView arg, int defaultValue) const noexcept {
int ClArgs::getInt(ox::CRString arg, int defaultValue) const noexcept {
auto [value, err] = m_ints.at(arg);
return !err ? *value : defaultValue;
}
Result<bool> ClArgs::getBool(ox::CRStringView arg) const noexcept {
Result<bool> ClArgs::getBool(ox::CRString arg) const noexcept {
oxRequire(out, m_bools.at(arg));
return *out;
}
Result<String> ClArgs::getString(ox::CRStringView argName) const noexcept {
Result<String> ClArgs::getString(ox::CRString argName) const noexcept {
oxRequire(out, m_strings.at(argName));
return *out;
}
Result<int> ClArgs::getInt(ox::CRStringView arg) const noexcept {
Result<int> ClArgs::getInt(ox::CRString arg) const noexcept {
oxRequire(out, m_ints.at(arg));
return *out;
}

View File

@@ -23,21 +23,21 @@ class ClArgs {
ClArgs(int argc, const char **args) noexcept;
[[nodiscard]]
bool getBool(ox::CRStringView arg, bool defaultValue) const noexcept;
bool getBool(ox::CRString arg, bool defaultValue) const noexcept;
[[nodiscard]]
String getString(ox::CRStringView argName, const char *defaultValue) const noexcept;
String getString(ox::CRString argName, const char *defaultValue) const noexcept;
[[nodiscard]]
int getInt(ox::CRStringView arg, int defaultValue) const noexcept;
int getInt(ox::CRString arg, int defaultValue) const noexcept;
[[nodiscard]]
Result<bool> getBool(ox::CRStringView arg) const noexcept;
Result<bool> getBool(ox::CRString arg) const noexcept;
[[nodiscard]]
Result<String> getString(ox::CRStringView argName) const noexcept;
Result<String> getString(ox::CRString argName) const noexcept;
Result<int> getInt(ox::CRStringView arg) const noexcept;
Result<int> getInt(ox::CRString arg) const noexcept;
};