[ox] Update more C strings to StringViews

This commit is contained in:
2023-01-03 03:31:22 -06:00
parent 5508dc5dc0
commit 3cd638737a
4 changed files with 28 additions and 25 deletions

View File

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

View File

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