[ox] Fix remaining implicit conversion issues

This commit is contained in:
2023-06-06 23:32:23 -05:00
parent acf04665bc
commit 3fdfee33a9
50 changed files with 218 additions and 191 deletions

View File

@@ -12,6 +12,11 @@ set_property(
POSITION_INDEPENDENT_CODE ON
)
if(NOT MSVC)
target_compile_options(OxClArgs PRIVATE -Wsign-conversion)
target_compile_options(OxClArgs PRIVATE -Wconversion)
endif()
target_link_libraries(
OxClArgs PUBLIC
OxStd

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 - 2022 gary@drinkingtea.net
* Copyright 2015 - 2023 gary@drinkingtea.net
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -12,7 +12,7 @@
namespace ox {
ClArgs::ClArgs(int argc, const char **args) noexcept {
for (int i = 0; i < argc; i++) {
for (auto i = 0u; i < static_cast<unsigned>(argc); ++i) {
String arg = args[i];
if (arg[0] == '-') {
while (arg[0] == '-' && arg.len()) {
@@ -20,7 +20,7 @@ ClArgs::ClArgs(int argc, const char **args) noexcept {
}
m_bools[arg] = true;
// parse additional arguments
if (i < argc && args[i + 1]) {
if (i < static_cast<unsigned>(argc) && args[i + 1]) {
String val = args[i + 1];
if (val.len() && val[i] != '-') {
if (val == "false") {
@@ -30,7 +30,7 @@ ClArgs::ClArgs(int argc, const char **args) noexcept {
if (auto r = ox_atoi(val.c_str()); r.error == 0) {
m_ints[arg] = r.value;
}
i++;
++i;
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 - 2022 gary@drinkingtea.net
* Copyright 2015 - 2023 gary@drinkingtea.net
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -26,13 +26,15 @@ class ClArgs {
bool getBool(ox::CRStringView arg, bool defaultValue) const noexcept;
[[nodiscard]]
String getString(ox::CRStringView argName, const char *defaultArg) const noexcept;
String getString(ox::CRStringView argName, const char *defaultValue) const noexcept;
[[nodiscard]]
int getInt(ox::CRStringView arg, int defaultValue) const noexcept;
[[nodiscard]]
Result<bool> getBool(ox::CRStringView arg) const noexcept;
[[nodiscard]]
Result<String> getString(ox::CRStringView argName) const noexcept;
Result<int> getInt(ox::CRStringView arg) const noexcept;