NativeFormatting.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //===- NativeFormatting.h - Low level formatting helpers ---------*- C++-*-===//
  2. //
  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
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef LLVM_SUPPORT_NATIVEFORMATTING_H
  9. #define LLVM_SUPPORT_NATIVEFORMATTING_H
  10. #include "llvm/ADT/Optional.h"
  11. #include <cstdint>
  12. namespace llvm {
  13. class raw_ostream;
  14. enum class FloatStyle { Exponent, ExponentUpper, Fixed, Percent };
  15. enum class IntegerStyle {
  16. Integer,
  17. Number,
  18. };
  19. enum class HexPrintStyle { Upper, Lower, PrefixUpper, PrefixLower };
  20. size_t getDefaultPrecision(FloatStyle Style);
  21. bool isPrefixedHexStyle(HexPrintStyle S);
  22. void write_integer(raw_ostream &S, unsigned int N, size_t MinDigits,
  23. IntegerStyle Style);
  24. void write_integer(raw_ostream &S, int N, size_t MinDigits, IntegerStyle Style);
  25. void write_integer(raw_ostream &S, unsigned long N, size_t MinDigits,
  26. IntegerStyle Style);
  27. void write_integer(raw_ostream &S, long N, size_t MinDigits,
  28. IntegerStyle Style);
  29. void write_integer(raw_ostream &S, unsigned long long N, size_t MinDigits,
  30. IntegerStyle Style);
  31. void write_integer(raw_ostream &S, long long N, size_t MinDigits,
  32. IntegerStyle Style);
  33. void write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style,
  34. Optional<size_t> Width = None);
  35. void write_double(raw_ostream &S, double D, FloatStyle Style,
  36. Optional<size_t> Precision = None);
  37. }
  38. #endif