[ox] Fix remaining implicit conversion issues
This commit is contained in:
5
deps/ox/src/ox/clargs/CMakeLists.txt
vendored
5
deps/ox/src/ox/clargs/CMakeLists.txt
vendored
@@ -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
|
||||
|
8
deps/ox/src/ox/clargs/clargs.cpp
vendored
8
deps/ox/src/ox/clargs/clargs.cpp
vendored
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
6
deps/ox/src/ox/clargs/clargs.hpp
vendored
6
deps/ox/src/ox/clargs/clargs.hpp
vendored
@@ -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;
|
||||
|
Reference in New Issue
Block a user