Path: blob/main/contrib/llvm-project/lldb/source/Core/StreamAsynchronousIO.cpp
39587 views
//===-- StreamAsynchronousIO.cpp ------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "lldb/Core/StreamAsynchronousIO.h"910#include "lldb/Core/Debugger.h"11#include "lldb/lldb-enumerations.h"1213using namespace lldb;14using namespace lldb_private;1516StreamAsynchronousIO::StreamAsynchronousIO(Debugger &debugger, bool for_stdout,17bool colors)18: Stream(0, 4, eByteOrderBig, colors), m_debugger(debugger), m_data(),19m_for_stdout(for_stdout) {}2021StreamAsynchronousIO::~StreamAsynchronousIO() {22// Flush when we destroy to make sure we display the data23Flush();24}2526void StreamAsynchronousIO::Flush() {27if (!m_data.empty()) {28m_debugger.PrintAsync(m_data.data(), m_data.size(), m_for_stdout);29m_data = std::string();30}31}3233size_t StreamAsynchronousIO::WriteImpl(const void *s, size_t length) {34m_data.append((const char *)s, length);35return length;36}373839