}
void Input::beginMapping() {
- if (EC)
+ if (hasError())
return;
// CurrentNode can be null if the document is empty.
MapHNode *MN = dyn_cast_or_null<MapHNode>(CurrentNode);
bool Input::preflightKey(const char *Key, bool Required, bool, bool &UseDefault,
void *&SaveInfo) {
UseDefault = false;
- if (EC)
+ if (hasError())
return false;
// CurrentNode is null for empty documents, which is an error in case required
}
void Input::endMapping() {
- if (EC)
+ if (hasError())
return;
// CurrentNode can be null if the document is empty.
MapHNode *MN = dyn_cast_or_null<MapHNode>(CurrentNode);
}
bool Input::preflightElement(unsigned Index, void *&SaveInfo) {
- if (EC)
+ if (hasError())
return false;
if (SequenceHNode *SQ = dyn_cast<SequenceHNode>(CurrentNode)) {
SaveInfo = CurrentNode;
unsigned Input::beginFlowSequence() { return beginSequence(); }
bool Input::preflightFlowElement(unsigned index, void *&SaveInfo) {
- if (EC)
+ if (hasError())
return false;
if (SequenceHNode *SQ = dyn_cast<SequenceHNode>(CurrentNode)) {
SaveInfo = CurrentNode;
}
bool Input::bitSetMatch(const char *Str, bool) {
- if (EC)
+ if (hasError())
return false;
if (SequenceHNode *SQ = dyn_cast<SequenceHNode>(CurrentNode)) {
unsigned Index = 0;
}
void Input::endBitSetScalar() {
- if (EC)
+ if (hasError())
return;
if (SequenceHNode *SQ = dyn_cast<SequenceHNode>(CurrentNode)) {
assert(BitValuesUsed.size() == SQ->Entries.size());
this->setError(hnode->_node, message);
}
+bool Input::hasError() const { return EC || Strm->failed(); }
+
void Input::setError(Node *node, const Twine &message) {
Strm->printError(node, message);
EC = make_error_code(errc::invalid_argument);
auto SQHNode = llvm::make_unique<SequenceHNode>(N);
for (Node &SN : *SQ) {
auto Entry = this->createHNodes(&SN);
- if (EC)
+ if (hasError())
break;
SQHNode->Entries.push_back(std::move(Entry));
}
KeyStr = StringStorage.str().copy(StringAllocator);
}
auto ValueHNode = this->createHNodes(KVN.getValue());
- if (EC)
+ if (hasError())
break;
mapHNode->Mapping[KeyStr] = std::move(ValueHNode);
}