#ifndef LLVM_SUPPORT_YAMLTRAITS_H
#define LLVM_SUPPORT_YAMLTRAITS_H
-
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/Optional.h"
namespace llvm {
namespace yaml {
-
/// This class should be specialized by any type that needs to be converted
/// to/from a YAML mapping. For example:
///
// static const bool flow = true;
};
-
/// This class should be specialized by any integral type that converts
/// to/from a YAML scalar where there is a one-to-one mapping between
/// in-memory values and a string in YAML. For example:
// static void enumeration(IO &io, T &value);
};
-
/// This class should be specialized by any integer type that is a union
/// of bit values and the YAML representation is a flow sequence of
/// strings. For example:
// static void bitset(IO &io, T &value);
};
-
/// This class should be specialized by type that requires custom conversion
/// to/from a yaml scalar. For example:
///
// static StringRef input(StringRef Scalar, void *ctxt, T &Value);
};
-
/// This class should be specialized by any type that needs to be converted
/// to/from a YAML sequence. For example:
///
// static const bool flow = true;
};
-
/// This class should be specialized by any type that needs to be converted
/// to/from a list of YAML documents.
template<typename T>
// static T::value_type& element(IO &io, T &seq, size_t index);
};
-
// Only used by compiler if both template types are the same
template <typename T, T>
struct SameType;
template <typename T>
struct MissingTrait;
-
-
// Test if ScalarEnumerationTraits<T> is defined on type T.
template <class T>
struct has_ScalarEnumerationTraits
(sizeof(test<ScalarEnumerationTraits<T> >(nullptr)) == 1);
};
-
// Test if ScalarBitSetTraits<T> is defined on type T.
template <class T>
struct has_ScalarBitSetTraits
static bool const value = (sizeof(test<ScalarBitSetTraits<T> >(nullptr)) == 1);
};
-
// Test if ScalarTraits<T> is defined on type T.
template <class T>
struct has_ScalarTraits
(sizeof(test<ScalarTraits<T>>(nullptr, nullptr, nullptr)) == 1);
};
-
// Test if BlockScalarTraits<T> is defined on type T.
template <class T>
struct has_BlockScalarTraits
(sizeof(test<BlockScalarTraits<T>>(nullptr, nullptr)) == 1);
};
-
// Test if MappingTraits<T> is defined on type T.
template <class T>
struct has_MappingTraits
static bool const value = (sizeof(test<MappingTraits<T> >(nullptr)) == 1);
};
-
-
// Test if SequenceTraits<T> is defined on type T.
template <class T>
struct has_SequenceMethodTraits
static bool const value = (sizeof(test<SequenceTraits<T> >(nullptr)) == 1);
};
-
// has_FlowTraits<int> will cause an error with some compilers because
// it subclasses int. Using this wrapper only instantiates the
// real has_FlowTraits only if the template type is a class.
static bool const value = sizeof(f<Derived>(nullptr)) == 2;
};
-
-
// Test if SequenceTraits<T> is defined on type T
template<typename T>
struct has_SequenceTraits : public std::integral_constant<bool,
has_SequenceMethodTraits<T>::value > { };
-
// Test if DocumentListTraits<T> is defined on type T
template <class T>
struct has_DocumentListTraits
return false;
}
-
template<typename T>
struct missingTraits : public std::integral_constant<bool,
!has_ScalarEnumerationTraits<T>::value
void *Ctxt;
};
-
-
template<typename T>
typename std::enable_if<has_ScalarEnumerationTraits<T>::value,void>::type
yamlize(IO &io, T &Val, bool) {
}
}
-
template<typename T>
typename std::enable_if<has_ScalarTraits<T>::value,void>::type
yamlize(IO &io, T &Val, bool) {
}
}
-
template<>
struct ScalarTraits<bool> {
static void output(const bool &, void*, llvm::raw_ostream &);
static bool mustQuote(StringRef) { return false; }
};
-
-
// Utility for use within MappingTraits<>::mapping() method
// to [de]normalize an object for use with YAML conversion.
template <typename TNorm, typename TFinal>
TFinal &Result;
};
-
-
// Utility for use within MappingTraits<>::mapping() method
// to [de]normalize an object for use with YAML conversion.
template <typename TNorm, typename TFinal>
struct MappingNormalizationHeap {
MappingNormalizationHeap(IO &i_o, TFinal &Obj)
- : io(i_o), BufPtr(NULL), Result(Obj) {
+ : io(i_o), BufPtr(nullptr), Result(Obj) {
if ( io.outputting() ) {
BufPtr = new (&Buffer) TNorm(io, Obj);
}
TFinal &Result;
};
-
-
///
/// The Input class is used to parse a yaml document into in-memory structs
/// and vectors.
void setError(HNode *hnode, const Twine &message);
void setError(Node *node, const Twine &message);
-
public:
// These are only used by operator>>. They could be private
// if those templated things could be made friends.
bool ScalarMatchFound;
};
-
-
-
///
/// The Output class is used to generate a yaml document from in-memory structs
/// and vectors.
///
class Output : public IO {
public:
- Output(llvm::raw_ostream &, void *Ctxt=nullptr);
+ Output(llvm::raw_ostream &, void *Ctxt = nullptr, int WrapColumn = 70);
~Output() override;
bool outputting() override;
};
llvm::raw_ostream &Out;
+ int WrapColumn;
SmallVector<InState, 8> StateStack;
int Column;
int ColumnAtFlowStart;
bool NeedsNewLine;
};
-
-
-
/// YAML I/O does conversion based on types. But often native data types
/// are just a typedef of built in intergral types (e.g. int). But the C++
/// type matching system sees through the typedef and all the typedefed types
_base value; \
};
-
-
///
/// Use these types instead of uintXX_t in any mapping to have
/// its yaml output formatted as hexadecimal.
LLVM_YAML_STRONG_TYPEDEF(uint32_t, Hex32)
LLVM_YAML_STRONG_TYPEDEF(uint64_t, Hex64)
-
template<>
struct ScalarTraits<Hex8> {
static void output(const Hex8 &, void*, llvm::raw_ostream &);
static bool mustQuote(StringRef) { return false; }
};
-
// Define non-member operator>> so that Input can stream in a document list.
template <typename T>
inline
return yin;
}
-
// Define non-member operator<< so that Output can stream out document list.
template <typename T>
inline
return yout;
}
-
} // namespace yaml
} // namespace llvm
-
/// Utility for declaring that a std::vector of a particular type
/// should be considered a YAML sequence.
#define LLVM_YAML_IS_SEQUENCE_VECTOR(_type) \
} \
}
-
-
#endif // LLVM_SUPPORT_YAMLTRAITS_H