Skip to content

Commit

Permalink
clean up some compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
phlptp committed May 5, 2024
1 parent 90563bd commit d95f4f6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
13 changes: 9 additions & 4 deletions units/commodity_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace commodities {
template<size_t N>
constexpr std::uint32_t generateStringCode(const char (&code)[N])
{
static_assert(N == 6, "invalid string code");
static_assert(N == 6, "invalid string code, must be 5 characters");
return 0x60000000U +
((static_cast<std::uint32_t>(code[0] - '_') & 0X1FU) << 20U) +
((static_cast<std::uint32_t>(code[1] - '_') & 0X1FU) << 15U) +
Expand All @@ -54,7 +54,7 @@ namespace commodities {
template<size_t N>
constexpr std::uint32_t generateStringCodeUpper(const char (&code)[N])
{
static_assert(N == 6, "invalid string code");
static_assert(N == 6, "invalid string code, must be 5 characters");
return 0x70000000U +
((static_cast<std::uint32_t>(code[0] - '@') & 0X1FU) << 20U) +
((static_cast<std::uint32_t>(code[1] - '@') & 0X1FU) << 15U) +
Expand Down Expand Up @@ -91,7 +91,7 @@ namespace commodities {
template<size_t N>
constexpr std::uint32_t generateCurrencyCode(const char (&code)[N])
{
static_assert(N == 4, "invalid string code");
static_assert(N == 4, "invalid currency code, must be 3 characters");
return 0x46000000U + (static_cast<std::uint32_t>(code[0]) << 16U) +
(static_cast<std::uint32_t>(code[1]) << 8U) +
static_cast<std::uint32_t>(code[2]);
Expand All @@ -100,7 +100,7 @@ namespace commodities {
template<size_t N>
constexpr std::uint32_t generateChemCode(const char (&code)[N])
{
static_assert(N == 5, "invalid string code");
static_assert(N == 5, "invalid chem code must be 4 characters");
return 0x4D000000U +
((static_cast<std::uint32_t>(code[0] - ' ') & 0X3FU) << 18U) +
((static_cast<std::uint32_t>(code[1] - ' ') & 0X3FU) << 12U) +
Expand Down Expand Up @@ -516,6 +516,11 @@ namespace commodities {
alcohol = generateHarmonizedCode(22, 07, 10),
choline_chloride = generateHarmonizedCode(29, 23, 10),
};

constexpr std::uint32_t package(std::uint32_t packaging, std::uint32_t commodity)
{
return packaging|commodity;
}
} // namespace commodities

} // namespace UNITS_NAMESPACE
20 changes: 10 additions & 10 deletions units/r20_conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1973,7 +1973,7 @@ namespace precise {
unitD{
"KLK",
"lactic dry material percentage",
{1.0, percent, commodities::packaging::dry + commodities::milk}},
{1.0, percent, commodities::package(commodities::packaging::dry,commodities::milk)}},
unitD{"KLX", "kilolux", kilo* lux},
unitD{
"KMA",
Expand All @@ -1991,7 +1991,7 @@ namespace precise {
"milliequivalence caustic potash per gram of product",
{1.0,
milli / g,
commodities::packaging::equivalent + commodities::chemicals::KOH}},
commodities::package(commodities::packaging::equivalent,commodities::chemicals::KOH)}},
unitD{"KPA", "kilopascal", kilo* Pa},
unitD{
"KPH",
Expand Down Expand Up @@ -2146,7 +2146,7 @@ namespace precise {
"lactose excess percentage",
{1.0,
percent,
commodities::packaging::excess + commodities::lactose}},
commodities::package(commodities::packaging::excess,commodities::lactose)}},
unitD{"LBR", "pound", lb},
unitD{"LBT", "troy pound (US)", troy::pound},
unitD{
Expand Down Expand Up @@ -2764,16 +2764,16 @@ namespace precise {
"proof litre",
{1.0,
L,
commodities::packaging::equivalent +
commodities::chemicals::alcohol}},
commodities::package(commodities::packaging::equivalent,
commodities::chemicals::alcohol)}},
unitD{"PG", "plate", {1.0, count, commodities::packaging::plate}},
unitD{
"PGL",
"proof gallon",
{1.0,
gal,
commodities::packaging::equivalent +
commodities::chemicals::alcohol}},
commodities::package(commodities::packaging::equivalent,
commodities::chemicals::alcohol)}},
unitD{"PI", "pitch", {1.0, count / in, commodities::character}},
unitD{"PK", "pack", {1.0, count, commodities::packaging::pack}},
unitD{"PL", "pail", {1.0, count, commodities::packaging::pail}},
Expand Down Expand Up @@ -2836,14 +2836,14 @@ namespace precise {
unitD{
"QB",
"page - hardcopy",
{1.0, count, commodities::packaging::page + commodities::paper}},
{1.0, count, commodities::package(commodities::packaging::page,commodities::paper)}},
unitD{"QD", "quarter dozen", {3, one}},
unitD{"QH", "quarter hour", {0.25, hr}},
unitD{"QK", "quarter kilogram", {0.25, kg}},
unitD{
"QR",
"quire",
{25.0, count, commodities::packaging::sheet + commodities::paper}},
{25.0, count, commodities::package(commodities::packaging::sheet,commodities::paper)}},
unitD{"QT", "quart (US)", us::quart},
unitD{"QTD", "dry quart (US)", us::dry::quart},
unitD{"QTI", "quart (UK)", imp::quart},
Expand Down Expand Up @@ -2934,7 +2934,7 @@ namespace precise {
"stick, cigarette",
{1.0,
count,
commodities::packaging::stick + commodities::cigarette}},
commodities::package(commodities::packaging::stick,commodities::cigarette)}},
unitD{"STL", "standard litre", L},
unitD{"STN", "ton (US)", av::ton},
unitD{"STW", "straw", {1.0, count, commodities::packaging::straw}},
Expand Down

0 comments on commit d95f4f6

Please sign in to comment.