1 //===-- StreamAsynchronousIO.cpp ------------------------------------------===//
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 "lldb/Core/StreamAsynchronousIO.h"
11 #include "lldb/Core/Debugger.h"
12 #include "lldb/lldb-enumerations.h"
15 using namespace lldb_private
;
17 StreamAsynchronousIO::StreamAsynchronousIO(Debugger
&debugger
, bool for_stdout
,
19 : Stream(0, 4, eByteOrderBig
, colors
), m_debugger(debugger
), m_data(),
20 m_for_stdout(for_stdout
) {}
22 StreamAsynchronousIO::~StreamAsynchronousIO() {
23 // Flush when we destroy to make sure we display the data
27 void StreamAsynchronousIO::Flush() {
28 if (!m_data
.empty()) {
29 m_debugger
.PrintAsync(m_data
.data(), m_data
.size(), m_for_stdout
);
30 m_data
= std::string();
34 size_t StreamAsynchronousIO::WriteImpl(const void *s
, size_t length
) {
35 m_data
.append((const char *)s
, length
);