23 #ifndef LLVM_SUPPORT_FORMAT_H
24 #define LLVM_SUPPORT_FORMAT_H
28 #include "llvm/Support/DataTypes.h"
45 virtual int snprint(
char *Buffer,
unsigned BufferSize)
const = 0;
53 unsigned print(
char *Buffer,
unsigned BufferSize)
const {
54 assert(BufferSize &&
"Invalid buffer size!");
61 return BufferSize * 2;
65 if (
unsigned(N) >= BufferSize)
78 template <
typename... Ts>
80 std::tuple<Ts...> Vals;
82 template <std::size_t... Is>
83 int snprint_tuple(
char *Buffer,
unsigned BufferSize,
86 return _snprintf(Buffer, BufferSize,
Fmt, std::get<Is>(Vals)...);
88 return snprintf(Buffer, BufferSize,
Fmt, std::get<Is>(Vals)...);
96 int snprint(
char *Buffer,
unsigned BufferSize)
const override {
110 template <
typename... Ts>
123 : Str(S), Width(W), RightJustify(R) { }
152 : HexValue(HV), DecValue(DV), Width(W), Hex(H), Upper(U),
163 bool Upper =
false) {
164 assert(Width <= 18 &&
"hex width must be <= 18");
176 bool Upper =
false) {
177 assert(Width <= 18 &&
"hex width must be <= 18");
FormattedString left_justify(StringRef Str, unsigned Width)
left_justify - append spaces after string so total output is Width characters.
FormattedNumber format_hex(uint64_t N, unsigned Width, bool Upper=false)
format_hex - Output N as a fixed width hexadecimal.
Alias for the common case of a sequence of size_ts.
FormattedString right_justify(StringRef Str, unsigned Width)
right_justify - add spaces before string so total output is Width characters.
format_object< Ts...> format(const char *Fmt, const Ts &...Vals)
These are helper functions used to produce formatted output.
Creates a compile-time integer sequence for a parameter pack.
FormattedNumber format_decimal(int64_t N, unsigned Width)
format_decimal - Output N as a right justified, fixed-width decimal.
FormattedNumber format_hex_no_prefix(uint64_t N, unsigned Width, bool Upper=false)
format_hex_no_prefix - Output N as a fixed width hexadecimal.
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.