StreamString.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #ifndef LLDB_UTILITY_STREAMSTRING_H
  9. #define LLDB_UTILITY_STREAMSTRING_H
  10. #include "lldb/Utility/Stream.h"
  11. #include "lldb/lldb-enumerations.h"
  12. #include "llvm/ADT/StringRef.h"
  13. #include <string>
  14. #include <cstddef>
  15. #include <cstdint>
  16. namespace lldb_private {
  17. class StreamString : public Stream {
  18. public:
  19. StreamString();
  20. StreamString(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order);
  21. ~StreamString() override;
  22. void Flush() override;
  23. void Clear();
  24. bool Empty() const;
  25. size_t GetSize() const;
  26. size_t GetSizeOfLastLine() const;
  27. llvm::StringRef GetString() const;
  28. const char *GetData() const { return m_packet.c_str(); }
  29. void FillLastLineToColumn(uint32_t column, char fill_char);
  30. protected:
  31. std::string m_packet;
  32. size_t WriteImpl(const void *s, size_t length) override;
  33. };
  34. } // namespace lldb_private
  35. #endif // LLDB_UTILITY_STREAMSTRING_H