MCPcopy Create free account
hub / github.com/ByConity/ByConity / readIntText

Function readIntText

base/common/JSON.cpp:56–95  ·  view source on GitHub ↗

Прочитать знаковое целое в простом формате из не-0-terminated строки.

Source from the content-addressed store, hash-verified

54
55/// Прочитать знаковое целое в простом формате из не-0-terminated строки.
56static Int64 readIntText(const char * buf, const char * end)
57{
58 bool negative = false;
59 UInt64 x = 0;
60
61 if (buf == end)
62 throw JSONException("JSON: cannot parse signed integer: unexpected end of data.");
63
64 bool run = true;
65 while (buf != end && run)
66 {
67 switch (*buf)
68 {
69 case '+':
70 break;
71 case '-':
72 negative = true;
73 break;
74 case '0':
75 case '1':
76 case '2':
77 case '3':
78 case '4':
79 case '5':
80 case '6':
81 case '7':
82 case '8':
83 case '9':
84 x *= 10;
85 x += *buf - '0';
86 break;
87 default:
88 run = false;
89 break;
90 }
91 ++buf;
92 }
93
94 return negative ? -x : x;
95}
96
97
98/// Прочитать число с плавающей запятой в простом формате, с грубым округлением, из не-0-terminated строки.

Callers 3

readFloatTextFunction · 0.70
getIntMethod · 0.70
mainFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected