]>
Commit | Line | Data |
---|---|---|
b4c522fa | 1 | |
f3ed896c | 2 | /* Copyright (C) 1999-2019 by The D Language Foundation, All Rights Reserved |
b4c522fa IB |
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 | */ | |
8 | ||
9 | #pragma once | |
10 | ||
f9ab59ff | 11 | #include "dsystem.h" |
b4c522fa IB |
12 | #include "port.h" |
13 | #include "rmem.h" | |
14 | ||
15 | class RootObject; | |
16 | ||
17 | struct OutBuffer | |
18 | { | |
19 | unsigned char *data; | |
20 | size_t offset; | |
21 | size_t size; | |
22 | ||
23 | int level; | |
24 | bool doindent; | |
25 | private: | |
26 | bool notlinehead; | |
27 | public: | |
28 | ||
29 | OutBuffer() | |
30 | { | |
31 | data = NULL; | |
32 | offset = 0; | |
33 | size = 0; | |
34 | ||
35 | doindent = 0; | |
36 | level = 0; | |
37 | notlinehead = 0; | |
38 | } | |
39 | ~OutBuffer() | |
40 | { | |
41 | mem.xfree(data); | |
42 | } | |
43 | char *extractData(); | |
44 | ||
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(); | |
74 | }; |