Lines Matching +full:double +full:- +full:buffering

1 //=== JSON.cpp - JSON value, parsing and serialization - C++ -----------*-===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===---------------------------------------------------------------------===//
25 return try_emplace(K, nullptr).first->getSecond(); in operator []()
28 return try_emplace(std::move(K), nullptr).first->getSecond(); in operator []()
34 return &I->second; in get()
40 return &I->second; in get()
44 return V->getAsNull(); in getNull()
49 return V->getAsBoolean(); in getBoolean()
52 std::optional<double> Object::getNumber(StringRef K) const { in getNumber()
54 return V->getAsNumber(); in getNumber()
59 return V->getAsInteger(); in getInteger()
64 return V->getAsString(); in getString()
69 return V->getAsObject(); in getObject()
74 return V->getAsObject(); in getObject()
79 return V->getAsArray(); in getArray()
84 return V->getAsArray(); in getArray()
92 if (R == RHS.end() || L.second != R->second) in operator ==()
195 // The same integer must convert to the same double, per the standard. in operator ==()
196 // However we see 64-vs-80-bit precision comparisons with gcc-7 -O3 -m32. in operator ==()
215 for (P = this; P->Parent != nullptr; P = P->Parent) in report()
217 Path::Root *R = P->Seg.root(); in report()
219 R->ErrorMessage = Msg; in report()
220 R->ErrorPath.resize(Count); in report()
221 auto It = R->ErrorPath.begin(); in report()
222 for (P = this; P->Parent != nullptr; P = P->Parent) in report()
223 *It++ = P->Seg; in report()
251 return L->first < R->first; in sortedElements()
256 // Prints a one-line version of a value that isn't our main focus.
257 // We interleave writes to OS and JOS, exploiting the lack of extra buffering.
262 JOS.rawValue(V.getAsArray()->empty() ? "[]" : "[ ... ]"); in abbreviate()
265 JOS.rawValue(V.getAsObject()->empty() ? "{}" : "{ ... }"); in abbreviate()
283 // Prints a semi-expanded version of a value that is our main focus.
296 JOS.attributeBegin(KV->first); in abbreviateChildren()
297 abbreviate(KV->second, JOS); in abbreviateChildren()
330 if (!O || !O->get(FieldName)) in printErrorContext()
334 JOS.attributeBegin(KV->first); in printErrorContext()
335 if (FieldName == StringRef(KV->first)) in printErrorContext()
336 Recurse(KV->second, Path.drop_back(), Recurse); in printErrorContext()
338 abbreviate(KV->second, JOS); in printErrorContext()
345 if (!A || S.index() >= A->size()) in printErrorContext()
362 // Simple recursive-descent JSON parser.
370 if (isUTF8(StringRef(Start, End - Start), &ErrOffset)) in checkUTF8()
373 return parseError("Invalid UTF-8 sequence"); in checkUTF8()
407 C == 'e' || C == 'E' || C == '+' || C == '-' || C == '.'; in isNumber()
420 // Bare null/true/false are easy - first char identifies them. in parseValue()
505 // Read the number into a string. (Must be null-terminated for strto*). in parseNumber()
523 if (First != '-') { in parseNumber()
609 // Parse a UTF-16 \uNNNN escape sequence. "\u" has already been consumed.
615 auto Invalid = [&] { Out.append(/* UTF-8 */ {'\xef', '\xbf', '\xbd'}); }; in parseUnicode()
617 auto Parse4Hex = [this](uint16_t &Out) -> bool { in parseUnicode()
624 Out |= (C > '9') ? (C & ~0x20) - 'A' + 10 : (C - '0'); in parseUnicode()
628 uint16_t First; // UTF-16 code unit from the first \u escape. in parseUnicode()
632 // We loop to allow proper surrogate-pair error handling. in parseUnicode()
634 // Case 1: the UTF-16 code unit is already a codepoint in the BMP. in parseUnicode()
663 encodeUtf8(0x10000 | ((First - 0xD800) << 10) | (Second - 0xDC00), Out); in parseUnicode()
678 std::make_unique<ParseError>(Msg, Line, P - StartOfLine, P - Start)); in parseError()
694 // Fast-path for ASCII, which is valid UTF-8. in isUTF8()
703 *ErrOffset = Rest - Data; in isUTF8()
708 // This isn't particularly efficient, but is only for error-recovery. in fixUTF8()
714 Codepoints.resize(Out32 - Codepoints.data()); in fixUTF8()
720 Res.resize(reinterpret_cast<char *>(Out8) - Res.data()); in fixUTF8()
771 OS << format("%.*g", std::numeric_limits<double>::max_digits10, in value()
786 attribute(E->first, E->second); in value()
850 Indent -= IndentSize; in arrayEnd()
869 Indent -= IndentSize; in objectEnd()
890 assert(false && "Invalid UTF-8 in attribute key"); in attributeBegin()