LLDB mainline
StreamString.h
Go to the documentation of this file.
1//===-- StreamString.h ------------------------------------------*- 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
9#ifndef LLDB_UTILITY_STREAMSTRING_H
10#define LLDB_UTILITY_STREAMSTRING_H
11
12#include "lldb/Utility/Stream.h"
14#include "llvm/ADT/StringRef.h"
15#include "llvm/Support/FormatProviders.h"
16
17#include <string>
18
19#include <cstddef>
20#include <cstdint>
21
22namespace lldb_private {
23
25
26class StreamString : public Stream {
27public:
28 StreamString(bool colors = false);
29
30 StreamString(uint32_t flags, lldb::ByteOrder byte_order);
31
32 ~StreamString() override;
33
34 void Flush() override;
35
36 void Clear();
37
38 bool Empty() const;
39
40 size_t GetSize() const;
41
42 size_t GetSizeOfLastLine() const;
43
44 llvm::StringRef GetString() const;
45
46 const char *GetData() const { return m_packet.c_str(); }
47
48 void FillLastLineToColumn(uint32_t column, char fill_char);
49
50protected:
52
53 std::string m_packet;
54 size_t WriteImpl(const void *s, size_t length) override;
55};
56
57} // namespace lldb_private
58
59namespace llvm {
60template <> struct format_provider<lldb_private::StreamString> {
61 static void format(const lldb_private::StreamString &label, raw_ostream &OS,
62 StringRef Style);
63};
64} // end namespace llvm
65
66#endif // LLDB_UTILITY_STREAMSTRING_H
friend class ScriptInterpreterBridge
size_t WriteImpl(const void *s, size_t length) override
Output character bytes to the stream.
size_t GetSizeOfLastLine() const
const char * GetData() const
void Flush() override
Flush the stream.
llvm::StringRef GetString() const
void FillLastLineToColumn(uint32_t column, char fill_char)
StreamString(bool colors=false)
Stream(uint32_t flags, lldb::ByteOrder byte_order, bool colors=false)
Construct with flags and address size and byte order.
Definition Stream.cpp:27
A class that represents a running process on the host machine.
ByteOrder
Byte ordering definitions.
static void format(const lldb_private::StreamString &label, raw_ostream &OS, StringRef Style)