mirror of
https://github.com/RPCS3/llvm.git
synced 2026-01-31 01:25:19 +01:00
We have need to reuse this functionality, including making additional generic stream types that are smarter about how and when they copy memory versus referencing the original memory. So all of these structures belong in the common library rather than being pdb specific. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270751 91177308-0d34-0410-b5e6-96231b3b80d8
56 lines
1.5 KiB
C++
56 lines
1.5 KiB
C++
//===- ByteStream.h - Reads stream data from a byte sequence ----*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_DEBUGINFO_CODEVIEW_BYTESTREAM_H
|
|
#define LLVM_DEBUGINFO_CODEVIEW_BYTESTREAM_H
|
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
|
#include "llvm/ADT/StringRef.h"
|
|
#include "llvm/DebugInfo/CodeView/StreamInterface.h"
|
|
#include "llvm/Support/Error.h"
|
|
#include <cstdint>
|
|
#include <memory>
|
|
|
|
namespace llvm {
|
|
namespace codeview {
|
|
class StreamReader;
|
|
|
|
class ByteStream : public StreamInterface {
|
|
public:
|
|
ByteStream();
|
|
explicit ByteStream(MutableArrayRef<uint8_t> Bytes);
|
|
explicit ByteStream(uint32_t Length);
|
|
~ByteStream() override;
|
|
|
|
void reset();
|
|
void initialize(MutableArrayRef<uint8_t> Bytes);
|
|
void initialize(uint32_t Length);
|
|
Error initialize(StreamReader &Reader, uint32_t Length);
|
|
|
|
Error readBytes(uint32_t Offset,
|
|
MutableArrayRef<uint8_t> Buffer) const override;
|
|
|
|
Error getArrayRef(uint32_t Offset, ArrayRef<uint8_t> &Buffer,
|
|
uint32_t Length) const override;
|
|
|
|
uint32_t getLength() const override;
|
|
|
|
ArrayRef<uint8_t> data() const { return Data; }
|
|
StringRef str() const;
|
|
|
|
private:
|
|
MutableArrayRef<uint8_t> Data;
|
|
std::unique_ptr<uint8_t[]> Ownership;
|
|
};
|
|
|
|
} // end namespace pdb
|
|
} // end namespace llvm
|
|
|
|
#endif // LLVM_DEBUGINFO_CODEVIEW_BYTESTREAM_H
|