1 //===- NativeFormatting.h - Low level formatting helpers ---------*- C++-*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_SUPPORT_NATIVE_FORMATTING_H
10 #define LLVM_SUPPORT_NATIVE_FORMATTING_H
12 #include "llvm/ADT/Optional.h"
13 #include "llvm/Support/raw_ostream.h"
18 enum class FloatStyle
{ Exponent
, ExponentUpper
, Fixed
, Percent
};
19 enum class IntegerStyle
{
23 enum class HexPrintStyle
{ Upper
, Lower
, PrefixUpper
, PrefixLower
};
25 size_t getDefaultPrecision(FloatStyle Style
);
27 bool isPrefixedHexStyle(HexPrintStyle S
);
29 void write_integer(raw_ostream
&S
, unsigned int N
, size_t MinDigits
,
31 void write_integer(raw_ostream
&S
, int N
, size_t MinDigits
, IntegerStyle Style
);
32 void write_integer(raw_ostream
&S
, unsigned long N
, size_t MinDigits
,
34 void write_integer(raw_ostream
&S
, long N
, size_t MinDigits
,
36 void write_integer(raw_ostream
&S
, unsigned long long N
, size_t MinDigits
,
38 void write_integer(raw_ostream
&S
, long long N
, size_t MinDigits
,
41 void write_hex(raw_ostream
&S
, uint64_t N
, HexPrintStyle Style
,
42 Optional
<size_t> Width
= None
);
43 void write_double(raw_ostream
&S
, double D
, FloatStyle Style
,
44 Optional
<size_t> Precision
= None
);