Files
Alain Carlucci 557ee758e6 MetaAddress: enable quoting on YAML serialization
Enable quotes around MetaAddress during serialization, since ':' is a
valid YAML separator, which causes wrong deserialization when a vector
of MetaAddress is serialized as a list
2021-02-08 12:25:12 +01:00

28 lines
660 B
C++

#pragma once
//
// This file is distributed under the MIT License. See LICENSE.md for details.
//
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/YAMLTraits.h"
#include "llvm/Support/raw_ostream.h"
#include "revng/Support/MetaAddress.h"
template<>
struct llvm::yaml::ScalarTraits<MetaAddress> {
static void
output(const MetaAddress &Value, void *, llvm::raw_ostream &Output) {
Output << Value.toString();
}
static StringRef input(llvm::StringRef Scalar, void *, MetaAddress &Value) {
Value = MetaAddress::fromString(Scalar);
return StringRef();
}
static QuotingType mustQuote(StringRef) { return QuotingType::Double; }
};