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