Lines Matching +full:input +full:- +full:value
1 //===- lib/Support/YAMLTraits.cpp -----------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
34 //===----------------------------------------------------------------------===//
36 //===----------------------------------------------------------------------===//
51 llvm_unreachable("Only supported for Input"); in setAllowUnknownKeys()
54 //===----------------------------------------------------------------------===//
55 // Input
56 //===----------------------------------------------------------------------===//
58 Input::Input(StringRef InputContent, void *Ctxt, in Input() function in Input
63 DocIterator = Strm->begin(); in Input()
66 Input::Input(MemoryBufferRef Input, void *Ctxt, in Input() function in Input
68 : IO(Ctxt), Strm(new Stream(Input, SrcMgr, false, &EC)) { in Input()
71 DocIterator = Strm->begin(); in Input()
74 Input::~Input() = default;
76 std::error_code Input::error() { return EC; } in error()
78 bool Input::outputting() const { in outputting()
82 bool Input::setCurrentDocument() { in setCurrentDocument()
83 if (DocIterator != Strm->end()) { in setCurrentDocument()
84 Node *N = DocIterator->getRoot(); in setCurrentDocument()
103 bool Input::nextDocument() { in nextDocument()
104 return ++DocIterator != Strm->end(); in nextDocument()
107 const Node *Input::getCurrentNode() const { in getCurrentNode()
108 return CurrentNode ? CurrentNode->_node : nullptr; in getCurrentNode()
111 bool Input::mapTag(StringRef Tag, bool Default) { in mapTag()
117 std::string foundTag = CurrentNode->_node->getVerbatimTag(); in mapTag()
126 void Input::beginMapping() { in beginMapping()
132 MN->ValidKeys.clear(); in beginMapping()
136 std::vector<StringRef> Input::keys() { in keys()
143 for (auto &P : MN->Mapping) in keys()
148 bool Input::preflightKey(const char *Key, bool Required, bool, bool &UseDefault, in preflightKey()
172 MN->ValidKeys.push_back(Key); in preflightKey()
173 HNode *Value = MN->Mapping[Key].first; in preflightKey() local
174 if (!Value) { in preflightKey()
182 CurrentNode = Value; in preflightKey()
186 void Input::postflightKey(void *saveInfo) { in postflightKey()
190 void Input::endMapping() { in endMapping()
197 for (const auto &NN : MN->Mapping) { in endMapping()
198 if (!is_contained(MN->ValidKeys, NN.first())) { in endMapping()
209 void Input::beginFlowMapping() { beginMapping(); } in beginFlowMapping()
211 void Input::endFlowMapping() { endMapping(); } in endFlowMapping()
213 unsigned Input::beginSequence() { in beginSequence()
215 return SQ->Entries.size(); in beginSequence()
218 // Treat case where there's a scalar "null" value as an empty sequence. in beginSequence()
220 if (isNull(SN->value())) in beginSequence()
228 void Input::endSequence() { in endSequence()
231 bool Input::preflightElement(unsigned Index, void *&SaveInfo) { in preflightElement()
236 CurrentNode = SQ->Entries[Index]; in preflightElement()
242 void Input::postflightElement(void *SaveInfo) { in postflightElement()
246 unsigned Input::beginFlowSequence() { return beginSequence(); } in beginFlowSequence()
248 bool Input::preflightFlowElement(unsigned index, void *&SaveInfo) { in preflightFlowElement()
253 CurrentNode = SQ->Entries[index]; in preflightFlowElement()
259 void Input::postflightFlowElement(void *SaveInfo) { in postflightFlowElement()
263 void Input::endFlowSequence() { in endFlowSequence()
266 void Input::beginEnumScalar() { in beginEnumScalar()
270 bool Input::matchEnumScalar(const char *Str, bool) { in matchEnumScalar()
274 if (SN->value() == Str) { in matchEnumScalar()
282 bool Input::matchEnumFallback() { in matchEnumFallback()
289 void Input::endEnumScalar() { in endEnumScalar()
295 bool Input::beginBitSetScalar(bool &DoClear) { in beginBitSetScalar()
298 BitValuesUsed.resize(SQ->Entries.size()); in beginBitSetScalar()
306 bool Input::bitSetMatch(const char *Str, bool) { in bitSetMatch()
311 for (auto &N : SQ->Entries) { in bitSetMatch()
313 if (SN->value() == Str) { in bitSetMatch()
328 void Input::endBitSetScalar() { in endBitSetScalar()
332 assert(BitValuesUsed.size() == SQ->Entries.size()); in endBitSetScalar()
333 for (unsigned i = 0; i < SQ->Entries.size(); ++i) { in endBitSetScalar()
335 setError(SQ->Entries[i], "unknown bit value"); in endBitSetScalar()
342 void Input::scalarString(StringRef &S, QuotingType) { in scalarString()
344 S = SN->value(); in scalarString()
350 void Input::blockScalarString(StringRef &S) { scalarString(S, QuotingType::None); } in blockScalarString()
352 void Input::scalarTag(std::string &Tag) { in scalarTag()
353 Tag = CurrentNode->_node->getVerbatimTag(); in scalarTag()
356 void Input::setError(HNode *hnode, const Twine &message) { in setError()
358 setError(hnode->_node, message); in setError()
361 NodeKind Input::getNodeKind() { in getNodeKind()
371 void Input::setError(Node *node, const Twine &message) { in setError()
372 Strm->printError(node, message); in setError()
376 void Input::setError(const SMRange &range, const Twine &message) { in setError()
377 Strm->printError(range, message); in setError()
381 void Input::reportWarning(HNode *hnode, const Twine &message) { in reportWarning()
383 Strm->printError(hnode->_node, message, SourceMgr::DK_Warning); in reportWarning()
386 void Input::reportWarning(Node *node, const Twine &message) { in reportWarning()
387 Strm->printError(node, message, SourceMgr::DK_Warning); in reportWarning()
390 void Input::reportWarning(const SMRange &range, const Twine &message) { in reportWarning()
391 Strm->printError(range, message, SourceMgr::DK_Warning); in reportWarning()
394 void Input::releaseHNodeBuffers() { in releaseHNodeBuffers()
401 Input::HNode *Input::createHNodes(Node *N) { in createHNodes()
403 switch (N->getType()) { in createHNodes()
406 StringRef KeyStr = SN->getValue(StringStorage); in createHNodes()
415 StringRef ValueCopy = BSN->getValue().copy(StringAllocator); in createHNodes()
425 SQHNode->Entries.push_back(Entry); in createHNodes()
435 Node *Value = KVN.getValue(); in createHNodes() local
436 if (!Key || !Value) { in createHNodes()
439 if (!Value) in createHNodes()
440 setError(KeyNode, "Map value must not be empty"); in createHNodes()
444 StringRef KeyStr = Key->getValue(StringStorage); in createHNodes()
449 if (mapHNode->Mapping.count(KeyStr)) in createHNodes()
451 // key/value node pairs, with the restriction that each of the keys is in createHNodes()
454 auto ValueHNode = createHNodes(Value); in createHNodes()
457 mapHNode->Mapping[KeyStr] = in createHNodes()
458 std::make_pair(std::move(ValueHNode), KeyNode->getSourceRange()); in createHNodes()
470 void Input::setError(const Twine &Message) { in setError()
474 void Input::setAllowUnknownKeys(bool Allow) { AllowUnknownKeys = Allow; } in setAllowUnknownKeys()
476 bool Input::canElideEmptySequence() { in canElideEmptySequence()
480 //===----------------------------------------------------------------------===//
482 //===----------------------------------------------------------------------===//
506 auto &E = StateStack[StateStack.size() - 2]; in mapTag()
585 outputUpToEndOfLine("---"); in beginDocuments()
590 outputUpToEndOfLine("\n---"); in preflightDocument()
688 llvm_unreachable("bad runtime enum value"); in endEnumScalar()
755 // Normally, with an optional key/value where the value is an empty sequence, in canElideEmptySequence()
756 // the whole key/value can be not written. But, that produces wrong yaml in canElideEmptySequence()
757 // if the key/value is the only thing in the map and the map is used in in canElideEmptySequence()
758 // a sequence. This detects if the this sequence is the first key/value in canElideEmptySequence()
764 return !inSeqAnyElement(StateStack[StateStack.size() - 2]); in canElideEmptySequence()
783 // When using double-quoted strings (and only in that case), non-printable in output()
785 // unicode-scalar and special short-form escapes. This is handled in in output()
798 // When using single-quoted strings, any single quote ' must be doubled to be in output()
802 output(StringRef(&Base[i], j - i)); // "flush". in output()
808 output(StringRef(&Base[i], j - i)); in output()
824 // if seq at top, indent as if map, then add "- "
825 // if seq in middle, use "- " if firstKey, else use " "
840 unsigned Indent = StateStack.size() - 1; in newLineCheck()
850 inSeqAnyElement(StateStack[StateStack.size() - 2])) { in newLineCheck()
851 --Indent; in newLineCheck()
859 output("- "); in newLineCheck()
905 //===----------------------------------------------------------------------===//
906 // traits for built-in types
907 //===----------------------------------------------------------------------===//
913 StringRef ScalarTraits<bool>::input(StringRef Scalar, void *, bool &Val) { in input() function in ScalarTraits
926 StringRef ScalarTraits<StringRef>::input(StringRef Scalar, void *, in input() function in ScalarTraits
937 StringRef ScalarTraits<std::string>::input(StringRef Scalar, void *, in input() function in ScalarTraits::string
950 StringRef ScalarTraits<uint8_t>::input(StringRef Scalar, void *, uint8_t &Val) { in input() function in ScalarTraits
965 StringRef ScalarTraits<uint16_t>::input(StringRef Scalar, void *, in input() function in ScalarTraits
981 StringRef ScalarTraits<uint32_t>::input(StringRef Scalar, void *, in input() function in ScalarTraits
997 StringRef ScalarTraits<uint64_t>::input(StringRef Scalar, void *, in input() function in ScalarTraits
1012 StringRef ScalarTraits<int8_t>::input(StringRef Scalar, void *, int8_t &Val) { in input() function in ScalarTraits
1016 if ((N > 127) || (N < -128)) in input()
1027 StringRef ScalarTraits<int16_t>::input(StringRef Scalar, void *, int16_t &Val) { in input() function in ScalarTraits
1042 StringRef ScalarTraits<int32_t>::input(StringRef Scalar, void *, int32_t &Val) { in input() function in ScalarTraits
1057 StringRef ScalarTraits<int64_t>::input(StringRef Scalar, void *, int64_t &Val) { in input() function in ScalarTraits
1069 StringRef ScalarTraits<double>::input(StringRef Scalar, void *, double &Val) { in input() function in ScalarTraits
1079 StringRef ScalarTraits<float>::input(StringRef Scalar, void *, float &Val) { in input() function in ScalarTraits
1089 StringRef ScalarTraits<Hex8>::input(StringRef Scalar, void *, Hex8 &Val) { in input() function in ScalarTraits
1103 StringRef ScalarTraits<Hex16>::input(StringRef Scalar, void *, Hex16 &Val) { in input() function in ScalarTraits
1117 StringRef ScalarTraits<Hex32>::input(StringRef Scalar, void *, Hex32 &Val) { in input() function in ScalarTraits
1131 StringRef ScalarTraits<Hex64>::input(StringRef Scalar, void *, Hex64 &Val) { in input() function in ScalarTraits
1144 StringRef ScalarTraits<VersionTuple>::input(StringRef Scalar, void *, in input() function in ScalarTraits