LLDB
mainline
llvm-project
lldb
include
lldb
Core
StreamBuffer.h
Go to the documentation of this file.
1
//===-- StreamBuffer.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_CORE_STREAMBUFFER_H
10
#define LLDB_CORE_STREAMBUFFER_H
11
12
#include "
lldb/Utility/Stream.h
"
13
#include "llvm/ADT/SmallVector.h"
14
#include <cstdio>
15
#include <string>
16
17
namespace
lldb_private
{
18
19
template
<
unsigned
N>
class
StreamBuffer
:
public
Stream
{
20
public
:
21
StreamBuffer
() :
Stream
(0, 4,
lldb
::
eByteOrderBig
),
m_packet
() {}
22
23
StreamBuffer
(
uint32_t
flags,
uint32_t
addr_size,
lldb::ByteOrder
byte_order)
24
:
Stream
(flags, addr_size, byte_order),
m_packet
() {}
25
26
~StreamBuffer
()
override
=
default
;
27
28
void
Flush
()
override
{
29
// Nothing to do when flushing a buffer based stream...
30
}
31
32
void
Clear
() {
m_packet
.clear(); }
33
34
// Beware, this might not be NULL terminated as you can expect from
35
// StringString as there may be random bits in the llvm::SmallVector. If you
36
// are using this class to create a C string, be sure the call PutChar ('\0')
37
// after you have created your string, or use StreamString.
38
const
char
*
GetData
()
const
{
return
m_packet
.data(); }
39
40
size_t
GetSize
()
const
{
return
m_packet
.size(); }
41
42
protected
:
43
llvm::SmallVector<char, N>
m_packet
;
44
45
size_t
WriteImpl
(
const
void
*s,
size_t
length)
override
{
46
if
(s && length)
47
m_packet
.append((
const
char
*)s, ((
const
char
*)s) + length);
48
return
length;
49
}
50
};
51
52
}
// namespace lldb_private
53
54
#endif // LLDB_CORE_STREAMBUFFER_H
lldb_private::StreamBuffer::StreamBuffer
StreamBuffer(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order)
Definition:
StreamBuffer.h:23
lldb_private::Stream
Definition:
Stream.h:28
lldb_private::StreamBuffer::StreamBuffer
StreamBuffer()
Definition:
StreamBuffer.h:21
lldb_private::StreamBuffer::Flush
void Flush() override
Flush the stream.
Definition:
StreamBuffer.h:28
lldb_private::StreamBuffer::GetSize
size_t GetSize() const
Definition:
StreamBuffer.h:40
uint32_t
lldb_private::StreamBuffer::Clear
void Clear()
Definition:
StreamBuffer.h:32
lldb_private::StreamBuffer::GetData
const char * GetData() const
Definition:
StreamBuffer.h:38
lldb_private::StreamBuffer
Definition:
StreamBuffer.h:19
lldb_private
A class that represents a running process on the host machine.
Definition:
SBCommandInterpreterRunOptions.h:16
lldb_private::StreamBuffer::WriteImpl
size_t WriteImpl(const void *s, size_t length) override
Output character bytes to the stream.
Definition:
StreamBuffer.h:45
lldb_private::StreamBuffer::m_packet
llvm::SmallVector< char, N > m_packet
Definition:
StreamBuffer.h:43
lldb::eByteOrderBig
@ eByteOrderBig
Definition:
lldb-enumerations.h:140
Stream.h
lldb
Definition:
SBAddress.h:15
lldb_private::StreamBuffer::~StreamBuffer
~StreamBuffer() override=default
lldb::ByteOrder
ByteOrder
Byte ordering definitions.
Definition:
lldb-enumerations.h:138
Generated on Wed May 18 2022 02:55:27 for LLDB by
1.8.17