llvm/lldb/include/lldb/Utility/Stream.h

//===-- Stream.h ------------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLDB_UTILITY_STREAM_H
#define LLDB_UTILITY_STREAM_H

#include "lldb/Utility/Flags.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-enumerations.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/raw_ostream.h"

#include <cstdarg>
#include <cstddef>
#include <cstdint>
#include <type_traits>

namespace lldb_private {

/// \class Stream Stream.h "lldb/Utility/Stream.h"
/// A stream class that can stream formatted output to a file.
class Stream {};

/// Output an address value to this stream.
///
/// Put an address \a addr out to the stream with optional \a prefix and \a
/// suffix strings.
///
/// \param[in] s
///     The output stream.
///
/// \param[in] addr
///     An address value.
///
/// \param[in] addr_size
///     Size in bytes of the address, used for formatting.
///
/// \param[in] prefix
///     A prefix C string. If nullptr, no prefix will be output.
///
/// \param[in] suffix
///     A suffix C string. If nullptr, no suffix will be output.
void DumpAddress(llvm::raw_ostream &s, uint64_t addr, uint32_t addr_size,
                 const char *prefix = nullptr, const char *suffix = nullptr);

/// Output an address range to this stream.
///
/// Put an address range \a lo_addr - \a hi_addr out to the stream with
/// optional \a prefix and \a suffix strings.
///
/// \param[in] s
///     The output stream.
///
/// \param[in] lo_addr
///     The start address of the address range.
///
/// \param[in] hi_addr
///     The end address of the address range.
///
/// \param[in] addr_size
///     Size in bytes of the address, used for formatting.
///
/// \param[in] prefix
///     A prefix C string. If nullptr, no prefix will be output.
///
/// \param[in] suffix
///     A suffix C string. If nullptr, no suffix will be output.
void DumpAddressRange(llvm::raw_ostream &s, uint64_t lo_addr, uint64_t hi_addr,
                      uint32_t addr_size, const char *prefix = nullptr,
                      const char *suffix = nullptr);

} // namespace lldb_private

#endif // LLDB_UTILITY_STREAM_H