LLVM: include/llvm/Support/circular_raw_ostream.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_SUPPORT_CIRCULAR_RAW_OSTREAM_H

15#define LLVM_SUPPORT_CIRCULAR_RAW_OSTREAM_H

16

18

19namespace llvm {

20

21

22

23

25 public:

26

27

28

29

31

32

33

34

36

37 private:

38

39

40

42

43

44

45

46 bool OwnsStream;

47

48

49

50 size_t BufferSize;

51

52

53

54 char *BufferArray = nullptr;

55

56

57

58 char *Cur;

59

60

61

62

63 bool Filled = false;

64

65

66

67

68 const char *Banner;

69

70

71

72 void flushBuffer() {

73 if (Filled)

74

75 TheStream->write(Cur, BufferArray + BufferSize - Cur);

76

77 TheStream->write(BufferArray, Cur - BufferArray);

78 Cur = BufferArray;

79 Filled = false;

80 }

81

82 void write_impl(const char *Ptr, size_t Size) override;

83

84

85

86

87 uint64_t current_pos() const override {

88

89

91 }

92

93 public:

94

95

96

97

98

99

100

101

102

103

104

105

106

110 BufferSize(BuffSize), Banner(Header) {

111 if (BufferSize != 0)

112 BufferArray = new char[BufferSize];

113 Cur = BufferArray;

115 }

116

120 releaseStream();

121 delete[] BufferArray;

122 }

123

125 return TheStream->is_displayed();

126 }

127

128

129

130

131

132

134 releaseStream();

135 TheStream = &Stream;

136 OwnsStream = Owns;

137 }

138

139

140

141

143

144 private:

145

146

147

148

149 void releaseStream() {

150 if (!TheStream)

151 return;

152 if (OwnsStream)

153 delete TheStream;

154 }

155 };

156}

157

158#endif

~circular_raw_ostream() override

Definition circular_raw_ostream.h:117

void flushBufferWithBanner()

flushBufferWithBanner - Force output of the buffer along with a small header.

static constexpr bool TAKE_OWNERSHIP

TAKE_OWNERSHIP - Tell this stream that it owns the underlying stream and is responsible for cleanup,...

Definition circular_raw_ostream.h:30

bool is_displayed() const override

This function determines if this stream is connected to a "tty" or "console" window.

Definition circular_raw_ostream.h:124

circular_raw_ostream(raw_ostream &Stream, const char *Header, size_t BuffSize=0, bool Owns=REFERENCE_ONLY)

circular_raw_ostream - Construct an optionally circular-buffered stream, handing it an underlying str...

Definition circular_raw_ostream.h:107

static constexpr bool REFERENCE_ONLY

REFERENCE_ONLY - Tell this stream it should not manage the held stream.

Definition circular_raw_ostream.h:35

void setStream(raw_ostream &Stream, bool Owns=REFERENCE_ONLY)

setStream - Tell the circular_raw_ostream to output a different stream.

Definition circular_raw_ostream.h:133

raw_ostream(bool unbuffered=false, OStreamKind K=OStreamKind::OK_OStream)

uint64_t tell() const

tell - Return the current offset with the file.

size_t GetNumBytesInBuffer() const

This is an optimization pass for GlobalISel generic memory operations.