1 //===- FormatUtil.cpp ----------------------------------------- *- 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 #include "FormatUtil.h"
10 #include "llvm/Support/Format.h"
11 #include "llvm/Support/FormatVariadic.h"
13 using namespace lldb_private
;
16 LinePrinter::Line::~Line() {
21 LinePrinter::LinePrinter(int Indent
, llvm::raw_ostream
&Stream
)
22 : OS(Stream
), IndentSpaces(Indent
), CurrentIndent(0) {}
24 void LinePrinter::Indent(uint32_t Amount
) {
26 Amount
= IndentSpaces
;
27 CurrentIndent
+= Amount
;
30 void LinePrinter::Unindent(uint32_t Amount
) {
32 Amount
= IndentSpaces
;
33 CurrentIndent
= std::max
<int>(0, CurrentIndent
- Amount
);
36 void LinePrinter::NewLine() {
40 void LinePrinter::formatBinary(StringRef Label
, ArrayRef
<uint8_t> Data
,
41 uint32_t StartOffset
) {
43 line() << Label
<< " ()";
46 line() << Label
<< " (";
47 OS
<< format_bytes_with_ascii(Data
, StartOffset
, 32, 4,
48 CurrentIndent
+ IndentSpaces
, true);
53 void LinePrinter::formatBinary(StringRef Label
, ArrayRef
<uint8_t> Data
,
54 uint64_t Base
, uint32_t StartOffset
) {
56 line() << Label
<< " ()";
59 line() << Label
<< " (";
61 OS
<< format_bytes_with_ascii(Data
, Base
, 32, 4, CurrentIndent
+ IndentSpaces
,