Coverage Report

Created: 2017-02-24 18:24

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/include/llvm/DebugInfo/MSF/StreamInterface.h
Line
Count
Source
1
//===- StreamInterface.h - Base interface for a stream of data --*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
10
#ifndef LLVM_DEBUGINFO_MSF_STREAMINTERFACE_H
11
#define LLVM_DEBUGINFO_MSF_STREAMINTERFACE_H
12
13
#include "llvm/ADT/ArrayRef.h"
14
#include "llvm/Support/Error.h"
15
#include <cstdint>
16
17
namespace llvm {
18
namespace msf {
19
20
class ReadableStream {
21
public:
22
10.2k
  virtual ~ReadableStream() = default;
23
24
  // Given an offset into the stream and a number of bytes, attempt to read
25
  // the bytes and set the output ArrayRef to point to a reference into the
26
  // stream, without copying any data.
27
  virtual Error readBytes(uint32_t Offset, uint32_t Size,
28
                          ArrayRef<uint8_t> &Buffer) const = 0;
29
30
  // Given an offset into the stream, read as much as possible without copying
31
  // any data.
32
  virtual Error readLongestContiguousChunk(uint32_t Offset,
33
                                           ArrayRef<uint8_t> &Buffer) const = 0;
34
35
  virtual uint32_t getLength() const = 0;
36
};
37
38
class WritableStream : public ReadableStream {
39
public:
40
844
  ~WritableStream() override = default;
41
42
  // Attempt to write the given bytes into the stream at the desired offset.
43
  // This will always necessitate a copy.  Cannot shrink or grow the stream,
44
  // only writes into existing allocated space.
45
  virtual Error writeBytes(uint32_t Offset, ArrayRef<uint8_t> Data) const = 0;
46
47
  virtual Error commit() const = 0;
48
};
49
50
} // end namespace msf
51
} // end namespace llvm
52
53
#endif // LLVM_DEBUGINFO_MSF_STREAMINTERFACE_H