2014-12-09 11:31:16 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-06-03 22:11:50 +00:00
|
|
|
#ifdef __clang__
|
|
|
|
#pragma clang diagnostic push
|
|
|
|
#pragma clang diagnostic ignored "-Wdouble-promotion"
|
|
|
|
#endif
|
|
|
|
|
2015-11-16 03:10:37 +00:00
|
|
|
#include <double-conversion/double-conversion.h>
|
2019-08-22 03:24:05 +00:00
|
|
|
#include <boost/noncopyable.hpp>
|
2014-12-09 11:31:16 +00:00
|
|
|
|
2018-06-03 22:11:50 +00:00
|
|
|
#ifdef __clang__
|
|
|
|
#pragma clang diagnostic pop
|
|
|
|
#endif
|
|
|
|
|
2015-11-30 15:15:45 +00:00
|
|
|
|
2014-12-09 11:31:16 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
template <bool emit_decimal_point> struct DoubleToStringConverterFlags
|
|
|
|
{
|
|
|
|
static constexpr auto flags = double_conversion::DoubleToStringConverter::NO_FLAGS;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <> struct DoubleToStringConverterFlags<true>
|
|
|
|
{
|
|
|
|
static constexpr auto flags = double_conversion::DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT;
|
|
|
|
};
|
|
|
|
|
2015-11-30 15:15:45 +00:00
|
|
|
template <bool emit_decimal_point>
|
2019-08-22 03:24:05 +00:00
|
|
|
class DoubleConverter : private boost::noncopyable
|
2014-12-09 11:31:16 +00:00
|
|
|
{
|
2015-11-30 15:15:45 +00:00
|
|
|
DoubleConverter() = default;
|
|
|
|
|
|
|
|
public:
|
2019-04-25 14:32:39 +00:00
|
|
|
/// Sign (1 byte) + DigitsBeforePoint + point (1 byte) + DigitsAfterPoint + zero byte.
|
|
|
|
/// See comment to DoubleToStringConverter::ToFixed method for explanation.
|
|
|
|
static constexpr auto MAX_REPRESENTATION_LENGTH =
|
|
|
|
1 + double_conversion::DoubleToStringConverter::kMaxFixedDigitsBeforePoint +
|
|
|
|
1 + double_conversion::DoubleToStringConverter::kMaxFixedDigitsAfterPoint + 1;
|
2015-11-30 15:15:45 +00:00
|
|
|
using BufferType = char[MAX_REPRESENTATION_LENGTH];
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2019-08-22 03:24:05 +00:00
|
|
|
static const double_conversion::DoubleToStringConverter & instance();
|
2015-11-30 15:15:45 +00:00
|
|
|
};
|
2014-12-09 11:31:16 +00:00
|
|
|
|
|
|
|
}
|