Skip to content

Commit ef8d3f4

Browse files
committed
Corrections
1 parent 886c964 commit ef8d3f4

3 files changed

Lines changed: 24 additions & 29 deletions

File tree

src/lib/CalendarConverter.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -517,12 +517,6 @@ namespace fbcpp::impl
517517
client.getUtil()->encodeTimeStampTz(
518518
statusWrapper, &opaque.value, 1u, 1u, 1u, 0u, 0u, 0u, 0u, timestampTz.zone.c_str());
519519

520-
/* FIXME:
521-
const auto ticks = (timestampTz.utcTimestamp - BASE_EPOCH).count() / 100;
522-
523-
opaque.value.utc_timestamp.timestamp_date = static_cast<ISC_DATE>(ticks / TICKS_PER_DAY);
524-
opaque.value.utc_timestamp.timestamp_time = static_cast<ISC_TIME>(ticks % TICKS_PER_DAY);
525-
*/
526520
const auto utcOpaque = timestampToOpaqueTimestamp(timestampTz.utcTimestamp);
527521
opaque.value.utc_timestamp = utcOpaque.value;
528522

@@ -666,7 +660,6 @@ namespace fbcpp::impl
666660
if (offsetDuration % std::chrono::minutes{1} != std::chrono::microseconds::zero())
667661
throwInvalidTimestampValue();
668662

669-
// FIXME:
670663
std::string resolvedTimeZoneName;
671664
opaqueTimestampTzToTimestampTz(encoded, &resolvedTimeZoneName);
672665

src/lib/NumericConverter.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,17 @@ namespace fbcpp::impl
163163
throw DatabaseException(client, STATUS_NUMERIC_OUT_OF_RANGE);
164164
}
165165

166+
[[noreturn]] void throwConversionErrorFromString(const std::string& str)
167+
{
168+
const std::intptr_t STATUS_CONVERSION_ERROR_FROM_STRING[] = {
169+
isc_convert_error,
170+
reinterpret_cast<std::intptr_t>(str.c_str()),
171+
isc_arg_end,
172+
};
173+
174+
throw DatabaseException(client, STATUS_CONVERSION_ERROR_FROM_STRING);
175+
}
176+
166177
public:
167178
template <IntegralNumber To, IntegralNumber From>
168179
To numberToNumber(const ScaledNumber<From>& from, int toScale)
@@ -426,17 +437,6 @@ namespace fbcpp::impl
426437
}
427438

428439
private:
429-
[[noreturn]] void throwConversionErrorFromString(const std::string& str)
430-
{
431-
const std::intptr_t STATUS_CONVERSION_ERROR_FROM_STRING[] = {
432-
isc_convert_error,
433-
reinterpret_cast<std::intptr_t>(str.c_str()),
434-
isc_arg_end,
435-
};
436-
437-
throw DatabaseException(client, STATUS_CONVERSION_ERROR_FROM_STRING);
438-
}
439-
440440
double powerOfTen(int scale) noexcept // FIXME: only for double?
441441
{
442442
/* FIXME:

src/lib/Statement.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,6 @@ namespace fbcpp
10391039
message[descriptor.offset] = numericConverter.stringToBoolean(value);
10401040
break;
10411041

1042-
// FIXME: scale
10431042
case DescriptorAdjustedType::INT16:
10441043
case DescriptorAdjustedType::INT32:
10451044
case DescriptorAdjustedType::INT64:
@@ -1066,8 +1065,6 @@ namespace fbcpp
10661065
}
10671066

10681067
#if FB_CPP_USE_BOOST_MULTIPRECISION != 0
1069-
// FIXME: try/rethrow when parsing
1070-
// FIXME: review
10711068
const auto parseDecimalToBoostInt128 = [this](std::string_view text)
10721069
{
10731070
bool isNegative = false;
@@ -1080,7 +1077,7 @@ namespace fbcpp
10801077
}
10811078

10821079
if (pos == text.size())
1083-
this->numericConverter.throwNumericOutOfRange(); // FIXME: conversion error
1080+
this->numericConverter.throwConversionErrorFromString(std::string{text});
10841081

10851082
BoostInt128 result{};
10861083

@@ -1089,7 +1086,7 @@ namespace fbcpp
10891086
const char c = text[pos];
10901087

10911088
if (c < '0' || c > '9')
1092-
this->numericConverter.throwNumericOutOfRange(); // FIXME: conversion error
1089+
this->numericConverter.throwConversionErrorFromString(std::string{text});
10931090

10941091
result *= 10;
10951092
result += static_cast<int>(c - '0');
@@ -1113,7 +1110,7 @@ namespace fbcpp
11131110
const auto convResult =
11141111
std::from_chars(strValue.data(), strValue.data() + strValue.size(), intValue);
11151112
if (convResult.ec != std::errc{} || convResult.ptr != strValue.data() + strValue.size())
1116-
numericConverter.throwNumericOutOfRange(); // FIXME: conversion error
1113+
numericConverter.throwConversionErrorFromString(strValue);
11171114
auto scaledValue = ScaledInt64{intValue, scale};
11181115

11191116
if (scale != descriptor.scale)
@@ -1134,7 +1131,7 @@ namespace fbcpp
11341131
double doubleValue;
11351132
const auto convResult = std::from_chars(value.data(), value.data() + value.size(), doubleValue);
11361133
if (convResult.ec != std::errc{} || convResult.ptr != value.data() + value.size())
1137-
numericConverter.throwNumericOutOfRange(); // FIXME: conversion error
1134+
numericConverter.throwConversionErrorFromString(std::string{value});
11381135
setDouble(index, doubleValue);
11391136
return;
11401137
}
@@ -1166,8 +1163,14 @@ namespace fbcpp
11661163
#if FB_CPP_USE_BOOST_MULTIPRECISION != 0
11671164
case DescriptorAdjustedType::DECFLOAT16:
11681165
case DescriptorAdjustedType::DECFLOAT34:
1169-
// FIXME: try/rethrow when parsing
1170-
setBoostDecFloat34(index, BoostDecFloat34{value});
1166+
try
1167+
{
1168+
setBoostDecFloat34(index, BoostDecFloat34{value});
1169+
}
1170+
catch (...)
1171+
{
1172+
numericConverter.throwConversionErrorFromString(std::string{value});
1173+
}
11711174
return;
11721175
#endif
11731176

@@ -2092,7 +2095,6 @@ namespace fbcpp
20922095
return outDescriptors[index];
20932096
}
20942097

2095-
// FIXME: typeName unneeded or incorrect?
20962098
///
20972099
/// @brief Converts and writes numeric parameter values following descriptor rules.
20982100
///
@@ -2237,7 +2239,7 @@ namespace fbcpp
22372239
T convertNumber(
22382240
const Descriptor& descriptor, const std::byte* data, std::optional<int>& toScale, const char* toTypeName)
22392241
{
2240-
if (!toScale.has_value()) // FIXME: ?
2242+
if (!toScale.has_value())
22412243
{
22422244
switch (descriptor.adjustedType)
22432245
{

0 commit comments

Comments
 (0)