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" 13 #include "lldb/lldb-enumerations.h" 14 #include "llvm/ADT/StringRef.h" 15 16 #include <string> 17 18 #include <cstddef> 19 #include <cstdint> 20 21 namespace lldb_private { 22 23 class ScriptInterpreter; 24 25 class StreamString : public Stream { 26 public: 27 StreamString(bool colors = false); 28 29 StreamString(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order); 30 31 ~StreamString() override; 32 33 void Flush() override; 34 35 void Clear(); 36 37 bool Empty() const; 38 39 size_t GetSize() const; 40 41 size_t GetSizeOfLastLine() const; 42 43 llvm::StringRef GetString() const; 44 GetData()45 const char *GetData() const { return m_packet.c_str(); } 46 47 void FillLastLineToColumn(uint32_t column, char fill_char); 48 49 protected: 50 friend class ScriptInterpreter; 51 52 std::string m_packet; 53 size_t WriteImpl(const void *s, size_t length) override; 54 }; 55 56 } // namespace lldb_private 57 58 #endif // LLDB_UTILITY_STREAMSTRING_H 59