[ox] Cleanup String/StringView conversions, MallocaPtr
This commit is contained in:
12
deps/ox/src/ox/clargs/clargs.cpp
vendored
12
deps/ox/src/ox/clargs/clargs.cpp
vendored
@@ -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;
|
||||
}
|
||||
|
12
deps/ox/src/ox/clargs/clargs.hpp
vendored
12
deps/ox/src/ox/clargs/clargs.hpp
vendored
@@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user