Merge dmd upstream 6243fa6d2
[official-gcc.git] / gcc / d / dmd / root / outbuffer.h
blob6e6b35d8d938f104f4731c355b92cc116de36ef2
2 /* Copyright (C) 1999-2018 by The D Language Foundation, All Rights Reserved
3 * http://www.digitalmars.com
4 * Distributed under the Boost Software License, Version 1.0.
5 * http://www.boost.org/LICENSE_1_0.txt
6 * https://github.com/dlang/dmd/blob/master/src/dmd/root/outbuffer.h
7 */
9 #pragma once
11 #include "dsystem.h"
12 #include "port.h"
13 #include "rmem.h"
15 class RootObject;
17 struct OutBuffer
19 unsigned char *data;
20 size_t offset;
21 size_t size;
23 int level;
24 bool doindent;
25 private:
26 bool notlinehead;
27 public:
29 OutBuffer()
31 data = NULL;
32 offset = 0;
33 size = 0;
35 doindent = 0;
36 level = 0;
37 notlinehead = 0;
39 ~OutBuffer()
41 mem.xfree(data);
43 char *extractData();
45 void reserve(size_t nbytes);
46 void setsize(size_t size);
47 void reset();
48 void write(const void *data, d_size_t nbytes);
49 void writebstring(utf8_t *string);
50 void writestring(const char *string);
51 void prependstring(const char *string);
52 void writenl(); // write newline
53 void writeByte(unsigned b);
54 void writeUTF8(unsigned b);
55 void prependbyte(unsigned b);
56 void writewchar(unsigned w);
57 void writeword(unsigned w);
58 void writeUTF16(unsigned w);
59 void write4(unsigned w);
60 void write(OutBuffer *buf);
61 void write(RootObject *obj);
62 void fill0(size_t nbytes);
63 void vprintf(const char *format, va_list args);
64 void printf(const char *format, ...);
65 void bracket(char left, char right);
66 size_t bracket(size_t i, const char *left, size_t j, const char *right);
67 void spread(size_t offset, size_t nbytes);
68 size_t insert(size_t offset, const void *data, size_t nbytes);
69 void remove(size_t offset, size_t nbytes);
70 // Append terminating null if necessary and get view of internal buffer
71 char *peekString();
72 // Append terminating null if necessary and take ownership of data
73 char *extractString();