From 65e912a05c2cc8999eb9c3c91b135fe08ae68c9b Mon Sep 17 00:00:00 2001 From: Dmitry Galuza Date: Fri, 20 Nov 2015 00:48:17 +0300 Subject: [PATCH] =?UTF-8?q?=E2=96=88=E2=96=88=E2=96=88=E2=96=88=E2=96=88?= =?UTF-8?q?=E2=96=88=E2=96=88=E2=96=88=E2=96=88=E2=96=88=E2=96=88:=20New?= =?UTF-8?q?=20fields=20into=20example=20[#METR-18831]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dbms/include/DB/IO/ReadHelpers.h | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/dbms/include/DB/IO/ReadHelpers.h b/dbms/include/DB/IO/ReadHelpers.h index 483947f7b58..2d07389e740 100644 --- a/dbms/include/DB/IO/ReadHelpers.h +++ b/dbms/include/DB/IO/ReadHelpers.h @@ -118,6 +118,14 @@ inline bool checkString(const String & s, ReadBuffer & buf) return checkString(s.c_str(), buf); } +inline bool checkChar(char c, ReadBuffer & buf) +{ + if (buf.eof() || *buf.position() != c) + return false; + ++buf.position(); + return true; +} + inline void readBoolText(bool & x, ReadBuffer & buf) { char tmp = '0'; @@ -250,7 +258,7 @@ bool exceptionPolicySelector(ExcepFun && excep_f, NoExcepFun && no_excep_f, Args /// грубо -template +template ReturnType readFloatTextImpl(T & x, ReadBuffer & buf) { static constexpr bool throw_exception = std::is_same::value; @@ -293,9 +301,6 @@ ReturnType readFloatTextImpl(T & x, ReadBuffer & buf) case '-': negative = true; break; - case '.': - after_point = true; - break; case '0': case '1': case '2': @@ -344,6 +349,12 @@ ReturnType readFloatTextImpl(T & x, ReadBuffer & buf) return ReturnType(parse_special_value("AN", std::numeric_limits::quiet_NaN())); default: + if (point_symbol == *buf.position()) + { + after_point = true; + break; + } + if (negative) x = -x; return ReturnType(true); @@ -362,6 +373,12 @@ inline bool tryReadFloatText(T & x, ReadBuffer & buf) return readFloatTextImpl(x, buf); } +template +inline bool tryReadFloatTextUnderscore(T & x, ReadBuffer & buf) +{ + return readFloatTextImpl(x, buf); +} + template inline void readFloatText(T & x, ReadBuffer & buf) {