suppress conversion warnings

-- tolower takes chars and returns chars, types are int because C only deals with ints
-- format parameter is size_t but there is no std parsing function that returns size_t. stoull is used instead as the widest alternative, and then the cast is applied to suppress the conversion warnings
This commit is contained in:
Crzyrndm 2018-06-18 23:24:13 +12:00
parent 1066b1007c
commit 5a14d7b9d1
3 changed files with 7 additions and 4 deletions

View File

@ -376,7 +376,6 @@ void cell::hyperlink(const std::string &url)
auto ws = worksheet(); auto ws = worksheet();
auto &manifest = ws.workbook().manifest(); auto &manifest = ws.workbook().manifest();
bool existing = false;
d_->hyperlink_ = detail::hyperlink_impl(); d_->hyperlink_ = detail::hyperlink_impl();

View File

@ -198,7 +198,11 @@ pattern_fill_type from_string(const std::string &string)
auto toLower = [](std::string str) { auto toLower = [](std::string str) {
auto bg{ std::begin (str) }; auto bg{ std::begin (str) };
auto en{ std::end (str) }; auto en{ std::end (str) };
std::transform (bg, en, bg, tolower); std::transform(bg, en, bg,
[](char c) {
// static cast to avoid int -> char narrowing warning
return static_cast<char>(tolower(c));
});
return str; return str;
}; };

View File

@ -246,7 +246,7 @@ cell xlsx_consumer::read_cell()
if (parser().attribute_present("s")) if (parser().attribute_present("s"))
{ {
cell.format(target_.format(std::stoull(parser().attribute("s")))); cell.format(target_.format(static_cast<std::size_t>(std::stoull(parser().attribute("s")))));
} }
auto has_value = false; auto has_value = false;
@ -673,7 +673,7 @@ void xlsx_consumer::read_worksheet_sheetdata()
if (parser().attribute_present("s")) if (parser().attribute_present("s"))
{ {
cell.format(target_.format(std::stoull(parser().attribute("s")))); cell.format(target_.format(static_cast<std::size_t>(std::stoull(parser().attribute("s")))));
} }
auto has_value = false; auto has_value = false;